From: Catalin Marinas <catalin.marinas@arm.com>
To: Fuad Tabba <fuad.tabba@linux.dev>
Cc: Will Deacon <will@kernel.org>,
linux-arm-kernel@lists.infradead.org,
Marc Zyngier <maz@kernel.org>, Oliver Upton <oupton@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Mark Brown <broonie@kernel.org>,
kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org,
Fuad Tabba <tabba@google.com>
Subject: Re: [PATCH v4 1/2] arm64: Apply overrides to CPU local capabilities
Date: Wed, 26 Aug 2026 14:47:15 +0100 [thread overview]
Message-ID: <ao7uY-dpJocX6ety@arm.com> (raw)
In-Reply-To: <20260825164219.3347229-2-fuad.tabba@linux.dev>
On Tue, Aug 25, 2026 at 05:42:18PM +0100, Fuad Tabba wrote:
> From: Suzuki K Poulose <suzuki.poulose@arm.com>
>
> If an override has been applied, make sure we apply that for the
> secondary CPUs too, to limit the features.
>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> Link: https://lore.kernel.org/all/afc5bd00-28ca-413b-b047-ee53589c285d@arm.com/
> Cc: stable@vger.kernel.org
> [Fuad: whitespace and comment fixes]
> Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
For completeness, we should add:
Fixes: b3341ae0efa2 ("arm64: cpufeature: Use IDreg override in __read_sysreg_by_encoding()")
> diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
> index 9a22df0c5120f..88b15b5ef2f7f 100644
> --- a/arch/arm64/kernel/cpufeature.c
> +++ b/arch/arm64/kernel/cpufeature.c
> @@ -1232,10 +1232,43 @@ void __init init_cpu_features(struct cpuinfo_arm64 *info)
> init_cpu_ftr_reg(SYS_GMID_EL1, info->reg_gmid);
> }
>
> +/*
> + * Sanitise the register fields to clamp the values to the overrides that
> + * have been applied.
> + */
> +static u64 override_cpu_ftr_reg(struct arm64_ftr_reg *reg, u64 val)
> +{
> + const struct arm64_ftr_bits *ftrp;
> +
> + if (!reg || !reg->override->mask)
> + return val;
> +
> + for (ftrp = reg->ftr_bits; ftrp->width; ftrp++) {
> + u64 ftr_mask = arm64_ftr_mask(ftrp);
> + s64 ftr_val, ftr_ovr, ftr_safe;
> +
> + /* Skip the fields not overridden */
> + if ((ftr_mask & reg->override->mask) != ftr_mask)
> + continue;
> +
> + ftr_val = arm64_ftr_value(ftrp, val);
> + ftr_ovr = arm64_ftr_value(ftrp, reg->override->val);
> + ftr_safe = arm64_ftr_safe_value(ftrp, ftr_ovr, ftr_val);
> +
> + if (ftr_safe != ftr_val)
> + val = arm64_ftr_set_value(ftrp, val, ftr_safe);
> + }
> +
> + return val;
> +}
> +
> static void update_cpu_ftr_reg(struct arm64_ftr_reg *reg, u64 new)
> {
> const struct arm64_ftr_bits *ftrp;
>
> + /* Apply the overrides */
> + new = override_cpu_ftr_reg(reg, new);
Not sure we need this. The init value has already been clamped, made
safe, so it won't change the result.
Otherwise:
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
next prev parent reply other threads:[~2026-08-26 13:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 16:42 [PATCH v4 0/2] arm64: Clamp ID overrides and gate the GMID_EL1 read Fuad Tabba
2026-08-25 16:42 ` [PATCH v4 1/2] arm64: Apply overrides to CPU local capabilities Fuad Tabba
2026-08-26 13:47 ` Catalin Marinas [this message]
2026-08-27 8:58 ` Fuad Tabba
2026-08-25 16:42 ` [PATCH v4 2/2] arm64: Don't read GMID_EL1 when MTE is disabled Fuad Tabba
2026-08-26 13:48 ` Catalin Marinas
2026-08-27 12:56 ` Will Deacon
2026-08-27 13:19 ` Will Deacon
2026-08-28 10:50 ` Catalin Marinas
2026-08-28 13:53 ` Will Deacon
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=ao7uY-dpJocX6ety@arm.com \
--to=catalin.marinas@arm.com \
--cc=broonie@kernel.org \
--cc=fuad.tabba@linux.dev \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=tabba@google.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®