.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
---|
3 | | - * Licensed under the GPL |
---|
4 | 4 | */ |
---|
5 | 5 | |
---|
6 | 6 | #include <linux/mm.h> |
---|
.. | .. |
---|
10 | 10 | #include <linux/uaccess.h> |
---|
11 | 11 | #include <linux/sched/debug.h> |
---|
12 | 12 | #include <asm/current.h> |
---|
13 | | -#include <asm/pgtable.h> |
---|
14 | 13 | #include <asm/tlbflush.h> |
---|
15 | 14 | #include <arch.h> |
---|
16 | 15 | #include <as-layout.h> |
---|
.. | .. |
---|
19 | 18 | #include <skas.h> |
---|
20 | 19 | |
---|
21 | 20 | /* |
---|
22 | | - * Note this is constrained to return 0, -EFAULT, -EACCESS, -ENOMEM by |
---|
| 21 | + * Note this is constrained to return 0, -EFAULT, -EACCES, -ENOMEM by |
---|
23 | 22 | * segv(). |
---|
24 | 23 | */ |
---|
25 | 24 | int handle_page_fault(unsigned long address, unsigned long ip, |
---|
.. | .. |
---|
27 | 26 | { |
---|
28 | 27 | struct mm_struct *mm = current->mm; |
---|
29 | 28 | struct vm_area_struct *vma; |
---|
30 | | - pgd_t *pgd; |
---|
31 | | - pud_t *pud; |
---|
32 | 29 | pmd_t *pmd; |
---|
33 | 30 | pte_t *pte; |
---|
34 | 31 | int err = -EFAULT; |
---|
35 | | - unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE; |
---|
| 32 | + unsigned int flags = FAULT_FLAG_DEFAULT; |
---|
36 | 33 | |
---|
37 | 34 | *code_out = SEGV_MAPERR; |
---|
38 | 35 | |
---|
.. | .. |
---|
46 | 43 | if (is_user) |
---|
47 | 44 | flags |= FAULT_FLAG_USER; |
---|
48 | 45 | retry: |
---|
49 | | - down_read(&mm->mmap_sem); |
---|
| 46 | + mmap_read_lock(mm); |
---|
50 | 47 | vma = find_vma(mm, address); |
---|
51 | 48 | if (!vma) |
---|
52 | 49 | goto out; |
---|
.. | .. |
---|
74 | 71 | do { |
---|
75 | 72 | vm_fault_t fault; |
---|
76 | 73 | |
---|
77 | | - fault = handle_mm_fault(vma, address, flags); |
---|
| 74 | + fault = handle_mm_fault(vma, address, flags, NULL); |
---|
78 | 75 | |
---|
79 | 76 | if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) |
---|
80 | 77 | goto out_nosemaphore; |
---|
.. | .. |
---|
91 | 88 | BUG(); |
---|
92 | 89 | } |
---|
93 | 90 | if (flags & FAULT_FLAG_ALLOW_RETRY) { |
---|
94 | | - if (fault & VM_FAULT_MAJOR) |
---|
95 | | - current->maj_flt++; |
---|
96 | | - else |
---|
97 | | - current->min_flt++; |
---|
98 | 91 | if (fault & VM_FAULT_RETRY) { |
---|
99 | | - flags &= ~FAULT_FLAG_ALLOW_RETRY; |
---|
100 | 92 | flags |= FAULT_FLAG_TRIED; |
---|
101 | 93 | |
---|
102 | 94 | goto retry; |
---|
103 | 95 | } |
---|
104 | 96 | } |
---|
105 | 97 | |
---|
106 | | - pgd = pgd_offset(mm, address); |
---|
107 | | - pud = pud_offset(pgd, address); |
---|
108 | | - pmd = pmd_offset(pud, address); |
---|
| 98 | + pmd = pmd_off(mm, address); |
---|
109 | 99 | pte = pte_offset_kernel(pmd, address); |
---|
110 | 100 | } while (!pte_present(*pte)); |
---|
111 | 101 | err = 0; |
---|
.. | .. |
---|
122 | 112 | #endif |
---|
123 | 113 | flush_tlb_page(vma, address); |
---|
124 | 114 | out: |
---|
125 | | - up_read(&mm->mmap_sem); |
---|
| 115 | + mmap_read_unlock(mm); |
---|
126 | 116 | out_nosemaphore: |
---|
127 | 117 | return err; |
---|
128 | 118 | |
---|
.. | .. |
---|
131 | 121 | * We ran out of memory, call the OOM killer, and return the userspace |
---|
132 | 122 | * (which will retry the fault, or kill us if we got oom-killed). |
---|
133 | 123 | */ |
---|
134 | | - up_read(&mm->mmap_sem); |
---|
| 124 | + mmap_read_unlock(mm); |
---|
135 | 125 | if (!is_user) |
---|
136 | 126 | goto out_nosemaphore; |
---|
137 | 127 | pagefault_out_of_memory(); |
---|
.. | .. |
---|
163 | 153 | static void bad_segv(struct faultinfo fi, unsigned long ip) |
---|
164 | 154 | { |
---|
165 | 155 | 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)); |
---|
168 | 157 | } |
---|
169 | 158 | |
---|
170 | 159 | void fatal_sigsegv(void) |
---|
171 | 160 | { |
---|
172 | | - force_sigsegv(SIGSEGV, current); |
---|
| 161 | + force_sigsegv(SIGSEGV); |
---|
173 | 162 | do_signal(¤t->thread.regs); |
---|
174 | 163 | /* |
---|
175 | 164 | * This is to tell gcc that we're not returning - do_signal |
---|
.. | .. |
---|
268 | 257 | |
---|
269 | 258 | if (err == -EACCES) { |
---|
270 | 259 | 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); |
---|
273 | 261 | } else { |
---|
274 | 262 | BUG_ON(err != -EFAULT); |
---|
275 | 263 | 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); |
---|
278 | 265 | } |
---|
279 | 266 | |
---|
280 | 267 | out: |
---|
.. | .. |
---|
304 | 291 | if ((err == 0) && (siginfo_layout(sig, code) == SIL_FAULT)) { |
---|
305 | 292 | struct faultinfo *fi = UPT_FAULTINFO(regs); |
---|
306 | 293 | 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)); |
---|
309 | 295 | } else { |
---|
310 | 296 | printk(KERN_ERR "Attempted to relay unknown signal %d (si_code = %d) with errno %d\n", |
---|
311 | 297 | sig, code, err); |
---|
312 | | - force_sig(sig, current); |
---|
| 298 | + force_sig(sig); |
---|
313 | 299 | } |
---|
314 | 300 | } |
---|
315 | 301 | |
---|