The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Oliver Upton <oupton@kernel.org>
To: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Cc: Marc Zyngier <maz@kernel.org>, Joey Gouly <joey.gouly@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>, Kees Cook <kees@kernel.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Jonathan Corbet <corbet@lwn.net>, Shuah Khan <shuah@kernel.org>,
	Shuah Khan <skhan@linuxfoundation.org>,
	linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org,
	devel@daynix.com, kvm@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v8 1/7] KVM: arm64: Disallow vPMU when pPMUs do not cover all CPUs
Date: Tue, 7 Jul 2026 11:20:05 -0700	[thread overview]
Message-ID: <ak1DVUs0bgkpZh0N@kernel.org> (raw)
In-Reply-To: <e03f17b2-a765-4912-adf6-3da26e7eeecd@rsg.ci.i.u-tokyo.ac.jp>

On Tue, Jul 07, 2026 at 08:08:03PM +0900, Akihiko Odaki wrote:
> On 2026/07/07 2:04, Oliver Upton wrote:
> > Hi,
> > 
> > On Mon, Jul 06, 2026 at 07:03:24PM +0900, Akihiko Odaki wrote:
> > > Commit ec3eb9ed6081 ("KVM: arm64: PMU: Disallow vPMU on non-uniform
> > > PMUVer") made KVM reject vPMU unless the system-wide PMUVer is usable.
> > > That covers systems where PMUv3 is absent or non-uniform, as well as
> > > systems where IMPDEF PMUv3 sysreg traps are unavailable.
> > > 
> > > However, KVM can still accept vPMU when all CPUs uniformly trap PMUv3
> > > sysregs, but the pPMUs registered with KVM only cover a subset of
> > > possible CPUs.
> > > 
> > > Reject vPMU unless the registered pPMUs cover every possible CPU.
> > > This avoids carrying support for partial pPMU coverage into the
> > > fixed-counters-only UAPI introduced later in the series.
> > 
> > Doesn't CPU hotplug screw this up? I could online a CPU that doesn't
> > have a PMU after creating the VM.>
> > I'd rather just change ARM64_WORKAROUND_PMUV3_IMPDEF_TRAPS to become a
> > system feature. That way any CPU which breaks the system-wide assumption
> > cannot be onlined.
> 
> ARM64_WORKAROUND_PMUV3_IMPDEF_TRAPS only says that IMPDEF PMUv3 sysregs are
> trapped. It does not say that KVM has a driver-backed PMU usable for PMUv3
> emulation. This patch checks that extra requirement.
> 
> I re-checked CPU hotplug. Onlining a CPU without a PMU later does not make
> an accepted VM unsafe, since the check is against cpu_possible_mask.

Sorry, I missed that this was against the possible mask.

> The problem is the reverse case on ACPI: this check can disable vPMU when a
> possible CPU is offline. DT populates supported_cpus at boot, while ACPI
> initially populates it only from online CPUs and grows it as matching CPUs
> come online.
> 
> That makes this patch too conservative. In practice, I do not expect systems
> to mix CPUs with and without a usable PMU. A better approach is probably to
> treat such a host as out of spec and add TAINT_CPU_OUT_OF_SPEC. We already
> do that for architectural PMUv3 by detecting mismatches in
> ID_AA64DFR0_EL1.PMUVer; we can do the same for
> ARM64_WORKAROUND_PMUV3_IMPDEF_TRAPS with non-standard PMUs.

The presence of the workaround is, by definition, out of spec. I just
never bothered tainting the kernel because these machines are already
TAINT_CPU_OUT_OF_SPEC by way of the broken VGIC.

Ok, so how about you keep the check that you're doing here and promote
IMPDEF_TRAPS to a system-wide feature? That would satisfy the two
preconditions we have for PMU emulation, which is system register traps
and a backing arm_pmu that understands PMUv3 events.

Thanks,
Oliver

  reply	other threads:[~2026-07-07 18:20 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-06 10:03 [PATCH v8 0/7] KVM: arm64: PMU: Use multiple host PMUs Akihiko Odaki
2026-07-06 10:03 ` [PATCH v8 1/7] KVM: arm64: Disallow vPMU when pPMUs do not cover all CPUs Akihiko Odaki
2026-07-06 17:04   ` Oliver Upton
2026-07-07 11:08     ` Akihiko Odaki
2026-07-07 18:20       ` Oliver Upton [this message]
2026-07-06 10:03 ` [PATCH v8 2/7] KVM: arm64: PMU: Protect the list of PMUs with RCU Akihiko Odaki
2026-07-06 10:03 ` [PATCH v8 3/7] KVM: arm64: PMU: Pass the pPMU to kvm_map_pmu_event() Akihiko Odaki
2026-07-06 10:03 ` [PATCH v8 4/7] KVM: arm64: PMU: Pass the target CPU to kvm_pmu_probe_armpmu() Akihiko Odaki
2026-07-06 10:03 ` [PATCH v8 5/7] KVM: arm64: PMU: Implement fixed-counters-only emulation Akihiko Odaki
2026-07-06 18:23   ` Oliver Upton
2026-07-07 11:23     ` Akihiko Odaki
2026-07-07 12:52       ` Akihiko Odaki
2026-07-07 18:02         ` Oliver Upton
2026-07-06 10:03 ` [PATCH v8 6/7] KVM: arm64: PMU: Introduce FIXED_COUNTERS_ONLY Akihiko Odaki
2026-07-06 17:58   ` Oliver Upton
2026-07-07 11:36     ` Akihiko Odaki
2026-07-06 10:03 ` [PATCH v8 7/7] KVM: arm64: selftests: Test PMU_V3_FIXED_COUNTERS_ONLY Akihiko Odaki
2026-07-06 18:28 ` [PATCH v8 0/7] KVM: arm64: PMU: Use multiple host PMUs Oliver Upton
2026-07-07  7:58   ` Marc Zyngier
2026-07-07  8:10     ` Oliver Upton
2026-07-07  9:41       ` Marc Zyngier

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=ak1DVUs0bgkpZh0N@kernel.org \
    --to=oupton@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=corbet@lwn.net \
    --cc=devel@daynix.com \
    --cc=gustavoars@kernel.org \
    --cc=joey.gouly@arm.com \
    --cc=kees@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
    --cc=pbonzini@redhat.com \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=suzuki.poulose@arm.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