This series adds a new test, aarch64/vgic-irq, that validates the injection of different types of IRQs from userspace using various methods and configurations (when applicable): Intid Method | | Configuration | | IRQ_LINE | | SGI LEVEL_INFO | | PPI x IRQFD | x | level-sensitive x EOIR + DIR SPI ISPENDR | | edge-triggered EOIR only bogus ISACTIVER | | | | vgic-irq is implemented by having a single vcpu started in any of the 4 (2x2) configurations above. The guest then "asks" userspace to inject all intids of a given IRQ type using each applicable method via a GUEST_SYNC call. The applicable methods and intids for a given configuration are specified in tables like this one: /* edge-triggered */ static struct kvm_inject_desc inject_edge_fns[] = { /* sgi ppi spi */ { KVM_IRQ_LINE, false, false, true }, { IRQFD, false, false, true }, { ISPENDR, true, false, true }, }; Based on the (example) table above, a guest running in an edge-triggered configuration will try injecting SGIs and SPIs. The specific methods are also given in the table, e.g.: SGIs are injected from userspace by writing into the ISPENDR register. This test also adds some extra edge tests like: IRQ preemption, restoring active IRQs, trying to inject bogus intid's (e.g., above the configured KVM nr_irqs). Note that vgic-irq is currently limited to a single vcpu, GICv3, and does not test the vITS (no MSIs). - Commits 1-3 add some GICv3 library functions on the guest side, e.g.: set the priority of an IRQ. - Commits 4-5 add some vGICv3 library functions on the userspace side, e.g.: a wrapper for KVM_IRQ_LINE. - Commit 6 adds the basic version of this test: inject an SPI using KVM_IRQ_LINE. - Commits 7-17 add other IRQs types, methods and configurations. Ricardo Koller (17): KVM: selftests: aarch64: move gic_v3.h to shared headers KVM: selftests: aarch64: add function for accessing GICv3 dist and redist registers KVM: selftests: aarch64: add GICv3 register accessor library functions KVM: selftests: add kvm_irq_line library function KVM: selftests: aarch64: add vGIC library functions to deal with vIRQ state KVM: selftests: aarch64: add vgic_irq to test userspace IRQ injection KVM: selftests: aarch64: abstract the injection functions in vgic_irq KVM: selftests: aarch64: cmdline arg to set number of IRQs in vgic_irq test KVM: selftests: aarch64: cmdline arg to set EOI mode in vgic_irq KVM: selftests: aarch64: add preemption tests in vgic_irq KVM: selftests: aarch64: level-sensitive interrupts tests in vgic_irq KVM: selftests: aarch64: add tests for LEVEL_INFO in vgic_irq KVM: selftests: aarch64: add test_inject_fail to vgic_irq KVM: selftests: add IRQ GSI routing library functions KVM: selftests: aarch64: add tests for IRQFD in vgic_irq KVM: selftests: aarch64: add ISPENDR write tests in vgic_irq KVM: selftests: aarch64: add test for restoring active IRQs tools/testing/selftests/kvm/.gitignore | 1 + tools/testing/selftests/kvm/Makefile | 1 + .../selftests/kvm/aarch64/arch_timer.c | 2 +- .../testing/selftests/kvm/aarch64/vgic_irq.c | 853 ++++++++++++++++++ .../selftests/kvm/include/aarch64/gic.h | 26 + .../kvm/{lib => include}/aarch64/gic_v3.h | 12 + .../selftests/kvm/include/aarch64/vgic.h | 18 +- .../testing/selftests/kvm/include/kvm_util.h | 10 + tools/testing/selftests/kvm/lib/aarch64/gic.c | 66 ++ .../selftests/kvm/lib/aarch64/gic_private.h | 11 + .../selftests/kvm/lib/aarch64/gic_v3.c | 206 ++++- .../testing/selftests/kvm/lib/aarch64/vgic.c | 103 ++- tools/testing/selftests/kvm/lib/kvm_util.c | 72 ++ 13 files changed, 1352 insertions(+), 29 deletions(-) create mode 100644 tools/testing/selftests/kvm/aarch64/vgic_irq.c rename tools/testing/selftests/kvm/{lib => include}/aarch64/gic_v3.h (80%) -- 2.34.0.rc0.344.g81b53c2807-goog