summaryrefslogtreecommitdiffstats
path: root/ArmVirtPkg/Library
diff options
context:
space:
mode:
authorArd Biesheuvel <ardb@kernel.org>2023-01-04 16:51:35 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-01-10 17:37:39 +0000
commitec54ce1f1ab41b92782b37ae59e752fff0ef9c41 (patch)
treea492453bac971fc30d9865e3f70cb730bb663de8 /ArmVirtPkg/Library
parent5ee17c5418bd4e0b26686bff14b71b3d83438a30 (diff)
downloadedk2-ec54ce1f1ab41b92782b37ae59e752fff0ef9c41.tar.gz
edk2-ec54ce1f1ab41b92782b37ae59e752fff0ef9c41.tar.bz2
edk2-ec54ce1f1ab41b92782b37ae59e752fff0ef9c41.zip
ArmVirtPkg/ArmVirtQemu: Avoid early ID map on ThunderX
The early ID map used by ArmVirtQemu uses ASID scoped non-global mappings, as this allows us to switch to the permanent ID map seamlessly without the need for explicit TLB maintenance. However, this triggers a known erratum on ThunderX, which does not tolerate non-global mappings that are executable at EL1, as this appears to result in I-cache corruption. (Linux disables the KPTI based Meltdown mitigation on ThunderX for the same reason) So work around this, by detecting the CPU implementor and part number, and proceeding without the early ID map if a ThunderX CPU is detected. Note that this requires the C code to be built with strict alignment again, as we may end up executing it with the MMU and caches off. Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Acked-by: Laszlo Ersek <lersek@redhat.com> Tested-by: dann frazier <dann.frazier@canonical.com>
Diffstat (limited to 'ArmVirtPkg/Library')
-rw-r--r--ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelper.S15
1 files changed, 15 insertions, 0 deletions
diff --git a/ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelper.S b/ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelper.S
index 1787d52fbf..5ac7c732f6 100644
--- a/ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelper.S
+++ b/ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelper.S
@@ -42,6 +42,21 @@
ASM_FUNC(ArmPlatformPeiBootAction)
+#ifdef CAVIUM_ERRATUM_27456
+ /*
+ * On Cavium ThunderX, using non-global mappings that are executable at EL1
+ * results in I-cache corruption. So just avoid the early ID mapping there.
+ *
+ * MIDR implementor 0x43
+ * MIDR part numbers 0xA1 0xA2 (but not 0xAF)
+ */
+ mrs x0, midr_el1 // read the MIDR into X0
+ ubfx x1, x0, #24, #8 // grab implementor id
+ ubfx x0, x0, #7, #9 // grab part number bits [11:3]
+ cmp x1, #0x43 // compare implementor id
+ ccmp x0, #0xA0 >> 3, #0, eq // compare part# bits [11:3]
+ b.eq 0f
+#endif
mrs x0, CurrentEL // check current exception level
tbnz x0, #3, 0f // omit early ID map if above EL1