* [PATCH] x86/efi: Fix graceful fault handling after FPU softirq changes
@ 2026-04-30 7:41 Ivan Hu
2026-04-30 8:30 ` Ard Biesheuvel
2026-05-01 5:52 ` Eric Biggers
0 siblings, 2 replies; 4+ messages in thread
From: Ivan Hu @ 2026-04-30 7:41 UTC (permalink / raw)
To: ardb, ilias.apalodimas, tglx, mingo, bp, dave.hansen, hpa,
ebiggers
Cc: x86, linux-efi, linux-kernel
Since commit d02198550423 ("x86/fpu: Improve crypto performance by
making kernel-mode FPU reliably usable in softirqs"), kernel_fpu_begin()
calls fpregs_lock() which uses local_bh_disable() instead of the
previous preempt_disable(). This sets SOFTIRQ_OFFSET in preempt_count
during the entire EFI runtime service call, causing in_interrupt() to
return true in normal task context.
The graceful page fault handler efi_crash_gracefully_on_page_fault()
uses in_interrupt() to bail out for faults in real interrupt context.
With SOFTIRQ_OFFSET now set, the handler always bails out, leaving EFI
firmware page faults unhandled. This escalates to die() which also sees
in_interrupt() as true and calls panic("Fatal exception in interrupt"),
resulting in a hard system freeze. On systems with buggy firmware that
triggers page faults during EFI runtime calls (e.g., accessing unmapped
memory in GetTime()), this causes an unrecoverable hang instead of the
expected graceful EFI_ABORTED recovery.
Fix by replacing in_interrupt() with in_hardirq() || in_nmi(). This
preserves the original intent of bailing for genuine hardware interrupt
or NMI faults, while no longer falsely triggering from the FPU code
path's local_bh_disable(). This is safe because softirqs cannot run
during EFI calls (they are explicitly blocked by fpregs_lock()), so
they can never be the source of a page fault in this context.
Fixes: d02198550423 ("x86/fpu: Improve crypto performance by making kernel-mode FPU reliably usable in softirqs")
Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
arch/x86/platform/efi/quirks.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
index df24ffc6105d..7475405119ce 100644
--- a/arch/x86/platform/efi/quirks.c
+++ b/arch/x86/platform/efi/quirks.c
@@ -767,10 +767,10 @@ void efi_crash_gracefully_on_page_fault(unsigned long phys_addr)
return;
/*
- * If we get an interrupt/NMI while processing an EFI runtime service
+ * If we get a hard IRQ or NMI while processing an EFI runtime service
* then this is a regular OOPS, not an EFI failure.
*/
- if (in_interrupt())
+ if (in_hardirq() || in_nmi())
return;
/*
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] x86/efi: Fix graceful fault handling after FPU softirq changes
2026-04-30 7:41 [PATCH] x86/efi: Fix graceful fault handling after FPU softirq changes Ivan Hu
@ 2026-04-30 8:30 ` Ard Biesheuvel
2026-05-01 5:52 ` Eric Biggers
1 sibling, 0 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2026-04-30 8:30 UTC (permalink / raw)
To: Ivan Hu, Ilias Apalodimas, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, dave.hansen, H . Peter Anvin, ebiggers
Cc: x86, linux-efi, linux-kernel
On Thu, 30 Apr 2026, at 09:41, Ivan Hu wrote:
> Since commit d02198550423 ("x86/fpu: Improve crypto performance by
> making kernel-mode FPU reliably usable in softirqs"), kernel_fpu_begin()
> calls fpregs_lock() which uses local_bh_disable() instead of the
> previous preempt_disable(). This sets SOFTIRQ_OFFSET in preempt_count
> during the entire EFI runtime service call, causing in_interrupt() to
> return true in normal task context.
>
> The graceful page fault handler efi_crash_gracefully_on_page_fault()
> uses in_interrupt() to bail out for faults in real interrupt context.
> With SOFTIRQ_OFFSET now set, the handler always bails out, leaving EFI
> firmware page faults unhandled. This escalates to die() which also sees
> in_interrupt() as true and calls panic("Fatal exception in interrupt"),
> resulting in a hard system freeze. On systems with buggy firmware that
> triggers page faults during EFI runtime calls (e.g., accessing unmapped
> memory in GetTime()), this causes an unrecoverable hang instead of the
> expected graceful EFI_ABORTED recovery.
>
> Fix by replacing in_interrupt() with in_hardirq() || in_nmi(). This
> preserves the original intent of bailing for genuine hardware interrupt
> or NMI faults, while no longer falsely triggering from the FPU code
> path's local_bh_disable(). This is safe because softirqs cannot run
> during EFI calls (they are explicitly blocked by fpregs_lock()), so
> they can never be the source of a page fault in this context.
>
> Fixes: d02198550423 ("x86/fpu: Improve crypto performance by making
> kernel-mode FPU reliably usable in softirqs")
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
> arch/x86/platform/efi/quirks.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
I'll take this via the EFI tree unless -tip prefers to take it.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] x86/efi: Fix graceful fault handling after FPU softirq changes
2026-04-30 7:41 [PATCH] x86/efi: Fix graceful fault handling after FPU softirq changes Ivan Hu
2026-04-30 8:30 ` Ard Biesheuvel
@ 2026-05-01 5:52 ` Eric Biggers
2026-05-01 6:38 ` Ard Biesheuvel
1 sibling, 1 reply; 4+ messages in thread
From: Eric Biggers @ 2026-05-01 5:52 UTC (permalink / raw)
To: Ivan Hu
Cc: ardb, ilias.apalodimas, tglx, mingo, bp, dave.hansen, hpa, x86,
linux-efi, linux-kernel
On Thu, Apr 30, 2026 at 03:41:07PM +0800, Ivan Hu wrote:
> Since commit d02198550423 ("x86/fpu: Improve crypto performance by
> making kernel-mode FPU reliably usable in softirqs"), kernel_fpu_begin()
> calls fpregs_lock() which uses local_bh_disable() instead of the
> previous preempt_disable(). This sets SOFTIRQ_OFFSET in preempt_count
> during the entire EFI runtime service call, causing in_interrupt() to
> return true in normal task context.
>
> The graceful page fault handler efi_crash_gracefully_on_page_fault()
> uses in_interrupt() to bail out for faults in real interrupt context.
> With SOFTIRQ_OFFSET now set, the handler always bails out, leaving EFI
> firmware page faults unhandled. This escalates to die() which also sees
> in_interrupt() as true and calls panic("Fatal exception in interrupt"),
> resulting in a hard system freeze. On systems with buggy firmware that
> triggers page faults during EFI runtime calls (e.g., accessing unmapped
> memory in GetTime()), this causes an unrecoverable hang instead of the
> expected graceful EFI_ABORTED recovery.
>
> Fix by replacing in_interrupt() with in_hardirq() || in_nmi(). This
> preserves the original intent of bailing for genuine hardware interrupt
> or NMI faults, while no longer falsely triggering from the FPU code
> path's local_bh_disable(). This is safe because softirqs cannot run
> during EFI calls (they are explicitly blocked by fpregs_lock()), so
> they can never be the source of a page fault in this context.
>
> Fixes: d02198550423 ("x86/fpu: Improve crypto performance by making kernel-mode FPU reliably usable in softirqs")
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
Sorry for the trouble here.
Can you check the Sashiko review at
https://sashiko.dev/#/patchset/20260430074107.27051-1-ivan.hu%40canonical.com
? The two things it found look legitimate.
- Eric
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] x86/efi: Fix graceful fault handling after FPU softirq changes
2026-05-01 5:52 ` Eric Biggers
@ 2026-05-01 6:38 ` Ard Biesheuvel
0 siblings, 0 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2026-05-01 6:38 UTC (permalink / raw)
To: Eric Biggers, Ivan Hu
Cc: Ilias Apalodimas, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
dave.hansen, H . Peter Anvin, x86, linux-efi, linux-kernel
On Fri, 1 May 2026, at 07:52, Eric Biggers wrote:
> On Thu, Apr 30, 2026 at 03:41:07PM +0800, Ivan Hu wrote:
>> Since commit d02198550423 ("x86/fpu: Improve crypto performance by
>> making kernel-mode FPU reliably usable in softirqs"), kernel_fpu_begin()
>> calls fpregs_lock() which uses local_bh_disable() instead of the
>> previous preempt_disable(). This sets SOFTIRQ_OFFSET in preempt_count
>> during the entire EFI runtime service call, causing in_interrupt() to
>> return true in normal task context.
>>
>> The graceful page fault handler efi_crash_gracefully_on_page_fault()
>> uses in_interrupt() to bail out for faults in real interrupt context.
>> With SOFTIRQ_OFFSET now set, the handler always bails out, leaving EFI
>> firmware page faults unhandled. This escalates to die() which also sees
>> in_interrupt() as true and calls panic("Fatal exception in interrupt"),
>> resulting in a hard system freeze. On systems with buggy firmware that
>> triggers page faults during EFI runtime calls (e.g., accessing unmapped
>> memory in GetTime()), this causes an unrecoverable hang instead of the
>> expected graceful EFI_ABORTED recovery.
>>
>> Fix by replacing in_interrupt() with in_hardirq() || in_nmi(). This
>> preserves the original intent of bailing for genuine hardware interrupt
>> or NMI faults, while no longer falsely triggering from the FPU code
>> path's local_bh_disable(). This is safe because softirqs cannot run
>> during EFI calls (they are explicitly blocked by fpregs_lock()), so
>> they can never be the source of a page fault in this context.
>>
>> Fixes: d02198550423 ("x86/fpu: Improve crypto performance by making kernel-mode FPU reliably usable in softirqs")
>> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
>
> Sorry for the trouble here.
>
> Can you check the Sashiko review at
> https://sashiko.dev/#/patchset/20260430074107.27051-1-ivan.hu%40canonical.com
> ? The two things it found look legitimate.
>
Ah thanks for bringing that up. Yes, those concerns seem valid (as
usual for Sashiko :-))
So we should be using !in_task() here instead, to ensure that
in_serving_softirq() is taken into account too, or we might
trigger the EFI page fault handler inadvertently.
I will send out a patch for the other issue it identified separately.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-05-01 6:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-30 7:41 [PATCH] x86/efi: Fix graceful fault handling after FPU softirq changes Ivan Hu
2026-04-30 8:30 ` Ard Biesheuvel
2026-05-01 5:52 ` Eric Biggers
2026-05-01 6:38 ` Ard Biesheuvel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox