[PATCH v2 2/5] KVM: arm64: PMU: Disallow vPMU on non-uniform PMUVer systems

Oliver Upton oliver.upton at linux.dev
Mon Jul 31 09:41:02 PDT 2023


On Mon, Jul 31, 2023 at 04:54:04AM -0700, Reiji Watanabe wrote:
> Hi Oliver,
> 
> > This doesn't actually disallow userspace from configuring a vPMU, it
> > only hides the KVM cap. kvm_host_pmu_init() will still insert the host
> > PMU instance in the list of valid PMUs, and there doesn't appear to be
> > any check against the static key anywhere on that path.
> 
> In v6.5-rc3, which I used as the base, or even in v6.5-rc4,
> it appears kvm_reset_vcpu() checks against the static key.
> So, the initial KVM_ARM_VCPU_INIT with vPMU configured will
> fail on the systems.  Or am I missing something ? (Or is that
> going to be removed by other patches that are already queued?)

No, I definitely missed something, sorry for the noise! I had only
checked the PMU attributes, forgot about feature flags for a moment.

> > I actually prefer where we flip the static key, as PMU context switching
> > depends on both KVM support as well as the PMU driver coming up successfully.
> > Instead, you could hoist the check against the sanitised PMU version into
> > kvm_host_pmu_init(), maybe something like:
> 
> Thank you, it looks better.  I will fix this in v3.

Sounds good, thanks!

--
Best,
Oliver



More information about the linux-arm-kernel mailing list