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