@@ -55,6 +55,7 @@
PrePiHobListPointerLib
PlatformPeiLib
MemoryInitPeiLib
+ CacheMaintenanceLib
[Ppis]
gArmMpCoreInfoPpiGuid
@@ -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
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 <ard.biesheuvel@linaro.org> --- .../ArmVirtualizationPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf | 1 + ArmPlatformPkg/ArmVirtualizationPkg/PrePi/PrePi.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-)