Skip to content

Commit 16e604a

Browse files
Alexandru EliseiMarc Zyngier
authored andcommitted
KVM: arm/arm64: vgic: Reevaluate level sensitive interrupts on enable
A HW mapped level sensitive interrupt asserted by a device will not be put into the ap_list if it is disabled at the VGIC level. When it is enabled again, it will be inserted into the ap_list and written to a list register on guest entry regardless of the state of the device. We could argue that this can also happen on real hardware, when the command to enable the interrupt reached the GIC before the device had the chance to de-assert the interrupt signal; however, we emulate the distributor and redistributors in software and we can do better than that. Signed-off-by: Alexandru Elisei <[email protected]> Signed-off-by: Marc Zyngier <[email protected]>
1 parent c69509c commit 16e604a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

virt/kvm/arm/vgic/vgic-mmio.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,22 @@ void vgic_mmio_write_senable(struct kvm_vcpu *vcpu,
113113
struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, intid + i);
114114

115115
raw_spin_lock_irqsave(&irq->irq_lock, flags);
116+
if (vgic_irq_is_mapped_level(irq)) {
117+
bool was_high = irq->line_level;
118+
119+
/*
120+
* We need to update the state of the interrupt because
121+
* the guest might have changed the state of the device
122+
* while the interrupt was disabled at the VGIC level.
123+
*/
124+
irq->line_level = vgic_get_phys_line_level(irq);
125+
/*
126+
* Deactivate the physical interrupt so the GIC will let
127+
* us know when it is asserted again.
128+
*/
129+
if (!irq->active && was_high && !irq->line_level)
130+
vgic_irq_set_phys_active(irq, false);
131+
}
116132
irq->enabled = true;
117133
vgic_queue_irq_unlock(vcpu->kvm, irq, flags);
118134

0 commit comments

Comments
 (0)