Skip to content

Commit 90cac1f

Browse files
author
Christoffer Dall
committed
KVM: arm/arm64: vgic: Only set underflow when actually out of LRs
We currently assume that all the interrupts in our AP list will be queued to LRs, but that's not necessarily the case, because some of them could have been migrated away to different VCPUs and only the VCPU thread itself can remove interrupts from its AP list. Therefore, slightly change the logic to only setting the underflow interrupt when we actually run out of LRs. As it turns out, this allows us to further simplify the handling in vgic_sync_hwstate in later patches. Acked-by: Marc Zyngier <[email protected]> Signed-off-by: Christoffer Dall <[email protected]>
1 parent 00dafa0 commit 90cac1f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

virt/kvm/arm/vgic/vgic.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -601,10 +601,8 @@ static void vgic_flush_lr_state(struct kvm_vcpu *vcpu)
601601

602602
DEBUG_SPINLOCK_BUG_ON(!spin_is_locked(&vgic_cpu->ap_list_lock));
603603

604-
if (compute_ap_list_depth(vcpu) > kvm_vgic_global_state.nr_lr) {
605-
vgic_set_underflow(vcpu);
604+
if (compute_ap_list_depth(vcpu) > kvm_vgic_global_state.nr_lr)
606605
vgic_sort_ap_list(vcpu);
607-
}
608606

609607
list_for_each_entry(irq, &vgic_cpu->ap_list_head, ap_list) {
610608
spin_lock(&irq->irq_lock);
@@ -623,8 +621,12 @@ static void vgic_flush_lr_state(struct kvm_vcpu *vcpu)
623621
next:
624622
spin_unlock(&irq->irq_lock);
625623

626-
if (count == kvm_vgic_global_state.nr_lr)
624+
if (count == kvm_vgic_global_state.nr_lr) {
625+
if (!list_is_last(&irq->ap_list,
626+
&vgic_cpu->ap_list_head))
627+
vgic_set_underflow(vcpu);
627628
break;
629+
}
628630
}
629631

630632
vcpu->arch.vgic_cpu.used_lrs = count;

0 commit comments

Comments
 (0)