Skip to content

Commit aa37c51

Browse files
hansendcPeter Zijlstra
authored andcommitted
x86/mm: Break out user address space handling
The last patch broke out kernel address space handing into its own helper. Now, do the same for user address space handling. Cc: x86@kernel.org Cc: Jann Horn <jannh@google.com> Cc: Sean Christopherson <sean.j.christopherson@intel.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Andy Lutomirski <luto@kernel.org> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: http://lkml.kernel.org/r/20180928160223.9C4F6440@viggo.jf.intel.com
1 parent 8fed620 commit aa37c51

File tree

1 file changed

+28
-19
lines changed

1 file changed

+28
-19
lines changed

arch/x86/mm/fault.c

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,7 @@ bad_area_access_error(struct pt_regs *regs, unsigned long error_code,
966966
__bad_area(regs, error_code, address, vma, SEGV_ACCERR);
967967
}
968968

969+
/* Handle faults in the kernel portion of the address space */
969970
static void
970971
do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
971972
u32 *pkey, unsigned int fault)
@@ -1254,14 +1255,11 @@ do_kern_addr_fault(struct pt_regs *regs, unsigned long hw_error_code,
12541255
}
12551256
NOKPROBE_SYMBOL(do_kern_addr_fault);
12561257

1257-
/*
1258-
* This routine handles page faults. It determines the address,
1259-
* and the problem, and then passes it off to one of the appropriate
1260-
* routines.
1261-
*/
1262-
static noinline void
1263-
__do_page_fault(struct pt_regs *regs, unsigned long hw_error_code,
1264-
unsigned long address)
1258+
/* Handle faults in the user portion of the address space */
1259+
static inline
1260+
void do_user_addr_fault(struct pt_regs *regs,
1261+
unsigned long hw_error_code,
1262+
unsigned long address)
12651263
{
12661264
unsigned long sw_error_code;
12671265
struct vm_area_struct *vma;
@@ -1274,17 +1272,6 @@ __do_page_fault(struct pt_regs *regs, unsigned long hw_error_code,
12741272
tsk = current;
12751273
mm = tsk->mm;
12761274

1277-
prefetchw(&mm->mmap_sem);
1278-
1279-
if (unlikely(kmmio_fault(regs, address)))
1280-
return;
1281-
1282-
/* Was the fault on kernel-controlled part of the address space? */
1283-
if (unlikely(fault_in_kernel_space(address))) {
1284-
do_kern_addr_fault(regs, hw_error_code, address);
1285-
return;
1286-
}
1287-
12881275
/* kprobes don't want to hook the spurious faults: */
12891276
if (unlikely(kprobes_fault(regs)))
12901277
return;
@@ -1488,6 +1475,28 @@ __do_page_fault(struct pt_regs *regs, unsigned long hw_error_code,
14881475

14891476
check_v8086_mode(regs, address, tsk);
14901477
}
1478+
NOKPROBE_SYMBOL(do_user_addr_fault);
1479+
1480+
/*
1481+
* This routine handles page faults. It determines the address,
1482+
* and the problem, and then passes it off to one of the appropriate
1483+
* routines.
1484+
*/
1485+
static noinline void
1486+
__do_page_fault(struct pt_regs *regs, unsigned long hw_error_code,
1487+
unsigned long address)
1488+
{
1489+
prefetchw(&current->mm->mmap_sem);
1490+
1491+
if (unlikely(kmmio_fault(regs, address)))
1492+
return;
1493+
1494+
/* Was the fault on kernel-controlled part of the address space? */
1495+
if (unlikely(fault_in_kernel_space(address)))
1496+
do_kern_addr_fault(regs, hw_error_code, address);
1497+
else
1498+
do_user_addr_fault(regs, hw_error_code, address);
1499+
}
14911500
NOKPROBE_SYMBOL(__do_page_fault);
14921501

14931502
static nokprobe_inline void

0 commit comments

Comments
 (0)