mirror-linux/arch
Cedric Xing 614da1d3d4 x86: make page fault handling disable interrupts properly
There's a big comment in the x86 do_page_fault() about our interrupt
disabling code:

    * User address page fault handling might have reenabled
    * interrupts. Fixing up all potential exit points of
    * do_user_addr_fault() and its leaf functions is just not
    * doable w/o creating an unholy mess or turning the code
    * upside down.

but it turns out that comment is subtly wrong, and the code as a result
is also wrong.

Because it's certainly true that we may have re-enabled interrupts when
handling user page faults.  And it's most certainly true that we don't
want to bother fixing up all the cases.

But what isn't true is that it's limited to user address page faults.

The confusion stems from the fact that we have logic here that depends
on the address range of the access, but other code then depends on the
_context_ the access was done in.  The two are not related, even though
both of them are about user-vs-kernel.

In other words, both user and kernel addresses can cause interrupts to
have been enabled (eg when __bad_area_nosemaphore() gets called for user
accesses to kernel addresses).  As a result we should make sure to
disable interrupts again regardless of the address range before
returning to the low-level fault handling code.

The __bad_area_nosemaphore() code actually did disable interrupts again
after enabling them, just not consistently.  Ironically, as noted in the
original comment, fixing up all the cases is just not worth it, when the
simple solution is to just do it unconditionally in one single place.

So remove the incomplete case that unsuccessfully tried to do what the
comment said was "not doable" in commit ca4c6a9858 ("x86/traps: Make
interrupt enable/disable symmetric in C code"), and just make it do the
simple and straightforward thing.

Signed-off-by: Cedric Xing <cedric.xing@intel.com>
Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com>
Fixes: ca4c6a9858 ("x86/traps: Make interrupt enable/disable symmetric in C code")
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2026-01-22 16:49:17 -08:00
..
alpha alpha updates for v6.19 2025-12-11 08:01:52 +09:00
arc
arm Nuvoton NPCM Arm fixes for v6.19 2026-01-20 16:08:41 +01:00
arm64 Qualcomm Arm64 DeviceTree fixes for v6.19 2026-01-21 09:52:19 +01:00
csky csky 6.19 Release Notes 2025-12-10 12:17:29 +09:00
hexagon This update includes the following changes: 2025-12-03 11:28:38 -08:00
loongarch LoongArch: KVM: Fix kvm_device leak in kvm_pch_pic_destroy() 2026-01-17 10:57:03 +08:00
m68k Networking changes for 6.19. 2025-12-03 17:24:33 -08:00
microblaze
mips mips: fix HIGHMEM initialization 2026-01-14 22:16:22 -08:00
nios2 arch/nios2: replace "__auto_type" and adjacent equivalent with "auto" 2025-12-08 15:32:15 -08:00
openrisc
parisc TTY/Serial changes for 6.19-rc1 2025-12-06 18:38:19 -08:00
powerpc powerpc/watchdog: add support for hardlockup_sys_info sysctl 2026-01-14 22:16:22 -08:00
riscv bpf-fixes 2026-01-13 21:21:13 -08:00
s390 s390/stacktrace: Do not fallback to RA register 2025-12-14 11:03:58 +01:00
sh treewide: Update email address 2026-01-11 06:09:11 -10:00
sparc treewide: Update email address 2026-01-11 06:09:11 -10:00
um Address various objtool scalability bugs/inefficiencies exposed by 2025-12-06 11:56:51 -08:00
x86 x86: make page fault handling disable interrupts properly 2026-01-22 16:49:17 -08:00
xtensa TTY/Serial changes for 6.19-rc1 2025-12-06 18:38:19 -08:00
.gitignore
Kconfig