Skip to content

Commit bebd8f3

Browse files
Ricardo KollerMarc Zyngier
authored andcommitted
KVM: selftests: aarch64: Add ISPENDR write tests in vgic_irq
Add injection tests that use writing into the ISPENDR register (to mark IRQs as pending). This is typically used by migration code. Signed-off-by: Ricardo Koller <[email protected]> Acked-by: Andrew Jones <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 6a5a471 commit bebd8f3

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tools/testing/selftests/kvm/aarch64/vgic_irq.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ typedef enum {
6565
KVM_SET_IRQ_LINE_HIGH,
6666
KVM_SET_LEVEL_INFO_HIGH,
6767
KVM_INJECT_IRQFD,
68+
KVM_WRITE_ISPENDR,
6869
} kvm_inject_cmd;
6970

7071
struct kvm_inject_args {
@@ -105,6 +106,7 @@ static struct kvm_inject_desc inject_edge_fns[] = {
105106
/* sgi ppi spi */
106107
{ KVM_INJECT_EDGE_IRQ_LINE, false, false, true },
107108
{ KVM_INJECT_IRQFD, false, false, true },
109+
{ KVM_WRITE_ISPENDR, true, false, true },
108110
{ 0, },
109111
};
110112

@@ -113,6 +115,7 @@ static struct kvm_inject_desc inject_level_fns[] = {
113115
{ KVM_SET_IRQ_LINE_HIGH, false, true, true },
114116
{ KVM_SET_LEVEL_INFO_HIGH, false, true, true },
115117
{ KVM_INJECT_IRQFD, false, false, true },
118+
{ KVM_WRITE_ISPENDR, false, true, true },
116119
{ 0, },
117120
};
118121

@@ -495,6 +498,20 @@ static void kvm_set_gsi_routing_irqchip_check(struct kvm_vm *vm,
495498
}
496499
}
497500

501+
static void kvm_irq_write_ispendr_check(int gic_fd, uint32_t intid,
502+
uint32_t vcpu, bool expect_failure)
503+
{
504+
/*
505+
* Ignore this when expecting failure as invalid intids will lead to
506+
* either trying to inject SGIs when we configured the test to be
507+
* level_sensitive (or the reverse), or inject large intids which
508+
* will lead to writing above the ISPENDR register space (and we
509+
* don't want to do that either).
510+
*/
511+
if (!expect_failure)
512+
kvm_irq_write_ispendr(gic_fd, intid, vcpu);
513+
}
514+
498515
static void kvm_routing_and_irqfd_check(struct kvm_vm *vm,
499516
uint32_t intid, uint32_t num, uint32_t kvm_max_routes,
500517
bool expect_failure)
@@ -597,6 +614,11 @@ static void run_guest_cmd(struct kvm_vm *vm, int gic_fd,
597614
test_args->kvm_max_routes,
598615
expect_failure);
599616
break;
617+
case KVM_WRITE_ISPENDR:
618+
for (i = intid; i < intid + num; i++)
619+
kvm_irq_write_ispendr_check(gic_fd, i,
620+
VCPU_ID, expect_failure);
621+
break;
600622
default:
601623
break;
602624
}

0 commit comments

Comments
 (0)