[PATCH v3 0/4] KVM: arm64: PMU: Fix PMUver related handling of vPMU support

Reiji Watanabe reijiw at google.com
Fri Aug 18 21:39:43 PDT 2023


This series fixes a couple of PMUver related handling of
vPMU support.

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 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 [1]).

The patch-2 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-3 and patch-4 will try to hide the STALL_SLOT*
events unconditionally per Oliver's suggestion [2].
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-3 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-4 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-rc6.

v3:
 - Fixed to not insert the host PMU instance in the list of valid
   PMUs [Oliver]

v2: https://lore.kernel.org/all/20230728181907.1759513-1-reijiw@google.com/
 - Combined a two separate v1 series
 - Disallow STALL_SLOT* event unconditionally [Oliver]

v1: https://lore.kernel.org/all/20230610061520.3026530-1-reijiw@google.com/
    https://lore.kernel.org/all/20230610194510.4146549-1-reijiw@google.com/

[1] https://lore.kernel.org/all/874jnqp73o.wl-maz@kernel.org/
[2] https://lore.kernel.org/all/ZIm1kdFBfXYMdfbV@linux.dev/

Reiji Watanabe (4):
  KVM: arm64: PMU: Disallow vPMU on non-uniform PMUVer
  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/pmu-emul.c | 37 ++++++++++++++++++++++++++-----------
 1 file changed, 26 insertions(+), 11 deletions(-)


base-commit: 2ccdd1b13c591d306f0401d98dedc4bdcd02b421
-- 
2.42.0.rc1.204.g551eb34607-goog




More information about the linux-arm-kernel mailing list