]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: selftests: Compute number of extra pages needed in mmu_stress_test
authorSean Christopherson <seanjc@google.com>
Thu, 28 Nov 2024 00:55:38 +0000 (16:55 -0800)
committerSean Christopherson <seanjc@google.com>
Wed, 18 Dec 2024 22:14:56 +0000 (14:14 -0800)
Create mmu_stress_tests's VM with the correct number of extra pages needed
to map all of memory in the guest.  The bug hasn't been noticed before as
the test currently runs only on x86, which maps guest memory with 1GiB
pages, i.e. doesn't need much memory in the guest for page tables.

Reviewed-by: James Houghton <jthoughton@google.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Link: https://lore.kernel.org/r/20241128005547.4077116-8-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/mmu_stress_test.c

index 847da23ec1b120a846722749170c0af2fa693948..5467b12f59036f2f09e094dde5740191cfb2cb81 100644 (file)
@@ -209,7 +209,13 @@ int main(int argc, char *argv[])
        vcpus = malloc(nr_vcpus * sizeof(*vcpus));
        TEST_ASSERT(vcpus, "Failed to allocate vCPU array");
 
-       vm = vm_create_with_vcpus(nr_vcpus, guest_code, vcpus);
+       vm = __vm_create_with_vcpus(VM_SHAPE_DEFAULT, nr_vcpus,
+#ifdef __x86_64__
+                                   max_mem / SZ_1G,
+#else
+                                   max_mem / vm_guest_mode_params[VM_MODE_DEFAULT].page_size,
+#endif
+                                   guest_code, vcpus);
 
        max_gpa = vm->max_gfn << vm->page_shift;
        TEST_ASSERT(max_gpa > (4 * slot_size), "MAXPHYADDR <4gb ");