mbox series

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

Message ID 20230819043947.4100985-1-reijiw@google.com (mailing list archive)
Headers show
Series KVM: arm64: PMU: Fix PMUver related handling of vPMU support | expand

Message

Reiji Watanabe Aug. 19, 2023, 4:39 a.m. UTC
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

Comments

Marc Zyngier Aug. 20, 2023, 8:44 a.m. UTC | #1
On Fri, 18 Aug 2023 21:39:43 -0700, Reiji Watanabe wrote:
> 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.
> 
> [...]

Applied to next, thanks!

[1/4] KVM: arm64: PMU: Disallow vPMU on non-uniform PMUVer
      commit: ec3eb9ed6081bea8ebf603ff545dba127071b928
[2/4] KVM: arm64: PMU: Avoid inappropriate use of host's PMUVer
      commit: 335ca49ff31f145c0f08540614062197a334e064
[3/4] KVM: arm64: PMU: Don't advertise the STALL_SLOT event
      commit: 8c694f557fd80ca9815ddb1cf5de10d8bf168110
[4/4] KVM: arm64: PMU: Don't advertise STALL_SLOT_{FRONTEND,BACKEND}
      commit: 64b81000b60b70f10a5834023fe100902d9f7a57

Cheers,

	M.