summaryrefslogtreecommitdiffstats
path: root/ArmPkg/Library/ArmMmuLib
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2020-03-07 09:38:49 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-03-10 00:19:30 +0000
commit748fea6279efc20de3fef483deb4b774f3c34906 (patch)
tree6a0b82186cd2b0a445076487b39a8353debe02e5 /ArmPkg/Library/ArmMmuLib
parent191fa79bcee103457724a4ac7cbda8c03bedac6a (diff)
downloadedk2-748fea6279efc20de3fef483deb4b774f3c34906.tar.gz
edk2-748fea6279efc20de3fef483deb4b774f3c34906.tar.bz2
edk2-748fea6279efc20de3fef483deb4b774f3c34906.zip
ArmPkg/ArmMmuLib AARCH64: invalidate page tables before populating them
As it turns out, ARMv8 also permits accesses made with the MMU and caches off to hit in the caches, so to ensure that any modifications we make before enabling the MMU are visible afterwards as well, we should invalidate page tables right after allocation like we do now on ARM, if the MMU is still disabled at that point. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Leif Lindholm <leif@nuviainc.com> Message-Id: <20200307083849.8940-3-ard.biesheuvel@linaro.org>
Diffstat (limited to 'ArmPkg/Library/ArmMmuLib')
-rw-r--r--ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
index 00a38bc31d..221175ca65 100644
--- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
+++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
@@ -204,6 +204,14 @@ UpdateRegionMappingRecursive (
return EFI_OUT_OF_RESOURCES;
}
+ if (!ArmMmuEnabled ()) {
+ //
+ // Make sure we are not inadvertently hitting in the caches
+ // when populating the page tables.
+ //
+ InvalidateDataCacheRange (TranslationTable, EFI_PAGE_SIZE);
+ }
+
if ((*Entry & TT_TYPE_MASK) == TT_TYPE_BLOCK_ENTRY) {
//
// We are splitting an existing block entry, so we have to populate
@@ -602,6 +610,12 @@ ArmConfigureMmu (
*TranslationTableSize = RootTableEntryCount * sizeof(UINT64);
}
+ //
+ // Make sure we are not inadvertently hitting in the caches
+ // when populating the page tables.
+ //
+ InvalidateDataCacheRange (TranslationTable,
+ RootTableEntryCount * sizeof(UINT64));
ZeroMem (TranslationTable, RootTableEntryCount * sizeof(UINT64));
TranslationTableAttribute = TT_ATTR_INDX_INVALID;