From: Oliver Upton <oupton@kernel.org>
To: Sean Christopherson <seanjc@google.com>
Cc: sashiko-reviews@lists.linux.dev, kvm@vger.kernel.org,
Marc Zyngier <maz@kernel.org>
Subject: Re: [PATCH] KVM: Send reschedule IPIs instead of SMP function calls for non-waiting requests
Date: Tue, 17 Nov 2026 16:03:03 -0800 [thread overview]
Message-ID: <avzrN0IZqTg3GlC1@kernel.org> (raw)
In-Reply-To: <avzoSx9ukQecCGq-@seanjc-mac.roam.internal>
On Tue, Nov 17, 2026 at 03:50:35PM -0800, Sean Christopherson wrote:
> +Oliver and Marc,
>
> FYI on what I think is a pre-existing TLB flush bug (that can affect other
> requests as well).
Thanks!
> > If an interrupt fires mid-loop and makes a non-waiting multi-vCPU request
> > (for example on arm64 via irqfd_wakeup() -> kvm_arch_set_irq_inatomic() ->
> > ... -> vgic_queue_irq_unlock()):
> >
> > kvm_flush_remote_tlbs()
> > kvm_make_all_cpus_request(kvm, KVM_REQ_TLB_FLUSH)
> > cpumask_clear(cpus)
> > kvm_make_vcpu_request(vcpu0, ...)
> > kvm_vcpu_exiting_guest_mode(vcpu0)
> > cmpxchg(&vcpu0->mode, IN_GUEST_MODE, EXITING_GUEST_MODE)
> > __cpumask_set_cpu(vcpu0->cpu, cpus)
> > <hardirq>
> > irqfd_wakeup()
> > ...
> > kvm_make_all_cpus_request(kvm, KVM_REQ_IRQ_PENDING)
> > cpumask_clear(cpus) <-- wipes vcpu0->cpu from cpu_kick_mask
> > kvm_make_vcpu_request(vcpu0, ...)
> > kvm_request_needs_ipi(vcpu0, ...) <-- false (EXITING_GUEST_MODE)
> > kvm_kick_many_cpus(cpus, true) <-- misses vcpu0->cpu
> >
> > Because the outer request already transitioned vcpu0->mode from
> > IN_GUEST_MODE to EXITING_GUEST_MODE, the nested non-waiting request sees
> > mode != IN_GUEST_MODE and neither sends a reschedule IPI nor re-adds
> > vcpu0->cpu to cpu_kick_mask. When the interrupt returns,
> > kvm_kick_many_cpus() skips kicking and waiting for vcpu0, so the waiting
> > request (such as a remote TLB flush) can complete while vcpu0 is still in
> > guest mode or reading shadow page tables.
> >
> > Only touching cpu_kick_mask when KVM_REQUEST_WAIT is set (and tracking
> > whether any CPU was kicked with a local boolean for the return value)
> > would avoid this.
>
> Unless I'm misreading this, clobbering cpu_kick_mask and dropping the kick for
> a waiting request is a pre-existing bug. I'll address this in v2, and make sure
> the series is tagged for stable@.
Yeah, this looks like bad things could happen on arm64 when we pause the
VM for global VGIC state changes among other things. CC us on the v2 if
you don't mind.
Thanks,
Oliver
prev parent reply other threads:[~2026-11-18 0:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 20:54 [PATCH] KVM: Send reschedule IPIs instead of SMP function calls for non-waiting requests Sean Christopherson
2026-11-17 21:18 ` sashiko-bot
2026-11-17 23:50 ` Sean Christopherson
2026-11-18 0:03 ` Oliver Upton [this message]
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=avzrN0IZqTg3GlC1@kernel.org \
--to=oupton@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=maz@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=seanjc@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox