All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64: Restore forced disabling of KPTI on ThunderX
@ 2021-09-22 13:59 dann frazier
  2021-09-22 14:11 ` Mark Brown
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: dann frazier @ 2021-09-22 13:59 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>
---
 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;
 	}
-- 
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	[flat|nested] 5+ messages in thread

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


[-- Attachment #1.1: Type: text/plain, Size: 328 bytes --]

On Wed, Sep 22, 2021 at 07:59:24AM -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

Reviwed-by: Mark Brown <broonie@kernel.org>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
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] 5+ messages in thread

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

On Wed, 22 Sep 2021 14:59:24 +0100,
dann frazier <dann.frazier@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@arm.com>
> Cc: stable@vger.kernel.org # 5.13+
> Signed-off-by: dann frazier <dann.frazier@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@kernel.org>

	M.

-- 
Without deviation from the norm, progress is not possible.

_______________________________________________
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] 5+ messages in thread

* Re: [PATCH] arm64: Restore forced disabling of KPTI on ThunderX
  2021-09-22 13:59 [PATCH] arm64: Restore forced disabling of KPTI on ThunderX dann frazier
  2021-09-22 14:11 ` Mark Brown
  2021-09-22 18:59 ` Marc Zyngier
@ 2021-09-23  9:41 ` Suzuki K Poulose
  2021-09-23 14:45   ` dann frazier
  2 siblings, 1 reply; 5+ messages in thread
From: Suzuki K Poulose @ 2021-09-23  9:41 UTC (permalink / raw)
  To: dann frazier, Catalin Marinas, Will Deacon
  Cc: Mark Brown, linux-arm-kernel, Marc Zyngier, Mark Rutland

On 22/09/2021 14:59, 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.
> 
> 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>
> ---
>   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)) {

Please could you also update the comment right above this line to
explain, why we do this and why this is fine (just like you have
in the description) ? Something like :

	 * Since we cannot rely on the order of the cpucaps
  	 * we cannot rely on the cpus_have_*cap() helpers to
	 * detect the erratum on the system. However, since
	 * affected CPUs are always in a homoegeneous configuration
	 * we could rely on this_cpu_has_cap()
	 */

So that looking at the code, it is easier to comprehend what we
figured out in the mailing list (and the description)

With that:

Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>

Suzuki

_______________________________________________
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] 5+ messages in thread

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

On Thu, Sep 23, 2021 at 10:41:00AM +0100, Suzuki K Poulose wrote:
> On 22/09/2021 14:59, 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.
> > 
> > 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>
> > ---
> >   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)) {
> 
> Please could you also update the comment right above this line to
> explain, why we do this and why this is fine (just like you have
> in the description) ? Something like :
> 
> 	 * Since we cannot rely on the order of the cpucaps
>  	 * we cannot rely on the cpus_have_*cap() helpers to
> 	 * detect the erratum on the system. However, since
> 	 * affected CPUs are always in a homoegeneous configuration
> 	 * we could rely on this_cpu_has_cap()
> 	 */
> 
> So that looking at the code, it is easier to comprehend what we
> figured out in the mailing list (and the description)

Sure thing, v2 coming shortly.

  -dann

> With that:
> 
> Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> 
> Suzuki

_______________________________________________
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] 5+ messages in thread

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-22 13:59 [PATCH] arm64: Restore forced disabling of KPTI on ThunderX dann frazier
2021-09-22 14:11 ` Mark Brown
2021-09-22 18:59 ` Marc Zyngier
2021-09-23  9:41 ` Suzuki K Poulose
2021-09-23 14:45   ` dann frazier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.