irqfd_test on arm triggers the following assertion: ==== Test Assertion Failure ==== include/kvm_util.h:527: !ret pid=3643 tid=3643 errno=11 - Resource temporarily unavailable 1 0x00000000004026d7: kvm_irqfd at kvm_util.h:527 2 0x0000000000402083: main at irqfd_test.c:100 3 0x0000ffffa5aab587: ?? ??:0 4 0x0000ffffa5aab65f: ?? ??:0 5 0x000000000040236f: _start at ??:? KVM_IRQFD failed, rc: -1 errno: 11 (Resource temporarily unavailable)
Fix this by setting up a vgic for the vm.
Signed-off-by: Sebastian Ott sebott@redhat.com --- tools/testing/selftests/kvm/irqfd_test.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/kvm/irqfd_test.c b/tools/testing/selftests/kvm/irqfd_test.c index 7c301b4c7005..f7b8766e9d42 100644 --- a/tools/testing/selftests/kvm/irqfd_test.c +++ b/tools/testing/selftests/kvm/irqfd_test.c @@ -8,7 +8,11 @@ #include <stdint.h> #include <sys/sysinfo.h>
+#include "processor.h" #include "kvm_util.h" +#ifdef __aarch64__ +#include "vgic.h" +#endif
static struct kvm_vm *vm1; static struct kvm_vm *vm2; @@ -86,14 +90,30 @@ static void juggle_eventfd_primary(struct kvm_vm *vm, int eventfd) kvm_irqfd(vm, GSI_BASE_PRIMARY + 1, eventfd, KVM_IRQFD_FLAG_DEASSIGN); }
+static struct kvm_vm *test_vm_create(void) +{ +#ifdef __aarch64__ + struct kvm_vm *vm; + struct kvm_vcpu *vcpu; + int gic_fd; + + vm = vm_create_with_one_vcpu(&vcpu, NULL); + gic_fd = vgic_v3_setup(vm, 1, 64); + __TEST_REQUIRE(gic_fd >= 0, "Failed to create vgic-v3"); + + return vm; +#endif + return vm_create(1); +} + int main(int argc, char *argv[]) { pthread_t racing_thread; int r, i;
/* Create "full" VMs, as KVM_IRQFD requires an in-kernel IRQ chip. */ - vm1 = vm_create(1); - vm2 = vm_create(1); + vm1 = test_vm_create(); + vm2 = test_vm_create();
WRITE_ONCE(__eventfd, kvm_new_eventfd());
On Mon, Aug 25, 2025, Sebastian Ott wrote:
irqfd_test on arm triggers the following assertion: ==== Test Assertion Failure ==== include/kvm_util.h:527: !ret pid=3643 tid=3643 errno=11 - Resource temporarily unavailable 1 0x00000000004026d7: kvm_irqfd at kvm_util.h:527 2 0x0000000000402083: main at irqfd_test.c:100 3 0x0000ffffa5aab587: ?? ??:0 4 0x0000ffffa5aab65f: ?? ??:0 5 0x000000000040236f: _start at ??:? KVM_IRQFD failed, rc: -1 errno: 11 (Resource temporarily unavailable)
Fix this by setting up a vgic for the vm.
Signed-off-by: Sebastian Ott sebott@redhat.com
@@ -86,14 +90,30 @@ static void juggle_eventfd_primary(struct kvm_vm *vm, int eventfd) kvm_irqfd(vm, GSI_BASE_PRIMARY + 1, eventfd, KVM_IRQFD_FLAG_DEASSIGN); } +static struct kvm_vm *test_vm_create(void) +{ +#ifdef __aarch64__
- struct kvm_vm *vm;
- struct kvm_vcpu *vcpu;
- int gic_fd;
- vm = vm_create_with_one_vcpu(&vcpu, NULL);
- gic_fd = vgic_v3_setup(vm, 1, 64);
- __TEST_REQUIRE(gic_fd >= 0, "Failed to create vgic-v3");
I don't think this test requires v3+, any GIC will do.
Is there a sane way to handle vGIC creation in kvm_arch_vm_post_create()? E.g. could we create a v3 GIC when possible, and fall back to v2? And then provide a way for tests to express a hard v3 GIC dependency?
Having to worry about things like this in fairly generic code is quite burdensome.
- return vm;
+#endif
- return vm_create(1);
+}
On Mon, 25 Aug 2025 20:52:21 +0100, Sean Christopherson seanjc@google.com wrote:
On Mon, Aug 25, 2025, Sebastian Ott wrote:
irqfd_test on arm triggers the following assertion: ==== Test Assertion Failure ==== include/kvm_util.h:527: !ret pid=3643 tid=3643 errno=11 - Resource temporarily unavailable 1 0x00000000004026d7: kvm_irqfd at kvm_util.h:527 2 0x0000000000402083: main at irqfd_test.c:100 3 0x0000ffffa5aab587: ?? ??:0 4 0x0000ffffa5aab65f: ?? ??:0 5 0x000000000040236f: _start at ??:? KVM_IRQFD failed, rc: -1 errno: 11 (Resource temporarily unavailable)
Fix this by setting up a vgic for the vm.
Signed-off-by: Sebastian Ott sebott@redhat.com
@@ -86,14 +90,30 @@ static void juggle_eventfd_primary(struct kvm_vm *vm, int eventfd) kvm_irqfd(vm, GSI_BASE_PRIMARY + 1, eventfd, KVM_IRQFD_FLAG_DEASSIGN); } +static struct kvm_vm *test_vm_create(void) +{ +#ifdef __aarch64__
- struct kvm_vm *vm;
- struct kvm_vcpu *vcpu;
- int gic_fd;
- vm = vm_create_with_one_vcpu(&vcpu, NULL);
- gic_fd = vgic_v3_setup(vm, 1, 64);
- __TEST_REQUIRE(gic_fd >= 0, "Failed to create vgic-v3");
I don't think this test requires v3+, any GIC will do.
There is no such thing as "any GIC". You need to know what is available, and ask for something that actually exists. So while the above is wrong on the ground that this doesn't work on v2 or v5, the selection has to be explicit.
Is there a sane way to handle vGIC creation in kvm_arch_vm_post_create()? E.g. could we create a v3 GIC when possible, and fall back to v2? And then provide a way for tests to express a hard v3 GIC dependency?
You can ask KVM what's available. Like an actual VMM does. There is no shortage of examples in the current code base.
And ideally, this should be made an integral part of creating a viable VM, which the current VM creation hack makes a point in not providing.
M.
On Mon, Aug 25, 2025, Marc Zyngier wrote:
On Mon, 25 Aug 2025 20:52:21 +0100, Sean Christopherson seanjc@google.com wrote:
Is there a sane way to handle vGIC creation in kvm_arch_vm_post_create()? E.g. could we create a v3 GIC when possible, and fall back to v2? And then provide a way for tests to express a hard v3 GIC dependency?
You can ask KVM what's available. Like an actual VMM does. There is no shortage of examples in the current code base.
Right, by "sane" I meant: is there a way to instantiate a supported GIC without making it hard/painful to write tests, and without having to plumb in arm64 specific requirements to common APIs?
E.g. are there tests that use the common vm_create() APIs and rely on NOT having a GIC?
And ideally, this should be made an integral part of creating a viable VM, which the current VM creation hack makes a point in not providing.
On Mon, Aug 25, 2025 at 02:11:30PM -0700, Sean Christopherson wrote:
On Mon, Aug 25, 2025, Marc Zyngier wrote:
On Mon, 25 Aug 2025 20:52:21 +0100, Sean Christopherson seanjc@google.com wrote:
Is there a sane way to handle vGIC creation in kvm_arch_vm_post_create()? E.g. could we create a v3 GIC when possible, and fall back to v2? And then provide a way for tests to express a hard v3 GIC dependency?
You can ask KVM what's available. Like an actual VMM does. There is no shortage of examples in the current code base.
Right, by "sane" I meant: is there a way to instantiate a supported GIC without making it hard/painful to write tests, and without having to plumb in arm64 specific requirements to common APIs?
E.g. are there tests that use the common vm_create() APIs and rely on NOT having a GIC?
Instead of stuffing a GIC in behind vm_create(), I'd rather we have a specific helper for creating a VM with an irqchip. There's tests in arm64 that rely on all this generic infrastructure and also need to select / dimension a GIC appropriately for the test.
The majority of selftests don't even need an irqchip anyway.
Thanks, Oliver
linux-kselftest-mirror@lists.linaro.org