From: "Pierre-Clément Tosi" <ptosi@google.com>
To: Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>
Cc: "Mark Rutland" <mark.rutland@arm.com>,
"Ryan Roberts" <ryan.roberts@arm.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
"Pierre-Clément Tosi" <ptosi@google.com>,
"Marc Zyngier" <maz@kernel.org>
Subject: [PATCH 4/5] arm64: cpufeature: Add cpucap for DCZID_EL0.DZP
Date: Tue, 01 Dec 2026 16:00:55 +0100 [thread overview]
Message-ID: <20261201-mte-page-optim-v1-4-322b9e4096c7@google.com> (raw)
In-Reply-To: <20261201-mte-page-optim-v1-0-322b9e4096c7@google.com>
Enable the use of static branches on a system-wide CPU capability
matching a (sanitized) DCZID_EL0.DZP by introducing ARM64_HAS_DC_ZVA.
Note that the architecture does not guarantee this field to be constant
(EL2 can alter it for EL1, and EL1 for EL0) but it seems impossible to
me to have a well-behaved system using DZP-dependent instructions under
conditions where the bit flips dynamically as the check MRS DCZID_EL0
followed by DC *VA is inherently TOCTOU-prone. If EL2 lets Linux boot
with DZP=0 and then decides to set it, it must emulate the instructions.
Also note that the polarity of the capability means that instructions
patched with this cpucap default to an always-valid fallback e.g. STZGM
instead of DC GZVA. Similarly, heterogeneous systems with differing DZP
values get sanitized to not having the capability.
Cc: Marc Zyngier <maz@kernel.org>
Signed-off-by: Pierre-Clément Tosi <ptosi@google.com>
---
arch/arm64/kernel/cpufeature.c | 14 ++++++++++++++
arch/arm64/tools/cpucaps | 1 +
2 files changed, 15 insertions(+)
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index e817d49037a6..09302f5ebc91 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -2424,6 +2424,13 @@ test_has_gicv5_legacy(const struct arm64_cpu_capabilities *entry, int scope)
return !!(read_sysreg_s(SYS_ICC_IDR0_EL1) & ICC_IDR0_EL1_GCIE_LEGACY);
}
+static bool has_dc_zva(const struct arm64_cpu_capabilities *entry, int scope)
+{
+ u64 dczid = read_scoped_sysreg(entry, scope);
+
+ return !SYS_FIELD_GET(DCZID_EL0, DZP, dczid);
+}
+
static const struct arm64_cpu_capabilities arm64_features[] = {
{
.capability = ARM64_ALWAYS_BOOT,
@@ -2619,6 +2626,13 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
ARM64_CPUID_FIELDS(ID_AA64PFR0_EL1, AMU, IMP)
},
#endif /* CONFIG_ARM64_AMU_EXTN */
+ {
+ .desc = "Data cache zero by VA permitted (DCZID_EL0.DZP == 0)",
+ .capability = ARM64_HAS_DC_ZVA,
+ .type = ARM64_CPUCAP_SYSTEM_FEATURE,
+ .sys_reg = SYS_DCZID_EL0,
+ .matches = has_dc_zva,
+ },
{
.desc = "Data cache clean to the PoU not required for I/D coherence",
.capability = ARM64_HAS_CACHE_IDC,
diff --git a/arch/arm64/tools/cpucaps b/arch/arm64/tools/cpucaps
index 51f5683374b0..283cc1c8fbe6 100644
--- a/arch/arm64/tools/cpucaps
+++ b/arch/arm64/tools/cpucaps
@@ -21,6 +21,7 @@ HAS_CNP
HAS_CRC32
HAS_DCPODP
HAS_DCPOP
+HAS_DC_ZVA
HAS_DIT
HAS_E0PD
HAS_ECV
--
2.56.1.839.g22a8290db9-goog
next prev parent reply other threads:[~2026-12-01 15:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 15:00 [PATCH 0/5] Optimize the MTE page tagging API Pierre-Clément Tosi
2026-12-01 15:00 ` [PATCH 1/5] arm64: Factor out macros in MTE assembly routines Pierre-Clément Tosi
2026-12-01 15:00 ` [PATCH 2/5] arm64: Use STZGM in __mte_tag_clear_page() Pierre-Clément Tosi
2026-12-01 15:00 ` [PATCH 3/5] arm64: Unroll 2x and align mte_tag_*pages() loops Pierre-Clément Tosi
2026-12-01 15:00 ` Pierre-Clément Tosi [this message]
2026-12-01 15:00 ` [PATCH 5/5] arm64: Use ARM64_HAS_DC_ZVA for MTE page tagging Pierre-Clément Tosi
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=20261201-mte-page-optim-v1-4-322b9e4096c7@google.com \
--to=ptosi@google.com \
--cc=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=will@kernel.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
all inboxes | Powered by JetHome®