From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BFAA7CAC5B0 for ; Fri, 3 Oct 2025 18:41:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=cyLluMWAimlwCww1hc5v1QbjyTfF1x0IAJ4cPCG+hC8=; b=xqkUut6a88ld4Musyqt6OL3eBL 246kt0PshsLqNJPnlTzBAqmBdy8ZL28NyuBdQ9z2IJSgXT7QU5NR9obCPuLBa18D0sPF4PFnQcq6t qHlJyn/rs2kLiE3BaUARXYNgQmGpDlfOWHf+ku9XLnSTsqeBR1QNTxUS0mmfGvwUpdFORhnvaEH9o y3TQtVvzeF1w5WEAQxcBDZWA4YzAphSqDY13YZ1XtUpRGldiJD6cCkV3vqRN2B0YlllfaodUToiX5 g9vK4W6IhJHnWbZOwkWKIy6jOY9su82/JJC+s2JSEGaGWcP1MbSXGRi4z4sR5sVWo8QyGwVXADBs7 UQSFtEbA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1v4kiK-0000000CwPJ-23Gn; Fri, 03 Oct 2025 18:41:08 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1v4kiE-0000000CwOf-3HQo for linux-arm-kernel@lists.infradead.org; Fri, 03 Oct 2025 18:41:07 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 23DE94341F; Fri, 3 Oct 2025 18:41:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13CE6C4CEF5; Fri, 3 Oct 2025 18:40:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1759516862; bh=6+ceEIobr/tikpj9aWCDQebyycpGL/lMoKhLVPn6C+Q=; h=From:To:Cc:Subject:Date:From; b=FRiy8PpmmgYXT5n2a5cQ/KJMHancD62TliTq+qHBVLOzCre8VoP7M4OW8U3lvgK2t Rt9sr+Um1Nfz5ZAplQa3IdYNWVRP+Gpe0T57JcTHkRcWoGf00UaS2rO4VObZ8jYWMv INLnl63iFUeSvWBySE/uz7RtU8BUfbyL3SqmY2Mj7lyguNJwsSxQKDzYUrBxCESm9W auw6IDMWKMP8vvYFapf86zd1ceAJZ8LlYxD+D3h27qgZaVDz/ZJAnDmHkBO2xIVAqs 4G3bPCywPzQnfelrS05UyHbIvr48SZRMlDUnStL1WDEwd7sGi0mxyvGEMdEugoovy7 tClKrnW6IJyrA== From: Will Deacon To: stable@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, Will Deacon , Ard Biesheuvel , Lee Jones , Sasha Levin , Greg Kroah-Hartman , Kenneth Van Alstyne Subject: [STABLE 6.6.y] [PATCH] KVM: arm64: Fix softirq masking in FPSIMD register saving sequence Date: Fri, 3 Oct 2025 19:40:54 +0100 Message-Id: <20251003184054.4286-1-will@kernel.org> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251003_114102_858018_DCD27BCB X-CRM114-Status: GOOD ( 11.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Stable commit 28b82be094e2 ("KVM: arm64: Fix kernel BUG() due to bad backport of FPSIMD/SVE/SME fix") fixed a kernel BUG() caused by a bad backport of upstream commit fbc7e61195e2 ("KVM: arm64: Unconditionally save+flush host FPSIMD/SVE/SME state") by ensuring that softirqs are disabled/enabled across the fpsimd register save operation. Unfortunately, although this fixes the original issue, it can now lead to deadlock when re-enabling softirqs causes pending softirqs to be handled with locks already held: | BUG: spinlock recursion on CPU#7, CPU 3/KVM/57616 | lock: 0xffff3045ef850240, .magic: dead4ead, .owner: CPU 3/KVM/57616, .owner_cpu: 7 | CPU: 7 PID: 57616 Comm: CPU 3/KVM Tainted: G O 6.1.152 #1 | Hardware name: SoftIron SoftIron Platform Mainboard/SoftIron Platform Mainboard, BIOS 1.31 May 11 2023 | Call trace: | dump_backtrace+0xe4/0x110 | show_stack+0x20/0x30 | dump_stack_lvl+0x6c/0x88 | dump_stack+0x18/0x34 | spin_dump+0x98/0xac | do_raw_spin_lock+0x70/0x128 | _raw_spin_lock+0x18/0x28 | raw_spin_rq_lock_nested+0x18/0x28 | update_blocked_averages+0x70/0x550 | run_rebalance_domains+0x50/0x70 | handle_softirqs+0x198/0x328 | __do_softirq+0x1c/0x28 | ____do_softirq+0x18/0x28 | call_on_irq_stack+0x30/0x48 | do_softirq_own_stack+0x24/0x30 | do_softirq+0x74/0x90 | __local_bh_enable_ip+0x64/0x80 | fpsimd_save_and_flush_cpu_state+0x5c/0x68 | kvm_arch_vcpu_put_fp+0x4c/0x88 | kvm_arch_vcpu_put+0x28/0x88 | kvm_sched_out+0x38/0x58 | __schedule+0x55c/0x6c8 | schedule+0x60/0xa8 Take a tiny step towards the upstream fix in 9b19700e623f ("arm64: fpsimd: Drop unneeded 'busy' flag") by additionally disabling hardirqs while saving the fpsimd registers. Cc: Ard Biesheuvel Cc: Lee Jones Cc: Sasha Levin Cc: Greg Kroah-Hartman Cc: # 6.6.y Fixes: 28b82be094e2 ("KVM: arm64: Fix kernel BUG() due to bad backport of FPSIMD/SVE/SME fix") Reported-by: Kenneth Van Alstyne Link: https://lore.kernel.org/r/010001999bae0958-4d80d25d-8dda-4006-a6b9-798f3e774f6c-000000@email.amazonses.com Signed-off-by: Will Deacon --- arch/arm64/kernel/fpsimd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index d0d836448a76..83827384982e 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -1873,13 +1873,17 @@ static void fpsimd_flush_cpu_state(void) */ void fpsimd_save_and_flush_cpu_state(void) { + unsigned long flags; + if (!system_supports_fpsimd()) return; WARN_ON(preemptible()); - get_cpu_fpsimd_context(); + local_irq_save(flags); + __get_cpu_fpsimd_context(); fpsimd_save(); fpsimd_flush_cpu_state(); - put_cpu_fpsimd_context(); + __put_cpu_fpsimd_context(); + local_irq_restore(flags); } #ifdef CONFIG_KERNEL_MODE_NEON -- 2.51.0.618.g983fd99d29-goog