From: Oliver Upton <oupton@kernel.org>
To: Fuad Tabba <fuad.tabba@linux.dev>
Cc: kvmarm@lists.linux.dev, Marc Zyngier <maz@kernel.org>,
Joey Gouly <joey.gouly@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Wei-Lin Chang <weilin.chang@arm.com>,
Steffen Eiden <seiden@linux.ibm.com>
Subject: Re: [PATCH 2/4] KVM: arm64: vgic: Move IRQ migrations out of vgic_prune_ap_list()
Date: Wed, 30 Sep 2026 14:50:09 -0700 [thread overview]
Message-ID: <ar2EETL_kXHwFx_L@kernel.org> (raw)
In-Reply-To: <CA+EHjTxu=rQ1Wz8QpGpMsMyw0NGU35qw6J12ZH07XeCwae5e9Q@mail.gmail.com>
Hi Fuad,
thanks for the review
On Wed, Sep 30, 2026 at 02:55:04PM +0100, Fuad Tabba wrote:
> Hi Oliver,
>
> On Tue, 29 Sep 2026 22:29:23 +0100, Oliver Upton <oupton@kernel.org> wrote:
> [...]
> > diff --git a/arch/arm64/kvm/vgic/vgic.c b/arch/arm64/kvm/vgic/vgic.c
> [...]
> > +void __vgic_update_irq_affinity(struct kvm *kvm, struct vgic_irq *irq,
> > + struct kvm_vcpu *old, struct kvm_vcpu *new,
> > + u32 data)
> [...]
> > + /* Fire! */
> > + kvm_pause_vcpu(tmp);
> > +
> > + scoped_guard(raw_spinlock_irqsave, &tmp->arch.vgic_cpu.ap_list_lock) {
> > + scoped_guard(raw_spinlock, &irq->irq_lock) {
> > + /*
> > + * The IRQ could've been moved to another AP list after
> > + * dropping the irq_lock. Make sure it's where we expect
> > + * it to be, remove from the list and retain the implied
> > + * reference until we queue it on the new vCPU.
> > + */
> > + if (irq->vcpu == tmp) {
> > + list_del(&irq->ap_list);
> > + irq->vcpu = NULL;
> > + irq->target_vcpu = new;
> > + if (vgic_is_v2(kvm))
> > + irq->targets = data;
> > + else
> > + irq->mpidr = data;
> > + pruned = true;
> > + }
>
> Could an active IRQ stay on its current vCPU until it's deactivated?
> With irq->vcpu cleared, the oracle returns target_vcpu for it, so with
> EOImode 0 the old vCPU's EOI finds no LR and the SPI stays active on
> the new vCPU. A scratch test moving the IROUTER of an active edge SPI
> loses it with this patch, but not on Marc's branch.
Ugh. Well spotted, of course. Too much time dealing with LPIs :)
Let me have a think about this. Ultimately the goal is to prevent the
guest from queueing up an unbounded amount of work in a context where
we can't schedule, but deactivation still requires some work to be done
locally on the vCPU.
We already have some infrastructure for async processing of the AP list
for EOImode=1, perhaps there's a chance for reusing that here with some
additional guardrails.
> Could this also make sure the IRQ isn't still in the old vCPU's LRs? A
> vCPU between the vgic flush and the IN_GUEST_MODE store is
> OUTSIDE_GUEST_MODE, so even kvm_arm_halt_guest() wouldn't wait for it.
So we set the request on the vCPU, which means we're guaranteed to sync
the LRs and recompute before entering the VM. This wouldn't affect
affinity changes but there's a chance of a stale LR overwriting the
current active/pending state. So yet another bug, ugh.
Thanks,
Oliver
next prev parent reply other threads:[~2026-09-30 21:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 21:29 [PATCH 0/4] KVM: arm64: vgic: Stop migrating IRQ from vgic_prune_ap_list() Oliver Upton
2026-09-29 21:29 ` [PATCH 1/4] KVM: arm64: Add helpers to halt a vCPU Oliver Upton
2026-09-30 13:33 ` Fuad Tabba
2026-09-29 21:29 ` [PATCH 2/4] KVM: arm64: vgic: Move IRQ migrations out of vgic_prune_ap_list() Oliver Upton
2026-09-30 13:55 ` Fuad Tabba
2026-09-30 21:50 ` Oliver Upton [this message]
2026-09-29 21:29 ` [PATCH 3/4] KVM: arm64: vgic-v3: Only pause the targeted vCPU when disabling LPIs Oliver Upton
2026-09-29 21:29 ` [PATCH 4/4] KVM: arm64: vgic-v3: Pause the source vCPU when processing MOVALL cmd Oliver Upton
2026-09-30 13:25 ` [PATCH 0/4] KVM: arm64: vgic: Stop migrating IRQ from vgic_prune_ap_list() Fuad Tabba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ar2EETL_kXHwFx_L@kernel.org \
--to=oupton@kernel.org \
--cc=fuad.tabba@linux.dev \
--cc=joey.gouly@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=seiden@linux.ibm.com \
--cc=suzuki.poulose@arm.com \
--cc=weilin.chang@arm.com \
--cc=yuzenghui@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.