All of lore.kernel.org
 help / color / mirror / Atom feed
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 v5] arm64: Don't read GMID_EL1 when MTE is disabled
Date: Fri, 28 Aug 2026 12:25:27 +0100	[thread overview]
Message-ID: <apFwJ-HHukM7XLCD@arm.com> (raw)
In-Reply-To: <20260827185937.1369099-1-fuad.tabba@linux.dev>

On Thu, Aug 27, 2026 at 07:59:37PM +0100, Fuad Tabba wrote:
> +bool gmid_el1_accessible(const struct cpuinfo_arm64 *info)
> +{
> +	const struct arm64_ftr_bits *ftrp;
> +	s64 mte, ovr;
> +	u64 ftr_mask;
> +
> +	/* No ID register reflects CONFIG_ARM64_MTE. */
> +	if (!IS_ENABLED(CONFIG_ARM64_MTE))
> +		return false;
> +
> +	for (ftrp = ftr_id_aa64pfr1; ftrp->width; ftrp++) {
> +		if (ftrp->shift == ID_AA64PFR1_EL1_MTE_SHIFT)
> +			break;
> +	}
> +
> +	ftr_mask = arm64_ftr_mask(ftrp);
> +	mte = arm64_ftr_value(ftrp, info->reg_id_aa64pfr1);
> +
> +	/* The boot CPU runs before init_cpu_ftr_reg() strips unsafe overrides. */
> +	if ((id_aa64pfr1_override.mask & ftr_mask) == ftr_mask) {
> +		ovr = arm64_ftr_value(ftrp, id_aa64pfr1_override.val);
> +		mte = arm64_ftr_safe_value(ftrp, ovr, mte);
> +	}

This works. Or we could cut a few lines and just do
cpuid_feature_extract_unsigned_field() for mte and ovr and do a
hard-coded min(mte, ovr) as we now it's lower-safe. I don't have a
strong opinion either way, so for this patch:

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>


  reply	other threads:[~2026-08-28 11:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-27 18:59 [PATCH v5] arm64: Don't read GMID_EL1 when MTE is disabled Fuad Tabba
2026-08-28 11:25 ` Catalin Marinas [this message]
2026-09-03 13:59 ` 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=apFwJ-HHukM7XLCD@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 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.