Skip to content

Commit 22b70e6

Browse files
dann frazierctmarinas
authored andcommitted
arm64: Restore forced disabling of KPTI on ThunderX
A noted side-effect of commit 0c6c2d3 ("arm64: Generate cpucaps.h") is that cpucaps are now sorted, changing the enumeration order. This assumed no dependencies between cpucaps, which turned out not to be true in one case. UNMAP_KERNEL_AT_EL0 currently needs to be processed after WORKAROUND_CAVIUM_27456. ThunderX systems are incompatible with KPTI, so unmap_kernel_at_el0() bails if WORKAROUND_CAVIUM_27456 is set. But because of the sorting, WORKAROUND_CAVIUM_27456 will not yet have been considered when unmap_kernel_at_el0() checks for it, so the kernel tries to run w/ KPTI - and quickly falls over. Because all ThunderX implementations have homogeneous CPUs, we can remove this dependency by just checking the current CPU for the erratum. Fixes: 0c6c2d3 ("arm64: Generate cpucaps.h") Cc: <[email protected]> # 5.13.x Signed-off-by: dann frazier <[email protected]> Suggested-by: Suzuki K Poulose <[email protected]> Reviewed-by: Suzuki K Poulose <[email protected]> Reviewed-by: Mark Brown <[email protected]> Acked-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 0e3dbf7 commit 22b70e6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

arch/arm64/kernel/cpufeature.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,9 +1526,13 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry,
15261526
/*
15271527
* For reasons that aren't entirely clear, enabling KPTI on Cavium
15281528
* ThunderX leads to apparent I-cache corruption of kernel text, which
1529-
* ends as well as you might imagine. Don't even try.
1529+
* ends as well as you might imagine. Don't even try. We cannot rely
1530+
* on the cpus_have_*cap() helpers here to detect the CPU erratum
1531+
* because cpucap detection order may change. However, since we know
1532+
* affected CPUs are always in a homogeneous configuration, it is
1533+
* safe to rely on this_cpu_has_cap() here.
15301534
*/
1531-
if (cpus_have_const_cap(ARM64_WORKAROUND_CAVIUM_27456)) {
1535+
if (this_cpu_has_cap(ARM64_WORKAROUND_CAVIUM_27456)) {
15321536
str = "ARM64_WORKAROUND_CAVIUM_27456";
15331537
__kpti_forced = -1;
15341538
}

0 commit comments

Comments
 (0)