[PATCH v9 20/22] KVM: arm64: Add vCPU device attr to partition the PMU
James Clark
james.clark at linaro.org
Wed Sep 30 08:27:27 PDT 2026
On 24/09/2026 18:29, Colton Lewis wrote:
> Add the KVM_ARM_VCPU_PMU_V3_ENABLE_PARTITION vCPU device attribute to
> enable a Partitioned PMU for a VM where PMUv3 and VHE are supported.
>
> When partitioning is enabled (tracked via
> KVM_ARCH_FLAG_PARTITION_PMU_ENABLED), userspace must explicitly
> configure the number of guest event counters via
> KVM_ARM_VCPU_PMU_V3_SET_NR_COUNTERS with a value strictly less than the
> maximum number of general-purpose counters implemented by the PMU (or
> 0 only when FEAT_HPMN0 is supported), leaving at least one
> general-purpose counter reserved for host profiling prior to calling
> KVM_ARM_VCPU_PMU_V3_INIT.
>
> Signed-off-by: Colton Lewis <coltonlewis at google.com>
> ---
> Documentation/virt/kvm/devices/vcpu.rst | 42 ++++++++++++++-
> arch/arm64/include/asm/kvm_host.h | 1 +
> arch/arm64/include/uapi/asm/kvm.h | 2 +
> arch/arm64/kvm/pmu.c | 71 ++++++++++++++++++++++++-
> arch/arm64/kvm/sys_regs.c | 5 +-
> 5 files changed, 118 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/virt/kvm/devices/vcpu.rst b/Documentation/virt/kvm/devices/vcpu.rst
> index deb5c51bc00c8..fb5921ed9dea2 100644
> --- a/Documentation/virt/kvm/devices/vcpu.rst
> +++ b/Documentation/virt/kvm/devices/vcpu.rst
> @@ -57,6 +57,9 @@ Returns:
> hardware PMU, or interrupt number not set (non-GICv5
> guests, only)
> -EBUSY PMUv3 already initialized
> + -EINVAL Partitioning enabled without explicitly configuring
> + fewer than max_counters via
> + KVM_ARM_VCPU_PMU_V3_SET_NR_COUNTERS
> ======= ======================================================
>
> Request the initialization of the PMUv3. If using the PMUv3 with an in-kernel
> @@ -162,7 +165,8 @@ the cpu field to the processor id.
> -EFAULT Error accessing the value pointed to by addr
> -ENODEV PMUv3 not supported or GIC not initialized
> -EINVAL No PMUv3 explicitly selected, or value of N out of
> - range
> + range (or N >= max_counters when partitioning is
> + enabled)
"No PMUv3 explicitly selected, or value of N > max_counters, or N >
max_counters - 1 when partitioning is enabled".
That might be clearer, otherwise it seems like max_counters being
relevant to "out of range" only applies to when partitioning is enabled,
not that it's max_counters all the time but one is -1.
More information about the linux-arm-kernel
mailing list