[PATCH 0/2] KVM: arm64: Fix PMU counter overflows for non-protected guests in pKVM
Fuad Tabba
fuad.tabba at linux.dev
Fri Dec 4 02:49:09 PST 2026
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
More information about the linux-arm-kernel
mailing list