diff options
author | Sam Ravnborg <sam@ravnborg.org> | 2012-05-15 13:02:08 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-05-15 13:43:48 -0400 |
commit | 70168dfa1cfa9489062264d89a273e0c30bf044b (patch) | |
tree | c88773b831981c108931b6545a3d441d244de83e /arch | |
parent | c7020eb4661eaf568a277056258a387ef88a9349 (diff) |
sparc32: cleanup mm/fault_32.c
- remove unused variables
- fix coding style issues that hurts my eyes
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/sparc/include/asm/pgtable_32.h | 2 | ||||
-rw-r--r-- | arch/sparc/mm/fault_32.c | 94 |
2 files changed, 44 insertions, 52 deletions
diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h index 28a67bfa71c1..cbbbed5cb3aa 100644 --- a/arch/sparc/include/asm/pgtable_32.h +++ b/arch/sparc/include/asm/pgtable_32.h | |||
@@ -361,8 +361,6 @@ void srmmu_mapiorange(unsigned int bus, unsigned long xpa, | |||
361 | unsigned long xva, unsigned int len); | 361 | unsigned long xva, unsigned int len); |
362 | void srmmu_unmapiorange(unsigned long virt_addr, unsigned int len); | 362 | void srmmu_unmapiorange(unsigned long virt_addr, unsigned int len); |
363 | 363 | ||
364 | extern int invalid_segment; | ||
365 | |||
366 | /* Encode and de-code a swap entry */ | 364 | /* Encode and de-code a swap entry */ |
367 | static inline unsigned long __swp_type(swp_entry_t entry) | 365 | static inline unsigned long __swp_type(swp_entry_t entry) |
368 | { | 366 | { |
diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c index 5d37f1f8142c..f46cf6be3370 100644 --- a/arch/sparc/mm/fault_32.c +++ b/arch/sparc/mm/fault_32.c | |||
@@ -30,22 +30,13 @@ | |||
30 | #include <asm/traps.h> | 30 | #include <asm/traps.h> |
31 | #include <asm/uaccess.h> | 31 | #include <asm/uaccess.h> |
32 | 32 | ||
33 | extern int prom_node_root; | ||
34 | |||
35 | int show_unhandled_signals = 1; | 33 | int show_unhandled_signals = 1; |
36 | 34 | ||
37 | /* At boot time we determine these two values necessary for setting | 35 | /* At boot time we determine these two values necessary for setting |
38 | * up the segment maps and page table entries (pte's). | 36 | * up the segment maps and page table entries (pte's). |
39 | */ | 37 | */ |
40 | 38 | ||
41 | int num_segmaps, num_contexts; | 39 | int num_contexts; |
42 | int invalid_segment; | ||
43 | |||
44 | /* various Virtual Address Cache parameters we find at boot time... */ | ||
45 | |||
46 | int vac_size, vac_linesize, vac_do_hw_vac_flushes; | ||
47 | int vac_entries_per_context, vac_entries_per_segment; | ||
48 | int vac_entries_per_page; | ||
49 | 40 | ||
50 | /* Return how much physical memory we have. */ | 41 | /* Return how much physical memory we have. */ |
51 | unsigned long probe_memory(void) | 42 | unsigned long probe_memory(void) |
@@ -62,32 +53,33 @@ unsigned long probe_memory(void) | |||
62 | static void unhandled_fault(unsigned long, struct task_struct *, | 53 | static void unhandled_fault(unsigned long, struct task_struct *, |
63 | struct pt_regs *) __attribute__ ((noreturn)); | 54 | struct pt_regs *) __attribute__ ((noreturn)); |
64 | 55 | ||
65 | static void unhandled_fault(unsigned long address, struct task_struct *tsk, | 56 | static void __noreturn unhandled_fault(unsigned long address, |
66 | struct pt_regs *regs) | 57 | struct task_struct *tsk, |
58 | struct pt_regs *regs) | ||
67 | { | 59 | { |
68 | if((unsigned long) address < PAGE_SIZE) { | 60 | if ((unsigned long) address < PAGE_SIZE) { |
69 | printk(KERN_ALERT | 61 | printk(KERN_ALERT |
70 | "Unable to handle kernel NULL pointer dereference\n"); | 62 | "Unable to handle kernel NULL pointer dereference\n"); |
71 | } else { | 63 | } else { |
72 | printk(KERN_ALERT "Unable to handle kernel paging request " | 64 | printk(KERN_ALERT "Unable to handle kernel paging request at virtual address %08lx\n", |
73 | "at virtual address %08lx\n", address); | 65 | address); |
74 | } | 66 | } |
75 | printk(KERN_ALERT "tsk->{mm,active_mm}->context = %08lx\n", | 67 | printk(KERN_ALERT "tsk->{mm,active_mm}->context = %08lx\n", |
76 | (tsk->mm ? tsk->mm->context : tsk->active_mm->context)); | 68 | (tsk->mm ? tsk->mm->context : tsk->active_mm->context)); |
77 | printk(KERN_ALERT "tsk->{mm,active_mm}->pgd = %08lx\n", | 69 | printk(KERN_ALERT "tsk->{mm,active_mm}->pgd = %08lx\n", |
78 | (tsk->mm ? (unsigned long) tsk->mm->pgd : | 70 | (tsk->mm ? (unsigned long) tsk->mm->pgd : |
79 | (unsigned long) tsk->active_mm->pgd)); | 71 | (unsigned long) tsk->active_mm->pgd)); |
80 | die_if_kernel("Oops", regs); | 72 | die_if_kernel("Oops", regs); |
81 | } | 73 | } |
82 | 74 | ||
83 | asmlinkage int lookup_fault(unsigned long pc, unsigned long ret_pc, | 75 | asmlinkage int lookup_fault(unsigned long pc, unsigned long ret_pc, |
84 | unsigned long address) | 76 | unsigned long address) |
85 | { | 77 | { |
86 | struct pt_regs regs; | 78 | struct pt_regs regs; |
87 | unsigned long g2; | 79 | unsigned long g2; |
88 | unsigned int insn; | 80 | unsigned int insn; |
89 | int i; | 81 | int i; |
90 | 82 | ||
91 | i = search_extables_range(ret_pc, &g2); | 83 | i = search_extables_range(ret_pc, &g2); |
92 | switch (i) { | 84 | switch (i) { |
93 | case 3: | 85 | case 3: |
@@ -107,14 +99,14 @@ asmlinkage int lookup_fault(unsigned long pc, unsigned long ret_pc, | |||
107 | /* for _from_ macros */ | 99 | /* for _from_ macros */ |
108 | insn = *((unsigned int *) pc); | 100 | insn = *((unsigned int *) pc); |
109 | if (!((insn >> 21) & 1) || ((insn>>19)&0x3f) == 15) | 101 | if (!((insn >> 21) & 1) || ((insn>>19)&0x3f) == 15) |
110 | return 2; | 102 | return 2; |
111 | break; | 103 | break; |
112 | 104 | ||
113 | default: | 105 | default: |
114 | break; | 106 | break; |
115 | } | 107 | } |
116 | 108 | ||
117 | memset(®s, 0, sizeof (regs)); | 109 | memset(®s, 0, sizeof(regs)); |
118 | regs.pc = pc; | 110 | regs.pc = pc; |
119 | regs.npc = pc + 4; | 111 | regs.npc = pc + 4; |
120 | __asm__ __volatile__( | 112 | __asm__ __volatile__( |
@@ -177,11 +169,10 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault) | |||
177 | if (text_fault) | 169 | if (text_fault) |
178 | return regs->pc; | 170 | return regs->pc; |
179 | 171 | ||
180 | if (regs->psr & PSR_PS) { | 172 | if (regs->psr & PSR_PS) |
181 | insn = *(unsigned int *) regs->pc; | 173 | insn = *(unsigned int *) regs->pc; |
182 | } else { | 174 | else |
183 | __get_user(insn, (unsigned int *) regs->pc); | 175 | __get_user(insn, (unsigned int *) regs->pc); |
184 | } | ||
185 | 176 | ||
186 | return safe_compute_effective_address(regs, insn); | 177 | return safe_compute_effective_address(regs, insn); |
187 | } | 178 | } |
@@ -207,7 +198,7 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write, | |||
207 | unsigned int flags = (FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE | | 198 | unsigned int flags = (FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE | |
208 | (write ? FAULT_FLAG_WRITE : 0)); | 199 | (write ? FAULT_FLAG_WRITE : 0)); |
209 | 200 | ||
210 | if(text_fault) | 201 | if (text_fault) |
211 | address = regs->pc; | 202 | address = regs->pc; |
212 | 203 | ||
213 | /* | 204 | /* |
@@ -227,25 +218,25 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write, | |||
227 | * If we're in an interrupt or have no user | 218 | * If we're in an interrupt or have no user |
228 | * context, we must not take the fault.. | 219 | * context, we must not take the fault.. |
229 | */ | 220 | */ |
230 | if (in_atomic() || !mm) | 221 | if (in_atomic() || !mm) |
231 | goto no_context; | 222 | goto no_context; |
232 | 223 | ||
233 | perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); | 224 | perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address); |
234 | 225 | ||
235 | retry: | 226 | retry: |
236 | down_read(&mm->mmap_sem); | 227 | down_read(&mm->mmap_sem); |
237 | 228 | ||
238 | if(!from_user && address >= PAGE_OFFSET) | 229 | if (!from_user && address >= PAGE_OFFSET) |
239 | goto bad_area; | 230 | goto bad_area; |
240 | 231 | ||
241 | vma = find_vma(mm, address); | 232 | vma = find_vma(mm, address); |
242 | if(!vma) | 233 | if (!vma) |
243 | goto bad_area; | 234 | goto bad_area; |
244 | if(vma->vm_start <= address) | 235 | if (vma->vm_start <= address) |
245 | goto good_area; | 236 | goto good_area; |
246 | if(!(vma->vm_flags & VM_GROWSDOWN)) | 237 | if (!(vma->vm_flags & VM_GROWSDOWN)) |
247 | goto bad_area; | 238 | goto bad_area; |
248 | if(expand_stack(vma, address)) | 239 | if (expand_stack(vma, address)) |
249 | goto bad_area; | 240 | goto bad_area; |
250 | /* | 241 | /* |
251 | * Ok, we have a good vm_area for this memory access, so | 242 | * Ok, we have a good vm_area for this memory access, so |
@@ -253,12 +244,12 @@ retry: | |||
253 | */ | 244 | */ |
254 | good_area: | 245 | good_area: |
255 | code = SEGV_ACCERR; | 246 | code = SEGV_ACCERR; |
256 | if(write) { | 247 | if (write) { |
257 | if(!(vma->vm_flags & VM_WRITE)) | 248 | if (!(vma->vm_flags & VM_WRITE)) |
258 | goto bad_area; | 249 | goto bad_area; |
259 | } else { | 250 | } else { |
260 | /* Allow reads even for write-only mappings */ | 251 | /* Allow reads even for write-only mappings */ |
261 | if(!(vma->vm_flags & (VM_READ | VM_EXEC))) | 252 | if (!(vma->vm_flags & (VM_READ | VM_EXEC))) |
262 | goto bad_area; | 253 | goto bad_area; |
263 | } | 254 | } |
264 | 255 | ||
@@ -324,14 +315,16 @@ no_context: | |||
324 | g2 = regs->u_regs[UREG_G2]; | 315 | g2 = regs->u_regs[UREG_G2]; |
325 | if (!from_user) { | 316 | if (!from_user) { |
326 | fixup = search_extables_range(regs->pc, &g2); | 317 | fixup = search_extables_range(regs->pc, &g2); |
327 | if (fixup > 10) { /* Values below are reserved for other things */ | 318 | /* Values below 10 are reserved for other things */ |
319 | if (fixup > 10) { | ||
328 | extern const unsigned __memset_start[]; | 320 | extern const unsigned __memset_start[]; |
329 | extern const unsigned __memset_end[]; | 321 | extern const unsigned __memset_end[]; |
330 | extern const unsigned __csum_partial_copy_start[]; | 322 | extern const unsigned __csum_partial_copy_start[]; |
331 | extern const unsigned __csum_partial_copy_end[]; | 323 | extern const unsigned __csum_partial_copy_end[]; |
332 | 324 | ||
333 | #ifdef DEBUG_EXCEPTIONS | 325 | #ifdef DEBUG_EXCEPTIONS |
334 | printk("Exception: PC<%08lx> faddr<%08lx>\n", regs->pc, address); | 326 | printk("Exception: PC<%08lx> faddr<%08lx>\n", |
327 | regs->pc, address); | ||
335 | printk("EX_TABLE: insn<%08lx> fixup<%08x> g2<%08lx>\n", | 328 | printk("EX_TABLE: insn<%08lx> fixup<%08x> g2<%08lx>\n", |
336 | regs->pc, fixup, g2); | 329 | regs->pc, fixup, g2); |
337 | #endif | 330 | #endif |
@@ -339,7 +332,7 @@ no_context: | |||
339 | regs->pc < (unsigned long)__memset_end) || | 332 | regs->pc < (unsigned long)__memset_end) || |
340 | (regs->pc >= (unsigned long)__csum_partial_copy_start && | 333 | (regs->pc >= (unsigned long)__csum_partial_copy_start && |
341 | regs->pc < (unsigned long)__csum_partial_copy_end)) { | 334 | regs->pc < (unsigned long)__csum_partial_copy_end)) { |
342 | regs->u_regs[UREG_I4] = address; | 335 | regs->u_regs[UREG_I4] = address; |
343 | regs->u_regs[UREG_I5] = regs->pc; | 336 | regs->u_regs[UREG_I5] = regs->pc; |
344 | } | 337 | } |
345 | regs->u_regs[UREG_G2] = g2; | 338 | regs->u_regs[UREG_G2] = g2; |
@@ -348,8 +341,8 @@ no_context: | |||
348 | return; | 341 | return; |
349 | } | 342 | } |
350 | } | 343 | } |
351 | 344 | ||
352 | unhandled_fault (address, tsk, regs); | 345 | unhandled_fault(address, tsk, regs); |
353 | do_exit(SIGKILL); | 346 | do_exit(SIGKILL); |
354 | 347 | ||
355 | /* | 348 | /* |
@@ -395,6 +388,7 @@ vmalloc_fault: | |||
395 | 388 | ||
396 | if (pmd_present(*pmd) || !pmd_present(*pmd_k)) | 389 | if (pmd_present(*pmd) || !pmd_present(*pmd_k)) |
397 | goto bad_area_nosemaphore; | 390 | goto bad_area_nosemaphore; |
391 | |||
398 | *pmd = *pmd_k; | 392 | *pmd = *pmd_k; |
399 | return; | 393 | return; |
400 | } | 394 | } |
@@ -412,21 +406,21 @@ static void force_user_fault(unsigned long address, int write) | |||
412 | 406 | ||
413 | down_read(&mm->mmap_sem); | 407 | down_read(&mm->mmap_sem); |
414 | vma = find_vma(mm, address); | 408 | vma = find_vma(mm, address); |
415 | if(!vma) | 409 | if (!vma) |
416 | goto bad_area; | 410 | goto bad_area; |
417 | if(vma->vm_start <= address) | 411 | if (vma->vm_start <= address) |
418 | goto good_area; | 412 | goto good_area; |
419 | if(!(vma->vm_flags & VM_GROWSDOWN)) | 413 | if (!(vma->vm_flags & VM_GROWSDOWN)) |
420 | goto bad_area; | 414 | goto bad_area; |
421 | if(expand_stack(vma, address)) | 415 | if (expand_stack(vma, address)) |
422 | goto bad_area; | 416 | goto bad_area; |
423 | good_area: | 417 | good_area: |
424 | code = SEGV_ACCERR; | 418 | code = SEGV_ACCERR; |
425 | if(write) { | 419 | if (write) { |
426 | if(!(vma->vm_flags & VM_WRITE)) | 420 | if (!(vma->vm_flags & VM_WRITE)) |
427 | goto bad_area; | 421 | goto bad_area; |
428 | } else { | 422 | } else { |
429 | if(!(vma->vm_flags & (VM_READ | VM_EXEC))) | 423 | if (!(vma->vm_flags & (VM_READ | VM_EXEC))) |
430 | goto bad_area; | 424 | goto bad_area; |
431 | } | 425 | } |
432 | switch (handle_mm_fault(mm, vma, address, write ? FAULT_FLAG_WRITE : 0)) { | 426 | switch (handle_mm_fault(mm, vma, address, write ? FAULT_FLAG_WRITE : 0)) { |
@@ -457,7 +451,7 @@ void window_overflow_fault(void) | |||
457 | unsigned long sp; | 451 | unsigned long sp; |
458 | 452 | ||
459 | sp = current_thread_info()->rwbuf_stkptrs[0]; | 453 | sp = current_thread_info()->rwbuf_stkptrs[0]; |
460 | if(((sp + 0x38) & PAGE_MASK) != (sp & PAGE_MASK)) | 454 | if (((sp + 0x38) & PAGE_MASK) != (sp & PAGE_MASK)) |
461 | force_user_fault(sp + 0x38, 1); | 455 | force_user_fault(sp + 0x38, 1); |
462 | force_user_fault(sp, 1); | 456 | force_user_fault(sp, 1); |
463 | 457 | ||
@@ -466,7 +460,7 @@ void window_overflow_fault(void) | |||
466 | 460 | ||
467 | void window_underflow_fault(unsigned long sp) | 461 | void window_underflow_fault(unsigned long sp) |
468 | { | 462 | { |
469 | if(((sp + 0x38) & PAGE_MASK) != (sp & PAGE_MASK)) | 463 | if (((sp + 0x38) & PAGE_MASK) != (sp & PAGE_MASK)) |
470 | force_user_fault(sp + 0x38, 0); | 464 | force_user_fault(sp + 0x38, 0); |
471 | force_user_fault(sp, 0); | 465 | force_user_fault(sp, 0); |
472 | 466 | ||
@@ -478,7 +472,7 @@ void window_ret_fault(struct pt_regs *regs) | |||
478 | unsigned long sp; | 472 | unsigned long sp; |
479 | 473 | ||
480 | sp = regs->u_regs[UREG_FP]; | 474 | sp = regs->u_regs[UREG_FP]; |
481 | if(((sp + 0x38) & PAGE_MASK) != (sp & PAGE_MASK)) | 475 | if (((sp + 0x38) & PAGE_MASK) != (sp & PAGE_MASK)) |
482 | force_user_fault(sp + 0x38, 0); | 476 | force_user_fault(sp + 0x38, 0); |
483 | force_user_fault(sp, 0); | 477 | force_user_fault(sp, 0); |
484 | 478 | ||