As a guest under virtualization, it is not sufficient to enable
the caches using the architecturally mandated procedure of
invalidating by set/way. We also have to explicitly invalidate
the stack and heap regions by virtual address, to prevent dirty
cachelines in system caches or on other CPUs to shadow the data
that we have written straight to main memory while executing
with the MMU off.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <[email protected]>
---
 .../ArmVirtualizationPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf   | 1 +
 ArmPlatformPkg/ArmVirtualizationPkg/PrePi/PrePi.c                   | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git 
a/ArmPlatformPkg/ArmVirtualizationPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf 
b/ArmPlatformPkg/ArmVirtualizationPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
index 86cf870b79ac..16023382a679 100755
--- 
a/ArmPlatformPkg/ArmVirtualizationPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
+++ 
b/ArmPlatformPkg/ArmVirtualizationPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
@@ -55,6 +55,7 @@
   PrePiHobListPointerLib
   PlatformPeiLib
   MemoryInitPeiLib
+  CacheMaintenanceLib
 
 [Ppis]
   gArmMpCoreInfoPpiGuid
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/PrePi/PrePi.c 
b/ArmPlatformPkg/ArmVirtualizationPkg/PrePi/PrePi.c
index 0772805890f2..99f23a665f46 100755
--- a/ArmPlatformPkg/ArmVirtualizationPkg/PrePi/PrePi.c
+++ b/ArmPlatformPkg/ArmVirtualizationPkg/PrePi/PrePi.c
@@ -20,6 +20,7 @@
 #include <Library/PrePiHobListPointerLib.h>
 #include <Library/TimerLib.h>
 #include <Library/PerformanceLib.h>
+#include <Library/CacheMaintenanceLib.h>
 
 #include <Ppi/GuidedSectionExtraction.h>
 #include <Ppi/ArmMpCoreInfo.h>
@@ -117,12 +118,15 @@ PrePiMain (
     );
   PrePeiSetHobList (HobList);
 
+  StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize);
+  InvalidateDataCacheRange ((VOID *) StacksBase, StacksSize);
+  InvalidateDataCacheRange ((VOID *) UefiMemoryBase, FixedPcdGet32 
(PcdSystemMemoryUefiRegionSize));
+
   // Initialize MMU and Memory HOBs (Resource Descriptor HOBs)
   Status = MemoryPeim (UefiMemoryBase, FixedPcdGet32 
(PcdSystemMemoryUefiRegionSize));
   ASSERT_EFI_ERROR (Status);
 
   // Create the Stacks HOB (reserve the memory for all stacks)
-  StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize);
   BuildStackHob (StacksBase, StacksSize);
 
   // Declare the Global Variable HOB
-- 
1.8.3.2


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to