Commit 3222d026 authored by Sean Christopherson's avatar Sean Christopherson Committed by Paolo Bonzini

KVM: selftests: Drop @slot0_mem_pages from __vm_create_with_vcpus()

All callers of __vm_create_with_vcpus() pass DEFAULT_GUEST_PHY_PAGES for
@slot_mem_pages; drop the param and just hardcode the "default" as the
base number of pages for slot0.
Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 68c1b3e9
...@@ -561,18 +561,15 @@ static inline struct kvm_vm *vm_create(uint64_t nr_pages) ...@@ -561,18 +561,15 @@ static inline struct kvm_vm *vm_create(uint64_t nr_pages)
return __vm_create(VM_MODE_DEFAULT, nr_pages); return __vm_create(VM_MODE_DEFAULT, nr_pages);
} }
/* Like vm_create_default_with_vcpus, but accepts mode and slot0 memory as a parameter */
struct kvm_vm *__vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus, struct kvm_vm *__vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus,
uint64_t slot0_mem_pages, uint64_t extra_mem_pages, uint64_t extra_mem_pages, uint32_t num_percpu_pages,
uint32_t num_percpu_pages, void *guest_code, void *guest_code, struct kvm_vcpu *vcpus[]);
struct kvm_vcpu *vcpus[]);
static inline struct kvm_vm *vm_create_with_vcpus(uint32_t nr_vcpus, static inline struct kvm_vm *vm_create_with_vcpus(uint32_t nr_vcpus,
void *guest_code, void *guest_code,
struct kvm_vcpu *vcpus[]) struct kvm_vcpu *vcpus[])
{ {
return __vm_create_with_vcpus(VM_MODE_DEFAULT, nr_vcpus, return __vm_create_with_vcpus(VM_MODE_DEFAULT, nr_vcpus, 0, 0,
DEFAULT_GUEST_PHY_PAGES, 0, 0,
guest_code, vcpus); guest_code, vcpus);
} }
......
...@@ -254,9 +254,8 @@ static struct kvm_vm *pre_init_before_test(enum vm_guest_mode mode, void *arg) ...@@ -254,9 +254,8 @@ static struct kvm_vm *pre_init_before_test(enum vm_guest_mode mode, void *arg)
/* Create a VM with enough guest pages */ /* Create a VM with enough guest pages */
guest_num_pages = test_mem_size / guest_page_size; guest_num_pages = test_mem_size / guest_page_size;
vm = __vm_create_with_vcpus(mode, nr_vcpus, DEFAULT_GUEST_PHY_PAGES, vm = __vm_create_with_vcpus(mode, nr_vcpus, guest_num_pages, 0,
guest_num_pages, 0, guest_code, guest_code, test_args.vcpus);
test_args.vcpus);
/* Align down GPA of the testing memslot */ /* Align down GPA of the testing memslot */
if (!p->phys_offset) if (!p->phys_offset)
......
...@@ -280,7 +280,6 @@ struct kvm_vm *__vm_create(enum vm_guest_mode mode, uint64_t nr_pages) ...@@ -280,7 +280,6 @@ struct kvm_vm *__vm_create(enum vm_guest_mode mode, uint64_t nr_pages)
* Input Args: * Input Args:
* mode - VM Mode (e.g. VM_MODE_P52V48_4K) * mode - VM Mode (e.g. VM_MODE_P52V48_4K)
* nr_vcpus - VCPU count * nr_vcpus - VCPU count
* slot0_mem_pages - Slot0 physical memory size
* extra_mem_pages - Non-slot0 physical memory total size * extra_mem_pages - Non-slot0 physical memory total size
* num_percpu_pages - Per-cpu physical memory pages * num_percpu_pages - Per-cpu physical memory pages
* guest_code - Guest entry point * guest_code - Guest entry point
...@@ -291,15 +290,13 @@ struct kvm_vm *__vm_create(enum vm_guest_mode mode, uint64_t nr_pages) ...@@ -291,15 +290,13 @@ struct kvm_vm *__vm_create(enum vm_guest_mode mode, uint64_t nr_pages)
* Return: * Return:
* Pointer to opaque structure that describes the created VM. * Pointer to opaque structure that describes the created VM.
* *
* Creates a VM with the mode specified by mode (e.g. VM_MODE_P52V48_4K), * Creates a VM with the mode specified by mode (e.g. VM_MODE_P52V48_4K).
* with customized slot0 memory size, at least 512 pages currently.
* extra_mem_pages is only used to calculate the maximum page table size, * extra_mem_pages is only used to calculate the maximum page table size,
* no real memory allocation for non-slot0 memory in this function. * no real memory allocation for non-slot0 memory in this function.
*/ */
struct kvm_vm *__vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus, struct kvm_vm *__vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus,
uint64_t slot0_mem_pages, uint64_t extra_mem_pages, uint64_t extra_mem_pages, uint32_t num_percpu_pages,
uint32_t num_percpu_pages, void *guest_code, void *guest_code, struct kvm_vcpu *vcpus[])
struct kvm_vcpu *vcpus[])
{ {
uint64_t vcpu_pages, extra_pg_pages, pages; uint64_t vcpu_pages, extra_pg_pages, pages;
struct kvm_vm *vm; struct kvm_vm *vm;
...@@ -307,10 +304,6 @@ struct kvm_vm *__vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus ...@@ -307,10 +304,6 @@ struct kvm_vm *__vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus
TEST_ASSERT(!nr_vcpus || vcpus, "Must provide vCPU array"); TEST_ASSERT(!nr_vcpus || vcpus, "Must provide vCPU array");
/* Force slot0 memory size not small than DEFAULT_GUEST_PHY_PAGES */
if (slot0_mem_pages < DEFAULT_GUEST_PHY_PAGES)
slot0_mem_pages = DEFAULT_GUEST_PHY_PAGES;
/* The maximum page table size for a memory region will be when the /* The maximum page table size for a memory region will be when the
* smallest pages are used. Considering each page contains x page * smallest pages are used. Considering each page contains x page
* table descriptors, the total extra size for page tables (for extra * table descriptors, the total extra size for page tables (for extra
...@@ -318,8 +311,8 @@ struct kvm_vm *__vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus ...@@ -318,8 +311,8 @@ struct kvm_vm *__vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus
* than N/x*2. * than N/x*2.
*/ */
vcpu_pages = (DEFAULT_STACK_PGS + num_percpu_pages) * nr_vcpus; vcpu_pages = (DEFAULT_STACK_PGS + num_percpu_pages) * nr_vcpus;
extra_pg_pages = (slot0_mem_pages + extra_mem_pages + vcpu_pages) / PTES_PER_MIN_PAGE * 2; extra_pg_pages = (DEFAULT_GUEST_PHY_PAGES + extra_mem_pages + vcpu_pages) / PTES_PER_MIN_PAGE * 2;
pages = slot0_mem_pages + vcpu_pages + extra_pg_pages; pages = DEFAULT_GUEST_PHY_PAGES + vcpu_pages + extra_pg_pages;
TEST_ASSERT(nr_vcpus <= kvm_check_cap(KVM_CAP_MAX_VCPUS), TEST_ASSERT(nr_vcpus <= kvm_check_cap(KVM_CAP_MAX_VCPUS),
"nr_vcpus = %d too large for host, max-vcpus = %d", "nr_vcpus = %d too large for host, max-vcpus = %d",
...@@ -340,8 +333,8 @@ struct kvm_vm *__vm_create_with_one_vcpu(struct kvm_vcpu **vcpu, ...@@ -340,8 +333,8 @@ struct kvm_vm *__vm_create_with_one_vcpu(struct kvm_vcpu **vcpu,
struct kvm_vcpu *vcpus[1]; struct kvm_vcpu *vcpus[1];
struct kvm_vm *vm; struct kvm_vm *vm;
vm = __vm_create_with_vcpus(VM_MODE_DEFAULT, 1, DEFAULT_GUEST_PHY_PAGES, vm = __vm_create_with_vcpus(VM_MODE_DEFAULT, 1, extra_mem_pages, 0,
extra_mem_pages, 0, guest_code, vcpus); guest_code, vcpus);
*vcpu = vcpus[0]; *vcpu = vcpus[0];
return vm; return vm;
......
...@@ -113,7 +113,7 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int nr_vcpus, ...@@ -113,7 +113,7 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int nr_vcpus,
{ {
struct perf_test_args *pta = &perf_test_args; struct perf_test_args *pta = &perf_test_args;
struct kvm_vm *vm; struct kvm_vm *vm;
uint64_t guest_num_pages, slot0_pages = DEFAULT_GUEST_PHY_PAGES; uint64_t guest_num_pages, slot0_pages = 0;
uint64_t backing_src_pagesz = get_backing_src_pagesz(backing_src); uint64_t backing_src_pagesz = get_backing_src_pagesz(backing_src);
uint64_t region_end_gfn; uint64_t region_end_gfn;
int i; int i;
...@@ -152,8 +152,7 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int nr_vcpus, ...@@ -152,8 +152,7 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int nr_vcpus,
* The memory is also added to memslot 0, but that's a benign side * The memory is also added to memslot 0, but that's a benign side
* effect as KVM allows aliasing HVAs in meslots. * effect as KVM allows aliasing HVAs in meslots.
*/ */
vm = __vm_create_with_vcpus(mode, nr_vcpus, DEFAULT_GUEST_PHY_PAGES, vm = __vm_create_with_vcpus(mode, nr_vcpus, slot0_pages + guest_num_pages, 0,
slot0_pages + guest_num_pages, 0,
perf_test_guest_code, vcpus); perf_test_guest_code, vcpus);
pta->vm = vm; pta->vm = vm;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment