linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] arm64: Restore forced disabling of KPTI on ThunderX
@ 2021-09-23 14:50 dann frazier
  2021-09-23 15:04 ` Catalin Marinas
  0 siblings, 1 reply; 2+ messages in thread
From: dann frazier @ 2021-09-23 14:50 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon
  Cc: Suzuki K Poulose, Mark Brown, linux-arm-kernel, Marc Zyngier,
	Mark Rutland

A noted side-effect of commit 0c6c2d3615ef ("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: 0c6c2d3615ef ("arm64: Generate cpucaps.h")
Suggested-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: stable@vger.kernel.org # 5.13+
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Reviewed-by: Mark Brown <broonie@kernel.org>
Acked-by: Marc Zyngier <maz@kernel.org>
[ dannf: Added comment text ]
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 arch/arm64/kernel/cpufeature.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index f8a3067d10c6..6ec7036ef7e1 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -1526,9 +1526,13 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry,
 	/*
 	 * For reasons that aren't entirely clear, enabling KPTI on Cavium
 	 * ThunderX leads to apparent I-cache corruption of kernel text, which
-	 * ends as well as you might imagine. Don't even try.
+	 * ends as well as you might imagine. Don't even try. We cannot rely
+	 * on the cpus_have_*cap() helpers here to detect the CPU erratum
+	 * because cpucap detection order may change. However, since we know
+	 * affected CPUs are always in a homogeneous configuration, it is
+	 * safe to rely on this_cpu_has_cap() here.
 	 */
-	if (cpus_have_const_cap(ARM64_WORKAROUND_CAVIUM_27456)) {
+	if (this_cpu_has_cap(ARM64_WORKAROUND_CAVIUM_27456)) {
 		str = "ARM64_WORKAROUND_CAVIUM_27456";
 		__kpti_forced = -1;
 	}
-- 
2.33.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] arm64: Restore forced disabling of KPTI on ThunderX
  2021-09-23 14:50 [PATCH v2] arm64: Restore forced disabling of KPTI on ThunderX dann frazier
@ 2021-09-23 15:04 ` Catalin Marinas
  0 siblings, 0 replies; 2+ messages in thread
From: Catalin Marinas @ 2021-09-23 15:04 UTC (permalink / raw)
  To: dann frazier, Will Deacon
  Cc: linux-arm-kernel, Marc Zyngier, Mark Rutland, Mark Brown,
	Suzuki K Poulose

On Thu, 23 Sep 2021 08:50:02 -0600, dann frazier wrote:
> A noted side-effect of commit 0c6c2d3615ef ("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.
> 
> [...]

Applied to arm64 (for-next/fixes), thanks!

[1/1] arm64: Restore forced disabling of KPTI on ThunderX
      https://git.kernel.org/arm64/c/22b70e6f2da0

-- 
Catalin


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-23 15:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-23 14:50 [PATCH v2] arm64: Restore forced disabling of KPTI on ThunderX dann frazier
2021-09-23 15:04 ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).