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 2/3] aarch64: Enable use of FPMR
Date: Sun, 11 May 2025 10:52:10 +0100 [thread overview]
Message-ID: <20250511095211.1638852-3-mark.rutland@arm.com> (raw)
In-Reply-To: <20250511095211.1638852-1-mark.rutland@arm.com>
FEAT_FPMR adds the FPMR register. Acceses to FPMR (whether direct or
indirect) trap to EL3 unless SCR_EL3.EnFPM is set, and so boot-wrapper
support is necessary.
Support for FEAT_FPMR was added to Linux in v6.8 without any
boot-wrapper support. Consequently when FPMR is enabled in a model, the
kernel will hang when attempting to write to the FPMR (e.g. when
entering userspace for the first time).
Add boot-wrapper support for FEAT_FPMR, 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
The ID_AA64PFR2_EL1 ID register has existed as reserved RES0 space since
ARMv8.0 but only recently gained a name, and so older assemblers may not
be able to encode ID_AA64PFR2_EL1 directly. Thus we need an explicit
definition of the sysreg encoding to support these assemblers.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Mark Brown <broonie@kernel.org>
---
arch/aarch64/include/asm/cpu.h | 4 ++++
arch/aarch64/init.c | 3 +++
2 files changed, 7 insertions(+)
diff --git a/arch/aarch64/include/asm/cpu.h b/arch/aarch64/include/asm/cpu.h
index 22d6cbf..aab7657 100644
--- a/arch/aarch64/include/asm/cpu.h
+++ b/arch/aarch64/include/asm/cpu.h
@@ -75,6 +75,7 @@
#define SCR_EL3_SCTLR2En BIT(44)
#define SCR_EL3_PIEN BIT(45)
#define SCR_EL3_D128En BIT(47)
+#define SCR_EL3_EnFPM BIT(50)
#define SCR_EL3_FGTEN2 BIT(59)
#define VTCR_EL2_MSA BIT(31)
@@ -125,6 +126,9 @@
#define ID_AA64PFR1_EL1_CSV2_frac BITS(35, 32)
#define ID_AA64PFR1_EL1_THE BITS(51, 48)
+#define ID_AA64PFR2_EL1 s3_0_c0_c4_2
+#define ID_AA64PFR2_EL1_FPMR BITS(35, 32)
+
#define ID_AA64SMFR0_EL1 s3_0_c0_c4_5
#define ID_AA64SMFR0_EL1_FA64 BIT(63)
diff --git a/arch/aarch64/init.c b/arch/aarch64/init.c
index fe7ed5f..bb19848 100644
--- a/arch/aarch64/init.c
+++ b/arch/aarch64/init.c
@@ -133,6 +133,9 @@ static void cpu_init_el3(void)
if (mrs_field(ID_AA64PFR1_EL1, THE))
scr |= SCR_EL3_RCWMASKEn;
+ if (mrs_field(ID_AA64PFR2_EL1, FPMR))
+ scr |= SCR_EL3_EnFPM;
+
msr(SCR_EL3, scr);
msr(CPTR_EL3, cptr);
--
2.30.2
next prev parent reply other threads:[~2025-05-11 9:56 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 ` Mark Rutland [this message]
2025-05-11 9:52 ` [BOOT-WRAPPER PATCH 3/3] aarch64: Enable use of ZT0 Mark Rutland
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-3-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