@@ -175,7 +175,7 @@ static void guest_code_move_memory_region(void)
175
175
GUEST_DONE ();
176
176
}
177
177
178
- static void test_move_memory_region (void )
178
+ static void test_move_memory_region (bool disable_slot_zap_quirk )
179
179
{
180
180
pthread_t vcpu_thread ;
181
181
struct kvm_vcpu * vcpu ;
@@ -184,6 +184,9 @@ static void test_move_memory_region(void)
184
184
185
185
vm = spawn_vm (& vcpu , & vcpu_thread , guest_code_move_memory_region );
186
186
187
+ if (disable_slot_zap_quirk )
188
+ vm_enable_cap (vm , KVM_CAP_DISABLE_QUIRKS2 , KVM_X86_QUIRK_SLOT_ZAP_ALL );
189
+
187
190
hva = addr_gpa2hva (vm , MEM_REGION_GPA );
188
191
189
192
/*
@@ -266,7 +269,7 @@ static void guest_code_delete_memory_region(void)
266
269
GUEST_ASSERT (0 );
267
270
}
268
271
269
- static void test_delete_memory_region (void )
272
+ static void test_delete_memory_region (bool disable_slot_zap_quirk )
270
273
{
271
274
pthread_t vcpu_thread ;
272
275
struct kvm_vcpu * vcpu ;
@@ -276,6 +279,9 @@ static void test_delete_memory_region(void)
276
279
277
280
vm = spawn_vm (& vcpu , & vcpu_thread , guest_code_delete_memory_region );
278
281
282
+ if (disable_slot_zap_quirk )
283
+ vm_enable_cap (vm , KVM_CAP_DISABLE_QUIRKS2 , KVM_X86_QUIRK_SLOT_ZAP_ALL );
284
+
279
285
/* Delete the memory region, the guest should not die. */
280
286
vm_mem_region_delete (vm , MEM_REGION_SLOT );
281
287
wait_for_vcpu ();
@@ -553,7 +559,10 @@ int main(int argc, char *argv[])
553
559
{
554
560
#ifdef __x86_64__
555
561
int i , loops ;
562
+ int j , disable_slot_zap_quirk = 0 ;
556
563
564
+ if (kvm_check_cap (KVM_CAP_DISABLE_QUIRKS2 ) & KVM_X86_QUIRK_SLOT_ZAP_ALL )
565
+ disable_slot_zap_quirk = 1 ;
557
566
/*
558
567
* FIXME: the zero-memslot test fails on aarch64 and s390x because
559
568
* KVM_RUN fails with ENOEXEC or EFAULT.
@@ -579,13 +588,17 @@ int main(int argc, char *argv[])
579
588
else
580
589
loops = 10 ;
581
590
582
- pr_info ("Testing MOVE of in-use region, %d loops\n" , loops );
583
- for (i = 0 ; i < loops ; i ++ )
584
- test_move_memory_region ();
591
+ for (j = 0 ; j <= disable_slot_zap_quirk ; j ++ ) {
592
+ pr_info ("Testing MOVE of in-use region, %d loops, slot zap quirk %s\n" ,
593
+ loops , j ? "disabled" : "enabled" );
594
+ for (i = 0 ; i < loops ; i ++ )
595
+ test_move_memory_region (!!j );
585
596
586
- pr_info ("Testing DELETE of in-use region, %d loops\n" , loops );
587
- for (i = 0 ; i < loops ; i ++ )
588
- test_delete_memory_region ();
597
+ pr_info ("Testing DELETE of in-use region, %d loops, slot zap quirk %s\n" ,
598
+ loops , j ? "disabled" : "enabled" );
599
+ for (i = 0 ; i < loops ; i ++ )
600
+ test_delete_memory_region (!!j );
601
+ }
589
602
#endif
590
603
591
604
return 0 ;
0 commit comments