[PATCH] arm64: Restore forced disabling of KPTI on ThunderX
Marc Zyngier
maz at kernel.org
Wed Sep 22 11:59:59 PDT 2021
On Wed, 22 Sep 2021 14:59:24 +0100,
dann frazier <dann.frazier at canonical.com> 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.
>
> 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 at arm.com>
> Cc: stable at vger.kernel.org # 5.13+
> Signed-off-by: dann frazier <dann.frazier at canonical.com>
> ---
> arch/arm64/kernel/cpufeature.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
> index f8a3067d10c6..7275b49034f3 100644
> --- a/arch/arm64/kernel/cpufeature.c
> +++ b/arch/arm64/kernel/cpufeature.c
> @@ -1528,7 +1528,7 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry,
> * ThunderX leads to apparent I-cache corruption of kernel text, which
> * ends as well as you might imagine. Don't even try.
> */
> - 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;
> }
Ouch, nice catch. Hopefully, nobody will build a big-little system
using TX1 in this instance of the universe.
Acked-by: Marc Zyngier <maz at kernel.org>
M.
--
Without deviation from the norm, progress is not possible.
More information about the linux-arm-kernel
mailing list