Re: [PATCH v5] KVM: arm64: Trap guest MPAM accesses whenever MPAM is implemented

From: Fuad Tabba

Date: Wed Nov 25 2026 - 04:20:18 EST


On Tue, 24 Nov 2026 at 12:00, Ben Horgan <ben.horgan@xxxxxxx> wrote:
>
> Hi Fuad,
>
> On 02/11/2026 09:56, Fuad Tabba wrote:
> > finalise_el2_state() clears the EL2 MPAM traps on every CPU whose ID
> > registers advertise MPAM once the arm64.nompam override is applied.
> > KVM sets them again on guest entry only when ARM64_MPAM is set, a
> > capability that also requires MPAM1_EL1.MPAMEN. Without EL3, only
> > MPAM2_EL2.MPAMEN is writable, and the kernel never sets it, so
> > ARM64_MPAM stays clear and so do the traps. A guest can then access
> > MPAM0_EL1, MPAM1_EL1, MPAMSM_EL1 and MPAMIDR_EL1 while its
> > ID_AA64PFR0_EL1.MPAM reads 0.
> >
> > Record two per-CPU flags at KVM's CPU init: whether MPAM is
> > implemented as finalise_el2_state() tests it, and whether
> > MPAMIDR_EL1.HAS_HCR is set (MPAMHCR_EL2 is UNDEFINED without it).
> > Read ID_AA64PFR0_EL1, ID_AA64PFR1_EL1 and MPAMIDR_EL1 from cpu_data,
> > which holds them with the overrides applied since commit 342e62ded77c6
> > ("arm64: cpufeature: Read MPAMIDR_EL1 in __cpuinfo_store_cpu()"). Set
>
> Ok as long as this patch isn't expected to be backported.

Nope. I didn't tag it as stable.

> > the traps from those flags. MPAMEN isn't part of any MPAM trap
> > condition, so the traps take effect whether or not it is set.
> >
> > Fixes: 31ff96c38ea3 ("KVM: arm64: Fix missing traps of guest accesses to the MPAM registers")
> > Signed-off-by: Fuad Tabba <fuad.tabba@xxxxxxxxx>
>
>
> Reviewed-by: Ben Horgan <ben.horgan@xxxxxxx>

Thanks!
/fuad