All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64: document the boot requirements for MTE
@ 2022-04-04 21:18 ` Peter Collingbourne
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Collingbourne @ 2022-04-04 21:18 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Jonathan Corbet, Mark Brown
  Cc: Peter Collingbourne, linux-arm-kernel, linux-doc, linux-kernel

When booting the kernel we access system registers such as GCR_EL1
if MTE is supported. These accesses are defined to trap to EL3 if
SCR_EL3.ATA is disabled. Furthermore, tag accesses will not behave
as expected if SCR_EL3.ATA is not set, or if HCR_EL2.ATA is not set
and we were booted at EL1. Therefore, require that these bits are
enabled when appropriate.

Signed-off-by: Peter Collingbourne <pcc@google.com>
Link: https://linux-review.googlesource.com/id/Iadcfd4dcd9ba3279b2813970b44d7485b0116709
---
 Documentation/arm64/booting.rst | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/Documentation/arm64/booting.rst b/Documentation/arm64/booting.rst
index 29884b261aa9..833af981b667 100644
--- a/Documentation/arm64/booting.rst
+++ b/Documentation/arm64/booting.rst
@@ -350,6 +350,16 @@ Before jumping into the kernel, the following conditions must be met:
 
     - SMCR_EL2.FA64 (bit 31) must be initialised to 0b1.
 
+  For CPUs with the Memory Tagging Extension feature:
+
+  - If EL3 is present:
+
+    - SCR_EL3.ATA (bit 26) must be initialised to 0b1.
+
+  - If the kernel is entered at EL1 and EL2 is present:
+
+    - HCR_EL2.ATA (bit 56) must be initialised to 0b1.
+
 The requirements described above for CPU mode, caches, MMUs, architected
 timers, coherency and system registers apply to all CPUs.  All CPUs must
 enter the kernel in the same exception level.  Where the values documented
-- 
2.35.1.1094.g7c7d902a7c-goog


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

* [PATCH] arm64: document the boot requirements for MTE
@ 2022-04-04 21:18 ` Peter Collingbourne
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Collingbourne @ 2022-04-04 21:18 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Jonathan Corbet, Mark Brown
  Cc: Peter Collingbourne, linux-arm-kernel, linux-doc, linux-kernel

When booting the kernel we access system registers such as GCR_EL1
if MTE is supported. These accesses are defined to trap to EL3 if
SCR_EL3.ATA is disabled. Furthermore, tag accesses will not behave
as expected if SCR_EL3.ATA is not set, or if HCR_EL2.ATA is not set
and we were booted at EL1. Therefore, require that these bits are
enabled when appropriate.

Signed-off-by: Peter Collingbourne <pcc@google.com>
Link: https://linux-review.googlesource.com/id/Iadcfd4dcd9ba3279b2813970b44d7485b0116709
---
 Documentation/arm64/booting.rst | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/Documentation/arm64/booting.rst b/Documentation/arm64/booting.rst
index 29884b261aa9..833af981b667 100644
--- a/Documentation/arm64/booting.rst
+++ b/Documentation/arm64/booting.rst
@@ -350,6 +350,16 @@ Before jumping into the kernel, the following conditions must be met:
 
     - SMCR_EL2.FA64 (bit 31) must be initialised to 0b1.
 
+  For CPUs with the Memory Tagging Extension feature:
+
+  - If EL3 is present:
+
+    - SCR_EL3.ATA (bit 26) must be initialised to 0b1.
+
+  - If the kernel is entered at EL1 and EL2 is present:
+
+    - HCR_EL2.ATA (bit 56) must be initialised to 0b1.
+
 The requirements described above for CPU mode, caches, MMUs, architected
 timers, coherency and system registers apply to all CPUs.  All CPUs must
 enter the kernel in the same exception level.  Where the values documented
-- 
2.35.1.1094.g7c7d902a7c-goog


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

* Re: [PATCH] arm64: document the boot requirements for MTE
  2022-04-04 21:18 ` Peter Collingbourne
@ 2022-04-05  8:04   ` Mark Brown
  -1 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2022-04-05  8:04 UTC (permalink / raw)
  To: Peter Collingbourne
  Cc: Catalin Marinas, Will Deacon, Jonathan Corbet, linux-arm-kernel,
	linux-doc, linux-kernel


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

On Mon, Apr 04, 2022 at 02:18:58PM -0700, Peter Collingbourne wrote:

> +  For CPUs with the Memory Tagging Extension feature:
> +
> +  - If EL3 is present:
> +
> +    - SCR_EL3.ATA (bit 26) must be initialised to 0b1.
> +
> +  - If the kernel is entered at EL1 and EL2 is present:
> +
> +    - HCR_EL2.ATA (bit 56) must be initialised to 0b1.

Very nitpicky but this is only required for FEAT_MTE2 and above, plain
FEAT_MTE doesn't have these traps.  I don't know that this is a thing
that anyone's actually implemented and from v8.7 on it's not permitted
but the above isn't strictly true if someone did for some reason have
the most basic version.

Otherwise

Reviewed-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] 8+ messages in thread

* Re: [PATCH] arm64: document the boot requirements for MTE
@ 2022-04-05  8:04   ` Mark Brown
  0 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2022-04-05  8:04 UTC (permalink / raw)
  To: Peter Collingbourne
  Cc: Catalin Marinas, Will Deacon, Jonathan Corbet, linux-arm-kernel,
	linux-doc, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 708 bytes --]

On Mon, Apr 04, 2022 at 02:18:58PM -0700, Peter Collingbourne wrote:

> +  For CPUs with the Memory Tagging Extension feature:
> +
> +  - If EL3 is present:
> +
> +    - SCR_EL3.ATA (bit 26) must be initialised to 0b1.
> +
> +  - If the kernel is entered at EL1 and EL2 is present:
> +
> +    - HCR_EL2.ATA (bit 56) must be initialised to 0b1.

Very nitpicky but this is only required for FEAT_MTE2 and above, plain
FEAT_MTE doesn't have these traps.  I don't know that this is a thing
that anyone's actually implemented and from v8.7 on it's not permitted
but the above isn't strictly true if someone did for some reason have
the most basic version.

Otherwise

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

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

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

* Re: [PATCH] arm64: document the boot requirements for MTE
  2022-04-05  8:04   ` Mark Brown
@ 2022-04-22 13:42     ` Catalin Marinas
  -1 siblings, 0 replies; 8+ messages in thread
From: Catalin Marinas @ 2022-04-22 13:42 UTC (permalink / raw)
  To: Mark Brown
  Cc: Peter Collingbourne, Will Deacon, Jonathan Corbet,
	linux-arm-kernel, linux-doc, linux-kernel

On Tue, Apr 05, 2022 at 09:04:04AM +0100, Mark Brown wrote:
> On Mon, Apr 04, 2022 at 02:18:58PM -0700, Peter Collingbourne wrote:
> 
> > +  For CPUs with the Memory Tagging Extension feature:
> > +
> > +  - If EL3 is present:
> > +
> > +    - SCR_EL3.ATA (bit 26) must be initialised to 0b1.
> > +
> > +  - If the kernel is entered at EL1 and EL2 is present:
> > +
> > +    - HCR_EL2.ATA (bit 56) must be initialised to 0b1.
> 
> Very nitpicky but this is only required for FEAT_MTE2 and above, plain
> FEAT_MTE doesn't have these traps.  I don't know that this is a thing
> that anyone's actually implemented

I think that's a valid point. CPUs may implement FEAT_MTE2 but downgrade
it to FEAT_MTE if the SoC does not provide allocation tag storage. So we
should make it clear here that only from FEAT_MTE2 we should set those
bits (ID_AA64PFR1_EL1.MTE >= 2), otherwise they should be 0 or
hyp/firmware risks the OS triggering random external aborts.

> and from v8.7 on it's not permitted but the above isn't strictly true
> if someone did for some reason have the most basic version.

The wording is tricky: "This feature is mandatory from Armv8.7 when
FEAT_MTE2 is implemented". So one can still implement FEAT_MTE (or none
at all).

-- 
Catalin

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

* Re: [PATCH] arm64: document the boot requirements for MTE
@ 2022-04-22 13:42     ` Catalin Marinas
  0 siblings, 0 replies; 8+ messages in thread
From: Catalin Marinas @ 2022-04-22 13:42 UTC (permalink / raw)
  To: Mark Brown
  Cc: Peter Collingbourne, Will Deacon, Jonathan Corbet,
	linux-arm-kernel, linux-doc, linux-kernel

On Tue, Apr 05, 2022 at 09:04:04AM +0100, Mark Brown wrote:
> On Mon, Apr 04, 2022 at 02:18:58PM -0700, Peter Collingbourne wrote:
> 
> > +  For CPUs with the Memory Tagging Extension feature:
> > +
> > +  - If EL3 is present:
> > +
> > +    - SCR_EL3.ATA (bit 26) must be initialised to 0b1.
> > +
> > +  - If the kernel is entered at EL1 and EL2 is present:
> > +
> > +    - HCR_EL2.ATA (bit 56) must be initialised to 0b1.
> 
> Very nitpicky but this is only required for FEAT_MTE2 and above, plain
> FEAT_MTE doesn't have these traps.  I don't know that this is a thing
> that anyone's actually implemented

I think that's a valid point. CPUs may implement FEAT_MTE2 but downgrade
it to FEAT_MTE if the SoC does not provide allocation tag storage. So we
should make it clear here that only from FEAT_MTE2 we should set those
bits (ID_AA64PFR1_EL1.MTE >= 2), otherwise they should be 0 or
hyp/firmware risks the OS triggering random external aborts.

> and from v8.7 on it's not permitted but the above isn't strictly true
> if someone did for some reason have the most basic version.

The wording is tricky: "This feature is mandatory from Armv8.7 when
FEAT_MTE2 is implemented". So one can still implement FEAT_MTE (or none
at all).

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

* Re: [PATCH] arm64: document the boot requirements for MTE
  2022-04-22 13:42     ` Catalin Marinas
@ 2022-04-22 20:29       ` Peter Collingbourne
  -1 siblings, 0 replies; 8+ messages in thread
From: Peter Collingbourne @ 2022-04-22 20:29 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Mark Brown, Will Deacon, Jonathan Corbet, Linux ARM, linux-doc,
	Linux Kernel Mailing List

On Fri, Apr 22, 2022 at 6:42 AM Catalin Marinas <catalin.marinas@arm.com> wrote:
>
> On Tue, Apr 05, 2022 at 09:04:04AM +0100, Mark Brown wrote:
> > On Mon, Apr 04, 2022 at 02:18:58PM -0700, Peter Collingbourne wrote:
> >
> > > +  For CPUs with the Memory Tagging Extension feature:
> > > +
> > > +  - If EL3 is present:
> > > +
> > > +    - SCR_EL3.ATA (bit 26) must be initialised to 0b1.
> > > +
> > > +  - If the kernel is entered at EL1 and EL2 is present:
> > > +
> > > +    - HCR_EL2.ATA (bit 56) must be initialised to 0b1.
> >
> > Very nitpicky but this is only required for FEAT_MTE2 and above, plain
> > FEAT_MTE doesn't have these traps.  I don't know that this is a thing
> > that anyone's actually implemented
>
> I think that's a valid point. CPUs may implement FEAT_MTE2 but downgrade
> it to FEAT_MTE if the SoC does not provide allocation tag storage. So we
> should make it clear here that only from FEAT_MTE2 we should set those
> bits (ID_AA64PFR1_EL1.MTE >= 2), otherwise they should be 0 or
> hyp/firmware risks the OS triggering random external aborts.
>
> > and from v8.7 on it's not permitted but the above isn't strictly true
> > if someone did for some reason have the most basic version.
>
> The wording is tricky: "This feature is mandatory from Armv8.7 when
> FEAT_MTE2 is implemented". So one can still implement FEAT_MTE (or none
> at all).

Okay, I changed it in v2 to explicitly say FEAT_MTE2.

Peter

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

* Re: [PATCH] arm64: document the boot requirements for MTE
@ 2022-04-22 20:29       ` Peter Collingbourne
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Collingbourne @ 2022-04-22 20:29 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Mark Brown, Will Deacon, Jonathan Corbet, Linux ARM, linux-doc,
	Linux Kernel Mailing List

On Fri, Apr 22, 2022 at 6:42 AM Catalin Marinas <catalin.marinas@arm.com> wrote:
>
> On Tue, Apr 05, 2022 at 09:04:04AM +0100, Mark Brown wrote:
> > On Mon, Apr 04, 2022 at 02:18:58PM -0700, Peter Collingbourne wrote:
> >
> > > +  For CPUs with the Memory Tagging Extension feature:
> > > +
> > > +  - If EL3 is present:
> > > +
> > > +    - SCR_EL3.ATA (bit 26) must be initialised to 0b1.
> > > +
> > > +  - If the kernel is entered at EL1 and EL2 is present:
> > > +
> > > +    - HCR_EL2.ATA (bit 56) must be initialised to 0b1.
> >
> > Very nitpicky but this is only required for FEAT_MTE2 and above, plain
> > FEAT_MTE doesn't have these traps.  I don't know that this is a thing
> > that anyone's actually implemented
>
> I think that's a valid point. CPUs may implement FEAT_MTE2 but downgrade
> it to FEAT_MTE if the SoC does not provide allocation tag storage. So we
> should make it clear here that only from FEAT_MTE2 we should set those
> bits (ID_AA64PFR1_EL1.MTE >= 2), otherwise they should be 0 or
> hyp/firmware risks the OS triggering random external aborts.
>
> > and from v8.7 on it's not permitted but the above isn't strictly true
> > if someone did for some reason have the most basic version.
>
> The wording is tricky: "This feature is mandatory from Armv8.7 when
> FEAT_MTE2 is implemented". So one can still implement FEAT_MTE (or none
> at all).

Okay, I changed it in v2 to explicitly say FEAT_MTE2.

Peter

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

end of thread, other threads:[~2022-04-22 21:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-04 21:18 [PATCH] arm64: document the boot requirements for MTE Peter Collingbourne
2022-04-04 21:18 ` Peter Collingbourne
2022-04-05  8:04 ` Mark Brown
2022-04-05  8:04   ` Mark Brown
2022-04-22 13:42   ` Catalin Marinas
2022-04-22 13:42     ` Catalin Marinas
2022-04-22 20:29     ` Peter Collingbourne
2022-04-22 20:29       ` Peter Collingbourne

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.