Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

KVM: selftests: Fix irqfd_test for non-x86 architectures

The KVM_IRQFD ioctl fails if no irqchip is present in-kernel, which
isn't too surprising as there's not much KVM can do for an IRQ if it
cannot resolve a destination.

As written the irqfd_test assumes that a 'default' VM created in
selftests has an in-kernel irqchip created implicitly. That may be the
case on x86 but it isn't necessarily true on other architectures.

Add an arch predicate indicating if 'default' VMs get an irqchip and
make the irqfd_test depend on it. Work around arm64 VGIC initialization
requirements by using vm_create_with_one_vcpu(), ignoring the created
vCPU as it isn't used for the test.

Reported-by: Sebastian Ott <sebott@redhat.com>
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Acked-by: Sean Christopherson <seanjc@google.com>
Fixes: 7e9b231c402a ("KVM: selftests: Add a KVM_IRQFD test to verify uniqueness requirements")
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Signed-off-by: Marc Zyngier <maz@kernel.org>

authored by

Oliver Upton and committed by
Marc Zyngier
a1330526 cc430932

+33 -3
+2
tools/testing/selftests/kvm/include/kvm_util.h
··· 1273 1273 1274 1274 uint32_t guest_get_vcpuid(void); 1275 1275 1276 + bool kvm_arch_has_default_irqchip(void); 1277 + 1276 1278 #endif /* SELFTEST_KVM_UTIL_H */
+11 -3
tools/testing/selftests/kvm/irqfd_test.c
··· 89 89 int main(int argc, char *argv[]) 90 90 { 91 91 pthread_t racing_thread; 92 + struct kvm_vcpu *unused; 92 93 int r, i; 93 94 94 - /* Create "full" VMs, as KVM_IRQFD requires an in-kernel IRQ chip. */ 95 - vm1 = vm_create(1); 96 - vm2 = vm_create(1); 95 + TEST_REQUIRE(kvm_arch_has_default_irqchip()); 96 + 97 + /* 98 + * Create "full" VMs, as KVM_IRQFD requires an in-kernel IRQ chip. Also 99 + * create an unused vCPU as certain architectures (like arm64) need to 100 + * complete IRQ chip initialization after all possible vCPUs for a VM 101 + * have been created. 102 + */ 103 + vm1 = vm_create_with_one_vcpu(&unused, NULL); 104 + vm2 = vm_create_with_one_vcpu(&unused, NULL); 97 105 98 106 WRITE_ONCE(__eventfd, kvm_new_eventfd()); 99 107
+5
tools/testing/selftests/kvm/lib/arm64/processor.c
··· 725 725 if (vm->arch.has_gic) 726 726 close(vm->arch.gic_fd); 727 727 } 728 + 729 + bool kvm_arch_has_default_irqchip(void) 730 + { 731 + return request_vgic && kvm_supports_vgic_v3(); 732 + }
+5
tools/testing/selftests/kvm/lib/kvm_util.c
··· 2344 2344 pg = paddr >> vm->page_shift; 2345 2345 return sparsebit_is_set(region->protected_phy_pages, pg); 2346 2346 } 2347 + 2348 + __weak bool kvm_arch_has_default_irqchip(void) 2349 + { 2350 + return false; 2351 + }
+5
tools/testing/selftests/kvm/lib/s390/processor.c
··· 221 221 void assert_on_unhandled_exception(struct kvm_vcpu *vcpu) 222 222 { 223 223 } 224 + 225 + bool kvm_arch_has_default_irqchip(void) 226 + { 227 + return true; 228 + }
+5
tools/testing/selftests/kvm/lib/x86/processor.c
··· 1318 1318 1319 1319 return ret; 1320 1320 } 1321 + 1322 + bool kvm_arch_has_default_irqchip(void) 1323 + { 1324 + return true; 1325 + }