Kernel KVM virtualization development
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: selftests: Pin vpmu_counter_access to one CPU
@ 2026-11-25 15:36 James Clark
  2026-11-25 15:42 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: James Clark @ 2026-11-25 15:36 UTC (permalink / raw)
  To: Leo Yan, Marc Zyngier, Oliver Upton, Fuad Tabba, Joey Gouly,
	Steffen Eiden, Suzuki K Poulose, Zenghui Yu, Paolo Bonzini,
	Sean Christopherson, Shuah Khan, Colton Lewis
  Cc: linux-arm-kernel, kvmarm, kvm, linux-kselftest, James Clark

The vpmu_counter_access test reads the maximum PMCR_EL0.N from one VM
and then creates new VMs for each number of counters up to that limit.
If the test migrates between CPU types the limit may not be valid for
the new VM which causes:

  ==== Test Assertion Failure ====
    arm64/vpmu_counter_access.c:483: !ret
    pid=9165 tid=9165 errno=22 - Invalid argument
  ...
    KVM_SET_DEVICE_ATTR failed, rc: -1 errno: 22 (Invalid argument)

For example on a Radxa Orion O6 with 20 counters on the big cores and 6
on the little cores, this happens on most runs.

Fix it by pinning the test to the CPU that it starts on before any VMs
are created.

Signed-off-by: James Clark <james.clark@linaro.org>
---
Assisted by Claude Opus 5.5.
---
 tools/testing/selftests/kvm/arm64/vpmu_counter_access.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/testing/selftests/kvm/arm64/vpmu_counter_access.c b/tools/testing/selftests/kvm/arm64/vpmu_counter_access.c
index 22223395969e..e7eac736260e 100644
--- a/tools/testing/selftests/kvm/arm64/vpmu_counter_access.c
+++ b/tools/testing/selftests/kvm/arm64/vpmu_counter_access.c
@@ -626,6 +626,9 @@ int main(void)
 {
 	u64 i, pmcr_n;
 
+	/* get_pmcr_n_limit() can be different across CPUs, so pin */
+	pin_self_to_any_cpu();
+
 	TEST_REQUIRE(kvm_has_cap(KVM_CAP_ARM_PMU_V3));
 	TEST_REQUIRE(kvm_supports_vgic_v3());
 	TEST_REQUIRE(kvm_supports_nr_counters_attr());

---
base-commit: 5715eba4f80a7655d85581c6c951b71d2abbd725
change-id: 20261125-james-kvm-pin-pmu-test-720393980044

Best regards,
--  
James Clark <james.clark@linaro.org>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM: arm64: selftests: Pin vpmu_counter_access to one CPU
  2026-11-25 15:36 [PATCH] KVM: arm64: selftests: Pin vpmu_counter_access to one CPU James Clark
@ 2026-11-25 15:42 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-25 15:42 UTC (permalink / raw)
  To: James Clark; +Cc: kvmarm, kvm, Oliver Upton, Marc Zyngier

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] KVM: arm64: selftests: missing Fixes trailer for
  vpmu_counter_access
--

commit 743d06a69fdece62aa16db9a505ef5da1403cfd6
Author: James Clark <james.clark@linaro.org>

> KVM: arm64: selftests: Pin vpmu_counter_access to one CPU
>
> The vpmu_counter_access test reads the maximum PMCR_EL0.N from one VM
> and then creates new VMs for each number of counters up to that limit.
> If the test migrates between CPU types the limit may not be valid for
> the new VM which causes:
>
>   ==== Test Assertion Failure ====
>     arm64/vpmu_counter_access.c:483: !ret
>     pid=9165 tid=9165 errno=22 - Invalid argument
>   ...
>     KVM_SET_DEVICE_ATTR failed, rc: -1 errno: 22 (Invalid argument)
>
> For example on a Radxa Orion O6 with 20 counters on the big cores and 6
> on the little cores, this happens on most runs.
>
> Fix it by pinning the test to the CPU that it starts on before any VMs
> are created.
>
> Signed-off-by: James Clark <james.clark@linaro.org>

[Severity: Low]
This fixes a bug present since the test was introduced.  Should this
include:

  Fixes: 8d0aebe1ca2b ("KVM: selftests: aarch64: Introduce vpmu_counter_access test")

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261125-james-kvm-pin-pmu-test-v1-1-c3ce989233fb@linaro.org?part=1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-25 15:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 15:36 [PATCH] KVM: arm64: selftests: Pin vpmu_counter_access to one CPU James Clark
2026-11-25 15:42 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox