* [STABLE 5.15.y] [PATCH] KVM: arm64: Fix softirq masking in FPSIMD register saving sequence
@ 2025-10-03 18:39 Will Deacon
2025-10-03 18:43 ` Will Deacon
2025-10-06 10:08 ` Patch "KVM: arm64: Fix softirq masking in FPSIMD register saving sequence" has been added to the 5.15-stable tree gregkh
0 siblings, 2 replies; 5+ messages in thread
From: Will Deacon @ 2025-10-03 18:39 UTC (permalink / raw)
To: stable
Cc: linux-arm-kernel, kvmarm, Will Deacon, Ard Biesheuvel, Lee Jones,
Sasha Levin, Kenneth Van Alstyne
Stable commit 23249dade24e ("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 <ardb@kernel.org>
Cc: Lee Jones <lee@kernel.org>
Cc: Sasha Levin <sashal@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org
Cc: <stable@vger.kernel.org> # 5.15.y
Fixes: 23249dade24e ("KVM: arm64: Fix kernel BUG() due to bad backport of FPSIMD/SVE/SME fix")
Reported-by: Kenneth Van Alstyne <kvanals@kvanals.org>
Link: https://lore.kernel.org/r/010001999bae0958-4d80d25d-8dda-4006-a6b9-798f3e774f6c-000000@email.amazonses.com
Signed-off-by: Will Deacon <will@kernel.org>
---
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 fc51cdd5aaa7..db1ed940a6dc 100644
--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
@@ -1300,13 +1300,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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [STABLE 5.15.y] [PATCH] KVM: arm64: Fix softirq masking in FPSIMD register saving sequence
2025-10-03 18:39 [STABLE 5.15.y] [PATCH] KVM: arm64: Fix softirq masking in FPSIMD register saving sequence Will Deacon
@ 2025-10-03 18:43 ` Will Deacon
2025-10-05 14:56 ` Ard Biesheuvel
2025-10-06 10:00 ` Greg KH
2025-10-06 10:08 ` Patch "KVM: arm64: Fix softirq masking in FPSIMD register saving sequence" has been added to the 5.15-stable tree gregkh
1 sibling, 2 replies; 5+ messages in thread
From: Will Deacon @ 2025-10-03 18:43 UTC (permalink / raw)
To: stable
Cc: linux-arm-kernel, kvmarm, Ard Biesheuvel, Lee Jones, Sasha Levin,
Kenneth Van Alstyne, gregkh
On Fri, Oct 03, 2025 at 07:39:17PM +0100, Will Deacon wrote:
> Stable commit 23249dade24e ("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 <ardb@kernel.org>
> Cc: Lee Jones <lee@kernel.org>
> Cc: Sasha Levin <sashal@kernel.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org
Sorry, Greg, I lost a stray '>' here ^^^ and so you didn't end up on CC
for this one.
Will
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [STABLE 5.15.y] [PATCH] KVM: arm64: Fix softirq masking in FPSIMD register saving sequence
2025-10-03 18:43 ` Will Deacon
@ 2025-10-05 14:56 ` Ard Biesheuvel
2025-10-06 10:00 ` Greg KH
1 sibling, 0 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2025-10-05 14:56 UTC (permalink / raw)
To: Will Deacon
Cc: stable, linux-arm-kernel, kvmarm, Lee Jones, Sasha Levin,
Kenneth Van Alstyne, gregkh
On Fri, 3 Oct 2025 at 20:43, Will Deacon <will@kernel.org> wrote:
>
> On Fri, Oct 03, 2025 at 07:39:17PM +0100, Will Deacon wrote:
> > Stable commit 23249dade24e ("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 <ardb@kernel.org>
> > Cc: Lee Jones <lee@kernel.org>
> > Cc: Sasha Levin <sashal@kernel.org>
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org
>
> Sorry, Greg, I lost a stray '>' here ^^^ and so you didn't end up on CC
> for this one.
>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [STABLE 5.15.y] [PATCH] KVM: arm64: Fix softirq masking in FPSIMD register saving sequence
2025-10-03 18:43 ` Will Deacon
2025-10-05 14:56 ` Ard Biesheuvel
@ 2025-10-06 10:00 ` Greg KH
1 sibling, 0 replies; 5+ messages in thread
From: Greg KH @ 2025-10-06 10:00 UTC (permalink / raw)
To: Will Deacon
Cc: stable, linux-arm-kernel, kvmarm, Ard Biesheuvel, Lee Jones,
Sasha Levin, Kenneth Van Alstyne
On Fri, Oct 03, 2025 at 07:43:19PM +0100, Will Deacon wrote:
> On Fri, Oct 03, 2025 at 07:39:17PM +0100, Will Deacon wrote:
> > Stable commit 23249dade24e ("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 <ardb@kernel.org>
> > Cc: Lee Jones <lee@kernel.org>
> > Cc: Sasha Levin <sashal@kernel.org>
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org
>
> Sorry, Greg, I lost a stray '>' here ^^^ and so you didn't end up on CC
> for this one.
No worries, I see the stuff going to stable@vger.kernel.org as well :)
Now all queued up, thanks for these.
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Patch "KVM: arm64: Fix softirq masking in FPSIMD register saving sequence" has been added to the 5.15-stable tree
2025-10-03 18:39 [STABLE 5.15.y] [PATCH] KVM: arm64: Fix softirq masking in FPSIMD register saving sequence Will Deacon
2025-10-03 18:43 ` Will Deacon
@ 2025-10-06 10:08 ` gregkh
1 sibling, 0 replies; 5+ messages in thread
From: gregkh @ 2025-10-06 10:08 UTC (permalink / raw)
To: ardb, gregkh, kvanals, kvmarm, lee, linux-arm-kernel, sashal,
will
Cc: stable-commits
This is a note to let you know that I've just added the patch titled
KVM: arm64: Fix softirq masking in FPSIMD register saving sequence
to the 5.15-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
kvm-arm64-fix-softirq-masking-in-fpsimd-register-saving-sequence.patch
and it can be found in the queue-5.15 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.
From will@kernel.org Mon Oct 6 11:59:13 2025
From: Will Deacon <will@kernel.org>
Date: Fri, 3 Oct 2025 19:39:17 +0100
Subject: KVM: arm64: Fix softirq masking in FPSIMD register saving sequence
To: stable@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, Will Deacon <will@kernel.org>, Ard Biesheuvel <ardb@kernel.org>, Lee Jones <lee@kernel.org>, Sasha Levin <sashal@kernel.org>, Kenneth Van Alstyne <kvanals@kvanals.org>
Message-ID: <20251003183917.4209-1-will@kernel.org>
From: Will Deacon <will@kernel.org>
Stable commit 23249dade24e ("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 <ardb@kernel.org>
Cc: Lee Jones <lee@kernel.org>
Cc: Sasha Levin <sashal@kernel.org>
Cc: <stable@vger.kernel.org> # 5.15.y
Fixes: 23249dade24e ("KVM: arm64: Fix kernel BUG() due to bad backport of FPSIMD/SVE/SME fix")
Reported-by: Kenneth Van Alstyne <kvanals@kvanals.org>
Link: https://lore.kernel.org/r/010001999bae0958-4d80d25d-8dda-4006-a6b9-798f3e774f6c-000000@email.amazonses.com
Signed-off-by: Will Deacon <will@kernel.org>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/arm64/kernel/fpsimd.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
@@ -1300,13 +1300,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
Patches currently in stable-queue which might be from will@kernel.org are
queue-5.15/kvm-arm64-fix-softirq-masking-in-fpsimd-register-saving-sequence.patch
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-10-06 10:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-03 18:39 [STABLE 5.15.y] [PATCH] KVM: arm64: Fix softirq masking in FPSIMD register saving sequence Will Deacon
2025-10-03 18:43 ` Will Deacon
2025-10-05 14:56 ` Ard Biesheuvel
2025-10-06 10:00 ` Greg KH
2025-10-06 10:08 ` Patch "KVM: arm64: Fix softirq masking in FPSIMD register saving sequence" has been added to the 5.15-stable tree gregkh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).