Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Fuad Tabba <fuad.tabba@linux.dev>
To: Marc Zyngier <maz@kernel.org>, Oliver Upton <oupton@kernel.org>
Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
	Joey Gouly <joey.gouly@arm.com>,
	Steffen Eiden <seiden@linux.ibm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Vincent Donnefort <vdonnefort@google.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Sean Christopherson <seanjc@google.com>,
	Shuah Khan <shuah@kernel.org>,
	James Clark <james.clark@linaro.org>,
	Fuad Tabba <tabba@google.com>
Subject: [PATCH 0/2] KVM: arm64: Fix PMU counter overflows for non-protected guests in pKVM
Date: Fri,  4 Dec 2026 10:49:09 +0000	[thread overview]
Message-ID: <20261204104911.2797512-1-fuad.tabba@linux.dev> (raw)

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


             reply	other threads:[~2026-12-04 10:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 10:49 Fuad Tabba [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261204104911.2797512-1-fuad.tabba@linux.dev \
    --to=fuad.tabba@linux.dev \
    --cc=catalin.marinas@arm.com \
    --cc=james.clark@linaro.org \
    --cc=joey.gouly@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=seiden@linux.ibm.com \
    --cc=shuah@kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=tabba@google.com \
    --cc=vdonnefort@google.com \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox