The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: James Morse <james.morse@arm.com>
To: Zeng Heng <zengheng4@huawei.com>,
	xry111@xry111.site, catalin.marinas@arm.com, maz@kernel.org,
	ardb@kernel.org, yang@os.amperecomputing.com,
	ryan.roberts@arm.com, kevin.brodsky@arm.com,
	reinette.chatre@intel.com, miko.lenczewski@arm.com,
	will@kernel.org, suzuki.poulose@arm.com, thuth@redhat.com,
	ben.horgan@arm.com, james.clark@linaro.org,
	lpieralisi@kernel.org, broonie@kernel.org, oupton@kernel.org,
	anshuman.khandual@arm.com, yeoreum.yun@arm.com, leo.yan@arm.com,
	mrigendra.chaubey@gmail.com, fenghuay@nvidia.com,
	ahmed.genidi@arm.com, mark.rutland@arm.com
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, wangkefeng.wang@huawei.com
Subject: Re: [PATCH v2 1/2] arm64: cpufeature: Add support for the MPAM v0.1 architecture version
Date: Thu, 7 May 2026 15:09:05 +0100	[thread overview]
Message-ID: <5869e7ef-fb07-414b-8bf3-359e74444c76@arm.com> (raw)
In-Reply-To: <20260203095406.6437-2-zengheng4@huawei.com>

Hi Zeng,

(sorry for the delay - arm silently blocked your original mail. I've added you
 to the whitelist, we'll see if that actually does anything!)

On 03/02/2026 09:54, Zeng Heng wrote:
> According to the MPAM spec [1], the supported architecture versions are
> v1.0, v1.1 and v0.1. MPAM versions v0.1 and v1.1 are functionally
> identical, but v0.1 additionally supports the FORCE_NS feature.
> 
> ID_AA64PR | ID_AA64PR | MPAM Extension | Notes
> F0_EL1.   | F1_EL1.   | Architecture   |
> MPAM      | MPAM_frac | version        |
> ---------------------------------------------------------------------------
> 0b0000    | 0b0001    | v0.1           | MPAM v0.1 is implemented.
>           |           |                | MPAM v0.1 is the same as MPAM v1.1
>           |           |                | with FORCE_NS which is
>           |           |                | incompatible with MPAM v1.0.
> ---------------------------------------------------------------------------
> 0b0001    | 0b0000    | v1.0           | MPAM v1.0 is implemented.
> ---------------------------------------------------------------------------
> 0b0001    | 0b0001    | v1.1           | MPAM v1.1 is implemented.
>           |           |                | MPAM v1.1 includes all features of
>           |           |                | MPAM v1.0.
>           |           |                | It must not include FORCE_NS.
> 
> FORCE_NS is a feature that operates in EL3 mode. Consequently, the current
> Linux MPAM driver is also compatible with MPAM v0.1. To support v0.1, the
> existing driver which only checks ID_AA64PFR0_EL1.MPAM for the major
> version needs to examine ID_AA64PFR1_EL1.MPAM_frac for the minor version
> as well.
> 
> [1] https://developer.arm.com/documentation/ddi0598/db/?lang=en


> diff --git a/arch/arm64/include/asm/el2_setup.h b/arch/arm64/include/asm/el2_setup.h
> index cacd20df1786..606cf14e4044 100644
> --- a/arch/arm64/include/asm/el2_setup.h
> +++ b/arch/arm64/include/asm/el2_setup.h
> @@ -501,7 +501,9 @@
>  #endif
>  
>  .macro finalise_el2_state
> -	check_override id_aa64pfr0, ID_AA64PFR0_EL1_MPAM_SHIFT, .Linit_mpam_\@, .Lskip_mpam_\@, x1, x2
> +	check_override id_aa64pfr0, ID_AA64PFR0_EL1_MPAM_SHIFT, .Linit_mpam_\@, .Lmpam_minor_\@, x1, x2
> +.Lmpam_minor_\@:
> +	check_override id_aa64pfr1, ID_AA64PFR1_EL1_MPAM_frac_SHIFT, .Linit_mpam_\@, .Lskip_mpam_\@, x1, x2

Heh, I see the 'frac' field already has an override.


> diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
> index c840a93b9ef9..e8fa6f7cf2a2 100644
> --- a/arch/arm64/kernel/cpufeature.c
> +++ b/arch/arm64/kernel/cpufeature.c
> @@ -1159,6 +1159,14 @@ static __init void detect_system_supports_pseudo_nmi(void)
>  static inline void detect_system_supports_pseudo_nmi(void) { }
>  #endif
>  
> +static bool detect_ftr_has_mpam(void)
> +{
> +	u64 pfr0 = read_sanitised_ftr_reg(SYS_ID_AA64PFR0_EL1);
> +	u64 pfr1 = read_sanitised_ftr_reg(SYS_ID_AA64PFR1_EL1);
> +
> +	return id_aa64pfr0_mpam(pfr0) || id_aa64pfr1_mpamfrac(pfr1);
> +}
> +
>  void __init init_cpu_features(struct cpuinfo_arm64 *info)
>  {
>  	/* Before we start using the tables, make sure it is sorted */
> @@ -2473,7 +2481,7 @@ cpucap_panic_on_conflict(const struct arm64_cpu_capabilities *cap)
>  static bool
>  test_has_mpam(const struct arm64_cpu_capabilities *entry, int scope)
>  {
> -	if (!has_cpuid_feature(entry, scope))
> +	if (!detect_ftr_has_mpam())
>  		return false;
>  
>  	/* Check firmware actually enabled MPAM on this cpu. */
> @@ -3078,7 +3086,6 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
>  		.capability = ARM64_MPAM,
>  		.matches = test_has_mpam,
>  		.cpu_enable = cpu_enable_mpam,
> -		ARM64_CPUID_FIELDS(ID_AA64PFR0_EL1, MPAM, 1)
>  	},
>  	{
>  		.desc = "Memory Partitioning And Monitoring Virtualisation",

I think this is preferable to a 'metacap' as the pointer auth code does - we never need
to expose the difference between MPAM v0.1 and v1.x to anything.

Reviewed-by: James Morse <james.morse@arm.com>


Thanks,

James

       reply	other threads:[~2026-05-07 14:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260203095406.6437-1-zengheng4@huawei.com>
     [not found] ` <20260203095406.6437-2-zengheng4@huawei.com>
2026-05-07 14:09   ` James Morse [this message]
2026-05-08  6:04     ` [PATCH v2 1/2] arm64: cpufeature: Add support for the MPAM v0.1 architecture version Zeng Heng
     [not found] ` <20260203095406.6437-3-zengheng4@huawei.com>
2026-05-07 16:03   ` [PATCH v2 2/2] arm_mpam: Update architecture version check for MPAM MSC James Morse
2026-05-08  2:26     ` Zeng Heng
2026-05-08  3:47       ` Zeng Heng
2026-05-08  9:37         ` Ben Horgan
2026-05-08  9:56           ` Ben Horgan
2026-05-08 16:07             ` James Morse

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=5869e7ef-fb07-414b-8bf3-359e74444c76@arm.com \
    --to=james.morse@arm.com \
    --cc=ahmed.genidi@arm.com \
    --cc=anshuman.khandual@arm.com \
    --cc=ardb@kernel.org \
    --cc=ben.horgan@arm.com \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=fenghuay@nvidia.com \
    --cc=james.clark@linaro.org \
    --cc=kevin.brodsky@arm.com \
    --cc=leo.yan@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=miko.lenczewski@arm.com \
    --cc=mrigendra.chaubey@gmail.com \
    --cc=oupton@kernel.org \
    --cc=reinette.chatre@intel.com \
    --cc=ryan.roberts@arm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=thuth@redhat.com \
    --cc=wangkefeng.wang@huawei.com \
    --cc=will@kernel.org \
    --cc=xry111@xry111.site \
    --cc=yang@os.amperecomputing.com \
    --cc=yeoreum.yun@arm.com \
    --cc=zengheng4@huawei.com \
    /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