Skip to content

Commit 218f641

Browse files
yanzhao56bonzini
authored andcommitted
KVM: selftests: Allow slot modification stress test with quirk disabled
Add a new user option to memslot_modification_stress_test to allow testing with slot zap quirk KVM_X86_QUIRK_SLOT_ZAP_ALL disabled. Signed-off-by: Yan Zhao <[email protected]> Message-ID: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent b4ed2c6 commit 218f641

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

tools/testing/selftests/kvm/memslot_modification_stress_test.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ struct test_params {
7979
useconds_t delay;
8080
uint64_t nr_iterations;
8181
bool partition_vcpu_memory_access;
82+
bool disable_slot_zap_quirk;
8283
};
8384

8485
static void run_test(enum vm_guest_mode mode, void *arg)
@@ -89,6 +90,13 @@ static void run_test(enum vm_guest_mode mode, void *arg)
8990
vm = memstress_create_vm(mode, nr_vcpus, guest_percpu_mem_size, 1,
9091
VM_MEM_SRC_ANONYMOUS,
9192
p->partition_vcpu_memory_access);
93+
#ifdef __x86_64__
94+
if (p->disable_slot_zap_quirk)
95+
vm_enable_cap(vm, KVM_CAP_DISABLE_QUIRKS2, KVM_X86_QUIRK_SLOT_ZAP_ALL);
96+
97+
pr_info("Memslot zap quirk %s\n", p->disable_slot_zap_quirk ?
98+
"disabled" : "enabled");
99+
#endif
92100

93101
pr_info("Finished creating vCPUs\n");
94102

@@ -107,11 +115,12 @@ static void run_test(enum vm_guest_mode mode, void *arg)
107115
static void help(char *name)
108116
{
109117
puts("");
110-
printf("usage: %s [-h] [-m mode] [-d delay_usec]\n"
118+
printf("usage: %s [-h] [-m mode] [-d delay_usec] [-q]\n"
111119
" [-b memory] [-v vcpus] [-o] [-i iterations]\n", name);
112120
guest_modes_help();
113121
printf(" -d: add a delay between each iteration of adding and\n"
114122
" deleting a memslot in usec.\n");
123+
printf(" -q: Disable memslot zap quirk.\n");
115124
printf(" -b: specify the size of the memory region which should be\n"
116125
" accessed by each vCPU. e.g. 10M or 3G.\n"
117126
" Default: 1G\n");
@@ -137,7 +146,7 @@ int main(int argc, char *argv[])
137146

138147
guest_modes_append_default();
139148

140-
while ((opt = getopt(argc, argv, "hm:d:b:v:oi:")) != -1) {
149+
while ((opt = getopt(argc, argv, "hm:d:qb:v:oi:")) != -1) {
141150
switch (opt) {
142151
case 'm':
143152
guest_modes_cmdline(optarg);
@@ -160,6 +169,12 @@ int main(int argc, char *argv[])
160169
case 'i':
161170
p.nr_iterations = atoi_positive("Number of iterations", optarg);
162171
break;
172+
case 'q':
173+
p.disable_slot_zap_quirk = true;
174+
175+
TEST_REQUIRE(kvm_check_cap(KVM_CAP_DISABLE_QUIRKS2) &
176+
KVM_X86_QUIRK_SLOT_ZAP_ALL);
177+
break;
163178
case 'h':
164179
default:
165180
help(argv[0]);

0 commit comments

Comments
 (0)