Commit b91b637f authored by Sean Christopherson's avatar Sean Christopherson Committed by Paolo Bonzini

KVM: selftests: Move per-VM GPA into perf_test_args

Move the per-VM GPA into perf_test_args instead of storing it as a
separate global variable.  It's not obvious that guest_test_phys_mem
holds a GPA, nor that it's connected/coupled with per_vcpu->gpa.

No functional change intended.
Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
Reviewed-by: default avatarBen Gardon <bgardon@google.com>
Signed-off-by: default avatarDavid Matlack <dmatlack@google.com>
Message-Id: <20211111000310.1435032-9-dmatlack@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 92e34c99
...@@ -29,6 +29,7 @@ struct perf_test_vcpu_args { ...@@ -29,6 +29,7 @@ struct perf_test_vcpu_args {
struct perf_test_args { struct perf_test_args {
struct kvm_vm *vm; struct kvm_vm *vm;
uint64_t host_page_size; uint64_t host_page_size;
uint64_t gpa;
uint64_t guest_page_size; uint64_t guest_page_size;
int wr_fract; int wr_fract;
...@@ -37,13 +38,6 @@ struct perf_test_args { ...@@ -37,13 +38,6 @@ struct perf_test_args {
extern struct perf_test_args perf_test_args; extern struct perf_test_args perf_test_args;
/*
* Guest physical memory offset of the testing memory slot.
* This will be set to the topmost valid physical address minus
* the test memory size.
*/
extern uint64_t guest_test_phys_mem;
struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus,
uint64_t vcpu_memory_bytes, int slots, uint64_t vcpu_memory_bytes, int slots,
enum vm_mem_backing_src_type backing_src); enum vm_mem_backing_src_type backing_src);
......
...@@ -10,8 +10,6 @@ ...@@ -10,8 +10,6 @@
struct perf_test_args perf_test_args; struct perf_test_args perf_test_args;
uint64_t guest_test_phys_mem;
/* /*
* Guest virtual memory offset of the testing memory slot. * Guest virtual memory offset of the testing memory slot.
* Must not conflict with identity mapped test code. * Must not conflict with identity mapped test code.
...@@ -97,20 +95,18 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, ...@@ -97,20 +95,18 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus,
guest_num_pages, vm_get_max_gfn(vm), vcpus, guest_num_pages, vm_get_max_gfn(vm), vcpus,
vcpu_memory_bytes); vcpu_memory_bytes);
guest_test_phys_mem = (vm_get_max_gfn(vm) - guest_num_pages) * pta->gpa = (vm_get_max_gfn(vm) - guest_num_pages) * pta->guest_page_size;
pta->guest_page_size; pta->gpa = align_down(pta->gpa, backing_src_pagesz);
guest_test_phys_mem = align_down(guest_test_phys_mem, backing_src_pagesz);
#ifdef __s390x__ #ifdef __s390x__
/* Align to 1M (segment size) */ /* Align to 1M (segment size) */
guest_test_phys_mem = align_down(guest_test_phys_mem, 1 << 20); pta->gpa = align_down(pta->gpa, 1 << 20);
#endif #endif
pr_info("guest physical test memory offset: 0x%lx\n", guest_test_phys_mem); pr_info("guest physical test memory offset: 0x%lx\n", pta->gpa);
/* Add extra memory slots for testing */ /* Add extra memory slots for testing */
for (i = 0; i < slots; i++) { for (i = 0; i < slots; i++) {
uint64_t region_pages = guest_num_pages / slots; uint64_t region_pages = guest_num_pages / slots;
vm_paddr_t region_start = guest_test_phys_mem + vm_paddr_t region_start = pta->gpa + region_pages * pta->guest_page_size * i;
region_pages * pta->guest_page_size * i;
vm_userspace_mem_region_add(vm, backing_src, region_start, vm_userspace_mem_region_add(vm, backing_src, region_start,
PERF_TEST_MEM_SLOT_INDEX + i, PERF_TEST_MEM_SLOT_INDEX + i,
...@@ -118,7 +114,7 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus, ...@@ -118,7 +114,7 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus,
} }
/* Do mapping for the demand paging memory slot */ /* Do mapping for the demand paging memory slot */
virt_map(vm, guest_test_virt_mem, guest_test_phys_mem, guest_num_pages); virt_map(vm, guest_test_virt_mem, pta->gpa, guest_num_pages);
ucall_init(vm, NULL); ucall_init(vm, NULL);
...@@ -148,13 +144,12 @@ void perf_test_setup_vcpus(struct kvm_vm *vm, int vcpus, ...@@ -148,13 +144,12 @@ void perf_test_setup_vcpus(struct kvm_vm *vm, int vcpus,
(vcpu_id * vcpu_memory_bytes); (vcpu_id * vcpu_memory_bytes);
vcpu_args->pages = vcpu_memory_bytes / vcpu_args->pages = vcpu_memory_bytes /
pta->guest_page_size; pta->guest_page_size;
vcpu_args->gpa = guest_test_phys_mem + vcpu_args->gpa = pta->gpa + (vcpu_id * vcpu_memory_bytes);
(vcpu_id * vcpu_memory_bytes);
} else { } else {
vcpu_args->gva = guest_test_virt_mem; vcpu_args->gva = guest_test_virt_mem;
vcpu_args->pages = (vcpus * vcpu_memory_bytes) / vcpu_args->pages = (vcpus * vcpu_memory_bytes) /
pta->guest_page_size; pta->guest_page_size;
vcpu_args->gpa = guest_test_phys_mem; vcpu_args->gpa = pta->gpa;
} }
vcpu_args_set(vm, vcpu_id, 1, vcpu_id); vcpu_args_set(vm, vcpu_id, 1, vcpu_id);
......
...@@ -80,7 +80,7 @@ static void add_remove_memslot(struct kvm_vm *vm, useconds_t delay, ...@@ -80,7 +80,7 @@ static void add_remove_memslot(struct kvm_vm *vm, useconds_t delay,
* Add the dummy memslot just below the perf_test_util memslot, which is * Add the dummy memslot just below the perf_test_util memslot, which is
* at the top of the guest physical address space. * at the top of the guest physical address space.
*/ */
gpa = guest_test_phys_mem - pages * vm_get_page_size(vm); gpa = perf_test_args.gpa - pages * vm_get_page_size(vm);
for (i = 0; i < nr_modifications; i++) { for (i = 0; i < nr_modifications; i++) {
usleep(delay); usleep(delay);
......
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