Kernel KVM virtualization development
 help / color / mirror / Atom feed
* [PATCH 0/2] KVM: arm64: Fix PMU counter overflows for non-protected guests in pKVM
@ 2026-12-04 10:49 Fuad Tabba
  2026-12-04 10:49 ` [PATCH 1/2] KVM: arm64: Don't copy the PMU registers between the host and hyp vCPU Fuad Tabba
  2026-12-04 10:49 ` [PATCH 2/2] KVM: arm64: selftests: Test PMU counter overflow in vpmu_counter_access Fuad Tabba
  0 siblings, 2 replies; 5+ messages in thread
From: Fuad Tabba @ 2026-12-04 10:49 UTC (permalink / raw)
  To: Marc Zyngier, Oliver Upton
  Cc: kvmarm, linux-arm-kernel, kvm, linux-kselftest, Joey Gouly,
	Steffen Eiden, Suzuki K Poulose, Zenghui Yu, Catalin Marinas,
	Will Deacon, Mark Rutland, Vincent Donnefort, Paolo Bonzini,
	Sean Christopherson, Shuah Khan, James Clark, Fuad Tabba

Hi folks,

A non-protected guest in pKVM loses PMU counter overflows. When a
counter overflows, the host sets the counter's bit in its copy of
PMOVSSET_EL0, and the next lazy state sync overwrites that copy with the
hyp vCPU's stale one. The guest then takes no overflow interrupt, or
takes it with the overflow bit clear. Patch 1 leaves the PMU registers
out of the sync.

I went through the other writes the host makes without first syncing
the guest's state, and they only touch the timer registers, which the
sync already skips.

Patch 2 adds a test case for counter overflow to vpmu_counter_access,
which fails in pKVM without the fix and passes with it in pKVM, nVHE,
VHE and NV. On a host with more than one PMU type, the test needs
James's fix [1].

Based on Linux 7.4-rc5 (fe6ff8d5d675c; also applies to kvmarm/fixes
012e4bc01e339).

Cheers,
/fuad

[1] https://lore.kernel.org/all/20261125-james-kvm-pin-pmu-test-v1-1-c3ce989233fb@linaro.org/

Fuad Tabba (2):
  KVM: arm64: Don't copy the PMU registers between the host and hyp vCPU
  KVM: arm64: selftests: Test PMU counter overflow in
    vpmu_counter_access

 arch/arm64/kvm/hyp/nvhe/hyp-main.c            |  12 +-
 .../selftests/kvm/arm64/vpmu_counter_access.c | 214 +++++++++++++++++-
 2 files changed, 224 insertions(+), 2 deletions(-)


base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
-- 
2.47.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-12-04 11:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 10:49 [PATCH 0/2] KVM: arm64: Fix PMU counter overflows for non-protected guests in pKVM Fuad Tabba
2026-12-04 10:49 ` [PATCH 1/2] KVM: arm64: Don't copy the PMU registers between the host and hyp vCPU Fuad Tabba
2026-12-04 10:49 ` [PATCH 2/2] KVM: arm64: selftests: Test PMU counter overflow in vpmu_counter_access Fuad Tabba
2026-12-04 11:06   ` sashiko-bot
2026-12-04 11:55     ` Fuad Tabba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox