mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 19:31:42 -04:00
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: 7e9b231c40 ("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>
This commit is contained in:
committed by
Marc Zyngier
parent
cc4309324d
commit
a133052666
@@ -1273,4 +1273,6 @@ bool vm_is_gpa_protected(struct kvm_vm *vm, vm_paddr_t paddr);
|
||||
|
||||
uint32_t guest_get_vcpuid(void);
|
||||
|
||||
bool kvm_arch_has_default_irqchip(void);
|
||||
|
||||
#endif /* SELFTEST_KVM_UTIL_H */
|
||||
|
||||
@@ -89,11 +89,19 @@ static void juggle_eventfd_primary(struct kvm_vm *vm, int eventfd)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
pthread_t racing_thread;
|
||||
struct kvm_vcpu *unused;
|
||||
int r, i;
|
||||
|
||||
/* Create "full" VMs, as KVM_IRQFD requires an in-kernel IRQ chip. */
|
||||
vm1 = vm_create(1);
|
||||
vm2 = vm_create(1);
|
||||
TEST_REQUIRE(kvm_arch_has_default_irqchip());
|
||||
|
||||
/*
|
||||
* Create "full" VMs, as KVM_IRQFD requires an in-kernel IRQ chip. Also
|
||||
* create an unused vCPU as certain architectures (like arm64) need to
|
||||
* complete IRQ chip initialization after all possible vCPUs for a VM
|
||||
* have been created.
|
||||
*/
|
||||
vm1 = vm_create_with_one_vcpu(&unused, NULL);
|
||||
vm2 = vm_create_with_one_vcpu(&unused, NULL);
|
||||
|
||||
WRITE_ONCE(__eventfd, kvm_new_eventfd());
|
||||
|
||||
|
||||
@@ -725,3 +725,8 @@ void kvm_arch_vm_release(struct kvm_vm *vm)
|
||||
if (vm->arch.has_gic)
|
||||
close(vm->arch.gic_fd);
|
||||
}
|
||||
|
||||
bool kvm_arch_has_default_irqchip(void)
|
||||
{
|
||||
return request_vgic && kvm_supports_vgic_v3();
|
||||
}
|
||||
|
||||
@@ -2344,3 +2344,8 @@ bool vm_is_gpa_protected(struct kvm_vm *vm, vm_paddr_t paddr)
|
||||
pg = paddr >> vm->page_shift;
|
||||
return sparsebit_is_set(region->protected_phy_pages, pg);
|
||||
}
|
||||
|
||||
__weak bool kvm_arch_has_default_irqchip(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -221,3 +221,8 @@ void vcpu_arch_dump(FILE *stream, struct kvm_vcpu *vcpu, uint8_t indent)
|
||||
void assert_on_unhandled_exception(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
}
|
||||
|
||||
bool kvm_arch_has_default_irqchip(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1318,3 +1318,8 @@ bool sys_clocksource_is_based_on_tsc(void)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool kvm_arch_has_default_irqchip(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user