traps_32.c 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333
  1. /*
  2. * Copyright (C) 1991, 1992 Linus Torvalds
  3. * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
  4. *
  5. * Pentium III FXSR, SSE support
  6. * Gareth Hughes <gareth@valinux.com>, May 2000
  7. */
  8. /*
  9. * 'Traps.c' handles hardware traps and faults after we have saved some
  10. * state in 'asm.s'.
  11. */
  12. #include <linux/interrupt.h>
  13. #include <linux/kallsyms.h>
  14. #include <linux/spinlock.h>
  15. #include <linux/highmem.h>
  16. #include <linux/kprobes.h>
  17. #include <linux/uaccess.h>
  18. #include <linux/utsname.h>
  19. #include <linux/kdebug.h>
  20. #include <linux/kernel.h>
  21. #include <linux/module.h>
  22. #include <linux/ptrace.h>
  23. #include <linux/string.h>
  24. #include <linux/unwind.h>
  25. #include <linux/delay.h>
  26. #include <linux/errno.h>
  27. #include <linux/kexec.h>
  28. #include <linux/sched.h>
  29. #include <linux/timer.h>
  30. #include <linux/init.h>
  31. #include <linux/bug.h>
  32. #include <linux/nmi.h>
  33. #include <linux/mm.h>
  34. #ifdef CONFIG_EISA
  35. #include <linux/ioport.h>
  36. #include <linux/eisa.h>
  37. #endif
  38. #ifdef CONFIG_MCA
  39. #include <linux/mca.h>
  40. #endif
  41. #if defined(CONFIG_EDAC)
  42. #include <linux/edac.h>
  43. #endif
  44. #include <asm/processor-flags.h>
  45. #include <asm/arch_hooks.h>
  46. #include <asm/stacktrace.h>
  47. #include <asm/processor.h>
  48. #include <asm/debugreg.h>
  49. #include <asm/atomic.h>
  50. #include <asm/system.h>
  51. #include <asm/unwind.h>
  52. #include <asm/desc.h>
  53. #include <asm/i387.h>
  54. #include <asm/nmi.h>
  55. #include <asm/smp.h>
  56. #include <asm/io.h>
  57. #include <asm/traps.h>
  58. #include "mach_traps.h"
  59. DECLARE_BITMAP(used_vectors, NR_VECTORS);
  60. EXPORT_SYMBOL_GPL(used_vectors);
  61. asmlinkage int system_call(void);
  62. /* Do we ignore FPU interrupts ? */
  63. char ignore_fpu_irq;
  64. /*
  65. * The IDT has to be page-aligned to simplify the Pentium
  66. * F0 0F bug workaround.. We have a special link segment
  67. * for this.
  68. */
  69. gate_desc idt_table[256]
  70. __attribute__((__section__(".data.idt"))) = { { { { 0, 0 } } }, };
  71. int panic_on_unrecovered_nmi;
  72. int kstack_depth_to_print = 24;
  73. static unsigned int code_bytes = 64;
  74. static int ignore_nmis;
  75. static int die_counter;
  76. static inline void conditional_sti(struct pt_regs *regs)
  77. {
  78. if (regs->flags & X86_EFLAGS_IF)
  79. local_irq_enable();
  80. }
  81. void printk_address(unsigned long address, int reliable)
  82. {
  83. #ifdef CONFIG_KALLSYMS
  84. unsigned long offset = 0;
  85. unsigned long symsize;
  86. const char *symname;
  87. char *modname;
  88. char *delim = ":";
  89. char namebuf[KSYM_NAME_LEN];
  90. char reliab[4] = "";
  91. symname = kallsyms_lookup(address, &symsize, &offset,
  92. &modname, namebuf);
  93. if (!symname) {
  94. printk(" [<%08lx>]\n", address);
  95. return;
  96. }
  97. if (!reliable)
  98. strcpy(reliab, "? ");
  99. if (!modname)
  100. modname = delim = "";
  101. printk(" [<%08lx>] %s%s%s%s%s+0x%lx/0x%lx\n",
  102. address, reliab, delim, modname, delim, symname, offset, symsize);
  103. #else
  104. printk(" [<%08lx>]\n", address);
  105. #endif
  106. }
  107. static inline int valid_stack_ptr(struct thread_info *tinfo,
  108. void *p, unsigned int size)
  109. {
  110. void *t = tinfo;
  111. return p > t && p <= t + THREAD_SIZE - size;
  112. }
  113. /* The form of the top of the frame on the stack */
  114. struct stack_frame {
  115. struct stack_frame *next_frame;
  116. unsigned long return_address;
  117. };
  118. static inline unsigned long
  119. print_context_stack(struct thread_info *tinfo,
  120. unsigned long *stack, unsigned long bp,
  121. const struct stacktrace_ops *ops, void *data)
  122. {
  123. struct stack_frame *frame = (struct stack_frame *)bp;
  124. while (valid_stack_ptr(tinfo, stack, sizeof(*stack))) {
  125. unsigned long addr;
  126. addr = *stack;
  127. if (__kernel_text_address(addr)) {
  128. if ((unsigned long) stack == bp + 4) {
  129. ops->address(data, addr, 1);
  130. frame = frame->next_frame;
  131. bp = (unsigned long) frame;
  132. } else {
  133. ops->address(data, addr, bp == 0);
  134. }
  135. }
  136. stack++;
  137. }
  138. return bp;
  139. }
  140. void dump_trace(struct task_struct *task, struct pt_regs *regs,
  141. unsigned long *stack, unsigned long bp,
  142. const struct stacktrace_ops *ops, void *data)
  143. {
  144. if (!task)
  145. task = current;
  146. if (!stack) {
  147. unsigned long dummy;
  148. stack = &dummy;
  149. if (task != current)
  150. stack = (unsigned long *)task->thread.sp;
  151. }
  152. #ifdef CONFIG_FRAME_POINTER
  153. if (!bp) {
  154. if (task == current) {
  155. /* Grab bp right from our regs */
  156. asm("movl %%ebp, %0" : "=r" (bp) :);
  157. } else {
  158. /* bp is the last reg pushed by switch_to */
  159. bp = *(unsigned long *) task->thread.sp;
  160. }
  161. }
  162. #endif
  163. for (;;) {
  164. struct thread_info *context;
  165. context = (struct thread_info *)
  166. ((unsigned long)stack & (~(THREAD_SIZE - 1)));
  167. bp = print_context_stack(context, stack, bp, ops, data);
  168. /*
  169. * Should be after the line below, but somewhere
  170. * in early boot context comes out corrupted and we
  171. * can't reference it:
  172. */
  173. if (ops->stack(data, "IRQ") < 0)
  174. break;
  175. stack = (unsigned long *)context->previous_esp;
  176. if (!stack)
  177. break;
  178. touch_nmi_watchdog();
  179. }
  180. }
  181. EXPORT_SYMBOL(dump_trace);
  182. static void
  183. print_trace_warning_symbol(void *data, char *msg, unsigned long symbol)
  184. {
  185. printk(data);
  186. print_symbol(msg, symbol);
  187. printk("\n");
  188. }
  189. static void print_trace_warning(void *data, char *msg)
  190. {
  191. printk("%s%s\n", (char *)data, msg);
  192. }
  193. static int print_trace_stack(void *data, char *name)
  194. {
  195. return 0;
  196. }
  197. /*
  198. * Print one address/symbol entries per line.
  199. */
  200. static void print_trace_address(void *data, unsigned long addr, int reliable)
  201. {
  202. printk("%s [<%08lx>] ", (char *)data, addr);
  203. if (!reliable)
  204. printk("? ");
  205. print_symbol("%s\n", addr);
  206. touch_nmi_watchdog();
  207. }
  208. static const struct stacktrace_ops print_trace_ops = {
  209. .warning = print_trace_warning,
  210. .warning_symbol = print_trace_warning_symbol,
  211. .stack = print_trace_stack,
  212. .address = print_trace_address,
  213. };
  214. static void
  215. show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
  216. unsigned long *stack, unsigned long bp, char *log_lvl)
  217. {
  218. dump_trace(task, regs, stack, bp, &print_trace_ops, log_lvl);
  219. printk("%s =======================\n", log_lvl);
  220. }
  221. void show_trace(struct task_struct *task, struct pt_regs *regs,
  222. unsigned long *stack, unsigned long bp)
  223. {
  224. show_trace_log_lvl(task, regs, stack, bp, "");
  225. }
  226. static void
  227. show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
  228. unsigned long *sp, unsigned long bp, char *log_lvl)
  229. {
  230. unsigned long *stack;
  231. int i;
  232. if (sp == NULL) {
  233. if (task)
  234. sp = (unsigned long *)task->thread.sp;
  235. else
  236. sp = (unsigned long *)&sp;
  237. }
  238. stack = sp;
  239. for (i = 0; i < kstack_depth_to_print; i++) {
  240. if (kstack_end(stack))
  241. break;
  242. if (i && ((i % 8) == 0))
  243. printk("\n%s ", log_lvl);
  244. printk("%08lx ", *stack++);
  245. }
  246. printk("\n%sCall Trace:\n", log_lvl);
  247. show_trace_log_lvl(task, regs, sp, bp, log_lvl);
  248. }
  249. void show_stack(struct task_struct *task, unsigned long *sp)
  250. {
  251. printk(" ");
  252. show_stack_log_lvl(task, NULL, sp, 0, "");
  253. }
  254. /*
  255. * The architecture-independent dump_stack generator
  256. */
  257. void dump_stack(void)
  258. {
  259. unsigned long bp = 0;
  260. unsigned long stack;
  261. #ifdef CONFIG_FRAME_POINTER
  262. if (!bp)
  263. asm("movl %%ebp, %0" : "=r" (bp):);
  264. #endif
  265. printk("Pid: %d, comm: %.20s %s %s %.*s\n",
  266. current->pid, current->comm, print_tainted(),
  267. init_utsname()->release,
  268. (int)strcspn(init_utsname()->version, " "),
  269. init_utsname()->version);
  270. show_trace(current, NULL, &stack, bp);
  271. }
  272. EXPORT_SYMBOL(dump_stack);
  273. void show_registers(struct pt_regs *regs)
  274. {
  275. int i;
  276. print_modules();
  277. __show_registers(regs, 0);
  278. printk(KERN_EMERG "Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)",
  279. TASK_COMM_LEN, current->comm, task_pid_nr(current),
  280. current_thread_info(), current, task_thread_info(current));
  281. /*
  282. * When in-kernel, we also print out the stack and code at the
  283. * time of the fault..
  284. */
  285. if (!user_mode_vm(regs)) {
  286. unsigned int code_prologue = code_bytes * 43 / 64;
  287. unsigned int code_len = code_bytes;
  288. unsigned char c;
  289. u8 *ip;
  290. printk("\n" KERN_EMERG "Stack: ");
  291. show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
  292. printk(KERN_EMERG "Code: ");
  293. ip = (u8 *)regs->ip - code_prologue;
  294. if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
  295. /* try starting at EIP */
  296. ip = (u8 *)regs->ip;
  297. code_len = code_len - code_prologue + 1;
  298. }
  299. for (i = 0; i < code_len; i++, ip++) {
  300. if (ip < (u8 *)PAGE_OFFSET ||
  301. probe_kernel_address(ip, c)) {
  302. printk(" Bad EIP value.");
  303. break;
  304. }
  305. if (ip == (u8 *)regs->ip)
  306. printk("<%02x> ", c);
  307. else
  308. printk("%02x ", c);
  309. }
  310. }
  311. printk("\n");
  312. }
  313. int is_valid_bugaddr(unsigned long ip)
  314. {
  315. unsigned short ud2;
  316. if (ip < PAGE_OFFSET)
  317. return 0;
  318. if (probe_kernel_address((unsigned short *)ip, ud2))
  319. return 0;
  320. return ud2 == 0x0b0f;
  321. }
  322. static raw_spinlock_t die_lock = __RAW_SPIN_LOCK_UNLOCKED;
  323. static int die_owner = -1;
  324. static unsigned int die_nest_count;
  325. unsigned __kprobes long oops_begin(void)
  326. {
  327. unsigned long flags;
  328. oops_enter();
  329. if (die_owner != raw_smp_processor_id()) {
  330. console_verbose();
  331. raw_local_irq_save(flags);
  332. __raw_spin_lock(&die_lock);
  333. die_owner = smp_processor_id();
  334. die_nest_count = 0;
  335. bust_spinlocks(1);
  336. } else {
  337. raw_local_irq_save(flags);
  338. }
  339. die_nest_count++;
  340. return flags;
  341. }
  342. void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
  343. {
  344. bust_spinlocks(0);
  345. die_owner = -1;
  346. add_taint(TAINT_DIE);
  347. __raw_spin_unlock(&die_lock);
  348. raw_local_irq_restore(flags);
  349. if (!regs)
  350. return;
  351. if (kexec_should_crash(current))
  352. crash_kexec(regs);
  353. if (in_interrupt())
  354. panic("Fatal exception in interrupt");
  355. if (panic_on_oops)
  356. panic("Fatal exception");
  357. oops_exit();
  358. do_exit(signr);
  359. }
  360. int __kprobes __die(const char *str, struct pt_regs *regs, long err)
  361. {
  362. unsigned short ss;
  363. unsigned long sp;
  364. printk(KERN_EMERG "%s: %04lx [#%d] ", str, err & 0xffff, ++die_counter);
  365. #ifdef CONFIG_PREEMPT
  366. printk("PREEMPT ");
  367. #endif
  368. #ifdef CONFIG_SMP
  369. printk("SMP ");
  370. #endif
  371. #ifdef CONFIG_DEBUG_PAGEALLOC
  372. printk("DEBUG_PAGEALLOC");
  373. #endif
  374. printk("\n");
  375. if (notify_die(DIE_OOPS, str, regs, err,
  376. current->thread.trap_no, SIGSEGV) == NOTIFY_STOP)
  377. return 1;
  378. show_registers(regs);
  379. /* Executive summary in case the oops scrolled away */
  380. sp = (unsigned long) (&regs->sp);
  381. savesegment(ss, ss);
  382. if (user_mode(regs)) {
  383. sp = regs->sp;
  384. ss = regs->ss & 0xffff;
  385. }
  386. printk(KERN_EMERG "EIP: [<%08lx>] ", regs->ip);
  387. print_symbol("%s", regs->ip);
  388. printk(" SS:ESP %04x:%08lx\n", ss, sp);
  389. return 0;
  390. }
  391. /*
  392. * This is gone through when something in the kernel has done something bad
  393. * and is about to be terminated:
  394. */
  395. void die(const char *str, struct pt_regs *regs, long err)
  396. {
  397. unsigned long flags = oops_begin();
  398. if (die_nest_count < 3) {
  399. report_bug(regs->ip, regs);
  400. if (__die(str, regs, err))
  401. regs = NULL;
  402. } else {
  403. printk(KERN_EMERG "Recursive die() failure, output suppressed\n");
  404. }
  405. oops_end(flags, regs, SIGSEGV);
  406. }
  407. static inline void
  408. die_if_kernel(const char *str, struct pt_regs *regs, long err)
  409. {
  410. if (!user_mode_vm(regs))
  411. die(str, regs, err);
  412. }
  413. static void __kprobes
  414. do_trap(int trapnr, int signr, char *str, int vm86, struct pt_regs *regs,
  415. long error_code, siginfo_t *info)
  416. {
  417. struct task_struct *tsk = current;
  418. if (regs->flags & X86_VM_MASK) {
  419. if (vm86)
  420. goto vm86_trap;
  421. goto trap_signal;
  422. }
  423. if (!user_mode(regs))
  424. goto kernel_trap;
  425. trap_signal:
  426. /*
  427. * We want error_code and trap_no set for userspace faults and
  428. * kernelspace faults which result in die(), but not
  429. * kernelspace faults which are fixed up. die() gives the
  430. * process no chance to handle the signal and notice the
  431. * kernel fault information, so that won't result in polluting
  432. * the information about previously queued, but not yet
  433. * delivered, faults. See also do_general_protection below.
  434. */
  435. tsk->thread.error_code = error_code;
  436. tsk->thread.trap_no = trapnr;
  437. if (info)
  438. force_sig_info(signr, info, tsk);
  439. else
  440. force_sig(signr, tsk);
  441. return;
  442. kernel_trap:
  443. if (!fixup_exception(regs)) {
  444. tsk->thread.error_code = error_code;
  445. tsk->thread.trap_no = trapnr;
  446. die(str, regs, error_code);
  447. }
  448. return;
  449. vm86_trap:
  450. if (handle_vm86_trap((struct kernel_vm86_regs *) regs,
  451. error_code, trapnr))
  452. goto trap_signal;
  453. return;
  454. }
  455. #define DO_TRAP(trapnr, signr, str, name) \
  456. void do_##name(struct pt_regs *regs, long error_code) \
  457. { \
  458. trace_hardirqs_fixup(); \
  459. if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
  460. == NOTIFY_STOP) \
  461. return; \
  462. do_trap(trapnr, signr, str, 0, regs, error_code, NULL); \
  463. }
  464. #define DO_TRAP_INFO(trapnr, signr, str, name, sicode, siaddr, irq) \
  465. void do_##name(struct pt_regs *regs, long error_code) \
  466. { \
  467. siginfo_t info; \
  468. if (irq) \
  469. local_irq_enable(); \
  470. info.si_signo = signr; \
  471. info.si_errno = 0; \
  472. info.si_code = sicode; \
  473. info.si_addr = (void __user *)siaddr; \
  474. if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
  475. == NOTIFY_STOP) \
  476. return; \
  477. do_trap(trapnr, signr, str, 0, regs, error_code, &info); \
  478. }
  479. #define DO_VM86_TRAP(trapnr, signr, str, name) \
  480. void do_##name(struct pt_regs *regs, long error_code) \
  481. { \
  482. if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
  483. == NOTIFY_STOP) \
  484. return; \
  485. do_trap(trapnr, signr, str, 1, regs, error_code, NULL); \
  486. }
  487. #define DO_VM86_TRAP_INFO(trapnr, signr, str, name, sicode, siaddr) \
  488. void do_##name(struct pt_regs *regs, long error_code) \
  489. { \
  490. siginfo_t info; \
  491. info.si_signo = signr; \
  492. info.si_errno = 0; \
  493. info.si_code = sicode; \
  494. info.si_addr = (void __user *)siaddr; \
  495. trace_hardirqs_fixup(); \
  496. if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
  497. == NOTIFY_STOP) \
  498. return; \
  499. do_trap(trapnr, signr, str, 1, regs, error_code, &info); \
  500. }
  501. #define DO_ERROR(trapnr, signr, str, name) \
  502. void do_##name(struct pt_regs *regs, long error_code) \
  503. { \
  504. trace_hardirqs_fixup(); \
  505. if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
  506. == NOTIFY_STOP) \
  507. return; \
  508. conditional_sti(regs); \
  509. do_trap(trapnr, signr, str, 0, regs, error_code, NULL); \
  510. }
  511. #define DO_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr, irq) \
  512. void do_##name(struct pt_regs *regs, long error_code) \
  513. { \
  514. siginfo_t info; \
  515. if (irq) \
  516. local_irq_enable(); \
  517. info.si_signo = signr; \
  518. info.si_errno = 0; \
  519. info.si_code = sicode; \
  520. info.si_addr = (void __user *)siaddr; \
  521. if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
  522. == NOTIFY_STOP) \
  523. return; \
  524. conditional_sti(regs); \
  525. do_trap(trapnr, signr, str, 0, regs, error_code, &info); \
  526. }
  527. #define DO_VM86_ERROR(trapnr, signr, str, name) \
  528. void do_##name(struct pt_regs *regs, long error_code) \
  529. { \
  530. if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
  531. == NOTIFY_STOP) \
  532. return; \
  533. conditional_sti(regs); \
  534. do_trap(trapnr, signr, str, 1, regs, error_code, NULL); \
  535. }
  536. #define DO_VM86_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \
  537. void do_##name(struct pt_regs *regs, long error_code) \
  538. { \
  539. siginfo_t info; \
  540. info.si_signo = signr; \
  541. info.si_errno = 0; \
  542. info.si_code = sicode; \
  543. info.si_addr = (void __user *)siaddr; \
  544. trace_hardirqs_fixup(); \
  545. if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
  546. == NOTIFY_STOP) \
  547. return; \
  548. conditional_sti(regs); \
  549. do_trap(trapnr, signr, str, 1, regs, error_code, &info); \
  550. }
  551. DO_VM86_ERROR_INFO(0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->ip)
  552. DO_VM86_ERROR(4, SIGSEGV, "overflow", overflow)
  553. DO_VM86_ERROR(5, SIGSEGV, "bounds", bounds)
  554. DO_ERROR_INFO(6, SIGILL, "invalid opcode", invalid_op, ILL_ILLOPN, regs->ip, 0)
  555. DO_ERROR(9, SIGFPE, "coprocessor segment overrun", coprocessor_segment_overrun)
  556. DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS)
  557. DO_ERROR(11, SIGBUS, "segment not present", segment_not_present)
  558. DO_ERROR(12, SIGBUS, "stack segment", stack_segment)
  559. DO_TRAP_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0, 0)
  560. DO_TRAP_INFO(32, SIGILL, "iret exception", iret_error, ILL_BADSTK, 0, 1)
  561. void __kprobes
  562. do_general_protection(struct pt_regs *regs, long error_code)
  563. {
  564. struct task_struct *tsk;
  565. struct thread_struct *thread;
  566. struct tss_struct *tss;
  567. int cpu;
  568. conditional_sti(regs);
  569. cpu = get_cpu();
  570. tss = &per_cpu(init_tss, cpu);
  571. thread = &current->thread;
  572. /*
  573. * Perform the lazy TSS's I/O bitmap copy. If the TSS has an
  574. * invalid offset set (the LAZY one) and the faulting thread has
  575. * a valid I/O bitmap pointer, we copy the I/O bitmap in the TSS
  576. * and we set the offset field correctly. Then we let the CPU to
  577. * restart the faulting instruction.
  578. */
  579. if (tss->x86_tss.io_bitmap_base == INVALID_IO_BITMAP_OFFSET_LAZY &&
  580. thread->io_bitmap_ptr) {
  581. memcpy(tss->io_bitmap, thread->io_bitmap_ptr,
  582. thread->io_bitmap_max);
  583. /*
  584. * If the previously set map was extending to higher ports
  585. * than the current one, pad extra space with 0xff (no access).
  586. */
  587. if (thread->io_bitmap_max < tss->io_bitmap_max) {
  588. memset((char *) tss->io_bitmap +
  589. thread->io_bitmap_max, 0xff,
  590. tss->io_bitmap_max - thread->io_bitmap_max);
  591. }
  592. tss->io_bitmap_max = thread->io_bitmap_max;
  593. tss->x86_tss.io_bitmap_base = IO_BITMAP_OFFSET;
  594. tss->io_bitmap_owner = thread;
  595. put_cpu();
  596. return;
  597. }
  598. put_cpu();
  599. if (regs->flags & X86_VM_MASK)
  600. goto gp_in_vm86;
  601. tsk = current;
  602. if (!user_mode(regs))
  603. goto gp_in_kernel;
  604. tsk->thread.error_code = error_code;
  605. tsk->thread.trap_no = 13;
  606. if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) &&
  607. printk_ratelimit()) {
  608. printk(KERN_INFO
  609. "%s[%d] general protection ip:%lx sp:%lx error:%lx",
  610. tsk->comm, task_pid_nr(tsk),
  611. regs->ip, regs->sp, error_code);
  612. print_vma_addr(" in ", regs->ip);
  613. printk("\n");
  614. }
  615. force_sig(SIGSEGV, tsk);
  616. return;
  617. gp_in_vm86:
  618. local_irq_enable();
  619. handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
  620. return;
  621. gp_in_kernel:
  622. if (fixup_exception(regs))
  623. return;
  624. tsk->thread.error_code = error_code;
  625. tsk->thread.trap_no = 13;
  626. if (notify_die(DIE_GPF, "general protection fault", regs,
  627. error_code, 13, SIGSEGV) == NOTIFY_STOP)
  628. return;
  629. die("general protection fault", regs, error_code);
  630. }
  631. static notrace __kprobes void
  632. mem_parity_error(unsigned char reason, struct pt_regs *regs)
  633. {
  634. printk(KERN_EMERG
  635. "Uhhuh. NMI received for unknown reason %02x on CPU %d.\n",
  636. reason, smp_processor_id());
  637. printk(KERN_EMERG
  638. "You have some hardware problem, likely on the PCI bus.\n");
  639. #if defined(CONFIG_EDAC)
  640. if (edac_handler_set()) {
  641. edac_atomic_assert_error();
  642. return;
  643. }
  644. #endif
  645. if (panic_on_unrecovered_nmi)
  646. panic("NMI: Not continuing");
  647. printk(KERN_EMERG "Dazed and confused, but trying to continue\n");
  648. /* Clear and disable the memory parity error line. */
  649. clear_mem_error(reason);
  650. }
  651. static notrace __kprobes void
  652. io_check_error(unsigned char reason, struct pt_regs *regs)
  653. {
  654. unsigned long i;
  655. printk(KERN_EMERG "NMI: IOCK error (debug interrupt?)\n");
  656. show_registers(regs);
  657. /* Re-enable the IOCK line, wait for a few seconds */
  658. reason = (reason & 0xf) | 8;
  659. outb(reason, 0x61);
  660. i = 2000;
  661. while (--i)
  662. udelay(1000);
  663. reason &= ~8;
  664. outb(reason, 0x61);
  665. }
  666. static notrace __kprobes void
  667. unknown_nmi_error(unsigned char reason, struct pt_regs *regs)
  668. {
  669. if (notify_die(DIE_NMIUNKNOWN, "nmi", regs, reason, 2, SIGINT) == NOTIFY_STOP)
  670. return;
  671. #ifdef CONFIG_MCA
  672. /*
  673. * Might actually be able to figure out what the guilty party
  674. * is:
  675. */
  676. if (MCA_bus) {
  677. mca_handle_nmi();
  678. return;
  679. }
  680. #endif
  681. printk(KERN_EMERG
  682. "Uhhuh. NMI received for unknown reason %02x on CPU %d.\n",
  683. reason, smp_processor_id());
  684. printk(KERN_EMERG "Do you have a strange power saving mode enabled?\n");
  685. if (panic_on_unrecovered_nmi)
  686. panic("NMI: Not continuing");
  687. printk(KERN_EMERG "Dazed and confused, but trying to continue\n");
  688. }
  689. static DEFINE_SPINLOCK(nmi_print_lock);
  690. void notrace __kprobes die_nmi(char *str, struct pt_regs *regs, int do_panic)
  691. {
  692. if (notify_die(DIE_NMIWATCHDOG, str, regs, 0, 2, SIGINT) == NOTIFY_STOP)
  693. return;
  694. spin_lock(&nmi_print_lock);
  695. /*
  696. * We are in trouble anyway, lets at least try
  697. * to get a message out:
  698. */
  699. bust_spinlocks(1);
  700. printk(KERN_EMERG "%s", str);
  701. printk(" on CPU%d, ip %08lx, registers:\n",
  702. smp_processor_id(), regs->ip);
  703. show_registers(regs);
  704. if (do_panic)
  705. panic("Non maskable interrupt");
  706. console_silent();
  707. spin_unlock(&nmi_print_lock);
  708. bust_spinlocks(0);
  709. /*
  710. * If we are in kernel we are probably nested up pretty bad
  711. * and might aswell get out now while we still can:
  712. */
  713. if (!user_mode_vm(regs)) {
  714. current->thread.trap_no = 2;
  715. crash_kexec(regs);
  716. }
  717. do_exit(SIGSEGV);
  718. }
  719. static notrace __kprobes void default_do_nmi(struct pt_regs *regs)
  720. {
  721. unsigned char reason = 0;
  722. int cpu;
  723. cpu = smp_processor_id();
  724. /* Only the BSP gets external NMIs from the system. */
  725. if (!cpu)
  726. reason = get_nmi_reason();
  727. if (!(reason & 0xc0)) {
  728. if (notify_die(DIE_NMI_IPI, "nmi_ipi", regs, reason, 2, SIGINT)
  729. == NOTIFY_STOP)
  730. return;
  731. #ifdef CONFIG_X86_LOCAL_APIC
  732. /*
  733. * Ok, so this is none of the documented NMI sources,
  734. * so it must be the NMI watchdog.
  735. */
  736. if (nmi_watchdog_tick(regs, reason))
  737. return;
  738. if (!do_nmi_callback(regs, cpu))
  739. unknown_nmi_error(reason, regs);
  740. #else
  741. unknown_nmi_error(reason, regs);
  742. #endif
  743. return;
  744. }
  745. if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT) == NOTIFY_STOP)
  746. return;
  747. /* AK: following checks seem to be broken on modern chipsets. FIXME */
  748. if (reason & 0x80)
  749. mem_parity_error(reason, regs);
  750. if (reason & 0x40)
  751. io_check_error(reason, regs);
  752. /*
  753. * Reassert NMI in case it became active meanwhile
  754. * as it's edge-triggered:
  755. */
  756. reassert_nmi();
  757. }
  758. notrace __kprobes void do_nmi(struct pt_regs *regs, long error_code)
  759. {
  760. int cpu;
  761. nmi_enter();
  762. cpu = smp_processor_id();
  763. ++nmi_count(cpu);
  764. if (!ignore_nmis)
  765. default_do_nmi(regs);
  766. nmi_exit();
  767. }
  768. void stop_nmi(void)
  769. {
  770. acpi_nmi_disable();
  771. ignore_nmis++;
  772. }
  773. void restart_nmi(void)
  774. {
  775. ignore_nmis--;
  776. acpi_nmi_enable();
  777. }
  778. void __kprobes do_int3(struct pt_regs *regs, long error_code)
  779. {
  780. #ifdef CONFIG_KPROBES
  781. trace_hardirqs_fixup();
  782. if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP)
  783. == NOTIFY_STOP)
  784. return;
  785. /*
  786. * This is an interrupt gate, because kprobes wants interrupts
  787. * disabled. Normal trap handlers don't.
  788. */
  789. conditional_sti(regs);
  790. #else
  791. if (notify_die(DIE_TRAP, "int3", regs, error_code, 3, SIGTRAP)
  792. == NOTIFY_STOP)
  793. return;
  794. #endif
  795. do_trap(3, SIGTRAP, "int3", 1, regs, error_code, NULL);
  796. }
  797. /*
  798. * Our handling of the processor debug registers is non-trivial.
  799. * We do not clear them on entry and exit from the kernel. Therefore
  800. * it is possible to get a watchpoint trap here from inside the kernel.
  801. * However, the code in ./ptrace.c has ensured that the user can
  802. * only set watchpoints on userspace addresses. Therefore the in-kernel
  803. * watchpoint trap can only occur in code which is reading/writing
  804. * from user space. Such code must not hold kernel locks (since it
  805. * can equally take a page fault), therefore it is safe to call
  806. * force_sig_info even though that claims and releases locks.
  807. *
  808. * Code in ./signal.c ensures that the debug control register
  809. * is restored before we deliver any signal, and therefore that
  810. * user code runs with the correct debug control register even though
  811. * we clear it here.
  812. *
  813. * Being careful here means that we don't have to be as careful in a
  814. * lot of more complicated places (task switching can be a bit lazy
  815. * about restoring all the debug state, and ptrace doesn't have to
  816. * find every occurrence of the TF bit that could be saved away even
  817. * by user code)
  818. */
  819. void __kprobes do_debug(struct pt_regs *regs, long error_code)
  820. {
  821. struct task_struct *tsk = current;
  822. unsigned int condition;
  823. int si_code;
  824. trace_hardirqs_fixup();
  825. get_debugreg(condition, 6);
  826. /*
  827. * The processor cleared BTF, so don't mark that we need it set.
  828. */
  829. clear_tsk_thread_flag(tsk, TIF_DEBUGCTLMSR);
  830. tsk->thread.debugctlmsr = 0;
  831. if (notify_die(DIE_DEBUG, "debug", regs, condition, error_code,
  832. SIGTRAP) == NOTIFY_STOP)
  833. return;
  834. /* It's safe to allow irq's after DR6 has been saved */
  835. if (regs->flags & X86_EFLAGS_IF)
  836. local_irq_enable();
  837. /* Mask out spurious debug traps due to lazy DR7 setting */
  838. if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3)) {
  839. if (!tsk->thread.debugreg7)
  840. goto clear_dr7;
  841. }
  842. if (regs->flags & X86_VM_MASK)
  843. goto debug_vm86;
  844. /* Save debug status register where ptrace can see it */
  845. tsk->thread.debugreg6 = condition;
  846. /*
  847. * Single-stepping through TF: make sure we ignore any events in
  848. * kernel space (but re-enable TF when returning to user mode).
  849. */
  850. if (condition & DR_STEP) {
  851. /*
  852. * We already checked v86 mode above, so we can
  853. * check for kernel mode by just checking the CPL
  854. * of CS.
  855. */
  856. if (!user_mode(regs))
  857. goto clear_TF_reenable;
  858. }
  859. si_code = get_si_code((unsigned long)condition);
  860. /* Ok, finally something we can handle */
  861. send_sigtrap(tsk, regs, error_code, si_code);
  862. /*
  863. * Disable additional traps. They'll be re-enabled when
  864. * the signal is delivered.
  865. */
  866. clear_dr7:
  867. set_debugreg(0, 7);
  868. return;
  869. debug_vm86:
  870. handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code, 1);
  871. return;
  872. clear_TF_reenable:
  873. set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
  874. regs->flags &= ~X86_EFLAGS_TF;
  875. return;
  876. }
  877. /*
  878. * Note that we play around with the 'TS' bit in an attempt to get
  879. * the correct behaviour even in the presence of the asynchronous
  880. * IRQ13 behaviour
  881. */
  882. void math_error(void __user *ip)
  883. {
  884. struct task_struct *task;
  885. siginfo_t info;
  886. unsigned short cwd, swd;
  887. /*
  888. * Save the info for the exception handler and clear the error.
  889. */
  890. task = current;
  891. save_init_fpu(task);
  892. task->thread.trap_no = 16;
  893. task->thread.error_code = 0;
  894. info.si_signo = SIGFPE;
  895. info.si_errno = 0;
  896. info.si_code = __SI_FAULT;
  897. info.si_addr = ip;
  898. /*
  899. * (~cwd & swd) will mask out exceptions that are not set to unmasked
  900. * status. 0x3f is the exception bits in these regs, 0x200 is the
  901. * C1 reg you need in case of a stack fault, 0x040 is the stack
  902. * fault bit. We should only be taking one exception at a time,
  903. * so if this combination doesn't produce any single exception,
  904. * then we have a bad program that isn't synchronizing its FPU usage
  905. * and it will suffer the consequences since we won't be able to
  906. * fully reproduce the context of the exception
  907. */
  908. cwd = get_fpu_cwd(task);
  909. swd = get_fpu_swd(task);
  910. switch (swd & ~cwd & 0x3f) {
  911. case 0x000: /* No unmasked exception */
  912. return;
  913. default: /* Multiple exceptions */
  914. break;
  915. case 0x001: /* Invalid Op */
  916. /*
  917. * swd & 0x240 == 0x040: Stack Underflow
  918. * swd & 0x240 == 0x240: Stack Overflow
  919. * User must clear the SF bit (0x40) if set
  920. */
  921. info.si_code = FPE_FLTINV;
  922. break;
  923. case 0x002: /* Denormalize */
  924. case 0x010: /* Underflow */
  925. info.si_code = FPE_FLTUND;
  926. break;
  927. case 0x004: /* Zero Divide */
  928. info.si_code = FPE_FLTDIV;
  929. break;
  930. case 0x008: /* Overflow */
  931. info.si_code = FPE_FLTOVF;
  932. break;
  933. case 0x020: /* Precision */
  934. info.si_code = FPE_FLTRES;
  935. break;
  936. }
  937. force_sig_info(SIGFPE, &info, task);
  938. }
  939. void do_coprocessor_error(struct pt_regs *regs, long error_code)
  940. {
  941. ignore_fpu_irq = 1;
  942. math_error((void __user *)regs->ip);
  943. }
  944. static void simd_math_error(void __user *ip)
  945. {
  946. struct task_struct *task;
  947. siginfo_t info;
  948. unsigned short mxcsr;
  949. /*
  950. * Save the info for the exception handler and clear the error.
  951. */
  952. task = current;
  953. save_init_fpu(task);
  954. task->thread.trap_no = 19;
  955. task->thread.error_code = 0;
  956. info.si_signo = SIGFPE;
  957. info.si_errno = 0;
  958. info.si_code = __SI_FAULT;
  959. info.si_addr = ip;
  960. /*
  961. * The SIMD FPU exceptions are handled a little differently, as there
  962. * is only a single status/control register. Thus, to determine which
  963. * unmasked exception was caught we must mask the exception mask bits
  964. * at 0x1f80, and then use these to mask the exception bits at 0x3f.
  965. */
  966. mxcsr = get_fpu_mxcsr(task);
  967. switch (~((mxcsr & 0x1f80) >> 7) & (mxcsr & 0x3f)) {
  968. case 0x000:
  969. default:
  970. break;
  971. case 0x001: /* Invalid Op */
  972. info.si_code = FPE_FLTINV;
  973. break;
  974. case 0x002: /* Denormalize */
  975. case 0x010: /* Underflow */
  976. info.si_code = FPE_FLTUND;
  977. break;
  978. case 0x004: /* Zero Divide */
  979. info.si_code = FPE_FLTDIV;
  980. break;
  981. case 0x008: /* Overflow */
  982. info.si_code = FPE_FLTOVF;
  983. break;
  984. case 0x020: /* Precision */
  985. info.si_code = FPE_FLTRES;
  986. break;
  987. }
  988. force_sig_info(SIGFPE, &info, task);
  989. }
  990. void do_simd_coprocessor_error(struct pt_regs *regs, long error_code)
  991. {
  992. if (cpu_has_xmm) {
  993. /* Handle SIMD FPU exceptions on PIII+ processors. */
  994. ignore_fpu_irq = 1;
  995. simd_math_error((void __user *)regs->ip);
  996. return;
  997. }
  998. /*
  999. * Handle strange cache flush from user space exception
  1000. * in all other cases. This is undocumented behaviour.
  1001. */
  1002. if (regs->flags & X86_VM_MASK) {
  1003. handle_vm86_fault((struct kernel_vm86_regs *)regs, error_code);
  1004. return;
  1005. }
  1006. current->thread.trap_no = 19;
  1007. current->thread.error_code = error_code;
  1008. die_if_kernel("cache flush denied", regs, error_code);
  1009. force_sig(SIGSEGV, current);
  1010. }
  1011. void do_spurious_interrupt_bug(struct pt_regs *regs, long error_code)
  1012. {
  1013. conditional_sti(regs);
  1014. #if 0
  1015. /* No need to warn about this any longer. */
  1016. printk(KERN_INFO "Ignoring P6 Local APIC Spurious Interrupt Bug...\n");
  1017. #endif
  1018. }
  1019. unsigned long patch_espfix_desc(unsigned long uesp, unsigned long kesp)
  1020. {
  1021. struct desc_struct *gdt = get_cpu_gdt_table(smp_processor_id());
  1022. unsigned long base = (kesp - uesp) & -THREAD_SIZE;
  1023. unsigned long new_kesp = kesp - base;
  1024. unsigned long lim_pages = (new_kesp | (THREAD_SIZE - 1)) >> PAGE_SHIFT;
  1025. __u64 desc = *(__u64 *)&gdt[GDT_ENTRY_ESPFIX_SS];
  1026. /* Set up base for espfix segment */
  1027. desc &= 0x00f0ff0000000000ULL;
  1028. desc |= ((((__u64)base) << 16) & 0x000000ffffff0000ULL) |
  1029. ((((__u64)base) << 32) & 0xff00000000000000ULL) |
  1030. ((((__u64)lim_pages) << 32) & 0x000f000000000000ULL) |
  1031. (lim_pages & 0xffff);
  1032. *(__u64 *)&gdt[GDT_ENTRY_ESPFIX_SS] = desc;
  1033. return new_kesp;
  1034. }
  1035. /*
  1036. * 'math_state_restore()' saves the current math information in the
  1037. * old math state array, and gets the new ones from the current task
  1038. *
  1039. * Careful.. There are problems with IBM-designed IRQ13 behaviour.
  1040. * Don't touch unless you *really* know how it works.
  1041. *
  1042. * Must be called with kernel preemption disabled (in this case,
  1043. * local interrupts are disabled at the call-site in entry.S).
  1044. */
  1045. asmlinkage void math_state_restore(void)
  1046. {
  1047. struct thread_info *thread = current_thread_info();
  1048. struct task_struct *tsk = thread->task;
  1049. if (!tsk_used_math(tsk)) {
  1050. local_irq_enable();
  1051. /*
  1052. * does a slab alloc which can sleep
  1053. */
  1054. if (init_fpu(tsk)) {
  1055. /*
  1056. * ran out of memory!
  1057. */
  1058. do_group_exit(SIGKILL);
  1059. return;
  1060. }
  1061. local_irq_disable();
  1062. }
  1063. clts(); /* Allow maths ops (or we recurse) */
  1064. restore_fpu(tsk);
  1065. thread->status |= TS_USEDFPU; /* So we fnsave on switch_to() */
  1066. tsk->fpu_counter++;
  1067. }
  1068. EXPORT_SYMBOL_GPL(math_state_restore);
  1069. #ifndef CONFIG_MATH_EMULATION
  1070. asmlinkage void math_emulate(long arg)
  1071. {
  1072. printk(KERN_EMERG
  1073. "math-emulation not enabled and no coprocessor found.\n");
  1074. printk(KERN_EMERG "killing %s.\n", current->comm);
  1075. force_sig(SIGFPE, current);
  1076. schedule();
  1077. }
  1078. #endif /* CONFIG_MATH_EMULATION */
  1079. void __kprobes do_device_not_available(struct pt_regs *regs, long error)
  1080. {
  1081. if (read_cr0() & X86_CR0_EM) {
  1082. conditional_sti(regs);
  1083. math_emulate(0);
  1084. } else {
  1085. math_state_restore(); /* interrupts still off */
  1086. conditional_sti(regs);
  1087. }
  1088. }
  1089. void __init trap_init(void)
  1090. {
  1091. int i;
  1092. #ifdef CONFIG_EISA
  1093. void __iomem *p = early_ioremap(0x0FFFD9, 4);
  1094. if (readl(p) == 'E' + ('I'<<8) + ('S'<<16) + ('A'<<24))
  1095. EISA_bus = 1;
  1096. early_iounmap(p, 4);
  1097. #endif
  1098. set_intr_gate(0, &divide_error);
  1099. set_intr_gate(1, &debug);
  1100. set_intr_gate(2, &nmi);
  1101. set_system_intr_gate(3, &int3); /* int3 can be called from all */
  1102. set_system_intr_gate(4, &overflow); /* int4 can be called from all */
  1103. set_intr_gate(5, &bounds);
  1104. set_intr_gate(6, &invalid_op);
  1105. set_intr_gate(7, &device_not_available);
  1106. set_task_gate(8, GDT_ENTRY_DOUBLEFAULT_TSS);
  1107. set_intr_gate(9, &coprocessor_segment_overrun);
  1108. set_intr_gate(10, &invalid_TSS);
  1109. set_intr_gate(11, &segment_not_present);
  1110. set_intr_gate(12, &stack_segment);
  1111. set_intr_gate(13, &general_protection);
  1112. set_intr_gate(14, &page_fault);
  1113. set_intr_gate(15, &spurious_interrupt_bug);
  1114. set_trap_gate(16, &coprocessor_error);
  1115. set_trap_gate(17, &alignment_check);
  1116. #ifdef CONFIG_X86_MCE
  1117. set_trap_gate(18, &machine_check);
  1118. #endif
  1119. set_trap_gate(19, &simd_coprocessor_error);
  1120. if (cpu_has_fxsr) {
  1121. printk(KERN_INFO "Enabling fast FPU save and restore... ");
  1122. set_in_cr4(X86_CR4_OSFXSR);
  1123. printk("done.\n");
  1124. }
  1125. if (cpu_has_xmm) {
  1126. printk(KERN_INFO
  1127. "Enabling unmasked SIMD FPU exception support... ");
  1128. set_in_cr4(X86_CR4_OSXMMEXCPT);
  1129. printk("done.\n");
  1130. }
  1131. set_system_gate(SYSCALL_VECTOR, &system_call);
  1132. /* Reserve all the builtin and the syscall vector: */
  1133. for (i = 0; i < FIRST_EXTERNAL_VECTOR; i++)
  1134. set_bit(i, used_vectors);
  1135. set_bit(SYSCALL_VECTOR, used_vectors);
  1136. /*
  1137. * Should be a barrier for any external CPU state:
  1138. */
  1139. cpu_init();
  1140. trap_init_hook();
  1141. }
  1142. static int __init kstack_setup(char *s)
  1143. {
  1144. kstack_depth_to_print = simple_strtoul(s, NULL, 0);
  1145. return 1;
  1146. }
  1147. __setup("kstack=", kstack_setup);
  1148. static int __init code_bytes_setup(char *s)
  1149. {
  1150. code_bytes = simple_strtoul(s, NULL, 0);
  1151. if (code_bytes > 8192)
  1152. code_bytes = 8192;
  1153. return 1;
  1154. }
  1155. __setup("code_bytes=", code_bytes_setup);