Re: [PATCH] KVM: arm64: Expose PMMIR_EL1.SLOTS to guests
From: Congkai Tan
Date: Mon Jun 08 2026 - 17:05:29 EST
On Mon, Jun 01, 2026 at 01:06:17PM -0700, Oliver Upton wrote:
> We can't change the value of PMMIR_EL1 unconditionally since older KVM
> treated this register as RAZ/WI. This also mixes poorly with the default
> PMU garbage that we have since as the value of the register can change
> based on where KVM_ARM_VCPU_INIT gets called...
>
> Considering everything, I'd like to see this wired up where:
>
> - PMMIR_EL1.SLOTS takes the value of the underlying hardware PMU only
> if the VMM explicitly selects a particular PMU implementation
>
> - KVM allows userspace to set PMMIR_EL1.SLOTS=0 for backwards
> compatibility
Thanks a lot for the review! Makes sense. We'll work on v2, and here is
the high-level design we plan to follow:
- Introduce a new VM-wide field, e.g. kvm->arch.pmmir_slots.
- Seed it from the underlying hardware value only when handling
KVM_ARM_VCPU_PMU_V3_SET_PMU; otherwise it stays 0.
- access_pmmir() returns whatever is in pmmir_slots.
- set_pmmir() writes pmmir_slots to 0 if the user input is 0;
otherwise it no-ops or rejects.
This way the guest only sees the underlying hardware value if the VMM
selects a PMU via KVM_ARM_VCPU_PMU_V3_SET_PMU, and userspace can pin
SLOTS = 0 through KVM_SET_ONE_REG for backwards compatibility.
Please let me know if there are any concerns. I'll send v2 once it's
ready.
Thanks,
Congkai