linux/arch/x86/platform
Ard Biesheuvel 2c340aab54 x86/efi: Restore IRQ state in EFI page fault handler
The kernel's softirq API does not permit re-enabling softirqs while IRQs
are disabled. The reason for this is that local_bh_enable() will not
only re-enable delivery of softirqs over the back of IRQs, it will also
handle any pending softirqs immediately, regardless of whether IRQs are
enabled at that point.

For this reason, commit

  d021985504 ("x86/fpu: Improve crypto performance by making kernel-mode FPU reliably usable in softirqs")

disables softirqs only when IRQs are enabled, as it is not permitted
otherwise, but also unnecessary, given that asynchronous softirq
delivery never happens to begin with while IRQs are disabled.

However, this does mean that entering a kernel mode FPU section with
IRQs enabled and leaving it with IRQs disabled leads to problems, as
identified by Sashiko [0]: the EFI page fault handler is called from
page_fault_oops() with IRQs disabled, and thus ends the kernel mode FPU
section with IRQs disabled as well, regardless of whether IRQs were
enabled when it was started. This may result in schedule() being called
with a non-zero preempt_count, causing a BUG().

So take care to re-enable IRQs when handling any EFI page faults if they
were taken with IRQs enabled.

[0] https://sashiko.dev/#/patchset/20260430074107.27051-1-ivan.hu%40canonical.com

Cc: Eric Biggers <ebiggers@kernel.org>
Cc: Ivan Hu <ivan.hu@canonical.com>
Cc: x86@kernel.org
Cc: <stable@vger.kernel.org>
Fixes: d021985504 ("x86/fpu: Improve crypto performance by making kernel-mode FPU reliably usable in softirqs")
Reviewed-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2026-05-05 09:31:28 +02:00
..
atom x86/platform/atom: Switch to new Intel CPU model defines 2024-06-03 09:49:00 +03:00
ce4100 serial: 8250: Move CE4100 quirks to a module under 8250 driver 2025-06-29 14:24:46 +02:00
efi x86/efi: Restore IRQ state in EFI page fault handler 2026-05-05 09:31:28 +02:00
geode x86/platform/geode: Fix on-stack property data use-after-return bug 2026-03-31 09:55:26 +02:00
intel x86/platform/iosf_mbi: Remove unused iosf_mbi_unregister_pmic_bus_access_notifier() 2025-04-01 20:31:39 +02:00
intel-mid x86/platform/intel-mid: Replace deprecated PCI functions 2024-11-11 11:59:21 +01:00
intel-quark x86/cpu: Fix FAM5_QUARK_X1000 to use X86_MATCH_VFM() 2024-10-31 12:02:21 -07:00
iris x86/platform: Switch back to struct platform_driver::remove() 2024-10-21 17:20:30 +02:00
olpc x86/platform/olpc: Replace strcpy() with strscpy() in xo15_sci_add() 2026-01-05 15:58:57 +01:00
pvh x86/PVH: Use boot params to pass RSDP address in start_info page 2026-03-03 15:06:19 +01:00
scx200 treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
ts5500 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
uv x86/apic: Convert to IRQCHIP_MOVE_DEFERRED 2025-01-15 21:38:53 +01:00
Makefile Simple Firmware Interface (SFI) support removal for v5.12-rc1 2021-02-24 10:35:29 -08:00