Skip to content

Commit

Permalink
KVM: arm/arm64: vgic: Consider priority and active state for pending irq
Browse files Browse the repository at this point in the history
When checking if there are any pending IRQs for the VM, consider the
active state and priority of the IRQs as well.

Otherwise we could be continuously scheduling a guest hypervisor without
it seeing an IRQ.

Signed-off-by: Christoffer Dall <[email protected]>
Signed-off-by: Marc Zyngier <[email protected]>
  • Loading branch information
christofferdall-arm authored and Marc Zyngier committed Dec 19, 2018
1 parent c23b2e6 commit 9009782
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion virt/kvm/arm/vgic/vgic.c
Original file line number Diff line number Diff line change
Expand Up @@ -908,18 +908,23 @@ int kvm_vgic_vcpu_pending_irq(struct kvm_vcpu *vcpu)
struct vgic_irq *irq;
bool pending = false;
unsigned long flags;
struct vgic_vmcr vmcr;

if (!vcpu->kvm->arch.vgic.enabled)
return false;

if (vcpu->arch.vgic_cpu.vgic_v3.its_vpe.pending_last)
return true;

vgic_get_vmcr(vcpu, &vmcr);

spin_lock_irqsave(&vgic_cpu->ap_list_lock, flags);

list_for_each_entry(irq, &vgic_cpu->ap_list_head, ap_list) {
spin_lock(&irq->irq_lock);
pending = irq_is_pending(irq) && irq->enabled;
pending = irq_is_pending(irq) && irq->enabled &&
!irq->active &&
irq->priority < vmcr.pmr;
spin_unlock(&irq->irq_lock);

if (pending)
Expand Down

0 comments on commit 9009782

Please sign in to comment.