From: Nicholas Piggin <[email protected]>

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 <[email protected]>
[Rebased to laest mainline tree]
Signed-off-by: Ritesh Harjani (IBM) <[email protected]>
---
 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


Reply via email to