[RFC v3 04/10] KVM: PPC: selftests: powerpc enable kvm_create_max_vcpus test

From: Ritesh Harjani (IBM)

Date: Wed May 27 2026 - 08:51:57 EST


From: Nicholas Piggin <npiggin@xxxxxxxxx>

powerpc's maximum permitted vCPU ID depends on the VM's SMT mode, and
the maximum reported by KVM_CAP_MAX_VCPU_ID exceeds a simple non-SMT
VM's limit.

The powerpc KVM selftest port uses non-SMT VMs, so add a workaround
to the kvm_create_max_vcpus test case to limit vCPU IDs to
KVM_CAP_MAX_VCPUS on powerpc.

Signed-off-by: Nicholas Piggin <npiggin@xxxxxxxxx>
[Rebased to latest mainline tree]
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@xxxxxxxxx>
---
tools/testing/selftests/kvm/kvm_create_max_vcpus.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/tools/testing/selftests/kvm/kvm_create_max_vcpus.c b/tools/testing/selftests/kvm/kvm_create_max_vcpus.c
index c5310736ed06..a82c13d6cdf5 100644
--- a/tools/testing/selftests/kvm/kvm_create_max_vcpus.c
+++ b/tools/testing/selftests/kvm/kvm_create_max_vcpus.c
@@ -56,6 +56,15 @@ int main(int argc, char *argv[])
"KVM_MAX_VCPU_IDS (%d) must be at least as large as KVM_MAX_VCPUS (%d).",
kvm_max_vcpu_id, kvm_max_vcpus);

+#ifdef __powerpc64__
+ /*
+ * powerpc has a particular format for the vcpu ID that depends on
+ * the guest SMT mode, and the max ID cap is too large for non-SMT
+ * modes, where the maximum ID is the same as the maximum vCPUs.
+ */
+ kvm_max_vcpu_id = kvm_max_vcpus;
+#endif
+
test_vcpu_creation(0, kvm_max_vcpus);

if (kvm_max_vcpu_id > kvm_max_vcpus)
--
2.39.5