diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2015-04-14 11:56:56 +0000 |
---|---|---|
committer | oliviermartin <oliviermartin@Edk2> | 2015-04-14 11:56:56 +0000 |
commit | c9e5618f84b0cb54a9ac2d7604f7b7e7859b45a7 (patch) | |
tree | 80d0bbbe7ec148fdadbb79dcd6a8a9ae305f30c6 /ArmPlatformPkg | |
parent | e1d529909966027d2d6a2b0095dcb7a8b0886fa5 (diff) | |
download | edk2-c9e5618f84b0cb54a9ac2d7604f7b7e7859b45a7.zip edk2-c9e5618f84b0cb54a9ac2d7604f7b7e7859b45a7.tar.gz edk2-c9e5618f84b0cb54a9ac2d7604f7b7e7859b45a7.tar.bz2 |
ArmVirtualizationPkg: Xen: shuffle init order to deal with incoherency
In order to prevent memory corruption issues caused by the fact that,
under virtualization, the guest is incoherent with the hypervisor's view
of memory until it enables its caches and MMU, this patch reshuffles the
init sequence so that the Xen shared memory regions are not touched
before the caches and MMU are enabled.
In addition, the loaded image itself is invalidated by virtual address,
to ensure that any runtime changes (such as the applied relocations) will
not suddenly become invisible once we turn the caches on.
Contributed-under: TianoCore Contribution Agreement 1.0
Reviewed-by: Olivier Martin <Olivier.Martin@arm.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17178 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPlatformPkg')
-rwxr-xr-x | ArmPlatformPkg/ArmVirtualizationPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf | 1 | ||||
-rwxr-xr-x | ArmPlatformPkg/ArmVirtualizationPkg/PrePi/PrePi.c | 20 |
2 files changed, 15 insertions, 6 deletions
diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf b/ArmPlatformPkg/ArmVirtualizationPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf index 86cf870..1602338 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 0772805..f9ad374 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>
@@ -102,12 +103,6 @@ PrePiMain ( // Initialize the architecture specific bits
ArchInitialize ();
- // Initialize the Serial Port
- SerialPortInitialize ();
- CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"UEFI firmware (version %s built at %a on %a)\n\r",
- (CHAR16*)PcdGetPtr(PcdFirmwareVersionString), __TIME__, __DATE__);
- SerialPortWrite ((UINT8 *) Buffer, CharCount);
-
// Declare the PI/UEFI memory region
HobList = HobConstructor (
(VOID*)UefiMemoryBase,
@@ -117,10 +112,23 @@ PrePiMain ( );
PrePeiSetHobList (HobList);
+ //
+ // Ensure that the loaded image is invalidated in the caches, so that any
+ // modifications we made with the caches and MMU off (such as the applied
+ // relocations) don't become invisible once we turn them on.
+ //
+ InvalidateDataCacheRange((VOID *)(UINTN)PcdGet64 (PcdFdBaseAddress), PcdGet32 (PcdFdSize));
+
// Initialize MMU and Memory HOBs (Resource Descriptor HOBs)
Status = MemoryPeim (UefiMemoryBase, FixedPcdGet32 (PcdSystemMemoryUefiRegionSize));
ASSERT_EFI_ERROR (Status);
+ // Initialize the Serial Port
+ SerialPortInitialize ();
+ CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"UEFI firmware (version %s built at %a on %a)\n\r",
+ (CHAR16*)PcdGetPtr(PcdFirmwareVersionString), __TIME__, __DATE__);
+ SerialPortWrite ((UINT8 *) Buffer, CharCount);
+
// Create the Stacks HOB (reserve the memory for all stacks)
StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize);
BuildStackHob (StacksBase, StacksSize);
|