arm64: kvm: Stop clobbering x0 for HVC_SOFT_RESTART
PATCH 1/1 arm64: kvm: Stop clobbering x0 for HVC_SOFT_RESTART
HVC_SOFT_RESTART is given values for x0-2 that it should installed before exiting to the new address so should not set x0 to stub HVC success or failure code.
--- arch/arm64/kvm/hyp-init.S | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
arch/arm64/kvm/hyp-init.S +7 -4
@@ -136,11 +136,15 @@ SYM_CODE_START(__kvm_handle_stub_hvc) 1: cmp x0, #HVC_RESET_VECTORS b.ne 1f -reset: + /* - * Reset kvm back to the hyp stub. Do not clobber x0-x4 in - * case we coming via HVC_SOFT_RESTART. + * Set the HVC_RESET_VECTORS return code before entering the common + * path so that we do not clobber x0-x2 in case we are coming via + * HVC_SOFT_RESTART. */ + mov x0, xzr +reset: + /* Reset kvm back to the hyp stub. */ mrs x5, sctlr_el2 mov_q x6, SCTLR_ELx_FLAGS bic x5, x5, x6 // Clear SCTL_M and etc
@@ -151,7 +155,6 @@ reset: /* Install stub vectors */ adr_l x5, __hyp_stub_vectors msr vbar_el2, x5 - mov x0, xzr eret 1: /* Bad stub call */
Signature · 6 lines
2.27.0.383.g050319c2ae-goog _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Marc Zyngier
maintainerQuoted 33 lines · Andrew Scull
HVC_SOFT_RESTARTis given values for x0-2 that it should installed before exiting to the new address so should not set x0 to stub HVC success or failure code.Signed-off-by Andrew Scull <[email protected]>--- arch/arm64/kvm/hyp-init.S | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)arch/arm64/kvm/hyp-init.S +7
-3@@ -136,11 +136,15 @@ SYM_CODE_START(__kvm_handle_stub_hvc) 1: cmp x0, #HVC_RESET_VECTORS b.ne 1f -reset: + /* - * Reset kvm back to the hyp stub. Do not clobber x0-x4 in - * case we coming via HVC_SOFT_RESTART. + * Set the HVC_RESET_VECTORS return code before entering the common + * path so that we do not clobber x0-x2 in case we are coming via + * HVC_SOFT_RESTART. */ + mov x0, xzr +reset: + /* Reset kvm back to the hyp stub. */ mrs x5, sctlr_el2 mov_q x6, SCTLR_ELx_FLAGS bic x5, x5, x6 // Clear SCTL_M and etc
arch/arm64/kvm/hyp-init.S reset: · line 160
Quoted 7 lines
arch/arm64/kvm/hyp-init.S +0
-1@@ -151,7 +155,6 @@ reset: /* Install stub vectors */ adr_l x5, __hyp_stub_vectors msr vbar_el2, x5 - mov x0, xzr eret 1: /* Bad stub call */
Huh, nice catch. I wonder what the fuss is about kexec, really, given that it is *that* broken. This deserves:
Thanks,
M.
Signature · 5 lines
Jazz is not dead. It just smells funny... _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Hi Marc, Andrew,
Quoted 35 lines · Marc Zyngier
Quoted 34 lines · Andrew Scull
HVC_SOFT_RESTARTis given values for x0-2 that it should installed before exiting to the new address so should not set x0 to stub HVC success or failure code.arch/arm64/kvm/hyp-init.S +0
-0@@ -136,11 +136,15 @@ SYM_CODE_START(__kvm_handle_stub_hvc)1: cmp x0, #HVC_RESET_VECTORS
b.ne 1farch/arm64/kvm/hyp-init.S +1
-1-reset: +/*
- * Reset kvm back to the hyp stub. Do not clobber x0-x4 in - * case we coming viaHVC_SOFT_RESTART.
+ * Set theHVC_RESET_VECTORSreturn code before entering the common + * path so that we do not clobber x0-x2 in case we are coming via + *HVC_SOFT_RESTART.
*/
+ mov x0, xzr
+reset:
+ /* Reset kvm back to the hyp stub. */
mrs x5,sctlr_el2
mov_q x6,SCTLR_ELx_FLAGS
bic x5, x5, x6 // ClearSCTL_Mand etcarch/arm64/kvm/hyp-init.S +0
-0@@ -151,7 +155,6 @@ reset: /* Install stub vectors */adr_l x5,
__hyp_stub_vectors
msrvbar_el2, x5
- mov x0, xzr
eret
Quoted 4 lines
Quoted 1 line
1: /* Bad stub call */
Huh, nice catch. I wonder what the fuss is about kexec, really, given that it is *that* broken.
This would only bite kdump on a v8.0 machine was also running a KVM guest.
Regular kexec would happen after KVM's kvm_reboot_notifier() has called hardware_disable_nolock() which unloads KVM and restores the hyp-stub.
I'm glad its been caught and fixed!
Thanks,
James
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Quoted 3 lines · Andrew Scull
HVC_SOFT_RESTARTis given values for x0-2 that it should installed before exiting to the new address so should not set x0 to stub HVC success or failure code.
Applied to kvm-arm64/fixes-5.8-3, thanks!
[1/1] KVM: arm64: Stop clobbering x0 for HVC_SOFT_RESTART
commit: e86a688bce9e2c77087c797504dd3dc97d688a62
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