* [PATCH 0/2] __do_hyp_init fix and tweak
@ 2021-01-25 14:54 Andrew Scull
2021-01-25 14:54 ` [PATCH 1/2] KVM: arm64: Simplify __kvm_hyp_init HVC detection Andrew Scull
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Andrew Scull @ 2021-01-25 14:54 UTC (permalink / raw)
To: kvmarm, kernel-team; +Cc: maz
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(-)
--
2.30.0.280.ga3ce27912f-goog
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] KVM: arm64: Simplify __kvm_hyp_init HVC detection
2021-01-25 14:54 [PATCH 0/2] __do_hyp_init fix and tweak Andrew Scull
@ 2021-01-25 14:54 ` Andrew Scull
2021-01-25 14:54 ` [PATCH 2/2] KVM: arm64: Don't clobber x4 in __do_hyp_init Andrew Scull
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Andrew Scull @ 2021-01-25 14:54 UTC (permalink / raw)
To: kvmarm, kernel-team; +Cc: maz
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.
Tested-by: David Brazdil <dbrazdil@google.com>
Signed-off-by: Andrew Scull <ascull@google.com>
---
arch/arm64/kvm/hyp/nvhe/hyp-init.S | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-init.S b/arch/arm64/kvm/hyp/nvhe/hyp-init.S
index 31b060a44045..b3915ccb23b0 100644
--- a/arch/arm64/kvm/hyp/nvhe/hyp-init.S
+++ b/arch/arm64/kvm/hyp/nvhe/hyp-init.S
@@ -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
--
2.30.0.280.ga3ce27912f-goog
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] KVM: arm64: Don't clobber x4 in __do_hyp_init
2021-01-25 14:54 [PATCH 0/2] __do_hyp_init fix and tweak Andrew Scull
2021-01-25 14:54 ` [PATCH 1/2] KVM: arm64: Simplify __kvm_hyp_init HVC detection Andrew Scull
@ 2021-01-25 14:54 ` Andrew Scull
2021-01-25 16:03 ` (subset) [PATCH 0/2] __do_hyp_init fix and tweak Marc Zyngier
2021-01-25 16:18 ` Marc Zyngier
3 siblings, 0 replies; 5+ messages in thread
From: Andrew Scull @ 2021-01-25 14:54 UTC (permalink / raw)
To: kvmarm, kernel-team; +Cc: maz
arm_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.
Tested-by: David Brazdil <dbrazdil@google.com>
Signed-off-by: Andrew Scull <ascull@google.com>
---
arch/arm64/kvm/hyp/nvhe/hyp-init.S | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-init.S b/arch/arm64/kvm/hyp/nvhe/hyp-init.S
index b3915ccb23b0..3df583ad12af 100644
--- a/arch/arm64/kvm/hyp/nvhe/hyp-init.S
+++ b/arch/arm64/kvm/hyp/nvhe/hyp-init.S
@@ -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
--
2.30.0.280.ga3ce27912f-goog
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: (subset) [PATCH 0/2] __do_hyp_init fix and tweak
2021-01-25 14:54 [PATCH 0/2] __do_hyp_init fix and tweak Andrew Scull
2021-01-25 14:54 ` [PATCH 1/2] KVM: arm64: Simplify __kvm_hyp_init HVC detection Andrew Scull
2021-01-25 14:54 ` [PATCH 2/2] KVM: arm64: Don't clobber x4 in __do_hyp_init Andrew Scull
@ 2021-01-25 16:03 ` Marc Zyngier
2021-01-25 16:18 ` Marc Zyngier
3 siblings, 0 replies; 5+ messages in thread
From: Marc Zyngier @ 2021-01-25 16:03 UTC (permalink / raw)
To: Andrew Scull, kvmarm, kernel-team
On Mon, 25 Jan 2021 14:54:13 +0000, Andrew Scull wrote:
> 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
>
> [...]
Applied to kvmarm-master/fixes, thanks!
[2/2] KVM: arm64: Don't clobber x4 in __do_hyp_init
commit: e500b805c39daff2670494fff94909d7e3d094d9
Cheers,
M.
--
Without deviation from the norm, progress is not possible.
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: (subset) [PATCH 0/2] __do_hyp_init fix and tweak
2021-01-25 14:54 [PATCH 0/2] __do_hyp_init fix and tweak Andrew Scull
` (2 preceding siblings ...)
2021-01-25 16:03 ` (subset) [PATCH 0/2] __do_hyp_init fix and tweak Marc Zyngier
@ 2021-01-25 16:18 ` Marc Zyngier
3 siblings, 0 replies; 5+ messages in thread
From: Marc Zyngier @ 2021-01-25 16:18 UTC (permalink / raw)
To: kvmarm, Andrew Scull, kernel-team
On Mon, 25 Jan 2021 14:54:13 +0000, Andrew Scull wrote:
> 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
>
> [...]
Applied to kvm-arm64/misc-5.12, thanks!
[1/2] KVM: arm64: Simplify __kvm_hyp_init HVC detection
commit: 87b26801f02ca9d7a110eb598dae8cd5d3bcace2
Cheers,
M.
--
Without deviation from the norm, progress is not possible.
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-01-25 16:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-25 14:54 [PATCH 0/2] __do_hyp_init fix and tweak Andrew Scull
2021-01-25 14:54 ` [PATCH 1/2] KVM: arm64: Simplify __kvm_hyp_init HVC detection Andrew Scull
2021-01-25 14:54 ` [PATCH 2/2] KVM: arm64: Don't clobber x4 in __do_hyp_init Andrew Scull
2021-01-25 16:03 ` (subset) [PATCH 0/2] __do_hyp_init fix and tweak Marc Zyngier
2021-01-25 16:18 ` Marc Zyngier
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.