ssbd_callback

Signed-off-by: David Brazdil <dbrazdil@google.com>
diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h
index 86d63fc..310ef17 100644
--- a/arch/arm64/include/asm/kvm_asm.h
+++ b/arch/arm64/include/asm/kvm_asm.h
@@ -53,7 +53,6 @@
 #define __KVM_HOST_SMCCC_FUNC___kvm_tlb_flush_local_vmid	4
 #define __KVM_HOST_SMCCC_FUNC___kvm_timer_set_cntvoff		5
 #define __KVM_HOST_SMCCC_FUNC___kvm_vcpu_run			6
-#define __KVM_HOST_SMCCC_FUNC___kvm_set_ssbd_callback_required	7
 #define __KVM_HOST_SMCCC_FUNC___kvm_enable_ssbs			8
 #define __KVM_HOST_SMCCC_FUNC___vgic_v3_get_ich_vtr_el2		9
 #define __KVM_HOST_SMCCC_FUNC___vgic_v3_read_vmcr		10
@@ -114,7 +113,6 @@
 extern void __kvm_tlb_flush_local_vmid(struct kvm_vcpu *vcpu);
 extern void __kvm_timer_set_cntvoff(u64 cntvoff);
 extern int __kvm_vcpu_run(struct kvm_vcpu *vcpu);
-extern void __kvm_set_ssbd_callback_required(void);
 extern void __kvm_enable_ssbs(void);
 extern u64 __vgic_v3_get_ich_vtr_el2(void);
 extern u64 __vgic_v3_read_vmcr(void);
diff --git a/arch/arm64/include/asm/kvm_hyp.h b/arch/arm64/include/asm/kvm_hyp.h
index 68e8077..1e6339a 100644
--- a/arch/arm64/include/asm/kvm_hyp.h
+++ b/arch/arm64/include/asm/kvm_hyp.h
@@ -15,6 +15,7 @@
 struct kvm_nvhe_hyp_params {
 	void *hyp_stack_ptr;
 	void *vector_ptr;
+	bool ssbd_callback_required;
 };
 
 #define read_sysreg_elx(r,nvh,vh)					\
diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index 5f8070d..da2e6a5 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -1313,6 +1313,7 @@
 		.hyp_stack_ptr = kern_hyp_va(page_address(stack_page)
 					     + PAGE_SIZE),
 		.vector_ptr = kvm_get_hyp_vector(),
+		.ssbd_callback_required = this_cpu_read(arm64_ssbd_callback_required),
 	};
 
 	/*
@@ -1326,10 +1327,6 @@
 			  pgd_ptr, tpidr_el2, start_hyp, &res);
 	WARN_ON(res.a0 != SMCCC_RET_SUCCESS);
 
-	/* Copy the arm64_ssbd_callback_required information to hyp. */
-	if (this_cpu_read(arm64_ssbd_callback_required))
-		kvm_call_hyp_nvhe(__kvm_set_ssbd_callback_required);
-
 	/*
 	 * Disabling SSBD on a non-VHE system requires us to enable SSBS
 	 * at EL2.
diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
index d15597f..7dce884 100644
--- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c
+++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
@@ -14,6 +14,11 @@
 DEFINE_PER_CPU(struct kvm_nvhe_hyp_params, kvm_nvhe_hyp_params);
 DEFINE_PER_CPU(struct kvm_vcpu, kvm_host_vcpu);
 
+/* nVHE copy of the arm64_ssbd_callback_required symbol. */
+#ifdef CONFIG_ARM64_SSBD
+DEFINE_PER_CPU_READ_MOSTLY(u64, arm64_ssbd_callback_required);
+#endif
+
 static void handle_host_hcall(struct kvm_vcpu *host_vcpu)
 {
 	unsigned long ret = 0;
@@ -108,6 +113,11 @@
 	struct kvm_host_data *hyp_data;
 	struct kvm_cpu_context *hyp_ctxt;
 
+#ifdef CONFIG_ARM64_SSBD
+	if (params->ssbd_callback_required)
+		__this_cpu_write(arm64_ssbd_callback_required, 1);
+#endif
+
 	host_vcpu = this_cpu_ptr(&kvm_host_vcpu);
 	hyp_data = this_cpu_ptr(&kvm_host_data);
 	hyp_ctxt = &hyp_data->host_ctxt;
diff --git a/arch/arm64/kvm/hyp/nvhe/sysreg-sr.c b/arch/arm64/kvm/hyp/nvhe/sysreg-sr.c
index f841584..88a25fc 100644
--- a/arch/arm64/kvm/hyp/nvhe/sysreg-sr.c
+++ b/arch/arm64/kvm/hyp/nvhe/sysreg-sr.c
@@ -18,11 +18,6 @@
  * Non-VHE: Both host and guest must save everything.
  */
 
-/* nVHE copy of the arm64_ssbd_callback_required symbol. */
-#ifdef CONFIG_ARM64_SSBD
-DEFINE_PER_CPU_READ_MOSTLY(u64, arm64_ssbd_callback_required);
-#endif
-
 void __sysreg_save_state_nvhe(struct kvm_cpu_context *ctxt)
 {
 	__sysreg_save_el1_state(ctxt);
@@ -49,10 +44,3 @@
 	"msr	sctlr_el2, %0"
 	: "=&r" (tmp) : "L" (SCTLR_ELx_DSSBS));
 }
-
-void __kvm_set_ssbd_callback_required(void)
-{
-#ifdef CONFIG_ARM64_SSBD
-	__this_cpu_write(arm64_ssbd_callback_required, 1);
-#endif
-}