]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
KVM: arm64: pkvm: Move error handling to the end of kvm_hyp_cpu_entry
authorMarc Zyngier <maz@kernel.org>
Sat, 21 Mar 2026 21:24:15 +0000 (21:24 +0000)
committerMarc Zyngier <maz@kernel.org>
Mon, 23 Mar 2026 11:03:53 +0000 (11:03 +0000)
We currently handle CPUs having booted at EL1 in the middle of
the kvm_hyp_cpu_entry function. Not only this adversely affects
readability, but this is also at a bizarre spot should more
error handling be added (which we're about to do).

Move the WFE/WFI loop to the end of the function and fix a comment.

Reviewed-by: Fuad Tabba <tabba@google.com>
Tested-by: Fuad Tabba <tabba@google.com>
Link: https://patch.msgid.link/20260321212419.2803972-2-maz@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/hyp/nvhe/hyp-init.S

index 0d42eedc7167c7390a2b6c4ca89cf9c4db74c15b..5d00bde092010edf30589c43872bb963fbe2a583 100644 (file)
@@ -201,14 +201,9 @@ SYM_CODE_START_LOCAL(__kvm_hyp_init_cpu)
        /* Check that the core was booted in EL2. */
        mrs     x0, CurrentEL
        cmp     x0, #CurrentEL_EL2
-       b.eq    2f
-
-       /* The core booted in EL1. KVM cannot be initialized on it. */
-1:     wfe
-       wfi
-       b       1b
+       b.ne    1f
 
-2:     msr     SPsel, #1                       // We want to use SP_EL{1,2}
+       msr     SPsel, #1                       // We want to use SP_EL2
 
        init_el2_hcr    0
 
@@ -222,6 +217,11 @@ SYM_CODE_START_LOCAL(__kvm_hyp_init_cpu)
        mov     x0, x29
        ldr     x1, =kvm_host_psci_cpu_entry
        br      x1
+
+       // The core booted in EL1. KVM cannot be initialized on it.
+1:     wfe
+       wfi
+       b       1b
 SYM_CODE_END(__kvm_hyp_init_cpu)
 
 SYM_CODE_START(__kvm_handle_stub_hvc)