From: Jia He <justin.he@arm.com>
To: maz@kernel.org, oupton@kernel.org
Cc: fuad.tabba@linux.dev, joey.gouly@arm.com, seiden@linux.ibm.com,
suzuki.poulose@arm.com, yuzenghui@huawei.com,
bigeasy@linutronix.de, linux-arm-kernel@lists.infradead.org,
kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-rt-devel@lists.linux.dev, Jia He <justin.he@arm.com>
Subject: [PATCH 0/2] KVM: arm64: gic-v5: Fix irq_desc locks taken under the runqueue lock
Date: Mon, 16 Nov 2026 07:13:02 +0000 [thread overview]
Message-ID: <20261116071304.2037895-1-justin.he@arm.com> (raw)
With a GICv5 guest, kvm_sched_out() takes irq_desc locks with the
runqueue lock held in two places. Lockdep reports both as a circular
dependency with any interrupt that queues affinity notifier work under
its own descriptor lock:
- kvm_timer_vcpu_put() clears the active state of the host timer
interrupts. These are per-CPU and never threaded, so this one is a
false positive. Patch 1 gives them a separate lockdep class, as
commit 7100185bdc11 ("irqchip/gic-v4: Use a separate lockdep class for
vPE doorbell IRQs") in kvmarm/fixes does for the GICv4 vPE doorbells.
- vgic_v5_put() can move the vPE doorbell with irq_set_affinity() when
the vcpu thread is scheduled out in the middle of WFI. This came up in
the review of "KVM: arm64: gic-v5: Request doorbells when VPEs enter
WFI", where the resident check was expected to make it unreachable.
It is reachable, because vgic_v5_load() makes the vPE resident again
when the halting vcpu thread is scheduled back in. As the doorbell can
be force-threaded, this can wake its irq thread under the runqueue
lock, so patch 2 stops moving the doorbell from kvm_sched_out()
rather than hiding it from lockdep.
Tested on the Arm FVP Base RevC AEMvA GICv5 model (11.31.28, 8 CPUs,
VHE) with PROVE_LOCKING, on top of eedaa7d61f1e.
Lockdep reproduction: to provide the other half of the cycle, a test
module registers an affinity notifier on the UART interrupt and changes
its affinity a few times.
- Patch 1: the vgic_v5 selftest pinned to CPU0 next to a busy loop.
Without the patch, lockdep reports the cycle through
kvm_timer_vcpu_put(). With it there is no report, and &rq->__lock
depends on the new class instead of &irq_desc_lock_class.
- Patch 2: a vcpu executing WFI in a loop, woken by an SPI every 5ms,
with halt_poll_ns at 50ms and the vcpu thread moved to another CPU
every 1ms. A kprobe on irq_set_affinity() saw 11 calls from
kvm_sched_out() without the patch, together with the lockdep report
quoted in the commit message, and none with it. The doorbell is still
moved from kvm_vcpu_wfi() itself (51 and 61 calls).
PREEMPT_RT reproduction: PREEMPT_RT force-threads the vPE doorbell, so
patch 2 also fixes a real inversion. Without the patch, and without the
test module, the same WFI test makes lockdep report the cycle closed by
the doorbell's own irq thread: irq_set_affinity() from kvm_vcpu_wfi()
wakes the thread under the descriptor lock, while kvm_sched_out() takes
the descriptor lock under the runqueue lock. The model stops making
progress right after the report. With patch 2 there is no report and the
test completes. (Booting PREEMPT_RT on the GICv5 model also needs
"arm64: smp: Don't force-thread the GICv5 IPIs", posted separately.)
Jia He (2):
KVM: arm64: Give the host timer interrupts a separate lockdep class
KVM: arm64: gic-v5: Don't move the vPE doorbell from kvm_sched_out()
arch/arm64/kvm/arch_timer.c | 15 +++++++++++++++
arch/arm64/kvm/vgic/vgic-v5.c | 8 +++++++-
2 files changed, 22 insertions(+), 1 deletion(-)
base-commit: eedaa7d61f1ec8ae053a9ece0d553785350ac486
--
2.34.1
next reply other threads:[~2026-11-16 7:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 7:13 Jia He [this message]
2026-11-16 7:13 ` [PATCH 1/2] KVM: arm64: Give the host timer interrupts a separate lockdep class Jia He
2026-11-16 7:13 ` [PATCH 2/2] KVM: arm64: gic-v5: Don't move the vPE doorbell from kvm_sched_out() Jia He
2026-11-16 8:07 ` sashiko-bot
2026-11-16 9:37 ` Justin He
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=20261116071304.2037895-1-justin.he@arm.com \
--to=justin.he@arm.com \
--cc=bigeasy@linutronix.de \
--cc=fuad.tabba@linux.dev \
--cc=joey.gouly@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=seiden@linux.ibm.com \
--cc=suzuki.poulose@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®