arm64: kvm: Use has_vhe() instead of hyp_alternate_select()
PATCH 1/1 arm64: kvm: Use has_vhe() instead of hyp_alternate_select()
Now all the cpu_hwcaps features have their own static keys. We don't need a separate function hyp_alternate_select() to patch the vhe/nvhe code. We can achieve the same functionality by using has_vhe(). It improves the code readability, uses the jump label instructions, and also compiler generates the better code with a fewer instructions.
Change-Id Ia8084189833f2081ff13c392deb5070c46a64038
Signed-off-by Shanker Donthineni <[email protected]>
--- arch/arm64/kvm/hyp/debug-sr.c | 12 ++++++---- arch/arm64/kvm/hyp/switch.c | 50 +++++++++++++++++++----------------------- arch/arm64/kvm/hyp/sysreg-sr.c | 23 +++++++++---------- 3 files changed, 43 insertions(+), 42 deletions(-)
arch/arm64/kvm/hyp/debug-sr.c +8 -4
@@ -109,9 +109,13 @@ static void __hyp_text __debug_save_spe_nvhe(u64 *pmscr_el1)dsb (nsh); } -static hyp_alternate_select(__debug_save_spe, - __debug_save_spe_nvhe, __debug_save_spe_vhe, - ARM64_HAS_VIRT_HOST_EXTN); +static void __hyp_text __debug_save_spe(u64 *pmscr_el1) +{ +if (has_vhe ()) +__debug_save_spe_vhe (pmscr_el1); +else +__debug_save_spe_nvhe (pmscr_el1); +} static void __hyp_text __debug_restore_spe(u64 pmscr_el1) {
@@ -180,7 +184,7 @@ void __hyp_text __debug_cond_save_host_state(struct kvm_vcpu *vcpu)__debug_save_state (vcpu, &vcpu->arch.host_debug_state.regs,kern_hyp_va (vcpu->arch.host_cpu_context)); -__debug_save_spe ()(&vcpu->arch.host_debug_state.pmscr_el1); +__debug_save_spe (&vcpu->arch.host_debug_state.pmscr_el1); } void __hyp_text __debug_cond_restore_host_state(struct kvm_vcpu *vcpu)
arch/arm64/kvm/hyp/switch.c +23 -27
111 lines not on this page · raw message
arch/arm64/kvm/hyp/sysreg-sr.c +12 -11
@@ -21,9 +21,6 @@#include <asm/kvm_asm.h> #include <asm/kvm_hyp.h> -/* Yes, this does nothing, on purpose */ -static void __hyp_text __sysreg_do_nothing(struct kvm_cpu_context *ctxt) { } -/* * Non-VHE: Both host and guest must save everything. *
@@ -68,13 +65,15 @@ static void __hyp_text __sysreg_save_state(struct kvm_cpu_context *ctxt) ctxt->gp_regs.spsr[KVM_SPSR_EL1 ]=read_sysreg_el1 (spsr); } -static hyp_alternate_select(__sysreg_call_save_host_state, - __sysreg_save_state, __sysreg_do_nothing, - ARM64_HAS_VIRT_HOST_EXTN); +static void __hyp_text __sysreg_call_save_host_state(struct kvm_cpu_context *ctxt) +{ +if (!has_vhe ()) +__sysreg_save_state (ctxt); +} void __hyp_text __sysreg_save_host_state(struct kvm_cpu_context *ctxt) { -__sysreg_call_save_host_state ()(ctxt); +__sysreg_call_save_host_state (ctxt);__sysreg_save_common_state (ctxt); }
@@ -121,13 +120,15 @@ static void __hyp_text __sysreg_restore_state(struct kvm_cpu_context *ctxt)write_sysreg_el1 (ctxt->gp_regs.spsr[KVM_SPSR_EL1 ],spsr); } -static hyp_alternate_select(__sysreg_call_restore_host_state, - __sysreg_restore_state, __sysreg_do_nothing, - ARM64_HAS_VIRT_HOST_EXTN); +static void __hyp_text __sysreg_call_restore_host_state(struct kvm_cpu_context *ctxt) +{ +if (!has_vhe ()) +__sysreg_restore_state (ctxt); +} void __hyp_text __sysreg_restore_host_state(struct kvm_cpu_context *ctxt) { -__sysreg_call_restore_host_state ()(ctxt); +__sysreg_call_restore_host_state (ctxt);__sysreg_restore_common_state (ctxt); }
Signature · 2 lines
Qualcomm Datacenter Technologies, Inc. on behalf of the Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.