armv8: Handle EL2 Host mode
authorMark Kettenis <kettenis@openbsd.org>
Wed, 10 Feb 2021 19:14:55 +0000 (20:14 +0100)
committerTom Rini <trini@konsulko.com>
Fri, 9 Jul 2021 15:36:12 +0000 (11:36 -0400)
On implementations that support VHE, the layout of the CPTR_EL2
register depends on whether HCR_EL2.E2H is set.  If the bit is
set, CPTR_EL2 uses the same layout as CPACR_EL1 and can in fact
be accessed through that register.  In that case, jump to the
EL1 code to enable access to the FP/SIMD registers.  This allows
U-Boot to run on systems that pass control to U-Boot in EL2 with
EL2 Host mode enabled such as machines using Apple's M1 SoC.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
Acked-by: Marc Zyngier <maz@kernel.org>
arch/arm/cpu/armv8/start.S

index 6624491..9e9c614 100644 (file)
@@ -132,11 +132,13 @@ pie_fixup_done:
        msr     cntfrq_el0, x0                  /* Initialize CNTFRQ */
 #endif
        b       0f
-2:     set_vbar        vbar_el2, x0
+2:     mrs     x1, hcr_el2
+       tbnz    x1, #34, 1f                     /* HCR_EL2.E2H */
+       set_vbar vbar_el2, x0
        mov     x0, #0x33ff
        msr     cptr_el2, x0                    /* Enable FP/SIMD */
        b       0f
-1:     set_vbar        vbar_el1, x0
+1:     set_vbar vbar_el1, x0
        mov     x0, #3 << 20
        msr     cpacr_el1, x0                   /* Enable FP/SIMD */
 0: