hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/arch/ia64/mm/fault.c
....@@ -14,34 +14,12 @@
1414 #include <linux/kdebug.h>
1515 #include <linux/prefetch.h>
1616 #include <linux/uaccess.h>
17
+#include <linux/perf_event.h>
1718
18
-#include <asm/pgtable.h>
1919 #include <asm/processor.h>
2020 #include <asm/exception.h>
2121
2222 extern int die(char *, struct pt_regs *, long);
23
-
24
-#ifdef CONFIG_KPROBES
25
-static inline int notify_page_fault(struct pt_regs *regs, int trap)
26
-{
27
- int ret = 0;
28
-
29
- if (!user_mode(regs)) {
30
- /* kprobe_running() needs smp_processor_id() */
31
- preempt_disable();
32
- if (kprobe_running() && kprobe_fault_handler(regs, trap))
33
- ret = 1;
34
- preempt_enable();
35
- }
36
-
37
- return ret;
38
-}
39
-#else
40
-static inline int notify_page_fault(struct pt_regs *regs, int trap)
41
-{
42
- return 0;
43
-}
44
-#endif
4523
4624 /*
4725 * Return TRUE if ADDRESS points at a page in the kernel's mapped segment
....@@ -51,6 +29,7 @@
5129 mapped_kernel_page_is_present (unsigned long address)
5230 {
5331 pgd_t *pgd;
32
+ p4d_t *p4d;
5433 pud_t *pud;
5534 pmd_t *pmd;
5635 pte_t *ptep, pte;
....@@ -59,7 +38,11 @@
5938 if (pgd_none(*pgd) || pgd_bad(*pgd))
6039 return 0;
6140
62
- pud = pud_offset(pgd, address);
41
+ p4d = p4d_offset(pgd, address);
42
+ if (p4d_none(*p4d) || p4d_bad(*p4d))
43
+ return 0;
44
+
45
+ pud = pud_offset(p4d, address);
6346 if (pud_none(*pud) || pud_bad(*pud))
6447 return 0;
6548
....@@ -87,13 +70,13 @@
8770 struct mm_struct *mm = current->mm;
8871 unsigned long mask;
8972 vm_fault_t fault;
90
- unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
73
+ unsigned int flags = FAULT_FLAG_DEFAULT;
9174
9275 mask = ((((isr >> IA64_ISR_X_BIT) & 1UL) << VM_EXEC_BIT)
9376 | (((isr >> IA64_ISR_W_BIT) & 1UL) << VM_WRITE_BIT));
9477
95
- /* mmap_sem is performance critical.... */
96
- prefetchw(&mm->mmap_sem);
78
+ /* mmap_lock is performance critical.... */
79
+ prefetchw(&mm->mmap_lock);
9780
9881 /*
9982 * If we're in an interrupt or have no user context, we must not take the fault..
....@@ -104,7 +87,7 @@
10487 #ifdef CONFIG_VIRTUAL_MEM_MAP
10588 /*
10689 * If fault is in region 5 and we are in the kernel, we may already
107
- * have the mmap_sem (pfn_valid macro is called during mmap). There
90
+ * have the mmap_lock (pfn_valid macro is called during mmap). There
10891 * is no vma for region 5 addr's anyway, so skip getting the semaphore
10992 * and go directly to the exception handling code.
11093 */
....@@ -116,15 +99,17 @@
11699 /*
117100 * This is to handle the kprobes on user space access instructions
118101 */
119
- if (notify_page_fault(regs, TRAP_BRKPT))
102
+ if (kprobe_page_fault(regs, TRAP_BRKPT))
120103 return;
121104
122105 if (user_mode(regs))
123106 flags |= FAULT_FLAG_USER;
124107 if (mask & VM_WRITE)
125108 flags |= FAULT_FLAG_WRITE;
109
+
110
+ perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
126111 retry:
127
- down_read(&mm->mmap_sem);
112
+ mmap_read_lock(mm);
128113
129114 vma = find_vma_prev(mm, address, &prev_vma);
130115 if (!vma && !prev_vma )
....@@ -161,9 +146,9 @@
161146 * sure we exit gracefully rather than endlessly redo the
162147 * fault.
163148 */
164
- fault = handle_mm_fault(vma, address, flags);
149
+ fault = handle_mm_fault(vma, address, flags, regs);
165150
166
- if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
151
+ if (fault_signal_pending(fault, regs))
167152 return;
168153
169154 if (unlikely(fault & VM_FAULT_ERROR)) {
....@@ -184,15 +169,10 @@
184169 }
185170
186171 if (flags & FAULT_FLAG_ALLOW_RETRY) {
187
- if (fault & VM_FAULT_MAJOR)
188
- current->maj_flt++;
189
- else
190
- current->min_flt++;
191172 if (fault & VM_FAULT_RETRY) {
192
- flags &= ~FAULT_FLAG_ALLOW_RETRY;
193173 flags |= FAULT_FLAG_TRIED;
194174
195
- /* No need to up_read(&mm->mmap_sem) as we would
175
+ /* No need to mmap_read_unlock(mm) as we would
196176 * have already released it in __lock_page_or_retry
197177 * in mm/filemap.c.
198178 */
....@@ -201,7 +181,7 @@
201181 }
202182 }
203183
204
- up_read(&mm->mmap_sem);
184
+ mmap_read_unlock(mm);
205185 return;
206186
207187 check_expansion:
....@@ -232,7 +212,7 @@
232212 goto good_area;
233213
234214 bad_area:
235
- up_read(&mm->mmap_sem);
215
+ mmap_read_unlock(mm);
236216 #ifdef CONFIG_VIRTUAL_MEM_MAP
237217 bad_area_no_up:
238218 #endif
....@@ -248,16 +228,8 @@
248228 return;
249229 }
250230 if (user_mode(regs)) {
251
- struct siginfo si;
252
-
253
- clear_siginfo(&si);
254
- si.si_signo = signal;
255
- si.si_errno = 0;
256
- si.si_code = code;
257
- si.si_addr = (void __user *) address;
258
- si.si_isr = isr;
259
- si.si_flags = __ISR_VALID;
260
- force_sig_info(signal, &si, current);
231
+ force_sig_fault(signal, code, (void __user *) address,
232
+ 0, __ISR_VALID, isr);
261233 return;
262234 }
263235
....@@ -302,11 +274,11 @@
302274 regs = NULL;
303275 bust_spinlocks(0);
304276 if (regs)
305
- do_exit(SIGKILL);
277
+ make_task_dead(SIGKILL);
306278 return;
307279
308280 out_of_memory:
309
- up_read(&mm->mmap_sem);
281
+ mmap_read_unlock(mm);
310282 if (!user_mode(regs))
311283 goto no_context;
312284 pagefault_out_of_memory();