Thread (13 messages) 13 messages, 4 authors, 17h ago

[PATCH v7 3/8] KVM: selftests: Skip the max vCPU ID test when KVM_CAP_PPC_SMT is set

flat view
HOTtoday IN LINUX-NEXT: 1 (0M)

From: "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>
Date: 2026-10-06 10:29:59
Also in: kvm, lkml
Subsystem: kernel selftest framework, kernel virtual machine (kvm), the rest · Maintainers: Shuah Khan, Shuah Khan, Paolo Bonzini, Linus Torvalds

Revision v7 of 5 in this series; 1 review trailer; queued in linux-next as 2bc2c4a8105f on 2026-10-13.

Revisions (5)
  1. v3 [diff vs current]
  2. v4 [diff vs current]
  3. v5 [diff vs current]
  4. v6 [diff vs current]
  5. v7 current
kvm_create_max_vcpus creates vCPUs from 0..MAX_VCPUS-1, then again
with ids at the top of KVM_CAP_MAX_VCPU_ID.

On PowerPC the vCPU id is not a flat index: it encodes SMT thread plus
core. So on powerpc 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.

So, skip that second loop when KVM_CAP_PPC_SMT is non-zero. The cap is
0 on other arches, so they still run it. The 0..MAX_VCPUS pass is
unchanged.

Suggested-by: Sean Christopherson <seanjc@google.com>
Tested-by: Anushree Mathur <redacted>
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
 tools/testing/selftests/kvm/kvm_create_max_vcpus.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kvm/kvm_create_max_vcpus.c b/tools/testing/selftests/kvm/kvm_create_max_vcpus.c
index c5310736ed06..1b95027d41ba 100644
--- a/tools/testing/selftests/kvm/kvm_create_max_vcpus.c
+++ b/tools/testing/selftests/kvm/kvm_create_max_vcpus.c
@@ -58,7 +58,13 @@ int main(int argc, char *argv[])

 	test_vcpu_creation(0, kvm_max_vcpus);

-	if (kvm_max_vcpu_id > kvm_max_vcpus)
+	/*
+	 * Skip the vCPU ID test when running on PowerPC with SMT support, in
+	 * which case system topology is encoded into the vCPU ID and so a VM
+	 * can't use the full advertised vCPU ID range without crafting a valid
+	 * platform specific topology.
+	 */
+	if (kvm_max_vcpu_id > kvm_max_vcpus && !kvm_check_cap(KVM_CAP_PPC_SMT))
 		test_vcpu_creation(
 			kvm_max_vcpu_id - kvm_max_vcpus, kvm_max_vcpus);

--
2.39.5

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help