Skip to content

Commit 1ddd3ea

Browse files
committed
KVM: selftests: Compute number of extra pages needed in mmu_stress_test
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 <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 55e164d commit 1ddd3ea

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tools/testing/selftests/kvm/mmu_stress_test.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,13 @@ int main(int argc, char *argv[])
209209
vcpus = malloc(nr_vcpus * sizeof(*vcpus));
210210
TEST_ASSERT(vcpus, "Failed to allocate vCPU array");
211211

212-
vm = vm_create_with_vcpus(nr_vcpus, guest_code, vcpus);
212+
vm = __vm_create_with_vcpus(VM_SHAPE_DEFAULT, nr_vcpus,
213+
#ifdef __x86_64__
214+
max_mem / SZ_1G,
215+
#else
216+
max_mem / vm_guest_mode_params[VM_MODE_DEFAULT].page_size,
217+
#endif
218+
guest_code, vcpus);
213219

214220
max_gpa = vm->max_gfn << vm->page_shift;
215221
TEST_ASSERT(max_gpa > (4 * slot_size), "MAXPHYADDR <4gb ");

0 commit comments

Comments
 (0)