Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: selftests: Drop DEFAULT_GUEST_PHY_PAGES, open code the magic number

Remove DEFAULT_GUEST_PHY_PAGES and open code the magic number (with a
comment) in vm_nr_pages_required(). Exposing DEFAULT_GUEST_PHY_PAGES to
tests was a symptom of the VM creation APIs not cleanly supporting tests
that create runnable vCPUs, but can't do so immediately. Now that tests
don't have to manually compute the amount of memory needed for basic
operation, make it harder for tests to do things that should be handled
by the framework, i.e. force developers to improve the framework instead
of hacking around flaws in individual tests.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by

Sean Christopherson and committed by
Paolo Bonzini
03260452 38081d28

+7 -2
-1
tools/testing/selftests/kvm/include/kvm_util_base.h
··· 100 100 #define KVM_UTIL_MIN_VADDR 0x2000 101 101 #define KVM_GUEST_PAGE_TABLE_MIN_PADDR 0x180000 102 102 103 - #define DEFAULT_GUEST_PHY_PAGES 512 104 103 #define DEFAULT_GUEST_STACK_VADDR_MIN 0xab6000 105 104 #define DEFAULT_STACK_PGS 5 106 105
+7 -1
tools/testing/selftests/kvm/lib/kvm_util.c
··· 271 271 "nr_vcpus = %d too large for host, max-vcpus = %d", 272 272 nr_runnable_vcpus, kvm_check_cap(KVM_CAP_MAX_VCPUS)); 273 273 274 - nr_pages = DEFAULT_GUEST_PHY_PAGES; 274 + /* 275 + * Arbitrarily allocate 512 pages (2mb when page size is 4kb) for the 276 + * test code and other per-VM assets that will be loaded into memslot0. 277 + */ 278 + nr_pages = 512; 279 + 280 + /* Account for the per-vCPU stacks on behalf of the test. */ 275 281 nr_pages += nr_runnable_vcpus * DEFAULT_STACK_PGS; 276 282 277 283 /*