From 5b80d7944d197494a84de42a5ba084769865a3d8 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Tue, 27 May 2025 17:52:42 +0200 Subject: [PATCH] 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 --- ArmPlatformPkg/Sec/AArch64/Helper.S | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ArmPlatformPkg/Sec/AArch64/Helper.S b/ArmPlatformPkg/Sec/AArch64/Helper.S index 81059855b8..dd097370ae 100644 --- a/ArmPlatformPkg/Sec/AArch64/Helper.S +++ b/ArmPlatformPkg/Sec/AArch64/Helper.S @@ -8,8 +8,6 @@ #include #include -.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