diff options
author | Stuart Menefy <stuart.menefy@st.com> | 2006-11-20 23:34:04 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2006-12-05 20:45:38 -0500 |
commit | b5a1bcbee434b843c8850a968d9a6c7541f1be9d (patch) | |
tree | 2745f5efa2b4d6dfe18f4f186738612f0e77f79c /arch/sh/kernel/traps.c | |
parent | f0bc814cfbc212683c882e58b3d1afec6b3e3aa3 (diff) |
sh: Set up correct siginfo structures for page faults.
Remove the previous saving of fault codes into the thread_struct
as they are never used, and appeared to be inherited from x86.
Signed-off-by: Stuart Menefy <stuart.menefy@st.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/kernel/traps.c')
-rw-r--r-- | arch/sh/kernel/traps.c | 74 |
1 files changed, 40 insertions, 34 deletions
diff --git a/arch/sh/kernel/traps.c b/arch/sh/kernel/traps.c index b52037bc1255..0ee298079d82 100644 --- a/arch/sh/kernel/traps.c +++ b/arch/sh/kernel/traps.c | |||
@@ -93,7 +93,7 @@ void die(const char * str, struct pt_regs * regs, long err) | |||
93 | 93 | ||
94 | if (!user_mode(regs) || in_interrupt()) | 94 | if (!user_mode(regs) || in_interrupt()) |
95 | dump_mem("Stack: ", regs->regs[15], THREAD_SIZE + | 95 | dump_mem("Stack: ", regs->regs[15], THREAD_SIZE + |
96 | (unsigned long)task_stack_page(current)); | 96 | (unsigned long)task_stack_page(current)); |
97 | 97 | ||
98 | bust_spinlocks(0); | 98 | bust_spinlocks(0); |
99 | spin_unlock_irq(&die_lock); | 99 | spin_unlock_irq(&die_lock); |
@@ -201,7 +201,7 @@ static int handle_unaligned_ins(u16 instruction, struct pt_regs *regs) | |||
201 | if (copy_to_user(dst,src,4)) | 201 | if (copy_to_user(dst,src,4)) |
202 | goto fetch_fault; | 202 | goto fetch_fault; |
203 | ret = 0; | 203 | ret = 0; |
204 | break; | 204 | break; |
205 | 205 | ||
206 | case 2: /* mov.[bwl] to memory, possibly with pre-decrement */ | 206 | case 2: /* mov.[bwl] to memory, possibly with pre-decrement */ |
207 | if (instruction & 4) | 207 | if (instruction & 4) |
@@ -225,7 +225,7 @@ static int handle_unaligned_ins(u16 instruction, struct pt_regs *regs) | |||
225 | if (copy_from_user(dst,src,4)) | 225 | if (copy_from_user(dst,src,4)) |
226 | goto fetch_fault; | 226 | goto fetch_fault; |
227 | ret = 0; | 227 | ret = 0; |
228 | break; | 228 | break; |
229 | 229 | ||
230 | case 6: /* mov.[bwl] from memory, possibly with post-increment */ | 230 | case 6: /* mov.[bwl] from memory, possibly with post-increment */ |
231 | src = (unsigned char*) *rm; | 231 | src = (unsigned char*) *rm; |
@@ -233,7 +233,7 @@ static int handle_unaligned_ins(u16 instruction, struct pt_regs *regs) | |||
233 | *rm += count; | 233 | *rm += count; |
234 | dst = (unsigned char*) rn; | 234 | dst = (unsigned char*) rn; |
235 | *(unsigned long*)dst = 0; | 235 | *(unsigned long*)dst = 0; |
236 | 236 | ||
237 | #ifdef __LITTLE_ENDIAN__ | 237 | #ifdef __LITTLE_ENDIAN__ |
238 | if (copy_from_user(dst, src, count)) | 238 | if (copy_from_user(dst, src, count)) |
239 | goto fetch_fault; | 239 | goto fetch_fault; |
@@ -244,7 +244,7 @@ static int handle_unaligned_ins(u16 instruction, struct pt_regs *regs) | |||
244 | } | 244 | } |
245 | #else | 245 | #else |
246 | dst += 4-count; | 246 | dst += 4-count; |
247 | 247 | ||
248 | if (copy_from_user(dst, src, count)) | 248 | if (copy_from_user(dst, src, count)) |
249 | goto fetch_fault; | 249 | goto fetch_fault; |
250 | 250 | ||
@@ -323,7 +323,8 @@ static inline int handle_unaligned_delayslot(struct pt_regs *regs) | |||
323 | return -EFAULT; | 323 | return -EFAULT; |
324 | 324 | ||
325 | /* kernel */ | 325 | /* kernel */ |
326 | die("delay-slot-insn faulting in handle_unaligned_delayslot", regs, 0); | 326 | die("delay-slot-insn faulting in handle_unaligned_delayslot", |
327 | regs, 0); | ||
327 | } | 328 | } |
328 | 329 | ||
329 | return handle_unaligned_ins(instruction,regs); | 330 | return handle_unaligned_ins(instruction,regs); |
@@ -364,7 +365,8 @@ static int handle_unaligned_access(u16 instruction, struct pt_regs *regs) | |||
364 | if (user_mode(regs) && handle_unaligned_notify_count>0) { | 365 | if (user_mode(regs) && handle_unaligned_notify_count>0) { |
365 | handle_unaligned_notify_count--; | 366 | handle_unaligned_notify_count--; |
366 | 367 | ||
367 | printk("Fixing up unaligned userspace access in \"%s\" pid=%d pc=0x%p ins=0x%04hx\n", | 368 | printk(KERN_NOTICE "Fixing up unaligned userspace access " |
369 | "in \"%s\" pid=%d pc=0x%p ins=0x%04hx\n", | ||
368 | current->comm,current->pid,(u16*)regs->pc,instruction); | 370 | current->comm,current->pid,(u16*)regs->pc,instruction); |
369 | } | 371 | } |
370 | 372 | ||
@@ -499,7 +501,15 @@ static int handle_unaligned_access(u16 instruction, struct pt_regs *regs) | |||
499 | #endif | 501 | #endif |
500 | 502 | ||
501 | /* | 503 | /* |
502 | * Handle various address error exceptions | 504 | * Handle various address error exceptions: |
505 | * - instruction address error: | ||
506 | * misaligned PC | ||
507 | * PC >= 0x80000000 in user mode | ||
508 | * - data address error (read and write) | ||
509 | * misaligned data access | ||
510 | * access to >= 0x80000000 is user mode | ||
511 | * Unfortuntaly we can't distinguish between instruction address error | ||
512 | * and data address errors caused by read acceses. | ||
503 | */ | 513 | */ |
504 | asmlinkage void do_address_error(struct pt_regs *regs, | 514 | asmlinkage void do_address_error(struct pt_regs *regs, |
505 | unsigned long writeaccess, | 515 | unsigned long writeaccess, |
@@ -507,6 +517,7 @@ asmlinkage void do_address_error(struct pt_regs *regs, | |||
507 | { | 517 | { |
508 | unsigned long error_code = 0; | 518 | unsigned long error_code = 0; |
509 | mm_segment_t oldfs; | 519 | mm_segment_t oldfs; |
520 | siginfo_t info; | ||
510 | #ifndef CONFIG_CPU_SH2A | 521 | #ifndef CONFIG_CPU_SH2A |
511 | u16 instruction; | 522 | u16 instruction; |
512 | int tmp; | 523 | int tmp; |
@@ -520,22 +531,15 @@ asmlinkage void do_address_error(struct pt_regs *regs, | |||
520 | oldfs = get_fs(); | 531 | oldfs = get_fs(); |
521 | 532 | ||
522 | if (user_mode(regs)) { | 533 | if (user_mode(regs)) { |
534 | int si_code = BUS_ADRERR; | ||
535 | |||
523 | local_irq_enable(); | 536 | local_irq_enable(); |
524 | current->thread.error_code = error_code; | ||
525 | #ifdef CONFIG_CPU_SH2 | ||
526 | /* | ||
527 | * On the SH-2, we only have a single vector for address | ||
528 | * errors, there's no differentiating between a load error | ||
529 | * and a store error. | ||
530 | */ | ||
531 | current->thread.trap_no = 9; | ||
532 | #else | ||
533 | current->thread.trap_no = (writeaccess) ? 8 : 7; | ||
534 | #endif | ||
535 | 537 | ||
536 | /* bad PC is not something we can fix */ | 538 | /* bad PC is not something we can fix */ |
537 | if (regs->pc & 1) | 539 | if (regs->pc & 1) { |
540 | si_code = BUS_ADRALN; | ||
538 | goto uspace_segv; | 541 | goto uspace_segv; |
542 | } | ||
539 | 543 | ||
540 | #ifndef CONFIG_CPU_SH2A | 544 | #ifndef CONFIG_CPU_SH2A |
541 | set_fs(USER_DS); | 545 | set_fs(USER_DS); |
@@ -554,9 +558,16 @@ asmlinkage void do_address_error(struct pt_regs *regs, | |||
554 | return; /* sorted */ | 558 | return; /* sorted */ |
555 | #endif | 559 | #endif |
556 | 560 | ||
557 | uspace_segv: | 561 | uspace_segv: |
558 | printk(KERN_NOTICE "Killing process \"%s\" due to unaligned access\n", current->comm); | 562 | printk(KERN_NOTICE "Sending SIGBUS to \"%s\" due to unaligned " |
559 | force_sig(SIGSEGV, current); | 563 | "access (PC %lx PR %lx)\n", current->comm, regs->pc, |
564 | regs->pr); | ||
565 | |||
566 | info.si_signo = SIGBUS; | ||
567 | info.si_errno = 0; | ||
568 | info.si_code = si_code; | ||
569 | info.si_addr = (void *) address; | ||
570 | force_sig_info(SIGBUS, &info, current); | ||
560 | } else { | 571 | } else { |
561 | if (regs->pc & 1) | 572 | if (regs->pc & 1) |
562 | die("unaligned program counter", regs, error_code); | 573 | die("unaligned program counter", regs, error_code); |
@@ -574,7 +585,9 @@ asmlinkage void do_address_error(struct pt_regs *regs, | |||
574 | handle_unaligned_access(instruction, regs); | 585 | handle_unaligned_access(instruction, regs); |
575 | set_fs(oldfs); | 586 | set_fs(oldfs); |
576 | #else | 587 | #else |
577 | printk(KERN_NOTICE "Killing process \"%s\" due to unaligned access\n", current->comm); | 588 | printk(KERN_NOTICE "Killing process \"%s\" due to unaligned " |
589 | "access\n", current->comm); | ||
590 | |||
578 | force_sig(SIGSEGV, current); | 591 | force_sig(SIGSEGV, current); |
579 | #endif | 592 | #endif |
580 | } | 593 | } |
@@ -617,9 +630,6 @@ asmlinkage void do_divide_error(unsigned long r4, unsigned long r5, | |||
617 | struct pt_regs *regs = RELOC_HIDE(&__regs, 0); | 630 | struct pt_regs *regs = RELOC_HIDE(&__regs, 0); |
618 | siginfo_t info; | 631 | siginfo_t info; |
619 | 632 | ||
620 | current->thread.trap_no = r4; | ||
621 | current->thread.error_code = 0; | ||
622 | |||
623 | switch (r4) { | 633 | switch (r4) { |
624 | case TRAP_DIVZERO_ERROR: | 634 | case TRAP_DIVZERO_ERROR: |
625 | info.si_code = FPE_INTDIV; | 635 | info.si_code = FPE_INTDIV; |
@@ -662,7 +672,7 @@ asmlinkage void do_reserved_inst(unsigned long r4, unsigned long r5, | |||
662 | 672 | ||
663 | #ifdef CONFIG_SH_DSP | 673 | #ifdef CONFIG_SH_DSP |
664 | /* Check if it's a DSP instruction */ | 674 | /* Check if it's a DSP instruction */ |
665 | if (is_dsp_inst(regs)) { | 675 | if (is_dsp_inst(regs)) { |
666 | /* Enable DSP mode, and restart instruction. */ | 676 | /* Enable DSP mode, and restart instruction. */ |
667 | regs->sr |= SR_DSP; | 677 | regs->sr |= SR_DSP; |
668 | return; | 678 | return; |
@@ -672,8 +682,6 @@ asmlinkage void do_reserved_inst(unsigned long r4, unsigned long r5, | |||
672 | lookup_exception_vector(error_code); | 682 | lookup_exception_vector(error_code); |
673 | 683 | ||
674 | local_irq_enable(); | 684 | local_irq_enable(); |
675 | tsk->thread.error_code = error_code; | ||
676 | tsk->thread.trap_no = TRAP_RESERVED_INST; | ||
677 | CHK_REMOTE_DEBUG(regs); | 685 | CHK_REMOTE_DEBUG(regs); |
678 | force_sig(SIGILL, tsk); | 686 | force_sig(SIGILL, tsk); |
679 | die_if_no_fixup("reserved instruction", regs, error_code); | 687 | die_if_no_fixup("reserved instruction", regs, error_code); |
@@ -745,8 +753,6 @@ asmlinkage void do_illegal_slot_inst(unsigned long r4, unsigned long r5, | |||
745 | lookup_exception_vector(error_code); | 753 | lookup_exception_vector(error_code); |
746 | 754 | ||
747 | local_irq_enable(); | 755 | local_irq_enable(); |
748 | tsk->thread.error_code = error_code; | ||
749 | tsk->thread.trap_no = TRAP_RESERVED_INST; | ||
750 | CHK_REMOTE_DEBUG(regs); | 756 | CHK_REMOTE_DEBUG(regs); |
751 | force_sig(SIGILL, tsk); | 757 | force_sig(SIGILL, tsk); |
752 | die_if_no_fixup("illegal slot instruction", regs, error_code); | 758 | die_if_no_fixup("illegal slot instruction", regs, error_code); |
@@ -805,7 +811,7 @@ void *set_exception_table_vec(unsigned int vec, void *handler) | |||
805 | { | 811 | { |
806 | extern void *exception_handling_table[]; | 812 | extern void *exception_handling_table[]; |
807 | void *old_handler; | 813 | void *old_handler; |
808 | 814 | ||
809 | old_handler = exception_handling_table[vec]; | 815 | old_handler = exception_handling_table[vec]; |
810 | exception_handling_table[vec] = handler; | 816 | exception_handling_table[vec] = handler; |
811 | return old_handler; | 817 | return old_handler; |
@@ -841,7 +847,7 @@ void __init trap_init(void) | |||
841 | set_exception_table_vec(TRAP_DIVZERO_ERROR, do_divide_error); | 847 | set_exception_table_vec(TRAP_DIVZERO_ERROR, do_divide_error); |
842 | set_exception_table_vec(TRAP_DIVOVF_ERROR, do_divide_error); | 848 | set_exception_table_vec(TRAP_DIVOVF_ERROR, do_divide_error); |
843 | #endif | 849 | #endif |
844 | 850 | ||
845 | /* Setup VBR for boot cpu */ | 851 | /* Setup VBR for boot cpu */ |
846 | per_cpu_trap_init(); | 852 | per_cpu_trap_init(); |
847 | } | 853 | } |