Re: [PATCH v2] KVM: arm64: Trap guest MPAM accesses whenever MPAM is implemented
From: Fuad Tabba
Date: Fri Sep 11 2026 - 03:16:02 EST
On Thu, 10 Sept 2026 at 11:40, Will Deacon <will@xxxxxxxxxx> wrote:
...
> > +static bool
> > +test_has_mpam_sysregs(const struct arm64_cpu_capabilities *entry, int __unused)
> > +{
> > + /* The registers exist whether or not firmware enabled MPAM. */
> > + return detect_ftr_has_mpam();
> > +}
> > +
> > static void
> > cpu_enable_mpam(const struct arm64_cpu_capabilities *entry)
> > {
> > @@ -3116,6 +3123,12 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
> > .matches = test_has_mpam,
> > .cpu_enable = cpu_enable_mpam,
> > },
> > + {
> > + .desc = "Memory Partitioning And Monitoring system registers",
> > + .type = ARM64_CPUCAP_SYSTEM_FEATURE,
> > + .capability = ARM64_MPAM_SYSREGS,
> > + .matches = test_has_mpam_sysregs,
> > + },
>
> We already have two system capabilities for MPAM so I'm not overly keen
> to add a third, especially as the MPAM code is largely confined to the
> resctrl driver. In fact, this feels a bit similar to things like TRBE
> and SPE in the sense that (a) we have to probe it per-cpu (b) it can
> be disabled by a higher EL and (c) most of the code is in a driver, but
> KVM needs to know how to switch it.
>
> Neither TRBE nor SPE need entries in arm64_features[] at all, so something
> isn't right here...
I think I've overthunk it. The problem isn't in what the host is
doing, but that KVM is basing its traps on whether MPAM support exists
and whether that support is enabled.
V3 should be more in line with what you're suggesting...
Cheers,
/fuad
>
> Will