summaryrefslogtreecommitdiffstats
path: root/ArmPlatformPkg
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2020-02-25 19:28:34 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-03-05 21:08:30 +0000
commit492679a55d2692ca5ccd33a9b2314f171d2cdd4e (patch)
tree718111a63e577245f9de1aedb86d51fc8c0aff0e /ArmPlatformPkg
parentd6607d8b3000188cd7f0d6cbb9372ec69ad9ae8d (diff)
downloadedk2-492679a55d2692ca5ccd33a9b2314f171d2cdd4e.tar.gz
edk2-492679a55d2692ca5ccd33a9b2314f171d2cdd4e.tar.bz2
edk2-492679a55d2692ca5ccd33a9b2314f171d2cdd4e.zip
ArmPlatformPkg/PrePi: replace set/way cache ops with by-VA ones
Cache maintenance operations by set/way are only intended to be used in the context of on/offlining a core, while it has been taken out of the coherency domain. Any use intended to ensure that the contents of the cache have made it to main memory is unreliable, since cacheline migration and non-architected system caches may cause these contents to linger elsewhere, without being visible in main memory once the MMU and caches are disabled. In KVM on Linux, there are horrid hacks in place to ensure that such set/way operations are trapped, and replaced with a single by-VA clean/invalidate of the entire guest VA space once the MMU state changes, which can be costly, and is unnecessary if we manage the caches a bit more carefully, and perform maintenance by virtual address only. So let's get rid of the call to ArmInvalidateDataCache () in the PrePeiCore startup code, and instead, invalidate the UEFI memory region by virtual address, which is the only memory region we will be touching with the caches and MMU both disabled and enabled. (This will lead to data corruption if data written with the MMU off is shadowed by clean, stale cachelines that stick around when the MMU is enabled again.) Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Acked-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Pete Batard <pete@akeo.ie> Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Diffstat (limited to 'ArmPlatformPkg')
-rw-r--r--ArmPlatformPkg/PrePi/PeiMPCore.inf1
-rw-r--r--ArmPlatformPkg/PrePi/PeiUniCore.inf1
-rw-r--r--ArmPlatformPkg/PrePi/PrePi.c8
3 files changed, 7 insertions, 3 deletions
diff --git a/ArmPlatformPkg/PrePi/PeiMPCore.inf b/ArmPlatformPkg/PrePi/PeiMPCore.inf
index 9c5da0d42a..053f9fd9e6 100644
--- a/ArmPlatformPkg/PrePi/PeiMPCore.inf
+++ b/ArmPlatformPkg/PrePi/PeiMPCore.inf
@@ -37,6 +37,7 @@
[LibraryClasses]
BaseLib
+ CacheMaintenanceLib
DebugLib
DebugAgentLib
ArmLib
diff --git a/ArmPlatformPkg/PrePi/PeiUniCore.inf b/ArmPlatformPkg/PrePi/PeiUniCore.inf
index ee9b05b253..78d218ae09 100644
--- a/ArmPlatformPkg/PrePi/PeiUniCore.inf
+++ b/ArmPlatformPkg/PrePi/PeiUniCore.inf
@@ -37,6 +37,7 @@
[LibraryClasses]
BaseLib
+ CacheMaintenanceLib
DebugLib
DebugAgentLib
ArmLib
diff --git a/ArmPlatformPkg/PrePi/PrePi.c b/ArmPlatformPkg/PrePi/PrePi.c
index 74284f1883..5129dd09a8 100644
--- a/ArmPlatformPkg/PrePi/PrePi.c
+++ b/ArmPlatformPkg/PrePi/PrePi.c
@@ -8,6 +8,7 @@
#include <PiPei.h>
+#include <Library/CacheMaintenanceLib.h>
#include <Library/DebugAgentLib.h>
#include <Library/PrePiLib.h>
#include <Library/PrintLib.h>
@@ -178,8 +179,6 @@ CEntryPoint (
// Data Cache enabled on Primary core when MMU is enabled.
ArmDisableDataCache ();
- // Invalidate Data cache
- ArmInvalidateDataCache ();
// Invalidate instruction cache
ArmInvalidateInstructionCache ();
// Enable Instruction Caches on all cores.
@@ -200,6 +199,10 @@ CEntryPoint (
// If not primary Jump to Secondary Main
if (ArmPlatformIsPrimaryCore (MpId)) {
+
+ InvalidateDataCacheRange ((VOID *)UefiMemoryBase,
+ FixedPcdGet32 (PcdSystemMemoryUefiRegionSize));
+
// Goto primary Main.
PrimaryMain (UefiMemoryBase, StacksBase, StartTimeStamp);
} else {
@@ -209,4 +212,3 @@ CEntryPoint (
// DXE Core should always load and never return
ASSERT (FALSE);
}
-