@@ -211,6 +211,7 @@ TEST_GEN_PROGS_powerpc += dirty_log_test
TEST_GEN_PROGS_powerpc += dirty_log_perf_test
TEST_GEN_PROGS_powerpc += guest_print_test
TEST_GEN_PROGS_powerpc += hardware_disable_test
+TEST_GEN_PROGS_powerpc += kvm_create_max_vcpus
TEST_GEN_PROGS_powerpc += kvm_page_table_test
TEST_GEN_PROGS_powerpc += max_guest_memory_test
TEST_GEN_PROGS_powerpc += memslot_modification_stress_test
@@ -51,6 +51,15 @@ int main(int argc, char *argv[])
pr_info("KVM_CAP_MAX_VCPU_ID: %d\n", kvm_max_vcpu_id);
pr_info("KVM_CAP_MAX_VCPUS: %d\n", 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
+
/*
* Check that we're allowed to open nr_fds_wanted file descriptors and
* try raising the limits if needed.
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. And enable the test case. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> --- tools/testing/selftests/kvm/Makefile | 1 + tools/testing/selftests/kvm/kvm_create_max_vcpus.c | 9 +++++++++ 2 files changed, 10 insertions(+)