arm64: kvm: Clean up cpu_init_hyp_mode()
PATCH 1/1 arm64: kvm: Clean up cpu_init_hyp_mode()
Pull bits of code to the only place where it is used. Remove empty function __cpu_init_stage2(). Remove redundant has_vhe() check since this function is nVHE-only. No functional changes intended.
Signed-off-by David Brazdil <[email protected]>
--- arch/arm64/include/asm/kvm_asm.h | 2 ++ arch/arm64/include/asm/kvm_host.h | 35 ------------------------------- arch/arm64/kvm/arm.c | 32 +++++++++++++++++++++++----- 3 files changed, 29 insertions(+), 40 deletions(-)
arch/arm64/include/asm/kvm_asm.h +2 -0
@@ -70,6 +70,8 @@ extern int kvm_vcpu_run_vhe(struct kvm_vcpu *vcpu);extern int __kvm_vcpu_run_nvhe (struct kvm_vcpu *vcpu); +extern void __kvm_enable_ssbs (void ); +extern u64 __vgic_v3_get_ich_vtr_el2 (void );extern u64 __vgic_v3_read_vmcr (void );extern void __vgic_v3_write_vmcr (u32 vmcr);
arch/arm64/include/asm/kvm_host.h +0 -35
@@ -533,39 +533,6 @@ static inline void kvm_init_host_cpu_context(struct kvm_cpu_context *cpu_ctxt) cpu_ctxt->sys_regs[MPIDR_EL1 ] =read_cpuid_mpidr (); } -void __kvm_enable_ssbs (void ); - -static inline void __cpu_init_hyp_mode (phys_addr_t pgd_ptr, -unsigned long hyp_stack_ptr, -unsigned long vector_ptr) -{ -/* -* Calculate the raw per-cpu offset without a translation from the -* kernel's mapping to the linear mapping, and store it in tpidr_el2 -* so that we can use adr_l to access per-cpu variables in EL2. -*/ -u64 tpidr_el2 = ((u64 )this_cpu_ptr (&kvm_host_data) - - (u64 )kvm_ksym_ref (kvm_host_data)); - -/* -* Call initialization code, and switch to the full blown HYP code. -* If the cpucaps haven't been finalized yet, something has gone very -* wrong, and hyp will crash and burn when it uses any -* cpus_have_const_cap() wrapper. -*/ -BUG_ON (!system_capabilities_finalized ()); -__kvm_call_hyp ((void *)pgd_ptr, hyp_stack_ptr, vector_ptr, tpidr_el2); - -/* -* Disabling SSBD on a non-VHE system requires us to enable SSBS -* at EL2. -*/ -if (!has_vhe () &&this_cpu_has_cap (ARM64_SSBS ) && -arm64_get_ssbd_state () ==ARM64_SSBD_FORCE_DISABLE ) { -kvm_call_hyp (__kvm_enable_ssbs); - } -} -static inline bool kvm_arch_requires_vhe (void ) {/*
@@ -601,8 +568,6 @@ int kvm_arm_vcpu_arch_get_attr(struct kvm_vcpu *vcpu,int kvm_arm_vcpu_arch_has_attr (struct kvm_vcpu *vcpu,struct kvm_device_attr *attr); -static inline void __cpu_init_stage2 (void ) {} -/* Guest/host FPSIMD coordination helpers */ int kvm_arch_vcpu_run_map_fp (struct kvm_vcpu *vcpu);void kvm_arch_vcpu_load_fp (struct kvm_vcpu *vcpu);
arch/arm64/kvm/arm.c +27 -5
@@ -1273,19 +1273,41 @@ static void cpu_init_hyp_mode(void) {phys_addr_t pgd_ptr;unsigned long hyp_stack_ptr; -unsigned long stack_page;unsigned long vector_ptr; +unsigned long tpidr_el2;/* Switch from the HYP stub to our own HYP init vector */ __hyp_set_vectors (kvm_get_idmap_vector ()); +/* +* Calculate the raw per-cpu offset without a translation from the +* kernel's mapping to the linear mapping, and store it in tpidr_el2 +* so that we can use adr_l to access per-cpu variables in EL2. +*/ + tpidr_el2 = ((unsigned long )this_cpu_ptr (&kvm_host_data) - + (unsigned long )kvm_ksym_ref (kvm_host_data)); + pgd_ptr =kvm_mmu_get_httbr (); - stack_page =__this_cpu_read (kvm_arm_hyp_stack_page); - hyp_stack_ptr = stack_page +PAGE_SIZE ; + hyp_stack_ptr =__this_cpu_read (kvm_arm_hyp_stack_page) +PAGE_SIZE ; vector_ptr = (unsigned long )kvm_get_hyp_vector (); -__cpu_init_hyp_mode (pgd_ptr, hyp_stack_ptr, vector_ptr); -__cpu_init_stage2 (); +/* +* Call initialization code, and switch to the full blown HYP code. +* If the cpucaps haven't been finalized yet, something has gone very +* wrong, and hyp will crash and burn when it uses any +* cpus_have_const_cap() wrapper. +*/ +BUG_ON (!system_capabilities_finalized ()); +__kvm_call_hyp ((void *)pgd_ptr, hyp_stack_ptr, vector_ptr, tpidr_el2); + +/* +* 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 )
Signature · 1 line
2.26.2
Quoted 9 lines · David Brazdil
Pull bits of code to the only place where it is used. Remove empty function
__cpu_init_stage2(). Remove redundanthas_vhe()check since this function is nVHE-only. No functional changes intended.Signed-off-by David Brazdil <[email protected]>Signed-off-by Marc Zyngier <[email protected]>[...]
Applied to kvmarm-master/next, thanks!
[1/1] KVM: arm64: Clean up cpu_init_hyp_mode()
commit: 71b3ec5f221b8b3ff545639be83ddfcd5d7c9800
Cheers,
M.
Signature · 8 lines
Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel