]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/PrePeiCore: permit entry with the MMU enabled
authorArd Biesheuvel <ardb@kernel.org>
Fri, 1 Jul 2022 18:24:26 +0000 (20:24 +0200)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 24 Oct 2022 14:30:33 +0000 (14:30 +0000)
Some platforms may set up a preliminary ID map in flash and enter EFI
with the MMU and caches enabled, as this removes a lot of the complexity
around cache coherency. Let's take this into account, and avoid touching
the MMU controls or perform cache invalidation when the MMU is enabled
at entry.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
ArmPlatformPkg/PrePeiCore/PrePeiCore.c

index 9c4b25df953dc371084790e468fda3371cbeb44b..8b86c6e69abdde98a0f58de07dd8812abad5f250 100644 (file)
@@ -58,17 +58,19 @@ CEntryPoint (
   IN  EFI_PEI_CORE_ENTRY_POINT  PeiCoreEntryPoint\r
   )\r
 {\r
-  // Data Cache enabled on Primary core when MMU is enabled.\r
-  ArmDisableDataCache ();\r
-  // Invalidate instruction cache\r
-  ArmInvalidateInstructionCache ();\r
-  // Enable Instruction Caches on all cores.\r
-  ArmEnableInstructionCache ();\r
-\r
-  InvalidateDataCacheRange (\r
-    (VOID *)(UINTN)PcdGet64 (PcdCPUCoresStackBase),\r
-    PcdGet32 (PcdCPUCorePrimaryStackSize)\r
-    );\r
+  if (!ArmMmuEnabled ()) {\r
+    // Data Cache enabled on Primary core when MMU is enabled.\r
+    ArmDisableDataCache ();\r
+    // Invalidate instruction cache\r
+    ArmInvalidateInstructionCache ();\r
+    // Enable Instruction Caches on all cores.\r
+    ArmEnableInstructionCache ();\r
+\r
+    InvalidateDataCacheRange (\r
+      (VOID *)(UINTN)PcdGet64 (PcdCPUCoresStackBase),\r
+      PcdGet32 (PcdCPUCorePrimaryStackSize)\r
+      );\r
+  }\r
 \r
   //\r
   // Note: Doesn't have to Enable CPU interface in non-secure world,\r