Skip to content

KVM: arm64: Fix PMU counter overflows for non-protected guests in pKVM

Fuad Tabba kvm kvmarm linux-arm-kernel linux-kselftest 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2KVM: arm64: Don't copy the PMU registers between the host and hyp vCPUarch/arm64/kvm/hyp/nvhe/hyp-main.c+11 -10 replies
2/2KVM: arm64: selftests: Test PMU counter overflow in vpmu_counter_accesstools/testing/selftests/kvm/arm64/vpmu_counter_access.c+213 -11 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] KVM: arm64: Fix PMU counter overflows for non-protected guests in pKVM

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/[email protected]/

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

Signature · 1 line
2.47.3