diff options
author | Ard Biesheuvel <ardb@kernel.org> | 2024-11-14 18:30:27 +0100 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-12-05 10:50:48 +0000 |
commit | 47e28a6d449c51f10d89e961c3c1afcfdfd99668 (patch) | |
tree | 65590dcc51646c688c0b3d62305df9f72b743fad | |
parent | 793f4d2662afe863a81315b141e0593ae210dd1f (diff) | |
download | edk2-47e28a6d449c51f10d89e961c3c1afcfdfd99668.tar.gz |
ArmVirtPkg/ArmPlatformLibQemu: Enable early ID map on EL2+VHE
When booting at EL2, enable VHE if available so that the early ID map
can be enabled as well. This gets rid of any memory accesses (reads or
writes) before the MMU and caches are enabled.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
-rw-r--r-- | ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelper.S | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelper.S b/ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelper.S index f20395c38b..55c01035bb 100644 --- a/ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelper.S +++ b/ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelper.S @@ -40,6 +40,9 @@ .set sctlrval, SCTLR_ELx_M | SCTLR_ELx_C | SCTLR_ELx_SA | SCTLR_EL1_ITD | SCTLR_EL1_SED
.set sctlrval, sctlrval | SCTLR_ELx_I | SCTLR_EL1_SPAN | SCTLR_EL1_RES1
+ .set ID_AA64MMFR1_VH_MASK, 0xf << 8
+ .set HCR_EL2_E2H, 0x1 << 34
+
ASM_FUNC(ArmPlatformPeiBootAction)
#ifdef CAVIUM_ERRATUM_27456
@@ -58,8 +61,17 @@ ASM_FUNC(ArmPlatformPeiBootAction) b.eq 0f
#endif
mrs x0, CurrentEL // check current exception level
- tbnz x0, #3, 0f // omit early ID map if above EL1
+ tbz x0, #3, .Learly_idmap // use early ID map if at EL1
+ mrs x0, id_aa64mmfr1_el1 // otherwise, check for VHE support
+ tst x0, #ID_AA64MMFR1_VH_MASK
+ b.eq 0f
+
+ mrs x0, hcr_el2 // Enable VHE support
+ orr x0, x0, #HCR_EL2_E2H
+ msr hcr_el2, x0
+ isb
+.Learly_idmap:
mov_i x0, mairval
mov_i x1, tcrval
adrp x2, idmap
|