[PATCH 1/2] KVM: arm64: Give the host timer interrupts a separate lockdep class
From: Jia He
Date: Mon Nov 16 2026 - 02:13:31 EST
With a GICv5 guest, kvm_timer_vcpu_put() clears the active state of the
host timer interrupts with irq_set_irqchip_state(), which takes their
irq_desc lock. On preemption this runs from kvm_sched_out() with the
runqueue lock held:
&rq->__lock --> &irq_desc_lock_class
By default, all irq descriptors share a single lockdep class, so this
closes a cycle with any interrupt that queues affinity notifier work
under its own descriptor lock (mlx5, for example), as already seen with
the GICv4 vPE doorbells:
&irq_desc_lock_class --> &pool->lock --> &p->pi_lock --> &rq->__lock
For the timer interrupts this is a false positive. Nothing that runs
under their descriptor lock leads back to the scheduler:
- They are requested only by KVM, with request_percpu_irq(). Per-CPU
interrupts are never threaded (irq_set_percpu_devid() sets
IRQ_NOTHREAD), so there is no irq thread to wake, unlike the vPE
doorbells with threadirqs.
- Their affinity is fixed and never changed, so no affinity notifier
work or thread affinity update is triggered.
- The irqchip callbacks reached under the lock (the KVM timer_chip,
forwarding to the GIC) only access GIC registers.
Give them a separate lockdep class. This is done for all vGIC types, as
none of the above is specific to GICv5. Both timers share the class, so
dependencies between them are still checked.
Fixes: 9491c63b6cd7 ("KVM: arm64: gic-v5: Enlighten arch timer for GICv5")
Signed-off-by: Jia He <justin.he@xxxxxxx>
---
arch/arm64/kvm/arch_timer.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c
index b2c5ba499aa5..1088563d32a3 100644
--- a/arch/arm64/kvm/arch_timer.c
+++ b/arch/arm64/kvm/arch_timer.c
@@ -1362,6 +1362,17 @@ static void kvm_irq_fixup_flags(unsigned int virq, u32 *flags)
}
}
+/*
+ * With a GICv5 guest, the timer interrupts' irq_desc lock is taken under
+ * the runqueue lock (kvm_sched_out() -> kvm_timer_vcpu_put()). Give them
+ * their own lockdep class, so that they are not mixed up with interrupts
+ * whose affinity notifier queues work under the irq_desc lock. Nothing
+ * under the timers' own irq_desc lock leads back to the scheduler: they
+ * are per-CPU (never threaded) and their affinity never changes.
+ */
+static struct lock_class_key kvm_timer_irq_lock_class;
+static struct lock_class_key kvm_timer_irq_request_class;
+
static int kvm_irq_init(struct arch_timer_kvm_info *info)
{
struct irq_domain *domain = NULL;
@@ -1374,6 +1385,8 @@ static int kvm_irq_init(struct arch_timer_kvm_info *info)
host_vtimer_irq = info->virtual_irq;
kvm_irq_fixup_flags(host_vtimer_irq, &host_vtimer_irq_flags);
+ irq_set_lockdep_class(host_vtimer_irq, &kvm_timer_irq_lock_class,
+ &kvm_timer_irq_request_class);
if (kvm_vgic_global_state.no_hw_deactivation ||
kvm_vgic_global_state.type == VGIC_V5) {
@@ -1401,6 +1414,8 @@ static int kvm_irq_init(struct arch_timer_kvm_info *info)
if (info->physical_irq > 0) {
host_ptimer_irq = info->physical_irq;
kvm_irq_fixup_flags(host_ptimer_irq, &host_ptimer_irq_flags);
+ irq_set_lockdep_class(host_ptimer_irq, &kvm_timer_irq_lock_class,
+ &kvm_timer_irq_request_class);
if (domain)
WARN_ON(irq_domain_push_irq(domain, host_ptimer_irq,
--
2.34.1