linux/arch/x86/platform/efi
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
..
efi_32.c efi/x86: Move EFI runtime call setup/teardown helpers out of line 2023-09-11 06:37:50 +00:00
efi_64.c x86/efi: Disable LASS while executing runtime services 2026-03-03 09:49:45 -08:00
efi_stub_32.S x86: Prepare asm files for straight-line-speculation 2021-12-08 12:25:37 +01:00
efi_stub_64.S objtool: Validate kCFI calls 2025-08-18 14:23:09 +02:00
efi_thunk_64.S efi/x86-mixed: move unmitigated RET into .rodata 2022-08-16 09:28:05 +02:00
efi.c integrity-v7.1 2026-04-17 15:42:01 -07:00
Makefile x86/efi: Drop support for fake EFI memory maps 2024-07-02 00:26:24 +02:00
memmap.c memblock, treewide: make memblock_free() handle late freeing 2026-04-01 11:20:15 +03:00
quirks.c x86/efi: Restore IRQ state in EFI page fault handler 2026-05-05 09:31:28 +02:00
runtime-map.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00