Skip to content

Commit ee6352b

Browse files
Frederic WeisbeckerIngo Molnar
authored andcommitted
x86/context-tracking: Remove exception_enter/exit() from do_page_fault()
do_page_fault(), like other exceptions, is already covered by user_enter() and user_exit() when the exception triggers in userspace. As explained in: 8c84014 ("x86/entry: Remove exception_enter() from most trap handlers") exception_enter/exit() only remained to handle possible page fault from kernel mode while context tracking is in CONTEXT_USER mode, ie: on kernel entry before we manage to call user_exit(). The only known offender was do_fast_syscall_32() fetching EBP register from where vDSO stashed it. Meanwhile this got fixed in: 9999c8c ("x86/entry: Call enter_from_user_mode() with IRQs off") that moved enter_from_user_mode() before the call to get_user(). So we can safely remove it now. Signed-off-by: Frederic Weisbecker <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Jim Mattson <[email protected]> Cc: Joerg Roedel <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Paolo Bonzini <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Radim Krčmář <[email protected]> Cc: Sean Christopherson <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vitaly Kuznetsov <[email protected]> Cc: Wanpeng Li <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent c79f46a commit ee6352b

File tree

1 file changed

+12
-27
lines changed

1 file changed

+12
-27
lines changed

arch/x86/mm/fault.c

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,27 +1486,6 @@ void do_user_addr_fault(struct pt_regs *regs,
14861486
}
14871487
NOKPROBE_SYMBOL(do_user_addr_fault);
14881488

1489-
/*
1490-
* Explicitly marked noinline such that the function tracer sees this as the
1491-
* page_fault entry point.
1492-
*/
1493-
static noinline void
1494-
__do_page_fault(struct pt_regs *regs, unsigned long hw_error_code,
1495-
unsigned long address)
1496-
{
1497-
prefetchw(&current->mm->mmap_sem);
1498-
1499-
if (unlikely(kmmio_fault(regs, address)))
1500-
return;
1501-
1502-
/* Was the fault on kernel-controlled part of the address space? */
1503-
if (unlikely(fault_in_kernel_space(address)))
1504-
do_kern_addr_fault(regs, hw_error_code, address);
1505-
else
1506-
do_user_addr_fault(regs, hw_error_code, address);
1507-
}
1508-
NOKPROBE_SYMBOL(__do_page_fault);
1509-
15101489
static __always_inline void
15111490
trace_page_fault_entries(struct pt_regs *regs, unsigned long error_code,
15121491
unsigned long address)
@@ -1521,13 +1500,19 @@ trace_page_fault_entries(struct pt_regs *regs, unsigned long error_code,
15211500
}
15221501

15231502
dotraplinkage void
1524-
do_page_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
1503+
do_page_fault(struct pt_regs *regs, unsigned long hw_error_code,
1504+
unsigned long address)
15251505
{
1526-
enum ctx_state prev_state;
1506+
prefetchw(&current->mm->mmap_sem);
1507+
trace_page_fault_entries(regs, hw_error_code, address);
15271508

1528-
prev_state = exception_enter();
1529-
trace_page_fault_entries(regs, error_code, address);
1530-
__do_page_fault(regs, error_code, address);
1531-
exception_exit(prev_state);
1509+
if (unlikely(kmmio_fault(regs, address)))
1510+
return;
1511+
1512+
/* Was the fault on kernel-controlled part of the address space? */
1513+
if (unlikely(fault_in_kernel_space(address)))
1514+
do_kern_addr_fault(regs, hw_error_code, address);
1515+
else
1516+
do_user_addr_fault(regs, hw_error_code, address);
15321517
}
15331518
NOKPROBE_SYMBOL(do_page_fault);

0 commit comments

Comments
 (0)