]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
arm64: cpufeature: Add support for the MPAM v0.1 architecture version
authorZeng Heng <zengheng4@huawei.com>
Fri, 8 May 2026 16:23:40 +0000 (17:23 +0100)
committerWill Deacon <will@kernel.org>
Tue, 19 May 2026 12:04:28 +0000 (13:04 +0100)
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

Signed-off-by: Zeng Heng <zengheng4@huawei.com>
Reviewed-by: James Morse <james.morse@arm.com>
Signed-off-by: James Morse <james.morse@arm.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/include/asm/cpufeature.h
arch/arm64/include/asm/el2_setup.h
arch/arm64/kernel/cpufeature.c

index 4de51f8d92cbacb24ba1e4f88e8c348e78a1d475..a57870fa96db5bd4741832f2bbde765cca42abbe 100644 (file)
@@ -620,6 +620,13 @@ static inline bool id_aa64pfr0_mpam(u64 pfr0)
        return val > 0;
 }
 
+static inline bool id_aa64pfr1_mpamfrac(u64 pfr1)
+{
+       u32 val = cpuid_feature_extract_unsigned_field(pfr1, ID_AA64PFR1_EL1_MPAM_frac_SHIFT);
+
+       return val > 0;
+}
+
 static inline bool id_aa64pfr1_mte(u64 pfr1)
 {
        u32 val = cpuid_feature_extract_unsigned_field(pfr1, ID_AA64PFR1_EL1_MTE_SHIFT);
index 587507a9980ec108fecb31b24a614c9d007cb181..aa8ec9df8024360e456906a78ccf5c6f233f3e57 100644 (file)
 #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
 
 .Linit_mpam_\@:
        mov     x0, #MPAM2_EL2_EnMPAMSM_MASK
index 6d53bb15cf7bb48e926330c7ff0c93c0c14b14c2..0a1d198b3995142c60174129386ca66a5d916af1 100644 (file)
@@ -1164,6 +1164,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 */
@@ -1211,7 +1219,7 @@ void __init init_cpu_features(struct cpuinfo_arm64 *info)
                cpacr_restore(cpacr);
        }
 
-       if (id_aa64pfr0_mpam(read_sanitised_ftr_reg(SYS_ID_AA64PFR0_EL1))) {
+       if (detect_ftr_has_mpam()) {
                info->reg_mpamidr = read_cpuid(MPAMIDR_EL1);
                init_cpu_ftr_reg(SYS_MPAMIDR_EL1, info->reg_mpamidr);
        }
@@ -1467,7 +1475,7 @@ void update_cpu_features(int cpu,
                cpacr_restore(cpacr);
        }
 
-       if (id_aa64pfr0_mpam(read_sanitised_ftr_reg(SYS_ID_AA64PFR0_EL1))) {
+       if (detect_ftr_has_mpam()) {
                info->reg_mpamidr = read_cpuid(MPAMIDR_EL1);
                taint |= check_update_ftr_reg(SYS_MPAMIDR_EL1, cpu,
                                        info->reg_mpamidr, boot->reg_mpamidr);
@@ -2486,7 +2494,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. */
@@ -3093,7 +3101,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",