[PATCH v3 2/6] arm64: cpufeature: discover CPU support for MPAM
Will Deacon
will at kernel.org
Fri Apr 12 07:41:20 PDT 2024
Hi James,
On Thu, Mar 21, 2024 at 04:57:24PM +0000, James Morse wrote:
> ARMv8.4 adds support for 'Memory Partitioning And Monitoring' (MPAM)
> which describes an interface to cache and bandwidth controls wherever
> they appear in the system.
>
> Add support to detect MPAM. Like SVE, MPAM has an extra id register that
> describes some more properties, including the virtualisation support,
> which is optional. Detect this separately so we can detect
> mismatched/insane systems, but still use MPAM on the host even if the
> virtualisation support is missing.
>
> MPAM needs enabling at the highest implemented exception level, otherwise
> the register accesses trap. The 'enabled' flag is accessible to lower
> exception levels, but its in a register that traps when MPAM isn't enabled.
> The cpufeature 'matches' hook is extended to test this on one of the
> CPUs, so that firmware can emulate MPAM as disabled if it is reserved
> for use by secure world.
>
> Secondary CPUs that appear late could trip cpufeature's 'lower safe'
> behaviour after the MPAM properties have been advertised to user-space.
> Add a verify call to ensure late secondaries match the existing CPUs.
>
> (If you have a boot failure that bisects here its likely your CPUs
> advertise MPAM in the id registers, but firmware failed to either enable
> or MPAM, or emulate the trap as if it were disabled)
I'm probably reading this wrong, but I'm a bit confused about the mixture
of open-coded system register definitions and updates to the 'sysreg'
file. For example:
> +/* CPU Registers */
> +#define MPAM_SYSREG_EN BIT_ULL(63)
> +#define MPAM_SYSREG_TRAP_IDR BIT_ULL(58)
> +#define MPAM_SYSREG_TRAP_MPAM0_EL1 BIT_ULL(49)
> +#define MPAM_SYSREG_TRAP_MPAM1_EL1 BIT_ULL(48)
> +#define MPAM_SYSREG_PMG_D GENMASK(47, 40)
> +#define MPAM_SYSREG_PMG_I GENMASK(39, 32)
> +#define MPAM_SYSREG_PARTID_D GENMASK(31, 16)
> +#define MPAM_SYSREG_PARTID_I GENMASK(15, 0)
MPAM_SYSREG_EN is then used in conjuntion with SYS_MPAM1_EL1:
> +static bool __maybe_unused
> +test_has_mpam(const struct arm64_cpu_capabilities *entry, int scope)
> +{
> + if (!has_cpuid_feature(entry, scope))
> + return false;
> +
> + /* Check firmware actually enabled MPAM on this cpu. */
> + return (read_sysreg_s(SYS_MPAM1_EL1) & MPAM_SYSREG_EN);
> +}
But that register has a 'sysreg' entry:
> +Sysreg MPAM1_EL1 3 0 10 5 0
> +Res0 63:48
> +Field 47:40 PMG_D
> +Field 39:32 PMG_I
> +Field 31:16 PARTID_D
> +Field 15:0 PARTID_I
> +EndSysreg
where bit 63 is RES0.
Will
More information about the linux-arm-kernel
mailing list