]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmVirtualizationPkg: invalidate PEI memory region by VA
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 14 Apr 2015 11:55:42 +0000 (11:55 +0000)
committeroliviermartin <oliviermartin@Edk2>
Tue, 14 Apr 2015 11:55:42 +0000 (11:55 +0000)
This updates ArmVirtualizationMemoryInitPeiLib so that the PEI memory
region, i.e., the region that is used both before and after the MMU
and caches are enabled, is invalidated by virtual address before
enabling the MMU.

This prevents issues where data we modified with the caches and MMU
off may be shadowed by clean cachelines in system caches or in lower
level caches on other CPUs, resulting in the this data to become
invisible once we turn the MMU and caches on.

Contributed-under: TianoCore Contribution Agreement 1.0
Reviewed-by: Olivier Martin <Olivier.Martin@arm.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17177 6f19259b-4bc3-4df7-8a09-765794883524

ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationMemoryInitPeiLib/ArmVirtualizationMemoryInitPeiLib.c
ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationMemoryInitPeiLib/ArmVirtualizationMemoryInitPeiLib.inf

index 5f6cd059c47fa4d242ccdef8f45426ccef74db37..8ce63b4596e2c08148116031e48729ebf219fb5e 100644 (file)
@@ -20,6 +20,7 @@
 #include <Library/HobLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/PcdLib.h>\r
+#include <Library/CacheMaintenanceLib.h>\r
 \r
 VOID\r
 BuildMemoryTypeInformationHob (\r
@@ -79,6 +80,15 @@ MemoryPeim (
       PcdGet64 (PcdSystemMemorySize)\r
   );\r
 \r
+  //\r
+  // When running under virtualization, the PI/UEFI memory region may be\r
+  // clean but not invalidated in system caches or in lower level caches\r
+  // on other CPUs. So invalidate the region by virtual address, to ensure\r
+  // that the contents we put there with the caches and MMU off will still\r
+  // be visible after turning them on.\r
+  //\r
+  InvalidateDataCacheRange ((VOID*)(UINTN)UefiMemoryBase, UefiMemorySize);\r
+\r
   // Build Memory Allocation Hob\r
   InitMmu ();\r
 \r