Change ssbd hyp calls to params 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 8858589..de99715 100644 --- a/arch/arm64/include/asm/kvm_asm.h +++ b/arch/arm64/include/asm/kvm_asm.h
@@ -53,15 +53,13 @@ #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 -#define __KVM_HOST_SMCCC_FUNC___vgic_v3_write_vmcr 11 -#define __KVM_HOST_SMCCC_FUNC___vgic_v3_init_lrs 12 -#define __KVM_HOST_SMCCC_FUNC___kvm_get_mdcr_el2 13 -#define __KVM_HOST_SMCCC_FUNC___vgic_v3_save_aprs 14 -#define __KVM_HOST_SMCCC_FUNC___vgic_v3_restore_aprs 15 +#define __KVM_HOST_SMCCC_FUNC___vgic_v3_get_ich_vtr_el2 7 +#define __KVM_HOST_SMCCC_FUNC___vgic_v3_read_vmcr 8 +#define __KVM_HOST_SMCCC_FUNC___vgic_v3_write_vmcr 9 +#define __KVM_HOST_SMCCC_FUNC___vgic_v3_init_lrs 10 +#define __KVM_HOST_SMCCC_FUNC___kvm_get_mdcr_el2 11 +#define __KVM_HOST_SMCCC_FUNC___vgic_v3_save_aprs 12 +#define __KVM_HOST_SMCCC_FUNC___vgic_v3_restore_aprs 13 #ifndef __ASSEMBLY__ @@ -116,7 +114,6 @@ extern void __kvm_tlb_flush_vmid(struct kvm *kvm); 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 a89de29..b773a0c 100644 --- a/arch/arm64/include/asm/kvm_hyp.h +++ b/arch/arm64/include/asm/kvm_hyp.h
@@ -9,12 +9,15 @@ #include <linux/compiler.h> #include <linux/kvm_host.h> +#include <linux/types.h> #include <asm/alternative.h> #include <asm/sysreg.h> struct kvm_nvhe_hyp_params { void *hyp_stack_ptr; void *vector_ptr; + bool ssbd_callback_required; + bool enable_ssbd; }; #define read_sysreg_elx(r,nvh,vh) \
diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index c6899e3..2ff11bc 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c
@@ -1318,6 +1318,9 @@ static void cpu_init_hyp_mode(void) .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), + .enable_ssbd = this_cpu_has_cap(ARM64_SSBS) && + arm64_get_ssbd_state() == ARM64_SSBD_FORCE_DISABLE, }; /* @@ -1328,19 +1331,6 @@ static void cpu_init_hyp_mode(void) */ BUG_ON(!system_capabilities_finalized()); __kvm_call_hyp_init(pgd_ptr, tpidr_el2, start_hyp); - - /* Copy the arm64_ssbd_callback_required information to hyp. */ - if (this_cpu_read(arm64_ssbd_callback_required)) - kvm_call_hyp(__kvm_set_ssbd_callback_required); - - /* - * Disabling SSBD on a non-VHE system requires us to enable SSBS - * at EL2. - */ - if (this_cpu_has_cap(ARM64_SSBS) && - arm64_get_ssbd_state() == ARM64_SSBD_FORCE_DISABLE) { - kvm_call_hyp(__kvm_enable_ssbs); - } } static void cpu_hyp_reset(void)
diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c index fa9bbd0..57bf267 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
@@ -57,9 +57,6 @@ static void handle_host_hcall(struct kvm_vcpu *host_vcpu) ret = __kvm_vcpu_run(vcpu); break; } - case KVM_HOST_SMCCC_FUNC(__kvm_enable_ssbs): - __kvm_enable_ssbs(); - break; case KVM_HOST_SMCCC_FUNC(__vgic_v3_get_ich_vtr_el2): ret = __vgic_v3_get_ich_vtr_el2(); break; @@ -119,6 +116,14 @@ void __noreturn kvm_hyp_main(struct kvm_nvhe_hyp_params *params) __sysreg_save_state_nvhe(&host_vcpu->arch.ctxt); + /* Handle init params */ +#ifdef CONFIG_ARM64_SSBD + if (params->ssbd_callback_required) + __this_cpu_write(arm64_ssbd_callback_required, 1); +#endif + if (params->enable_ssbd) + __kvm_enable_ssbs(); + while (true) { u64 exit_code;
diff --git a/arch/arm64/kvm/hyp/nvhe/sysreg-sr.c b/arch/arm64/kvm/hyp/nvhe/sysreg-sr.c index cd3bd58..daa7ef8 100644 --- a/arch/arm64/kvm/hyp/nvhe/sysreg-sr.c +++ b/arch/arm64/kvm/hyp/nvhe/sysreg-sr.c
@@ -63,10 +63,3 @@ void __kvm_enable_ssbs(void) "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 -}
diff --git a/arch/arm64/kvm/hyp/sysreg-sr.c b/arch/arm64/kvm/hyp/sysreg-sr.c index 8928977..7392873 100644 --- a/arch/arm64/kvm/hyp/sysreg-sr.c +++ b/arch/arm64/kvm/hyp/sysreg-sr.c
@@ -60,22 +60,6 @@ void __sysreg32_restore_state(struct kvm_vcpu *vcpu) ___sysreg32_restore_state(vcpu); } -void __kvm_enable_ssbs(void) -{ - /* - * Nothing to do on VHE. Needed because VHE and nVHE hyp code - * must expose the same interface. - */ -} - -void __kvm_set_ssbd_callback_required(void) -{ - /* - * Nothing to do on VHE. Needed because VHE and nVHE hyp code - * must expose the same interface. - */ -} - /** * kvm_vcpu_load_sysregs - Load guest system registers to the physical CPU *