1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * tools/testing/selftests/kvm/include/perf_test_util.h
4  *
5  * Copyright (C) 2020, Google LLC.
6  */
7 
8 #ifndef SELFTEST_KVM_PERF_TEST_UTIL_H
9 #define SELFTEST_KVM_PERF_TEST_UTIL_H
10 
11 #include "kvm_util.h"
12 
13 /* Default guest test virtual memory offset */
14 #define DEFAULT_GUEST_TEST_MEM		0xc0000000
15 
16 #define DEFAULT_PER_VCPU_MEM_SIZE	(1 << 30) /* 1G */
17 
18 #define PERF_TEST_MEM_SLOT_INDEX	1
19 
20 struct perf_test_vcpu_args {
21 	uint64_t gva;
22 	uint64_t pages;
23 
24 	/* Only used by the host userspace part of the vCPU thread */
25 	int vcpu_id;
26 };
27 
28 struct perf_test_args {
29 	struct kvm_vm *vm;
30 	uint64_t host_page_size;
31 	uint64_t guest_page_size;
32 	int wr_fract;
33 
34 	struct perf_test_vcpu_args vcpu_args[KVM_MAX_VCPUS];
35 };
36 
37 extern struct perf_test_args perf_test_args;
38 
39 /*
40  * Guest physical memory offset of the testing memory slot.
41  * This will be set to the topmost valid physical address minus
42  * the test memory size.
43  */
44 extern uint64_t guest_test_phys_mem;
45 
46 struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int vcpus,
47 				   uint64_t vcpu_memory_bytes, int slots,
48 				   enum vm_mem_backing_src_type backing_src);
49 void perf_test_destroy_vm(struct kvm_vm *vm);
50 void perf_test_setup_vcpus(struct kvm_vm *vm, int vcpus,
51 			   uint64_t vcpu_memory_bytes,
52 			   bool partition_vcpu_memory_access);
53 
54 #endif /* SELFTEST_KVM_PERF_TEST_UTIL_H */
55