ArmPlatformPkg/Sec: Re-use SetupExceptionLevel1 when running VHE at EL2

Given that CPACR_EL1 is aliased to CPTR_EL2 when running at EL2 with VHE
enabled, we can just fall back to SetupExceptionLevel1() instead of
fiddling with the init values for CPTR_EL2.

While at it, use the existing define to refer to the E2H bit in HCR_EL2.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
This commit is contained in:
Ard Biesheuvel
2025-05-27 17:52:42 +02:00
committed by mergify[bot]
parent 9cd4328f5e
commit 5b80d7944d

View File

@@ -8,8 +8,6 @@
#include <AsmMacroLib.h>
#include <AArch64/AArch64.h>
.set HCR_EL2_E2H, 0x1 << 34
// Setup EL1 while in EL1
ASM_FUNC(SetupExceptionLevel1)
mov x0, #CPACR_DEFAULT
@@ -27,11 +25,11 @@ ASM_FUNC(SetupExceptionLevel2)
msr hcr_el2, x0 // Write back our settings
// Check whether we have been entered with HCR_EL2.E2H set, which is
// permitted to be RES1. In this case, CPTR_EL2 looks like CPACR_EL1.
tst x0, #HCR_EL2_E2H
// permitted to be RES1. In this case, CPACR_EL1 is aliased to CPTR_EL2.
tst x0, #ARM_HCR_E2H
b.ne SetupExceptionLevel1
mov x0, #AARCH64_CPTR_DEFAULT
mov x1, #CPACR_DEFAULT
csel x0, x0, x1, eq
msr cptr_el2, x0 // Enable architectural features
ret