From: Mark Rutland <mark.rutland@arm.com>
To: linux-arm-kernel@lists.infradead.org
Cc: broonie@kernel.org, mark.rutland@arm.com
Subject: [BOOT-WRAPPER PATCH 3/3] aarch64: Enable use of ZT0
Date: Sun, 11 May 2025 10:52:11 +0100 [thread overview]
Message-ID: <20250511095211.1638852-4-mark.rutland@arm.com> (raw)
In-Reply-To: <20250511095211.1638852-1-mark.rutland@arm.com>
FEAT_SME2 adds the ZT0 register. Accesses to ZT0 trap to EL3 unless
SMCR_EL3.EZT0 is set, and so boot-wrapper support is necessary.
Support for FEAT_SME2 was added to Linux in v6.3 without any
boot-wrapper support. Consequently when SME2 is enabled in a model, any
attempt to access ZT0 (whether in userspace, kernel, or hypervisor) will
result in a hang. Linux will (only) access ZT0 during a context switch
when PSTATE.ZA==1, and so this hang is seen long after boot, when
applications first set PSTATE.ZA.
Add boot-wrapper support for ZT0, as described in the latest ARM ARM
(ARM DDI 0487 L.a), which can be found at:
https://developer.arm.com/documentation/ddi0487/la/?lang=en
All we need to do at EL3 is set SMCR_EL3.EZT0; it's up to lower ELs to
configure their SMCR_ELx register appropriately.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Mark Brown <broonie@kernel.org>
---
arch/aarch64/include/asm/cpu.h | 1 +
arch/aarch64/init.c | 3 +++
2 files changed, 4 insertions(+)
diff --git a/arch/aarch64/include/asm/cpu.h b/arch/aarch64/include/asm/cpu.h
index aab7657..2b3a659 100644
--- a/arch/aarch64/include/asm/cpu.h
+++ b/arch/aarch64/include/asm/cpu.h
@@ -175,6 +175,7 @@
#define ZCR_EL3_LEN_MAX 0xf
#define SMCR_EL3 s3_6_c1_c2_6
+#define SMCR_EL3_EZT0 BIT(30)
#define SMCR_EL3_FA64 BIT(31)
#define SMCR_EL3_LEN_MAX 0xf
diff --git a/arch/aarch64/init.c b/arch/aarch64/init.c
index bb19848..e1640a9 100644
--- a/arch/aarch64/init.c
+++ b/arch/aarch64/init.c
@@ -189,6 +189,9 @@ static void cpu_init_el3(void)
if (mrs_field(ID_AA64SMFR0_EL1, FA64))
smcr |= SMCR_EL3_FA64;
+ if (mrs_field(ID_AA64PFR1_EL1, SME) >= 2)
+ smcr |= SMCR_EL3_EZT0;
+
msr(SMCR_EL3, smcr);
}
}
--
2.30.2
next prev parent reply other threads:[~2025-05-11 10:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-11 9:52 [BOOT-WRAPPER PATCH 0/3] Enable use of FPMR and ZT0 Mark Rutland
2025-05-11 9:52 ` [BOOT-WRAPPER PATCH 1/3] aarch64: shuffle ID_AA64PFR{0,1}_EL1 definitions Mark Rutland
2025-05-11 9:52 ` [BOOT-WRAPPER PATCH 2/3] aarch64: Enable use of FPMR Mark Rutland
2025-05-11 9:52 ` Mark Rutland [this message]
2025-05-14 6:07 ` [BOOT-WRAPPER PATCH 0/3] Enable use of FPMR and ZT0 Mark Rutland
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250511095211.1638852-4-mark.rutland@arm.com \
--to=mark.rutland@arm.com \
--cc=broonie@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox