hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/um/kernel/trap.c
....@@ -1,6 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3
- * Licensed under the GPL
44 */
55
66 #include <linux/mm.h>
....@@ -10,7 +10,6 @@
1010 #include <linux/uaccess.h>
1111 #include <linux/sched/debug.h>
1212 #include <asm/current.h>
13
-#include <asm/pgtable.h>
1413 #include <asm/tlbflush.h>
1514 #include <arch.h>
1615 #include <as-layout.h>
....@@ -19,7 +18,7 @@
1918 #include <skas.h>
2019
2120 /*
22
- * Note this is constrained to return 0, -EFAULT, -EACCESS, -ENOMEM by
21
+ * Note this is constrained to return 0, -EFAULT, -EACCES, -ENOMEM by
2322 * segv().
2423 */
2524 int handle_page_fault(unsigned long address, unsigned long ip,
....@@ -27,12 +26,10 @@
2726 {
2827 struct mm_struct *mm = current->mm;
2928 struct vm_area_struct *vma;
30
- pgd_t *pgd;
31
- pud_t *pud;
3229 pmd_t *pmd;
3330 pte_t *pte;
3431 int err = -EFAULT;
35
- unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
32
+ unsigned int flags = FAULT_FLAG_DEFAULT;
3633
3734 *code_out = SEGV_MAPERR;
3835
....@@ -46,7 +43,7 @@
4643 if (is_user)
4744 flags |= FAULT_FLAG_USER;
4845 retry:
49
- down_read(&mm->mmap_sem);
46
+ mmap_read_lock(mm);
5047 vma = find_vma(mm, address);
5148 if (!vma)
5249 goto out;
....@@ -74,7 +71,7 @@
7471 do {
7572 vm_fault_t fault;
7673
77
- fault = handle_mm_fault(vma, address, flags);
74
+ fault = handle_mm_fault(vma, address, flags, NULL);
7875
7976 if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
8077 goto out_nosemaphore;
....@@ -91,21 +88,14 @@
9188 BUG();
9289 }
9390 if (flags & FAULT_FLAG_ALLOW_RETRY) {
94
- if (fault & VM_FAULT_MAJOR)
95
- current->maj_flt++;
96
- else
97
- current->min_flt++;
9891 if (fault & VM_FAULT_RETRY) {
99
- flags &= ~FAULT_FLAG_ALLOW_RETRY;
10092 flags |= FAULT_FLAG_TRIED;
10193
10294 goto retry;
10395 }
10496 }
10597
106
- pgd = pgd_offset(mm, address);
107
- pud = pud_offset(pgd, address);
108
- pmd = pmd_offset(pud, address);
98
+ pmd = pmd_off(mm, address);
10999 pte = pte_offset_kernel(pmd, address);
110100 } while (!pte_present(*pte));
111101 err = 0;
....@@ -122,7 +112,7 @@
122112 #endif
123113 flush_tlb_page(vma, address);
124114 out:
125
- up_read(&mm->mmap_sem);
115
+ mmap_read_unlock(mm);
126116 out_nosemaphore:
127117 return err;
128118
....@@ -131,7 +121,7 @@
131121 * We ran out of memory, call the OOM killer, and return the userspace
132122 * (which will retry the fault, or kill us if we got oom-killed).
133123 */
134
- up_read(&mm->mmap_sem);
124
+ mmap_read_unlock(mm);
135125 if (!is_user)
136126 goto out_nosemaphore;
137127 pagefault_out_of_memory();
....@@ -163,13 +153,12 @@
163153 static void bad_segv(struct faultinfo fi, unsigned long ip)
164154 {
165155 current->thread.arch.faultinfo = fi;
166
- force_sig_fault(SIGSEGV, SEGV_ACCERR, (void __user *) FAULT_ADDRESS(fi),
167
- current);
156
+ force_sig_fault(SIGSEGV, SEGV_ACCERR, (void __user *) FAULT_ADDRESS(fi));
168157 }
169158
170159 void fatal_sigsegv(void)
171160 {
172
- force_sigsegv(SIGSEGV, current);
161
+ force_sigsegv(SIGSEGV);
173162 do_signal(&current->thread.regs);
174163 /*
175164 * This is to tell gcc that we're not returning - do_signal
....@@ -268,13 +257,11 @@
268257
269258 if (err == -EACCES) {
270259 current->thread.arch.faultinfo = fi;
271
- force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *)address,
272
- current);
260
+ force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *)address);
273261 } else {
274262 BUG_ON(err != -EFAULT);
275263 current->thread.arch.faultinfo = fi;
276
- force_sig_fault(SIGSEGV, si_code, (void __user *) address,
277
- current);
264
+ force_sig_fault(SIGSEGV, si_code, (void __user *) address);
278265 }
279266
280267 out:
....@@ -304,12 +291,11 @@
304291 if ((err == 0) && (siginfo_layout(sig, code) == SIL_FAULT)) {
305292 struct faultinfo *fi = UPT_FAULTINFO(regs);
306293 current->thread.arch.faultinfo = *fi;
307
- force_sig_fault(sig, code, (void __user *)FAULT_ADDRESS(*fi),
308
- current);
294
+ force_sig_fault(sig, code, (void __user *)FAULT_ADDRESS(*fi));
309295 } else {
310296 printk(KERN_ERR "Attempted to relay unknown signal %d (si_code = %d) with errno %d\n",
311297 sig, code, err);
312
- force_sig(sig, current);
298
+ force_sig(sig);
313299 }
314300 }
315301