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.
This patch allows us to 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.

Suggested-by: Sean Christopherson <[email protected]>
Signed-off-by: Ritesh Harjani (IBM) <[email protected]>
---
 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..59ddc3757943 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


Reply via email to