]> git.proxmox.com Git - mirror_ubuntu-kernels.git/blame - arch/x86/kernel/traps_32.c
kgdb: fix NMI hangs
[mirror_ubuntu-kernels.git] / arch / x86 / kernel / traps_32.c
CommitLineData
1da177e4 1/*
1da177e4
LT
2 * Copyright (C) 1991, 1992 Linus Torvalds
3 *
4 * Pentium III FXSR, SSE support
5 * Gareth Hughes <gareth@valinux.com>, May 2000
6 */
7
8/*
9 * 'Traps.c' handles hardware traps and faults after we have saved some
10 * state in 'asm.s'.
11 */
1da177e4
LT
12#include <linux/sched.h>
13#include <linux/kernel.h>
14#include <linux/string.h>
15#include <linux/errno.h>
16#include <linux/timer.h>
17#include <linux/mm.h>
18#include <linux/init.h>
19#include <linux/delay.h>
20#include <linux/spinlock.h>
21#include <linux/interrupt.h>
22#include <linux/highmem.h>
23#include <linux/kallsyms.h>
24#include <linux/ptrace.h>
25#include <linux/utsname.h>
26#include <linux/kprobes.h>
6e274d14 27#include <linux/kexec.h>
176a2718 28#include <linux/unwind.h>
1e2af92e 29#include <linux/uaccess.h>
a36df98a 30#include <linux/nmi.h>
91768d6c 31#include <linux/bug.h>
1da177e4
LT
32
33#ifdef CONFIG_EISA
34#include <linux/ioport.h>
35#include <linux/eisa.h>
36#endif
37
38#ifdef CONFIG_MCA
39#include <linux/mca.h>
40#endif
41
c0d12172
DJ
42#if defined(CONFIG_EDAC)
43#include <linux/edac.h>
44#endif
45
1da177e4
LT
46#include <asm/processor.h>
47#include <asm/system.h>
1da177e4
LT
48#include <asm/io.h>
49#include <asm/atomic.h>
50#include <asm/debugreg.h>
51#include <asm/desc.h>
52#include <asm/i387.h>
53#include <asm/nmi.h>
176a2718 54#include <asm/unwind.h>
1da177e4
LT
55#include <asm/smp.h>
56#include <asm/arch_hooks.h>
1eeb66a1 57#include <linux/kdebug.h>
2b14a78c 58#include <asm/stacktrace.h>
1da177e4 59
1da177e4
LT
60#include <linux/module.h>
61
62#include "mach_traps.h"
63
29cbc78b
AK
64int panic_on_unrecovered_nmi;
65
dbeb2be2
RR
66DECLARE_BITMAP(used_vectors, NR_VECTORS);
67EXPORT_SYMBOL_GPL(used_vectors);
68
1da177e4
LT
69asmlinkage int system_call(void);
70
1da177e4
LT
71/* Do we ignore FPU interrupts ? */
72char ignore_fpu_irq = 0;
73
74/*
75 * The IDT has to be page-aligned to simplify the Pentium
76 * F0 0F bug workaround.. We have a special link segment
77 * for this.
78 */
010d4f82 79gate_desc idt_table[256]
6842ef0e 80 __attribute__((__section__(".data.idt"))) = { { { { 0, 0 } } }, };
1da177e4
LT
81
82asmlinkage void divide_error(void);
83asmlinkage void debug(void);
84asmlinkage void nmi(void);
85asmlinkage void int3(void);
86asmlinkage void overflow(void);
87asmlinkage void bounds(void);
88asmlinkage void invalid_op(void);
89asmlinkage void device_not_available(void);
90asmlinkage void coprocessor_segment_overrun(void);
91asmlinkage void invalid_TSS(void);
92asmlinkage void segment_not_present(void);
93asmlinkage void stack_segment(void);
94asmlinkage void general_protection(void);
95asmlinkage void page_fault(void);
96asmlinkage void coprocessor_error(void);
97asmlinkage void simd_coprocessor_error(void);
98asmlinkage void alignment_check(void);
99asmlinkage void spurious_interrupt_bug(void);
100asmlinkage void machine_check(void);
101
0741f4d2 102int kstack_depth_to_print = 24;
86c41837 103static unsigned int code_bytes = 64;
e041c683 104
a5ff677c
HH
105void printk_address(unsigned long address, int reliable)
106{
107#ifdef CONFIG_KALLSYMS
108 unsigned long offset = 0, symsize;
109 const char *symname;
110 char *modname;
111 char *delim = ":";
112 char namebuf[128];
113 char reliab[4] = "";
114
115 symname = kallsyms_lookup(address, &symsize, &offset,
116 &modname, namebuf);
117 if (!symname) {
118 printk(" [<%08lx>]\n", address);
119 return;
120 }
121 if (!reliable)
122 strcpy(reliab, "? ");
123
124 if (!modname)
125 modname = delim = "";
126 printk(" [<%08lx>] %s%s%s%s%s+0x%lx/0x%lx\n",
127 address, reliab, delim, modname, delim, symname, offset, symsize);
128#else
129 printk(" [<%08lx>]\n", address);
130#endif
131}
132
36ad4885 133static inline int valid_stack_ptr(struct thread_info *tinfo, void *p, unsigned size)
1da177e4
LT
134{
135 return p > (void *)tinfo &&
36ad4885 136 p <= (void *)tinfo + THREAD_SIZE - size;
1da177e4
LT
137}
138
36ad4885
LT
139/* The form of the top of the frame on the stack */
140struct stack_frame {
141 struct stack_frame *next_frame;
142 unsigned long return_address;
143};
144
1da177e4 145static inline unsigned long print_context_stack(struct thread_info *tinfo,
65ea5b03 146 unsigned long *stack, unsigned long bp,
9689ba8a 147 const struct stacktrace_ops *ops, void *data)
1da177e4 148{
65ea5b03 149 struct stack_frame *frame = (struct stack_frame *)bp;
36ad4885 150
36ad4885
LT
151 while (valid_stack_ptr(tinfo, stack, sizeof(*stack))) {
152 unsigned long addr;
153
e9d4efdd
AV
154 addr = *stack;
155 if (__kernel_text_address(addr)) {
156 if ((unsigned long) stack == bp + 4) {
157 ops->address(data, addr, 1);
158 frame = frame->next_frame;
159 bp = (unsigned long) frame;
160 } else {
5bc27dc2 161 ops->address(data, addr, bp == 0);
e9d4efdd
AV
162 }
163 }
164 stack++;
1da177e4 165 }
65ea5b03 166 return bp;
1da177e4
LT
167}
168
b615ebda
AK
169#define MSG(msg) ops->warning(data, msg)
170
2b14a78c 171void dump_trace(struct task_struct *task, struct pt_regs *regs,
5bc27dc2 172 unsigned long *stack, unsigned long bp,
9689ba8a 173 const struct stacktrace_ops *ops, void *data)
1da177e4 174{
1da177e4
LT
175 if (!task)
176 task = current;
177
a32cf397 178 if (!stack) {
2b14a78c
AK
179 unsigned long dummy;
180 stack = &dummy;
028a690a 181 if (task != current)
faca6227 182 stack = (unsigned long *)task->thread.sp;
176a2718
JB
183 }
184
a32cf397 185#ifdef CONFIG_FRAME_POINTER
65ea5b03 186 if (!bp) {
a32cf397 187 if (task == current) {
65ea5b03
PA
188 /* Grab bp right from our regs */
189 asm ("movl %%ebp, %0" : "=r" (bp) : );
a32cf397 190 } else {
65ea5b03 191 /* bp is the last reg pushed by switch_to */
faca6227 192 bp = *(unsigned long *) task->thread.sp;
a32cf397 193 }
1da177e4 194 }
a32cf397 195#endif
1da177e4
LT
196
197 while (1) {
198 struct thread_info *context;
199 context = (struct thread_info *)
200 ((unsigned long)stack & (~(THREAD_SIZE - 1)));
65ea5b03 201 bp = print_context_stack(context, stack, bp, ops, data);
2b14a78c
AK
202 /* Should be after the line below, but somewhere
203 in early boot context comes out corrupted and we
204 can't reference it -AK */
205 if (ops->stack(data, "IRQ") < 0)
206 break;
1da177e4
LT
207 stack = (unsigned long*)context->previous_esp;
208 if (!stack)
209 break;
a36df98a 210 touch_nmi_watchdog();
1da177e4
LT
211 }
212}
2b14a78c
AK
213EXPORT_SYMBOL(dump_trace);
214
215static void
216print_trace_warning_symbol(void *data, char *msg, unsigned long symbol)
217{
218 printk(data);
219 print_symbol(msg, symbol);
220 printk("\n");
221}
222
223static void print_trace_warning(void *data, char *msg)
224{
225 printk("%s%s\n", (char *)data, msg);
226}
227
228static int print_trace_stack(void *data, char *name)
229{
230 return 0;
231}
232
233/*
234 * Print one address/symbol entries per line.
235 */
bc850d6b 236static void print_trace_address(void *data, unsigned long addr, int reliable)
2b14a78c
AK
237{
238 printk("%s [<%08lx>] ", (char *)data, addr);
bc850d6b
AV
239 if (!reliable)
240 printk("? ");
2b14a78c 241 print_symbol("%s\n", addr);
601e6255 242 touch_nmi_watchdog();
2b14a78c
AK
243}
244
9689ba8a 245static const struct stacktrace_ops print_trace_ops = {
2b14a78c
AK
246 .warning = print_trace_warning,
247 .warning_symbol = print_trace_warning_symbol,
248 .stack = print_trace_stack,
249 .address = print_trace_address,
250};
251
252static void
253show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
5bc27dc2 254 unsigned long *stack, unsigned long bp, char *log_lvl)
2b14a78c 255{
5bc27dc2 256 dump_trace(task, regs, stack, bp, &print_trace_ops, log_lvl);
2b14a78c
AK
257 printk("%s =======================\n", log_lvl);
258}
1da177e4 259
2b14a78c 260void show_trace(struct task_struct *task, struct pt_regs *regs,
5bc27dc2 261 unsigned long *stack, unsigned long bp)
7aa89746 262{
5bc27dc2 263 show_trace_log_lvl(task, regs, stack, bp, "");
7aa89746
CE
264}
265
176a2718 266static void show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
5bc27dc2 267 unsigned long *sp, unsigned long bp, char *log_lvl)
1da177e4
LT
268{
269 unsigned long *stack;
270 int i;
271
65ea5b03 272 if (sp == NULL) {
1da177e4 273 if (task)
faca6227 274 sp = (unsigned long*)task->thread.sp;
1da177e4 275 else
65ea5b03 276 sp = (unsigned long *)&sp;
1da177e4
LT
277 }
278
65ea5b03 279 stack = sp;
1da177e4
LT
280 for(i = 0; i < kstack_depth_to_print; i++) {
281 if (kstack_end(stack))
282 break;
75874d5c
CE
283 if (i && ((i % 8) == 0))
284 printk("\n%s ", log_lvl);
1da177e4
LT
285 printk("%08lx ", *stack++);
286 }
75874d5c 287 printk("\n%sCall Trace:\n", log_lvl);
5bc27dc2 288 show_trace_log_lvl(task, regs, sp, bp, log_lvl);
7aa89746
CE
289}
290
65ea5b03 291void show_stack(struct task_struct *task, unsigned long *sp)
7aa89746 292{
75874d5c 293 printk(" ");
5bc27dc2 294 show_stack_log_lvl(task, NULL, sp, 0, "");
1da177e4
LT
295}
296
297/*
298 * The architecture-independent dump_stack generator
299 */
300void dump_stack(void)
301{
302 unsigned long stack;
5bc27dc2
AV
303 unsigned long bp = 0;
304
305#ifdef CONFIG_FRAME_POINTER
306 if (!bp)
307 asm("movl %%ebp, %0" : "=r" (bp):);
308#endif
1da177e4 309
57c351de
AV
310 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
311 current->pid, current->comm, print_tainted(),
312 init_utsname()->release,
313 (int)strcspn(init_utsname()->version, " "),
314 init_utsname()->version);
5bc27dc2 315 show_trace(current, NULL, &stack, bp);
1da177e4
LT
316}
317
318EXPORT_SYMBOL(dump_stack);
319
320void show_registers(struct pt_regs *regs)
321{
322 int i;
9d975ebd 323
1da177e4 324 print_modules();
9d975ebd 325 __show_registers(regs, 0);
7e04a118 326 printk(KERN_EMERG "Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)",
19c5870c 327 TASK_COMM_LEN, current->comm, task_pid_nr(current),
c9f4f06d 328 current_thread_info(), current, task_thread_info(current));
1da177e4
LT
329 /*
330 * When in-kernel, we also print out the stack and code at the
331 * time of the fault..
332 */
9d975ebd 333 if (!user_mode_vm(regs)) {
65ea5b03 334 u8 *ip;
86c41837
CE
335 unsigned int code_prologue = code_bytes * 43 / 64;
336 unsigned int code_len = code_bytes;
99325326 337 unsigned char c;
1da177e4 338
9c107805 339 printk("\n" KERN_EMERG "Stack: ");
5bc27dc2 340 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
1da177e4 341
9c107805 342 printk(KERN_EMERG "Code: ");
1da177e4 343
65ea5b03
PA
344 ip = (u8 *)regs->ip - code_prologue;
345 if (ip < (u8 *)PAGE_OFFSET ||
346 probe_kernel_address(ip, c)) {
99325326 347 /* try starting at EIP */
65ea5b03 348 ip = (u8 *)regs->ip;
86c41837 349 code_len = code_len - code_prologue + 1;
99325326 350 }
65ea5b03
PA
351 for (i = 0; i < code_len; i++, ip++) {
352 if (ip < (u8 *)PAGE_OFFSET ||
353 probe_kernel_address(ip, c)) {
1da177e4
LT
354 printk(" Bad EIP value.");
355 break;
356 }
65ea5b03 357 if (ip == (u8 *)regs->ip)
1da177e4
LT
358 printk("<%02x> ", c);
359 else
360 printk("%02x ", c);
361 }
362 }
363 printk("\n");
364}
365
65ea5b03 366int is_valid_bugaddr(unsigned long ip)
1da177e4
LT
367{
368 unsigned short ud2;
1da177e4 369
65ea5b03 370 if (ip < PAGE_OFFSET)
91768d6c 371 return 0;
65ea5b03 372 if (probe_kernel_address((unsigned short *)ip, ud2))
91768d6c 373 return 0;
1da177e4 374
91768d6c 375 return ud2 == 0x0b0f;
1da177e4
LT
376}
377
a604b380
HH
378static int die_counter;
379
380int __kprobes __die(const char * str, struct pt_regs * regs, long err)
381{
382 unsigned long sp;
383 unsigned short ss;
384
385 printk(KERN_EMERG "%s: %04lx [#%d] ", str, err & 0xffff, ++die_counter);
386#ifdef CONFIG_PREEMPT
387 printk("PREEMPT ");
388#endif
389#ifdef CONFIG_SMP
390 printk("SMP ");
391#endif
392#ifdef CONFIG_DEBUG_PAGEALLOC
393 printk("DEBUG_PAGEALLOC");
394#endif
395 printk("\n");
396
397 if (notify_die(DIE_OOPS, str, regs, err,
398 current->thread.trap_no, SIGSEGV) !=
399 NOTIFY_STOP) {
400 show_registers(regs);
401 /* Executive summary in case the oops scrolled away */
402 sp = (unsigned long) (&regs->sp);
403 savesegment(ss, ss);
404 if (user_mode(regs)) {
405 sp = regs->sp;
406 ss = regs->ss & 0xffff;
407 }
408 printk(KERN_EMERG "EIP: [<%08lx>] ", regs->ip);
409 print_symbol("%s", regs->ip);
410 printk(" SS:ESP %04x:%08lx\n", ss, sp);
411 return 0;
412 } else {
413 return 1;
414 }
415}
416
91768d6c
JF
417/*
418 * This is gone through when something in the kernel has done something bad and
419 * is about to be terminated.
420 */
1da177e4
LT
421void die(const char * str, struct pt_regs * regs, long err)
422{
423 static struct {
39743c9e 424 raw_spinlock_t lock;
1da177e4
LT
425 u32 lock_owner;
426 int lock_owner_depth;
427 } die = {
39743c9e 428 .lock = __RAW_SPIN_LOCK_UNLOCKED,
1da177e4
LT
429 .lock_owner = -1,
430 .lock_owner_depth = 0
431 };
e43d674f 432 unsigned long flags;
1da177e4 433
dd287796
AM
434 oops_enter();
435
39c715b7 436 if (die.lock_owner != raw_smp_processor_id()) {
1da177e4 437 console_verbose();
c0a698b7 438 raw_local_irq_save(flags);
39743c9e 439 __raw_spin_lock(&die.lock);
1da177e4
LT
440 die.lock_owner = smp_processor_id();
441 die.lock_owner_depth = 0;
442 bust_spinlocks(1);
c0a698b7
IM
443 } else
444 raw_local_irq_save(flags);
1da177e4
LT
445
446 if (++die.lock_owner_depth < 3) {
65ea5b03 447 report_bug(regs->ip, regs);
91768d6c 448
a604b380 449 if (__die(str, regs, err))
20c0d2d4 450 regs = NULL;
a604b380 451 } else {
9c107805 452 printk(KERN_EMERG "Recursive die() failure, output suppressed\n");
a604b380 453 }
1da177e4
LT
454
455 bust_spinlocks(0);
456 die.lock_owner = -1;
bcdcd8e7 457 add_taint(TAINT_DIE);
39743c9e
AK
458 __raw_spin_unlock(&die.lock);
459 raw_local_irq_restore(flags);
6e274d14 460
20c0d2d4
JB
461 if (!regs)
462 return;
463
6e274d14
AN
464 if (kexec_should_crash(current))
465 crash_kexec(regs);
466
1da177e4
LT
467 if (in_interrupt())
468 panic("Fatal exception in interrupt");
469
cea6a4ba 470 if (panic_on_oops)
012c437d 471 panic("Fatal exception");
cea6a4ba 472
dd287796 473 oops_exit();
1da177e4
LT
474 do_exit(SIGSEGV);
475}
476
477static inline void die_if_kernel(const char * str, struct pt_regs * regs, long err)
478{
717b594a 479 if (!user_mode_vm(regs))
1da177e4
LT
480 die(str, regs, err);
481}
482
3d97ae5b
PP
483static void __kprobes do_trap(int trapnr, int signr, char *str, int vm86,
484 struct pt_regs * regs, long error_code,
485 siginfo_t *info)
1da177e4 486{
4f339ecb 487 struct task_struct *tsk = current;
4f339ecb 488
65ea5b03 489 if (regs->flags & VM_MASK) {
1da177e4
LT
490 if (vm86)
491 goto vm86_trap;
492 goto trap_signal;
493 }
494
717b594a 495 if (!user_mode(regs))
1da177e4
LT
496 goto kernel_trap;
497
498 trap_signal: {
d1895183
AK
499 /*
500 * We want error_code and trap_no set for userspace faults and
501 * kernelspace faults which result in die(), but not
502 * kernelspace faults which are fixed up. die() gives the
503 * process no chance to handle the signal and notice the
504 * kernel fault information, so that won't result in polluting
505 * the information about previously queued, but not yet
506 * delivered, faults. See also do_general_protection below.
507 */
508 tsk->thread.error_code = error_code;
509 tsk->thread.trap_no = trapnr;
510
1da177e4
LT
511 if (info)
512 force_sig_info(signr, info, tsk);
513 else
514 force_sig(signr, tsk);
515 return;
516 }
517
518 kernel_trap: {
d1895183
AK
519 if (!fixup_exception(regs)) {
520 tsk->thread.error_code = error_code;
521 tsk->thread.trap_no = trapnr;
1da177e4 522 die(str, regs, error_code);
d1895183 523 }
1da177e4
LT
524 return;
525 }
526
527 vm86_trap: {
528 int ret = handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code, trapnr);
529 if (ret) goto trap_signal;
530 return;
531 }
532}
533
534#define DO_ERROR(trapnr, signr, str, name) \
75604d7f 535void do_##name(struct pt_regs * regs, long error_code) \
1da177e4
LT
536{ \
537 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
538 == NOTIFY_STOP) \
539 return; \
540 do_trap(trapnr, signr, str, 0, regs, error_code, NULL); \
541}
542
a10d9a71 543#define DO_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr, irq) \
75604d7f 544void do_##name(struct pt_regs * regs, long error_code) \
1da177e4
LT
545{ \
546 siginfo_t info; \
a10d9a71
PZ
547 if (irq) \
548 local_irq_enable(); \
1da177e4
LT
549 info.si_signo = signr; \
550 info.si_errno = 0; \
551 info.si_code = sicode; \
552 info.si_addr = (void __user *)siaddr; \
553 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
554 == NOTIFY_STOP) \
555 return; \
556 do_trap(trapnr, signr, str, 0, regs, error_code, &info); \
557}
558
559#define DO_VM86_ERROR(trapnr, signr, str, name) \
75604d7f 560void do_##name(struct pt_regs * regs, long error_code) \
1da177e4
LT
561{ \
562 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
563 == NOTIFY_STOP) \
564 return; \
565 do_trap(trapnr, signr, str, 1, regs, error_code, NULL); \
566}
567
568#define DO_VM86_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \
75604d7f 569void do_##name(struct pt_regs * regs, long error_code) \
1da177e4
LT
570{ \
571 siginfo_t info; \
572 info.si_signo = signr; \
573 info.si_errno = 0; \
574 info.si_code = sicode; \
575 info.si_addr = (void __user *)siaddr; \
fb1dac90 576 trace_hardirqs_fixup(); \
1da177e4
LT
577 if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
578 == NOTIFY_STOP) \
579 return; \
580 do_trap(trapnr, signr, str, 1, regs, error_code, &info); \
581}
582
65ea5b03 583DO_VM86_ERROR_INFO( 0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->ip)
1da177e4
LT
584#ifndef CONFIG_KPROBES
585DO_VM86_ERROR( 3, SIGTRAP, "int3", int3)
586#endif
587DO_VM86_ERROR( 4, SIGSEGV, "overflow", overflow)
588DO_VM86_ERROR( 5, SIGSEGV, "bounds", bounds)
65ea5b03 589DO_ERROR_INFO( 6, SIGILL, "invalid opcode", invalid_op, ILL_ILLOPN, regs->ip, 0)
1da177e4
LT
590DO_ERROR( 9, SIGFPE, "coprocessor segment overrun", coprocessor_segment_overrun)
591DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS)
592DO_ERROR(11, SIGBUS, "segment not present", segment_not_present)
593DO_ERROR(12, SIGBUS, "stack segment", stack_segment)
a10d9a71
PZ
594DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0, 0)
595DO_ERROR_INFO(32, SIGSEGV, "iret exception", iret_error, ILL_BADSTK, 0, 1)
1da177e4 596
75604d7f 597void __kprobes do_general_protection(struct pt_regs * regs,
3d97ae5b 598 long error_code)
1da177e4
LT
599{
600 int cpu = get_cpu();
601 struct tss_struct *tss = &per_cpu(init_tss, cpu);
602 struct thread_struct *thread = &current->thread;
603
604 /*
605 * Perform the lazy TSS's I/O bitmap copy. If the TSS has an
606 * invalid offset set (the LAZY one) and the faulting thread has
607 * a valid I/O bitmap pointer, we copy the I/O bitmap in the TSS
608 * and we set the offset field correctly. Then we let the CPU to
609 * restart the faulting instruction.
610 */
a75c54f9 611 if (tss->x86_tss.io_bitmap_base == INVALID_IO_BITMAP_OFFSET_LAZY &&
1da177e4
LT
612 thread->io_bitmap_ptr) {
613 memcpy(tss->io_bitmap, thread->io_bitmap_ptr,
614 thread->io_bitmap_max);
615 /*
616 * If the previously set map was extending to higher ports
617 * than the current one, pad extra space with 0xff (no access).
618 */
619 if (thread->io_bitmap_max < tss->io_bitmap_max)
620 memset((char *) tss->io_bitmap +
621 thread->io_bitmap_max, 0xff,
622 tss->io_bitmap_max - thread->io_bitmap_max);
623 tss->io_bitmap_max = thread->io_bitmap_max;
a75c54f9 624 tss->x86_tss.io_bitmap_base = IO_BITMAP_OFFSET;
d5cd4aad 625 tss->io_bitmap_owner = thread;
1da177e4
LT
626 put_cpu();
627 return;
628 }
629 put_cpu();
630
65ea5b03 631 if (regs->flags & VM_MASK)
1da177e4
LT
632 goto gp_in_vm86;
633
717b594a 634 if (!user_mode(regs))
1da177e4
LT
635 goto gp_in_kernel;
636
637 current->thread.error_code = error_code;
638 current->thread.trap_no = 13;
abd4f750 639 if (show_unhandled_signals && unhandled_signal(current, SIGSEGV) &&
03252919 640 printk_ratelimit()) {
abd4f750 641 printk(KERN_INFO
03252919 642 "%s[%d] general protection ip:%lx sp:%lx error:%lx",
19c5870c 643 current->comm, task_pid_nr(current),
65ea5b03 644 regs->ip, regs->sp, error_code);
03252919
AK
645 print_vma_addr(" in ", regs->ip);
646 printk("\n");
647 }
abd4f750 648
1da177e4
LT
649 force_sig(SIGSEGV, current);
650 return;
651
652gp_in_vm86:
653 local_irq_enable();
654 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
655 return;
656
657gp_in_kernel:
658 if (!fixup_exception(regs)) {
d1895183
AK
659 current->thread.error_code = error_code;
660 current->thread.trap_no = 13;
1da177e4
LT
661 if (notify_die(DIE_GPF, "general protection fault", regs,
662 error_code, 13, SIGSEGV) == NOTIFY_STOP)
663 return;
664 die("general protection fault", regs, error_code);
665 }
666}
667