aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/traps_32.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kernel/traps_32.c')
-rw-r--r--arch/x86/kernel/traps_32.c114
1 files changed, 57 insertions, 57 deletions
diff --git a/arch/x86/kernel/traps_32.c b/arch/x86/kernel/traps_32.c
index 9b0bbd508cd5..931ef10960ee 100644
--- a/arch/x86/kernel/traps_32.c
+++ b/arch/x86/kernel/traps_32.c
@@ -114,11 +114,11 @@ struct stack_frame {
114}; 114};
115 115
116static inline unsigned long print_context_stack(struct thread_info *tinfo, 116static inline unsigned long print_context_stack(struct thread_info *tinfo,
117 unsigned long *stack, unsigned long ebp, 117 unsigned long *stack, unsigned long bp,
118 const struct stacktrace_ops *ops, void *data) 118 const struct stacktrace_ops *ops, void *data)
119{ 119{
120#ifdef CONFIG_FRAME_POINTER 120#ifdef CONFIG_FRAME_POINTER
121 struct stack_frame *frame = (struct stack_frame *)ebp; 121 struct stack_frame *frame = (struct stack_frame *)bp;
122 while (valid_stack_ptr(tinfo, frame, sizeof(*frame))) { 122 while (valid_stack_ptr(tinfo, frame, sizeof(*frame))) {
123 struct stack_frame *next; 123 struct stack_frame *next;
124 unsigned long addr; 124 unsigned long addr;
@@ -145,7 +145,7 @@ static inline unsigned long print_context_stack(struct thread_info *tinfo,
145 ops->address(data, addr); 145 ops->address(data, addr);
146 } 146 }
147#endif 147#endif
148 return ebp; 148 return bp;
149} 149}
150 150
151#define MSG(msg) ops->warning(data, msg) 151#define MSG(msg) ops->warning(data, msg)
@@ -154,7 +154,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
154 unsigned long *stack, 154 unsigned long *stack,
155 const struct stacktrace_ops *ops, void *data) 155 const struct stacktrace_ops *ops, void *data)
156{ 156{
157 unsigned long ebp = 0; 157 unsigned long bp = 0;
158 158
159 if (!task) 159 if (!task)
160 task = current; 160 task = current;
@@ -167,13 +167,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
167 } 167 }
168 168
169#ifdef CONFIG_FRAME_POINTER 169#ifdef CONFIG_FRAME_POINTER
170 if (!ebp) { 170 if (!bp) {
171 if (task == current) { 171 if (task == current) {
172 /* Grab ebp right from our regs */ 172 /* Grab bp right from our regs */
173 asm ("movl %%ebp, %0" : "=r" (ebp) : ); 173 asm ("movl %%ebp, %0" : "=r" (bp) : );
174 } else { 174 } else {
175 /* ebp is the last reg pushed by switch_to */ 175 /* bp is the last reg pushed by switch_to */
176 ebp = *(unsigned long *) task->thread.esp; 176 bp = *(unsigned long *) task->thread.esp;
177 } 177 }
178 } 178 }
179#endif 179#endif
@@ -182,7 +182,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
182 struct thread_info *context; 182 struct thread_info *context;
183 context = (struct thread_info *) 183 context = (struct thread_info *)
184 ((unsigned long)stack & (~(THREAD_SIZE - 1))); 184 ((unsigned long)stack & (~(THREAD_SIZE - 1)));
185 ebp = print_context_stack(context, stack, ebp, ops, data); 185 bp = print_context_stack(context, stack, bp, ops, data);
186 /* Should be after the line below, but somewhere 186 /* Should be after the line below, but somewhere
187 in early boot context comes out corrupted and we 187 in early boot context comes out corrupted and we
188 can't reference it -AK */ 188 can't reference it -AK */
@@ -246,19 +246,19 @@ void show_trace(struct task_struct *task, struct pt_regs *regs,
246} 246}
247 247
248static void show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs, 248static void show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
249 unsigned long *esp, char *log_lvl) 249 unsigned long *sp, char *log_lvl)
250{ 250{
251 unsigned long *stack; 251 unsigned long *stack;
252 int i; 252 int i;
253 253
254 if (esp == NULL) { 254 if (sp == NULL) {
255 if (task) 255 if (task)
256 esp = (unsigned long*)task->thread.esp; 256 sp = (unsigned long*)task->thread.esp;
257 else 257 else
258 esp = (unsigned long *)&esp; 258 sp = (unsigned long *)&sp;
259 } 259 }
260 260
261 stack = esp; 261 stack = sp;
262 for(i = 0; i < kstack_depth_to_print; i++) { 262 for(i = 0; i < kstack_depth_to_print; i++) {
263 if (kstack_end(stack)) 263 if (kstack_end(stack))
264 break; 264 break;
@@ -267,13 +267,13 @@ static void show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
267 printk("%08lx ", *stack++); 267 printk("%08lx ", *stack++);
268 } 268 }
269 printk("\n%sCall Trace:\n", log_lvl); 269 printk("\n%sCall Trace:\n", log_lvl);
270 show_trace_log_lvl(task, regs, esp, log_lvl); 270 show_trace_log_lvl(task, regs, sp, log_lvl);
271} 271}
272 272
273void show_stack(struct task_struct *task, unsigned long *esp) 273void show_stack(struct task_struct *task, unsigned long *sp)
274{ 274{
275 printk(" "); 275 printk(" ");
276 show_stack_log_lvl(task, NULL, esp, ""); 276 show_stack_log_lvl(task, NULL, sp, "");
277} 277}
278 278
279/* 279/*
@@ -307,30 +307,30 @@ void show_registers(struct pt_regs *regs)
307 * time of the fault.. 307 * time of the fault..
308 */ 308 */
309 if (!user_mode_vm(regs)) { 309 if (!user_mode_vm(regs)) {
310 u8 *eip; 310 u8 *ip;
311 unsigned int code_prologue = code_bytes * 43 / 64; 311 unsigned int code_prologue = code_bytes * 43 / 64;
312 unsigned int code_len = code_bytes; 312 unsigned int code_len = code_bytes;
313 unsigned char c; 313 unsigned char c;
314 314
315 printk("\n" KERN_EMERG "Stack: "); 315 printk("\n" KERN_EMERG "Stack: ");
316 show_stack_log_lvl(NULL, regs, &regs->esp, KERN_EMERG); 316 show_stack_log_lvl(NULL, regs, &regs->sp, KERN_EMERG);
317 317
318 printk(KERN_EMERG "Code: "); 318 printk(KERN_EMERG "Code: ");
319 319
320 eip = (u8 *)regs->eip - code_prologue; 320 ip = (u8 *)regs->ip - code_prologue;
321 if (eip < (u8 *)PAGE_OFFSET || 321 if (ip < (u8 *)PAGE_OFFSET ||
322 probe_kernel_address(eip, c)) { 322 probe_kernel_address(ip, c)) {
323 /* try starting at EIP */ 323 /* try starting at EIP */
324 eip = (u8 *)regs->eip; 324 ip = (u8 *)regs->ip;
325 code_len = code_len - code_prologue + 1; 325 code_len = code_len - code_prologue + 1;
326 } 326 }
327 for (i = 0; i < code_len; i++, eip++) { 327 for (i = 0; i < code_len; i++, ip++) {
328 if (eip < (u8 *)PAGE_OFFSET || 328 if (ip < (u8 *)PAGE_OFFSET ||
329 probe_kernel_address(eip, c)) { 329 probe_kernel_address(ip, c)) {
330 printk(" Bad EIP value."); 330 printk(" Bad EIP value.");
331 break; 331 break;
332 } 332 }
333 if (eip == (u8 *)regs->eip) 333 if (ip == (u8 *)regs->ip)
334 printk("<%02x> ", c); 334 printk("<%02x> ", c);
335 else 335 else
336 printk("%02x ", c); 336 printk("%02x ", c);
@@ -339,13 +339,13 @@ void show_registers(struct pt_regs *regs)
339 printk("\n"); 339 printk("\n");
340} 340}
341 341
342int is_valid_bugaddr(unsigned long eip) 342int is_valid_bugaddr(unsigned long ip)
343{ 343{
344 unsigned short ud2; 344 unsigned short ud2;
345 345
346 if (eip < PAGE_OFFSET) 346 if (ip < PAGE_OFFSET)
347 return 0; 347 return 0;
348 if (probe_kernel_address((unsigned short *)eip, ud2)) 348 if (probe_kernel_address((unsigned short *)ip, ud2))
349 return 0; 349 return 0;
350 350
351 return ud2 == 0x0b0f; 351 return ud2 == 0x0b0f;
@@ -382,10 +382,10 @@ void die(const char * str, struct pt_regs * regs, long err)
382 raw_local_irq_save(flags); 382 raw_local_irq_save(flags);
383 383
384 if (++die.lock_owner_depth < 3) { 384 if (++die.lock_owner_depth < 3) {
385 unsigned long esp; 385 unsigned long sp;
386 unsigned short ss; 386 unsigned short ss;
387 387
388 report_bug(regs->eip, regs); 388 report_bug(regs->ip, regs);
389 389
390 printk(KERN_EMERG "%s: %04lx [#%d] ", str, err & 0xffff, 390 printk(KERN_EMERG "%s: %04lx [#%d] ", str, err & 0xffff,
391 ++die_counter); 391 ++die_counter);
@@ -405,15 +405,15 @@ void die(const char * str, struct pt_regs * regs, long err)
405 NOTIFY_STOP) { 405 NOTIFY_STOP) {
406 show_registers(regs); 406 show_registers(regs);
407 /* Executive summary in case the oops scrolled away */ 407 /* Executive summary in case the oops scrolled away */
408 esp = (unsigned long) (&regs->esp); 408 sp = (unsigned long) (&regs->sp);
409 savesegment(ss, ss); 409 savesegment(ss, ss);
410 if (user_mode(regs)) { 410 if (user_mode(regs)) {
411 esp = regs->esp; 411 sp = regs->sp;
412 ss = regs->xss & 0xffff; 412 ss = regs->ss & 0xffff;
413 } 413 }
414 printk(KERN_EMERG "EIP: [<%08lx>] ", regs->eip); 414 printk(KERN_EMERG "EIP: [<%08lx>] ", regs->ip);
415 print_symbol("%s", regs->eip); 415 print_symbol("%s", regs->ip);
416 printk(" SS:ESP %04x:%08lx\n", ss, esp); 416 printk(" SS:ESP %04x:%08lx\n", ss, sp);
417 } 417 }
418 else 418 else
419 regs = NULL; 419 regs = NULL;
@@ -454,7 +454,7 @@ static void __kprobes do_trap(int trapnr, int signr, char *str, int vm86,
454{ 454{
455 struct task_struct *tsk = current; 455 struct task_struct *tsk = current;
456 456
457 if (regs->eflags & VM_MASK) { 457 if (regs->flags & VM_MASK) {
458 if (vm86) 458 if (vm86)
459 goto vm86_trap; 459 goto vm86_trap;
460 goto trap_signal; 460 goto trap_signal;
@@ -548,13 +548,13 @@ fastcall void do_##name(struct pt_regs * regs, long error_code) \
548 do_trap(trapnr, signr, str, 1, regs, error_code, &info); \ 548 do_trap(trapnr, signr, str, 1, regs, error_code, &info); \
549} 549}
550 550
551DO_VM86_ERROR_INFO( 0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->eip) 551DO_VM86_ERROR_INFO( 0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->ip)
552#ifndef CONFIG_KPROBES 552#ifndef CONFIG_KPROBES
553DO_VM86_ERROR( 3, SIGTRAP, "int3", int3) 553DO_VM86_ERROR( 3, SIGTRAP, "int3", int3)
554#endif 554#endif
555DO_VM86_ERROR( 4, SIGSEGV, "overflow", overflow) 555DO_VM86_ERROR( 4, SIGSEGV, "overflow", overflow)
556DO_VM86_ERROR( 5, SIGSEGV, "bounds", bounds) 556DO_VM86_ERROR( 5, SIGSEGV, "bounds", bounds)
557DO_ERROR_INFO( 6, SIGILL, "invalid opcode", invalid_op, ILL_ILLOPN, regs->eip, 0) 557DO_ERROR_INFO( 6, SIGILL, "invalid opcode", invalid_op, ILL_ILLOPN, regs->ip, 0)
558DO_ERROR( 9, SIGFPE, "coprocessor segment overrun", coprocessor_segment_overrun) 558DO_ERROR( 9, SIGFPE, "coprocessor segment overrun", coprocessor_segment_overrun)
559DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS) 559DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS)
560DO_ERROR(11, SIGBUS, "segment not present", segment_not_present) 560DO_ERROR(11, SIGBUS, "segment not present", segment_not_present)
@@ -596,7 +596,7 @@ fastcall void __kprobes do_general_protection(struct pt_regs * regs,
596 } 596 }
597 put_cpu(); 597 put_cpu();
598 598
599 if (regs->eflags & VM_MASK) 599 if (regs->flags & VM_MASK)
600 goto gp_in_vm86; 600 goto gp_in_vm86;
601 601
602 if (!user_mode(regs)) 602 if (!user_mode(regs))
@@ -607,9 +607,9 @@ fastcall void __kprobes do_general_protection(struct pt_regs * regs,
607 if (show_unhandled_signals && unhandled_signal(current, SIGSEGV) && 607 if (show_unhandled_signals && unhandled_signal(current, SIGSEGV) &&
608 printk_ratelimit()) 608 printk_ratelimit())
609 printk(KERN_INFO 609 printk(KERN_INFO
610 "%s[%d] general protection eip:%lx esp:%lx error:%lx\n", 610 "%s[%d] general protection ip:%lx sp:%lx error:%lx\n",
611 current->comm, task_pid_nr(current), 611 current->comm, task_pid_nr(current),
612 regs->eip, regs->esp, error_code); 612 regs->ip, regs->sp, error_code);
613 613
614 force_sig(SIGSEGV, current); 614 force_sig(SIGSEGV, current);
615 return; 615 return;
@@ -705,8 +705,8 @@ void __kprobes die_nmi(struct pt_regs *regs, const char *msg)
705 */ 705 */
706 bust_spinlocks(1); 706 bust_spinlocks(1);
707 printk(KERN_EMERG "%s", msg); 707 printk(KERN_EMERG "%s", msg);
708 printk(" on CPU%d, eip %08lx, registers:\n", 708 printk(" on CPU%d, ip %08lx, registers:\n",
709 smp_processor_id(), regs->eip); 709 smp_processor_id(), regs->ip);
710 show_registers(regs); 710 show_registers(regs);
711 console_silent(); 711 console_silent();
712 spin_unlock(&nmi_print_lock); 712 spin_unlock(&nmi_print_lock);
@@ -847,7 +847,7 @@ fastcall void __kprobes do_debug(struct pt_regs * regs, long error_code)
847 SIGTRAP) == NOTIFY_STOP) 847 SIGTRAP) == NOTIFY_STOP)
848 return; 848 return;
849 /* It's safe to allow irq's after DR6 has been saved */ 849 /* It's safe to allow irq's after DR6 has been saved */
850 if (regs->eflags & X86_EFLAGS_IF) 850 if (regs->flags & X86_EFLAGS_IF)
851 local_irq_enable(); 851 local_irq_enable();
852 852
853 /* Mask out spurious debug traps due to lazy DR7 setting */ 853 /* Mask out spurious debug traps due to lazy DR7 setting */
@@ -856,7 +856,7 @@ fastcall void __kprobes do_debug(struct pt_regs * regs, long error_code)
856 goto clear_dr7; 856 goto clear_dr7;
857 } 857 }
858 858
859 if (regs->eflags & VM_MASK) 859 if (regs->flags & VM_MASK)
860 goto debug_vm86; 860 goto debug_vm86;
861 861
862 /* Save debug status register where ptrace can see it */ 862 /* Save debug status register where ptrace can see it */
@@ -892,7 +892,7 @@ debug_vm86:
892 892
893clear_TF_reenable: 893clear_TF_reenable:
894 set_tsk_thread_flag(tsk, TIF_SINGLESTEP); 894 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
895 regs->eflags &= ~TF_MASK; 895 regs->flags &= ~TF_MASK;
896 return; 896 return;
897} 897}
898 898
@@ -901,7 +901,7 @@ clear_TF_reenable:
901 * the correct behaviour even in the presence of the asynchronous 901 * the correct behaviour even in the presence of the asynchronous
902 * IRQ13 behaviour 902 * IRQ13 behaviour
903 */ 903 */
904void math_error(void __user *eip) 904void math_error(void __user *ip)
905{ 905{
906 struct task_struct * task; 906 struct task_struct * task;
907 siginfo_t info; 907 siginfo_t info;
@@ -917,7 +917,7 @@ void math_error(void __user *eip)
917 info.si_signo = SIGFPE; 917 info.si_signo = SIGFPE;
918 info.si_errno = 0; 918 info.si_errno = 0;
919 info.si_code = __SI_FAULT; 919 info.si_code = __SI_FAULT;
920 info.si_addr = eip; 920 info.si_addr = ip;
921 /* 921 /*
922 * (~cwd & swd) will mask out exceptions that are not set to unmasked 922 * (~cwd & swd) will mask out exceptions that are not set to unmasked
923 * status. 0x3f is the exception bits in these regs, 0x200 is the 923 * status. 0x3f is the exception bits in these regs, 0x200 is the
@@ -963,10 +963,10 @@ void math_error(void __user *eip)
963fastcall void do_coprocessor_error(struct pt_regs * regs, long error_code) 963fastcall void do_coprocessor_error(struct pt_regs * regs, long error_code)
964{ 964{
965 ignore_fpu_irq = 1; 965 ignore_fpu_irq = 1;
966 math_error((void __user *)regs->eip); 966 math_error((void __user *)regs->ip);
967} 967}
968 968
969static void simd_math_error(void __user *eip) 969static void simd_math_error(void __user *ip)
970{ 970{
971 struct task_struct * task; 971 struct task_struct * task;
972 siginfo_t info; 972 siginfo_t info;
@@ -982,7 +982,7 @@ static void simd_math_error(void __user *eip)
982 info.si_signo = SIGFPE; 982 info.si_signo = SIGFPE;
983 info.si_errno = 0; 983 info.si_errno = 0;
984 info.si_code = __SI_FAULT; 984 info.si_code = __SI_FAULT;
985 info.si_addr = eip; 985 info.si_addr = ip;
986 /* 986 /*
987 * The SIMD FPU exceptions are handled a little differently, as there 987 * The SIMD FPU exceptions are handled a little differently, as there
988 * is only a single status/control register. Thus, to determine which 988 * is only a single status/control register. Thus, to determine which
@@ -1020,13 +1020,13 @@ fastcall void do_simd_coprocessor_error(struct pt_regs * regs,
1020 if (cpu_has_xmm) { 1020 if (cpu_has_xmm) {
1021 /* Handle SIMD FPU exceptions on PIII+ processors. */ 1021 /* Handle SIMD FPU exceptions on PIII+ processors. */
1022 ignore_fpu_irq = 1; 1022 ignore_fpu_irq = 1;
1023 simd_math_error((void __user *)regs->eip); 1023 simd_math_error((void __user *)regs->ip);
1024 } else { 1024 } else {
1025 /* 1025 /*
1026 * Handle strange cache flush from user space exception 1026 * Handle strange cache flush from user space exception
1027 * in all other cases. This is undocumented behaviour. 1027 * in all other cases. This is undocumented behaviour.
1028 */ 1028 */
1029 if (regs->eflags & VM_MASK) { 1029 if (regs->flags & VM_MASK) {
1030 handle_vm86_fault((struct kernel_vm86_regs *)regs, 1030 handle_vm86_fault((struct kernel_vm86_regs *)regs,
1031 error_code); 1031 error_code);
1032 return; 1032 return;