From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796379958; b=Eqw6xIMZmwu69vqOWSTtRYKvjRNbaESOpGykzvrwVngY//ADDK6rXBSqC4GqxAqs75Jy Ll8u3ZV6I+s1r90TrJRn4EWnjo1bDn57dLsYsgyswdoMma+P9ggUg6vfbAGP9xKhpuNel rFBe9m5tZeyweoocrEd1FHNGu1ZZII8DWYIGnV9NpfJJUH9AbjX8czu8JQoru7FsgF2MN bgHWT+vJHBmUR/fa6EJnD3cSS4sANq0j9uWpQKq0pWcPTrRnwsdTAORGNNNkj9ghYuDCP S1djS2eUIqFdsn5hp03IMj9DlrwEKcCItCmLGpYUaBqKhtA/aiViW4LWvb9rZA+SVOQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379958; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=sCw0EejYOWzv9Vh/xLSi8ny26ldyZ5r23/KbCtDva6w=; b=VBmKl5VUPCPtc7cgwzkMHTLdqJeg37mbQ/G2dkNXV+CMiIbrKBVcaRLE9KxjmfKR7cR/ l4HA1NCjttqSAVRT/HPbDQrXQH/8phe+XPGMmvqEJJGWCTINNis5fQhr5LTEGlYFJJAaA DjF6E4gXTGIWs4Ga8eO5jCg+mmwsLjkHB+hrYJBKLk3aSrOzJnnt/UU/WOumc33/nSI7z eC7b4Ynnied92dzqMJoR9DueOGsdQ4gGk7zLIfOoHJOwdPKEPjuzNdjXRiVtiZsSfjQ9f ZA+8E4Jtk1DkvqyGCiyz2RziXA2T0YVqLPJplso5+DkLDUnYfKIRBlR2FtFX16iRsDg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="zaI/dAUG"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B51A9606A322; Fri, 4 Dec 2026 10:25:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=zaI/dAUG Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6EDF1F000C2; Fri, 4 Dec 2026 10:25:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379958; bh=sCw0EejYOWzv9Vh/xLSi8ny26ldyZ5r23/KbCtDva6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=zaI/dAUGqzvdtyk0QXPL/YEDdZs2lzSC/Srznj9DIPxTBJKLWKkPYeA6HzDjaElAj azHEmLXG3vvB5xjh2n2Q3Ia5QFSF4tvdMNQz7m+ER3Tweq9qJEqot1+UvwD5gBCrKH gEXxNc8dEGGYsLGOorsj/6oXctAEvj1OHuM1yIVQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Colton Lewis , Marc Zyngier , Sasha Levin Subject: [PATCH 7.3 068/742] irqchip/gic-v4: Use a separate lockdep class for vPE doorbell IRQs Date: Fri, 4 Dec 2026 18:58:52 +0900 Message-ID: <20261204100636.884277686@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Colton Lewis [ Upstream commit 7100185bdc1162eb2eca1dd20a036314e27f1561 ] By default, init_desc() assigns the shared irq_desc_lock_class lockdep key to desc->lock for every struct irq_desc. Device drivers that register an IRQ affinity notifier establish a lock dependency chain of &irq_desc_lock_class --> &pool->lock --> &p->pi_lock --> &rq->__lock when irq_set_affinity_locked() calls schedule_work() while holding desc->lock. On GICv4 systems, scheduling out a KVM vCPU calls kvm_sched_out() -> kvm_arch_vcpu_put() -> vgic_v3_put() -> vgic_v4_put() -> its_make_vpe_non_resident() -> irq_set_vcpu_affinity() while holding the scheduler runqueue lock (&rq->__lock). Acquiring the vPE doorbell IRQ's desc->lock establishes &rq->__lock --> &irq_desc_lock_class, triggering a lockdep circular locking splat: WARNING: possible circular locking dependency detected ------------------------------------------------------ VCPU-0/109705 is trying to acquire lock: ffff0001e41e4cc8 (&irq_desc_lock_class){-.-.}-{2:2}, at: __irq_get_desc_lock+0x5c/0xb0 but task is already holding lock: ffff00dad15fd260 (&rq->__lock){-.-.}-{2:2}, at: __schedule+0x23c/0x1850 which lock already depends on the new lock. Chain exists of: &irq_desc_lock_class --> &p->pi_lock --> &rq->__lock Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&rq->__lock); lock(&p->pi_lock); lock(&rq->__lock); lock(&irq_desc_lock_class); GICv4 vPE doorbell IRQs are internal to KVM and GICv4, set IRQ_NO_BALANCING, and never register an affinity notifier or queue work under desc->lock. However, under forced IRQ threading (threadirqs or CONFIG_PREEMPT_RT), request_irq() creates an IRQ thread for the doorbell handler, causing irq_set_affinity() -> irq_set_thread_affinity() in vgic_v4_load() to call wake_up_process() under desc->lock and establish a real desc->lock --> &p->pi_lock --> &rq->__lock dependency on the vPE doorbell IRQ itself. Mark vPE doorbell IRQs with irq_set_nothread() so they are never force-threaded, and assign them a dedicated lockdep class in its_alloc_vcpu_irqs() via irq_set_lockdep_class(). Fixes: 8e01d9a396e6 ("KVM: arm64: vgic-v4: Move the GICv4 residency flow to be driven by vcpu_load/put") Signed-off-by: Colton Lewis Link: https://patch.msgid.link/20261027180610.2840837-1-coltonlewis@google.com Signed-off-by: Marc Zyngier Signed-off-by: Sasha Levin --- drivers/irqchip/irq-gic-v4.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/irqchip/irq-gic-v4.c b/drivers/irqchip/irq-gic-v4.c index f707a3cb281aa..019aa0ded1bf9 100644 --- a/drivers/irqchip/irq-gic-v4.c +++ b/drivers/irqchip/irq-gic-v4.c @@ -163,6 +163,8 @@ static void its_free_sgi_irqs(struct its_vm *vm); int its_alloc_vcpu_irqs(struct its_vm *vm) { + static struct lock_class_key vpe_irq_lock_class; + static struct lock_class_key vpe_irq_request_class; int vpe_base_irq, i; vm->fwnode = irq_domain_alloc_named_id_fwnode("GICv4-vpe", @@ -189,6 +191,9 @@ int its_alloc_vcpu_irqs(struct its_vm *vm) for (i = 0; i < vm->nr_vpes; i++) { int ret; vm->vpes[i]->irq = vpe_base_irq + i; + irq_set_lockdep_class(vm->vpes[i]->irq, &vpe_irq_lock_class, + &vpe_irq_request_class); + irq_set_nothread(vm->vpes[i]->irq); ret = its_alloc_vcpu_sgis(vm->vpes[i], i); if (ret) goto err_free_irqs; -- 2.53.0