[PATCH v2 0/5] KVM: arm64: PMU: Fix PMUver related handling for vPMU support

Reiji Watanabe reijiw at google.com
Fri Jul 28 11:19:02 PDT 2023


This is a consolidated v2 of two separate series, [1] and [2].

On systems where the PMUVer is not uniform across all PEs,
KVM currently does not advertise PMUv3 to the guest,
even if userspace successfully runs KVM_ARM_VCPU_INIT with
KVM_ARM_VCPU_PMU_V3.
The patch-1 and patch-2 will address this inconsistent
behavior by disallowing userspace from configuring vPMU,
as such systems would be extremely uncommon and unlikely
to even use KVM (according to Marc [3]).

The patch-3 will fix improper use of the host's PMUver to
determine a valid range of PMU events for the guest (the
guest's PMUver should be used instead).

The patch-4 and patch-5 will try to hide the STALL_SLOT*
events unconditionally per Oliver's suggestion [4].

Presently, KVM hides the STALL_SLOT event depending on the
host PMU version, instead of the guest's PMU version, which
doesn't seem to be accurate, as it appears that older PMU than
PMUv3p4 could implement the event according to the Arm ARM.
Exposing the STALL_SLOT event without PMMIR_EL1 (supported
from PMUv3p4) for the guest won't be very useful though.
The patch-4 stops advertising the event for guest unconditionally,
rather than fixing or keeping the inaccurate checking to advertise
the event for the case, where it is not very useful.
The patch-5 stops advertising the STALL_SLOT_{FRONT,BACK}END
events to the guest, similar to the STALL_SLOT event, as when any
of these three events are implemented, all three of them should
be implemented, according to the Arm ARM.

This series is based on 6.5-rc3.

[1] https://lore.kernel.org/all/20230610061520.3026530-1-reijiw@google.com/
[2] https://lore.kernel.org/all/20230610194510.4146549-1-reijiw@google.com/
[3] https://lore.kernel.org/all/874jnqp73o.wl-maz@kernel.org/
[4] https://lore.kernel.org/all/ZIm1kdFBfXYMdfbV@linux.dev/

Reiji Watanabe (5):
  KVM: arm64: PMU: Use of pmuv3_implemented() instead of open-coded
    version
  KVM: arm64: PMU: Disallow vPMU on non-uniform PMUVer systems
  KVM: arm64: PMU: Avoid inappropriate use of host's PMUVer
  KVM: arm64: PMU: Don't advertise the STALL_SLOT event
  KVM: arm64: PMU: Don't advertise STALL_SLOT_{FRONTEND,BACKEND}

 arch/arm64/kvm/arm.c      |  1 +
 arch/arm64/kvm/pmu-emul.c | 44 ++++++++++++++++++++++++++-------------
 include/kvm/arm_pmu.h     |  3 +++
 3 files changed, 34 insertions(+), 14 deletions(-)


base-commit: 6eaae198076080886b9e7d57f4ae06fa782f90ef
-- 
2.41.0.585.gd2178a4bd4-goog




More information about the linux-arm-kernel mailing list