Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: arm64: GICv4.1: Restore VLPI pending state to physical side

When setting the forwarding path of a VLPI (switch to the HW mode),
we can also transfer the pending state from irq->pending_latch to
VPT (especially in migration, the pending states of VLPIs are restored
into kvm’s vgic first). And we currently send "INT+VSYNC" to trigger
a VLPI to pending.

Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
Signed-off-by: Shenming Lu <lushenming@huawei.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20210322060158.1584-6-lushenming@huawei.com

authored by

Zenghui Yu and committed by
Marc Zyngier
12df7429 f66b7b15

+19
+19
arch/arm64/kvm/vgic/vgic-v4.c
··· 404 404 struct vgic_its *its; 405 405 struct vgic_irq *irq; 406 406 struct its_vlpi_map map; 407 + unsigned long flags; 407 408 int ret; 408 409 409 410 if (!vgic_supports_direct_msis(kvm)) ··· 449 448 irq->hw = true; 450 449 irq->host_irq = virq; 451 450 atomic_inc(&map.vpe->vlpi_count); 451 + 452 + /* Transfer pending state */ 453 + raw_spin_lock_irqsave(&irq->irq_lock, flags); 454 + if (irq->pending_latch) { 455 + ret = irq_set_irqchip_state(irq->host_irq, 456 + IRQCHIP_STATE_PENDING, 457 + irq->pending_latch); 458 + WARN_RATELIMIT(ret, "IRQ %d", irq->host_irq); 459 + 460 + /* 461 + * Clear pending_latch and communicate this state 462 + * change via vgic_queue_irq_unlock. 463 + */ 464 + irq->pending_latch = false; 465 + vgic_queue_irq_unlock(kvm, irq, flags); 466 + } else { 467 + raw_spin_unlock_irqrestore(&irq->irq_lock, flags); 468 + } 452 469 453 470 out: 454 471 mutex_unlock(&its->its_lock);