__do_hyp_init fix and tweak
cover __do_hyp_init fix and tweak
These apply on 5.11-rc4. The second is a fix for a clobbered register, the first is more cosmetic.
Thanks, David, for helping with build and boot tests after my logistical issues.
Andrew Scull (2):
KVM: arm64: Simplify __kvm_hyp_init HVC detection
KVM: arm64: Don't clobber x4 in __do_hyp_init
arch/arm64/kvm/hyp/nvhe/hyp-init.S | 35 +++++++++++++----------------- 1 file changed, 15 insertions(+), 20 deletions(-)
Signature · 6 lines
2.30.0.280.ga3ce27912f-goog _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PATCH 1/2 KVM: arm64: Simplify __kvm_hyp_init HVC detection
The arguments for __do_hyp_init are now passed with a pointer to a struct which means there are scratch registers available for use. Thanks to this, we no longer need to use clever, but hard to read, tricks that avoid the need for scratch registers when checking for the __kvm_hyp_init HVC.
--- arch/arm64/kvm/hyp/nvhe/hyp-init.S | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
arch/arm64/kvm/hyp/nvhe/hyp-init.S +4 -11
@@ -55,17 +55,10 @@ __do_hyp_init: cmp x0, #HVC_STUB_HCALL_NR b.lo __kvm_handle_stub_hvc - // We only actively check bits [24:31], and everything - // else has to be zero, which we check at build time. -#if (KVM_HOST_SMCCC_FUNC(__kvm_hyp_init) & 0xFFFFFFFF00FFFFFF) -#error Unexpected __KVM_HOST_SMCCC_FUNC___kvm_hyp_init value -#endif - - ror x0, x0, #24 - eor x0, x0, #((KVM_HOST_SMCCC_FUNC(__kvm_hyp_init) >> 24) & 0xF) - ror x0, x0, #4 - eor x0, x0, #((KVM_HOST_SMCCC_FUNC(__kvm_hyp_init) >> 28) & 0xF) - cbz x0, 1f + mov x3, #KVM_HOST_SMCCC_FUNC(__kvm_hyp_init) + cmp x0, x3 + b.eq 1f + mov x0, #SMCCC_RET_NOT_SUPPORTED eret
Signature · 6 lines
2.30.0.280.ga3ce27912f-goog _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PATCH 2/2 KVM: arm64: Don't clobber x4 in __do_hyp_init
In reply to Andrew Scullarm_smccc_1_1_hvc() only adds write contraints for x0-3 in the inline assembly for the HVC instruction so make sure those are the only registers that change when __do_hyp_init is called.
--- arch/arm64/kvm/hyp/nvhe/hyp-init.S | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
arch/arm64/kvm/hyp/nvhe/hyp-init.S +11 -9
@@ -47,6 +47,8 @@ __invalid: b . /* + * Only uses x0..x3 so as to not clobber callee-saved SMCCC registers. + * * x0: SMCCC function ID * x1: struct kvm_nvhe_init_params PA */
@@ -63,9 +65,9 @@ __do_hyp_init: eret 1: mov x0, x1 - mov x4, lr - bl ___kvm_hyp_init - mov lr, x4 + mov x3, lr + bl ___kvm_hyp_init // Clobbers x0..x2 + mov lr, x3 /* Hello, World! */ mov x0, #SMCCC_RET_SUCCESS
@@ -75,8 +77,8 @@ SYM_CODE_END(__kvm_hyp_init) /* * Initialize the hypervisor in EL2. * - * Only uses x0..x3 so as to not clobber callee-saved SMCCC registers - * and leave x4 for the caller. + * Only uses x0..x2 so as to not clobber callee-saved SMCCC registers + * and leave x3 for the caller. * * x0: struct kvm_nvhe_init_params PA */
@@ -105,9 +107,9 @@ alternative_else_nop_endif /* * Set the PS bits in TCR_EL2. */ - ldr x1, [x0, #NVHE_INIT_TCR_EL2] - tcr_compute_pa_size x1, #TCR_EL2_PS_SHIFT, x2, x3 - msr tcr_el2, x1 + ldr x0, [x0, #NVHE_INIT_TCR_EL2] + tcr_compute_pa_size x0, #TCR_EL2_PS_SHIFT, x1, x2 + msr tcr_el2, x0 isb
@@ -186,7 +188,7 @@ SYM_CODE_START_LOCAL(__kvm_hyp_init_cpu) /* Enable MMU, set vectors and stack. */ mov x0, x28 - bl ___kvm_hyp_init // Clobbers x0..x3 + bl ___kvm_hyp_init // Clobbers x0..x2 /* Leave idmap. */ mov x0, x29
Signature · 6 lines
2.30.0.280.ga3ce27912f-goog _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: (subset) [PATCH 0/2] __do_hyp_init fix and tweak
In reply to Andrew ScullQuoted 11 lines · Andrew Scull
These apply on 5.11-rc4. The second is a fix for a clobbered register, the first is more cosmetic.
Thanks, David, for helping with build and boot tests after my logistical issues.
Andrew Scull (2):
KVM: arm64: Simplify__kvm_hyp_initHVC detection
KVM: arm64: Don't clobber x4 in__do_hyp_init[...]
Applied to kvmarm-master/fixes, thanks!
[2/2] KVM: arm64: Don't clobber x4 in __do_hyp_init
commit: e500b805c39daff2670494fff94909d7e3d094d9
Cheers,
M.
Signature · 7 lines
Without deviation from the norm, progress is not possible. _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: (subset) [PATCH 0/2] __do_hyp_init fix and tweak
In reply to Andrew ScullQuoted 11 lines · Andrew Scull
These apply on 5.11-rc4. The second is a fix for a clobbered register, the first is more cosmetic.
Thanks, David, for helping with build and boot tests after my logistical issues.
Andrew Scull (2):
KVM: arm64: Simplify__kvm_hyp_initHVC detection
KVM: arm64: Don't clobber x4 in__do_hyp_init[...]
Applied to kvm-arm64/misc-5.12, thanks!
[1/2] KVM: arm64: Simplify __kvm_hyp_init HVC detection
commit: 87b26801f02ca9d7a110eb598dae8cd5d3bcace2
Cheers,
M.
Signature · 7 lines
Without deviation from the norm, progress is not possible. _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm