hc
2024-05-10 748e4f3d702def1a4bff191e0cf93b6a05340f01
kernel/arch/sparc/mm/fault_32.c
....@@ -25,7 +25,6 @@
2525 #include <linux/uaccess.h>
2626
2727 #include <asm/page.h>
28
-#include <asm/pgtable.h>
2928 #include <asm/openprom.h>
3029 #include <asm/oplib.h>
3130 #include <asm/setup.h>
....@@ -131,7 +130,7 @@
131130 show_signal_msg(regs, sig, code,
132131 addr, current);
133132
134
- force_sig_fault(sig, code, (void __user *) addr, 0, current);
133
+ force_sig_fault(sig, code, (void __user *) addr, 0);
135134 }
136135
137136 static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
....@@ -168,7 +167,7 @@
168167 int from_user = !(regs->psr & PSR_PS);
169168 int code;
170169 vm_fault_t fault;
171
- unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
170
+ unsigned int flags = FAULT_FLAG_DEFAULT;
172171
173172 if (text_fault)
174173 address = regs->pc;
....@@ -196,7 +195,7 @@
196195 perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
197196
198197 retry:
199
- down_read(&mm->mmap_sem);
198
+ mmap_read_lock(mm);
200199
201200 if (!from_user && address >= PAGE_OFFSET)
202201 goto bad_area;
....@@ -235,9 +234,9 @@
235234 * make sure we exit gracefully rather than endlessly redo
236235 * the fault.
237236 */
238
- fault = handle_mm_fault(vma, address, flags);
237
+ fault = handle_mm_fault(vma, address, flags, regs);
239238
240
- if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
239
+ if (fault_signal_pending(fault, regs))
241240 return;
242241
243242 if (unlikely(fault & VM_FAULT_ERROR)) {
....@@ -251,20 +250,10 @@
251250 }
252251
253252 if (flags & FAULT_FLAG_ALLOW_RETRY) {
254
- if (fault & VM_FAULT_MAJOR) {
255
- current->maj_flt++;
256
- perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ,
257
- 1, regs, address);
258
- } else {
259
- current->min_flt++;
260
- perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN,
261
- 1, regs, address);
262
- }
263253 if (fault & VM_FAULT_RETRY) {
264
- flags &= ~FAULT_FLAG_ALLOW_RETRY;
265254 flags |= FAULT_FLAG_TRIED;
266255
267
- /* No need to up_read(&mm->mmap_sem) as we would
256
+ /* No need to mmap_read_unlock(mm) as we would
268257 * have already released it in __lock_page_or_retry
269258 * in mm/filemap.c.
270259 */
....@@ -273,7 +262,7 @@
273262 }
274263 }
275264
276
- up_read(&mm->mmap_sem);
265
+ mmap_read_unlock(mm);
277266 return;
278267
279268 /*
....@@ -281,7 +270,7 @@
281270 * Fix it, but check if it's kernel or user first..
282271 */
283272 bad_area:
284
- up_read(&mm->mmap_sem);
273
+ mmap_read_unlock(mm);
285274
286275 bad_area_nosemaphore:
287276 /* User mode accesses just cause a SIGSEGV */
....@@ -299,8 +288,6 @@
299288 if (fixup > 10) {
300289 extern const unsigned int __memset_start[];
301290 extern const unsigned int __memset_end[];
302
- extern const unsigned int __csum_partial_copy_start[];
303
- extern const unsigned int __csum_partial_copy_end[];
304291
305292 #ifdef DEBUG_EXCEPTIONS
306293 printk("Exception: PC<%08lx> faddr<%08lx>\n",
....@@ -309,9 +296,7 @@
309296 regs->pc, fixup, g2);
310297 #endif
311298 if ((regs->pc >= (unsigned long)__memset_start &&
312
- regs->pc < (unsigned long)__memset_end) ||
313
- (regs->pc >= (unsigned long)__csum_partial_copy_start &&
314
- regs->pc < (unsigned long)__csum_partial_copy_end)) {
299
+ regs->pc < (unsigned long)__memset_end)) {
315300 regs->u_regs[UREG_I4] = address;
316301 regs->u_regs[UREG_I5] = regs->pc;
317302 }
....@@ -330,7 +315,7 @@
330315 * us unable to handle the page fault gracefully.
331316 */
332317 out_of_memory:
333
- up_read(&mm->mmap_sem);
318
+ mmap_read_unlock(mm);
334319 if (from_user) {
335320 pagefault_out_of_memory();
336321 return;
....@@ -338,7 +323,7 @@
338323 goto no_context;
339324
340325 do_sigbus:
341
- up_read(&mm->mmap_sem);
326
+ mmap_read_unlock(mm);
342327 do_fault_siginfo(BUS_ADRERR, SIGBUS, regs, text_fault);
343328 if (!from_user)
344329 goto no_context;
....@@ -351,6 +336,8 @@
351336 */
352337 int offset = pgd_index(address);
353338 pgd_t *pgd, *pgd_k;
339
+ p4d_t *p4d, *p4d_k;
340
+ pud_t *pud, *pud_k;
354341 pmd_t *pmd, *pmd_k;
355342
356343 pgd = tsk->active_mm->pgd + offset;
....@@ -363,8 +350,13 @@
363350 return;
364351 }
365352
366
- pmd = pmd_offset(pgd, address);
367
- pmd_k = pmd_offset(pgd_k, address);
353
+ p4d = p4d_offset(pgd, address);
354
+ pud = pud_offset(p4d, address);
355
+ pmd = pmd_offset(pud, address);
356
+
357
+ p4d_k = p4d_offset(pgd_k, address);
358
+ pud_k = pud_offset(p4d_k, address);
359
+ pmd_k = pmd_offset(pud_k, address);
368360
369361 if (pmd_present(*pmd) || !pmd_present(*pmd_k))
370362 goto bad_area_nosemaphore;
....@@ -385,7 +377,7 @@
385377
386378 code = SEGV_MAPERR;
387379
388
- down_read(&mm->mmap_sem);
380
+ mmap_read_lock(mm);
389381 vma = find_vma(mm, address);
390382 if (!vma)
391383 goto bad_area;
....@@ -405,27 +397,27 @@
405397 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
406398 goto bad_area;
407399 }
408
- switch (handle_mm_fault(vma, address, flags)) {
400
+ switch (handle_mm_fault(vma, address, flags, NULL)) {
409401 case VM_FAULT_SIGBUS:
410402 case VM_FAULT_OOM:
411403 goto do_sigbus;
412404 }
413
- up_read(&mm->mmap_sem);
405
+ mmap_read_unlock(mm);
414406 return;
415407 bad_area:
416
- up_read(&mm->mmap_sem);
408
+ mmap_read_unlock(mm);
417409 __do_fault_siginfo(code, SIGSEGV, tsk->thread.kregs, address);
418410 return;
419411
420412 do_sigbus:
421
- up_read(&mm->mmap_sem);
413
+ mmap_read_unlock(mm);
422414 __do_fault_siginfo(BUS_ADRERR, SIGBUS, tsk->thread.kregs, address);
423415 }
424416
425417 static void check_stack_aligned(unsigned long sp)
426418 {
427419 if (sp & 0x7UL)
428
- force_sig(SIGILL, current);
420
+ force_sig(SIGILL);
429421 }
430422
431423 void window_overflow_fault(void)