traps_64.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  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 'entry.S'.
  11. */
  12. #include <linux/moduleparam.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/kallsyms.h>
  15. #include <linux/spinlock.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. #include <linux/smp.h>
  35. #include <linux/io.h>
  36. #if defined(CONFIG_EDAC)
  37. #include <linux/edac.h>
  38. #endif
  39. #include <asm/stacktrace.h>
  40. #include <asm/processor.h>
  41. #include <asm/debugreg.h>
  42. #include <asm/atomic.h>
  43. #include <asm/system.h>
  44. #include <asm/unwind.h>
  45. #include <asm/desc.h>
  46. #include <asm/i387.h>
  47. #include <asm/pgalloc.h>
  48. #include <asm/proto.h>
  49. #include <asm/pda.h>
  50. #include <asm/traps.h>
  51. #include <mach_traps.h>
  52. static int ignore_nmis;
  53. static inline void conditional_sti(struct pt_regs *regs)
  54. {
  55. if (regs->flags & X86_EFLAGS_IF)
  56. local_irq_enable();
  57. }
  58. static inline void preempt_conditional_sti(struct pt_regs *regs)
  59. {
  60. inc_preempt_count();
  61. if (regs->flags & X86_EFLAGS_IF)
  62. local_irq_enable();
  63. }
  64. static inline void preempt_conditional_cli(struct pt_regs *regs)
  65. {
  66. if (regs->flags & X86_EFLAGS_IF)
  67. local_irq_disable();
  68. /* Make sure to not schedule here because we could be running
  69. on an exception stack. */
  70. dec_preempt_count();
  71. }
  72. static void __kprobes
  73. do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
  74. long error_code, siginfo_t *info)
  75. {
  76. struct task_struct *tsk = current;
  77. if (!user_mode(regs))
  78. goto kernel_trap;
  79. /*
  80. * We want error_code and trap_no set for userspace faults and
  81. * kernelspace faults which result in die(), but not
  82. * kernelspace faults which are fixed up. die() gives the
  83. * process no chance to handle the signal and notice the
  84. * kernel fault information, so that won't result in polluting
  85. * the information about previously queued, but not yet
  86. * delivered, faults. See also do_general_protection below.
  87. */
  88. tsk->thread.error_code = error_code;
  89. tsk->thread.trap_no = trapnr;
  90. if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
  91. printk_ratelimit()) {
  92. printk(KERN_INFO
  93. "%s[%d] trap %s ip:%lx sp:%lx error:%lx",
  94. tsk->comm, tsk->pid, str,
  95. regs->ip, regs->sp, error_code);
  96. print_vma_addr(" in ", regs->ip);
  97. printk("\n");
  98. }
  99. if (info)
  100. force_sig_info(signr, info, tsk);
  101. else
  102. force_sig(signr, tsk);
  103. return;
  104. kernel_trap:
  105. if (!fixup_exception(regs)) {
  106. tsk->thread.error_code = error_code;
  107. tsk->thread.trap_no = trapnr;
  108. die(str, regs, error_code);
  109. }
  110. return;
  111. }
  112. #define DO_ERROR(trapnr, signr, str, name) \
  113. dotraplinkage void do_##name(struct pt_regs *regs, long error_code) \
  114. { \
  115. if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
  116. == NOTIFY_STOP) \
  117. return; \
  118. conditional_sti(regs); \
  119. do_trap(trapnr, signr, str, regs, error_code, NULL); \
  120. }
  121. #define DO_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \
  122. dotraplinkage void do_##name(struct pt_regs *regs, long error_code) \
  123. { \
  124. siginfo_t info; \
  125. info.si_signo = signr; \
  126. info.si_errno = 0; \
  127. info.si_code = sicode; \
  128. info.si_addr = (void __user *)siaddr; \
  129. if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
  130. == NOTIFY_STOP) \
  131. return; \
  132. conditional_sti(regs); \
  133. do_trap(trapnr, signr, str, regs, error_code, &info); \
  134. }
  135. DO_ERROR_INFO(0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->ip)
  136. DO_ERROR(4, SIGSEGV, "overflow", overflow)
  137. DO_ERROR(5, SIGSEGV, "bounds", bounds)
  138. DO_ERROR_INFO(6, SIGILL, "invalid opcode", invalid_op, ILL_ILLOPN, regs->ip)
  139. DO_ERROR(9, SIGFPE, "coprocessor segment overrun", coprocessor_segment_overrun)
  140. DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS)
  141. DO_ERROR(11, SIGBUS, "segment not present", segment_not_present)
  142. DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0)
  143. /* Runs on IST stack */
  144. dotraplinkage void do_stack_segment(struct pt_regs *regs, long error_code)
  145. {
  146. if (notify_die(DIE_TRAP, "stack segment", regs, error_code,
  147. 12, SIGBUS) == NOTIFY_STOP)
  148. return;
  149. preempt_conditional_sti(regs);
  150. do_trap(12, SIGBUS, "stack segment", regs, error_code, NULL);
  151. preempt_conditional_cli(regs);
  152. }
  153. dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code)
  154. {
  155. static const char str[] = "double fault";
  156. struct task_struct *tsk = current;
  157. /* Return not checked because double check cannot be ignored */
  158. notify_die(DIE_TRAP, str, regs, error_code, 8, SIGSEGV);
  159. tsk->thread.error_code = error_code;
  160. tsk->thread.trap_no = 8;
  161. /* This is always a kernel trap and never fixable (and thus must
  162. never return). */
  163. for (;;)
  164. die(str, regs, error_code);
  165. }
  166. dotraplinkage void __kprobes
  167. do_general_protection(struct pt_regs *regs, long error_code)
  168. {
  169. struct task_struct *tsk;
  170. conditional_sti(regs);
  171. tsk = current;
  172. if (!user_mode(regs))
  173. goto gp_in_kernel;
  174. tsk->thread.error_code = error_code;
  175. tsk->thread.trap_no = 13;
  176. if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) &&
  177. printk_ratelimit()) {
  178. printk(KERN_INFO
  179. "%s[%d] general protection ip:%lx sp:%lx error:%lx",
  180. tsk->comm, tsk->pid,
  181. regs->ip, regs->sp, error_code);
  182. print_vma_addr(" in ", regs->ip);
  183. printk("\n");
  184. }
  185. force_sig(SIGSEGV, tsk);
  186. return;
  187. gp_in_kernel:
  188. if (fixup_exception(regs))
  189. return;
  190. tsk->thread.error_code = error_code;
  191. tsk->thread.trap_no = 13;
  192. if (notify_die(DIE_GPF, "general protection fault", regs,
  193. error_code, 13, SIGSEGV) == NOTIFY_STOP)
  194. return;
  195. die("general protection fault", regs, error_code);
  196. }
  197. static notrace __kprobes void
  198. mem_parity_error(unsigned char reason, struct pt_regs *regs)
  199. {
  200. printk(KERN_EMERG "Uhhuh. NMI received for unknown reason %02x.\n",
  201. reason);
  202. printk(KERN_EMERG "You have some hardware problem, likely on the PCI bus.\n");
  203. #if defined(CONFIG_EDAC)
  204. if (edac_handler_set()) {
  205. edac_atomic_assert_error();
  206. return;
  207. }
  208. #endif
  209. if (panic_on_unrecovered_nmi)
  210. panic("NMI: Not continuing");
  211. printk(KERN_EMERG "Dazed and confused, but trying to continue\n");
  212. /* Clear and disable the memory parity error line. */
  213. reason = (reason & 0xf) | 4;
  214. outb(reason, 0x61);
  215. }
  216. static notrace __kprobes void
  217. io_check_error(unsigned char reason, struct pt_regs *regs)
  218. {
  219. printk("NMI: IOCK error (debug interrupt?)\n");
  220. show_registers(regs);
  221. /* Re-enable the IOCK line, wait for a few seconds */
  222. reason = (reason & 0xf) | 8;
  223. outb(reason, 0x61);
  224. mdelay(2000);
  225. reason &= ~8;
  226. outb(reason, 0x61);
  227. }
  228. static notrace __kprobes void
  229. unknown_nmi_error(unsigned char reason, struct pt_regs *regs)
  230. {
  231. if (notify_die(DIE_NMIUNKNOWN, "nmi", regs, reason, 2, SIGINT) ==
  232. NOTIFY_STOP)
  233. return;
  234. printk(KERN_EMERG "Uhhuh. NMI received for unknown reason %02x.\n",
  235. reason);
  236. printk(KERN_EMERG "Do you have a strange power saving mode enabled?\n");
  237. if (panic_on_unrecovered_nmi)
  238. panic("NMI: Not continuing");
  239. printk(KERN_EMERG "Dazed and confused, but trying to continue\n");
  240. }
  241. /* Runs on IST stack. This code must keep interrupts off all the time.
  242. Nested NMIs are prevented by the CPU. */
  243. asmlinkage notrace __kprobes void default_do_nmi(struct pt_regs *regs)
  244. {
  245. unsigned char reason = 0;
  246. int cpu;
  247. cpu = smp_processor_id();
  248. /* Only the BSP gets external NMIs from the system. */
  249. if (!cpu)
  250. reason = get_nmi_reason();
  251. if (!(reason & 0xc0)) {
  252. if (notify_die(DIE_NMI_IPI, "nmi_ipi", regs, reason, 2, SIGINT)
  253. == NOTIFY_STOP)
  254. return;
  255. /*
  256. * Ok, so this is none of the documented NMI sources,
  257. * so it must be the NMI watchdog.
  258. */
  259. if (nmi_watchdog_tick(regs, reason))
  260. return;
  261. if (!do_nmi_callback(regs, cpu))
  262. unknown_nmi_error(reason, regs);
  263. return;
  264. }
  265. if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT) == NOTIFY_STOP)
  266. return;
  267. /* AK: following checks seem to be broken on modern chipsets. FIXME */
  268. if (reason & 0x80)
  269. mem_parity_error(reason, regs);
  270. if (reason & 0x40)
  271. io_check_error(reason, regs);
  272. }
  273. dotraplinkage notrace __kprobes void
  274. do_nmi(struct pt_regs *regs, long error_code)
  275. {
  276. nmi_enter();
  277. add_pda(__nmi_count, 1);
  278. if (!ignore_nmis)
  279. default_do_nmi(regs);
  280. nmi_exit();
  281. }
  282. void stop_nmi(void)
  283. {
  284. acpi_nmi_disable();
  285. ignore_nmis++;
  286. }
  287. void restart_nmi(void)
  288. {
  289. ignore_nmis--;
  290. acpi_nmi_enable();
  291. }
  292. /* runs on IST stack. */
  293. dotraplinkage void __kprobes do_int3(struct pt_regs *regs, long error_code)
  294. {
  295. if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP)
  296. == NOTIFY_STOP)
  297. return;
  298. preempt_conditional_sti(regs);
  299. do_trap(3, SIGTRAP, "int3", regs, error_code, NULL);
  300. preempt_conditional_cli(regs);
  301. }
  302. /* Help handler running on IST stack to switch back to user stack
  303. for scheduling or signal handling. The actual stack switch is done in
  304. entry.S */
  305. asmlinkage __kprobes struct pt_regs *sync_regs(struct pt_regs *eregs)
  306. {
  307. struct pt_regs *regs = eregs;
  308. /* Did already sync */
  309. if (eregs == (struct pt_regs *)eregs->sp)
  310. ;
  311. /* Exception from user space */
  312. else if (user_mode(eregs))
  313. regs = task_pt_regs(current);
  314. /* Exception from kernel and interrupts are enabled. Move to
  315. kernel process stack. */
  316. else if (eregs->flags & X86_EFLAGS_IF)
  317. regs = (struct pt_regs *)(eregs->sp -= sizeof(struct pt_regs));
  318. if (eregs != regs)
  319. *regs = *eregs;
  320. return regs;
  321. }
  322. /* runs on IST stack. */
  323. dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
  324. {
  325. struct task_struct *tsk = current;
  326. unsigned long condition;
  327. int si_code;
  328. get_debugreg(condition, 6);
  329. /*
  330. * The processor cleared BTF, so don't mark that we need it set.
  331. */
  332. clear_tsk_thread_flag(tsk, TIF_DEBUGCTLMSR);
  333. tsk->thread.debugctlmsr = 0;
  334. if (notify_die(DIE_DEBUG, "debug", regs, condition, error_code,
  335. SIGTRAP) == NOTIFY_STOP)
  336. return;
  337. /* It's safe to allow irq's after DR6 has been saved */
  338. preempt_conditional_sti(regs);
  339. /* Mask out spurious debug traps due to lazy DR7 setting */
  340. if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3)) {
  341. if (!tsk->thread.debugreg7)
  342. goto clear_dr7;
  343. }
  344. /* Save debug status register where ptrace can see it */
  345. tsk->thread.debugreg6 = condition;
  346. /*
  347. * Single-stepping through TF: make sure we ignore any events in
  348. * kernel space (but re-enable TF when returning to user mode).
  349. */
  350. if (condition & DR_STEP) {
  351. if (!user_mode(regs))
  352. goto clear_TF_reenable;
  353. }
  354. si_code = get_si_code(condition);
  355. /* Ok, finally something we can handle */
  356. send_sigtrap(tsk, regs, error_code, si_code);
  357. /*
  358. * Disable additional traps. They'll be re-enabled when
  359. * the signal is delivered.
  360. */
  361. clear_dr7:
  362. set_debugreg(0, 7);
  363. preempt_conditional_cli(regs);
  364. return;
  365. clear_TF_reenable:
  366. set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
  367. regs->flags &= ~X86_EFLAGS_TF;
  368. preempt_conditional_cli(regs);
  369. return;
  370. }
  371. static int kernel_math_error(struct pt_regs *regs, const char *str, int trapnr)
  372. {
  373. if (fixup_exception(regs))
  374. return 1;
  375. notify_die(DIE_GPF, str, regs, 0, trapnr, SIGFPE);
  376. /* Illegal floating point operation in the kernel */
  377. current->thread.trap_no = trapnr;
  378. die(str, regs, 0);
  379. return 0;
  380. }
  381. /*
  382. * Note that we play around with the 'TS' bit in an attempt to get
  383. * the correct behaviour even in the presence of the asynchronous
  384. * IRQ13 behaviour
  385. */
  386. void math_error(void __user *ip)
  387. {
  388. struct task_struct *task;
  389. siginfo_t info;
  390. unsigned short cwd, swd;
  391. /*
  392. * Save the info for the exception handler and clear the error.
  393. */
  394. task = current;
  395. save_init_fpu(task);
  396. task->thread.trap_no = 16;
  397. task->thread.error_code = 0;
  398. info.si_signo = SIGFPE;
  399. info.si_errno = 0;
  400. info.si_code = __SI_FAULT;
  401. info.si_addr = ip;
  402. /*
  403. * (~cwd & swd) will mask out exceptions that are not set to unmasked
  404. * status. 0x3f is the exception bits in these regs, 0x200 is the
  405. * C1 reg you need in case of a stack fault, 0x040 is the stack
  406. * fault bit. We should only be taking one exception at a time,
  407. * so if this combination doesn't produce any single exception,
  408. * then we have a bad program that isn't synchronizing its FPU usage
  409. * and it will suffer the consequences since we won't be able to
  410. * fully reproduce the context of the exception
  411. */
  412. cwd = get_fpu_cwd(task);
  413. swd = get_fpu_swd(task);
  414. switch (swd & ~cwd & 0x3f) {
  415. case 0x000: /* No unmasked exception */
  416. default: /* Multiple exceptions */
  417. break;
  418. case 0x001: /* Invalid Op */
  419. /*
  420. * swd & 0x240 == 0x040: Stack Underflow
  421. * swd & 0x240 == 0x240: Stack Overflow
  422. * User must clear the SF bit (0x40) if set
  423. */
  424. info.si_code = FPE_FLTINV;
  425. break;
  426. case 0x002: /* Denormalize */
  427. case 0x010: /* Underflow */
  428. info.si_code = FPE_FLTUND;
  429. break;
  430. case 0x004: /* Zero Divide */
  431. info.si_code = FPE_FLTDIV;
  432. break;
  433. case 0x008: /* Overflow */
  434. info.si_code = FPE_FLTOVF;
  435. break;
  436. case 0x020: /* Precision */
  437. info.si_code = FPE_FLTRES;
  438. break;
  439. }
  440. force_sig_info(SIGFPE, &info, task);
  441. }
  442. dotraplinkage void do_coprocessor_error(struct pt_regs *regs, long error_code)
  443. {
  444. conditional_sti(regs);
  445. if (!user_mode(regs) &&
  446. kernel_math_error(regs, "kernel x87 math error", 16))
  447. return;
  448. math_error((void __user *)regs->ip);
  449. }
  450. asmlinkage void bad_intr(void)
  451. {
  452. printk("bad interrupt");
  453. }
  454. static void simd_math_error(void __user *ip)
  455. {
  456. struct task_struct *task;
  457. siginfo_t info;
  458. unsigned short mxcsr;
  459. /*
  460. * Save the info for the exception handler and clear the error.
  461. */
  462. task = current;
  463. save_init_fpu(task);
  464. task->thread.trap_no = 19;
  465. task->thread.error_code = 0;
  466. info.si_signo = SIGFPE;
  467. info.si_errno = 0;
  468. info.si_code = __SI_FAULT;
  469. info.si_addr = ip;
  470. /*
  471. * The SIMD FPU exceptions are handled a little differently, as there
  472. * is only a single status/control register. Thus, to determine which
  473. * unmasked exception was caught we must mask the exception mask bits
  474. * at 0x1f80, and then use these to mask the exception bits at 0x3f.
  475. */
  476. mxcsr = get_fpu_mxcsr(task);
  477. switch (~((mxcsr & 0x1f80) >> 7) & (mxcsr & 0x3f)) {
  478. case 0x000:
  479. default:
  480. break;
  481. case 0x001: /* Invalid Op */
  482. info.si_code = FPE_FLTINV;
  483. break;
  484. case 0x002: /* Denormalize */
  485. case 0x010: /* Underflow */
  486. info.si_code = FPE_FLTUND;
  487. break;
  488. case 0x004: /* Zero Divide */
  489. info.si_code = FPE_FLTDIV;
  490. break;
  491. case 0x008: /* Overflow */
  492. info.si_code = FPE_FLTOVF;
  493. break;
  494. case 0x020: /* Precision */
  495. info.si_code = FPE_FLTRES;
  496. break;
  497. }
  498. force_sig_info(SIGFPE, &info, task);
  499. }
  500. dotraplinkage void
  501. do_simd_coprocessor_error(struct pt_regs *regs, long error_code)
  502. {
  503. conditional_sti(regs);
  504. if (!user_mode(regs) &&
  505. kernel_math_error(regs, "kernel simd math error", 19))
  506. return;
  507. simd_math_error((void __user *)regs->ip);
  508. }
  509. dotraplinkage void
  510. do_spurious_interrupt_bug(struct pt_regs *regs, long error_code)
  511. {
  512. }
  513. asmlinkage void __attribute__((weak)) smp_thermal_interrupt(void)
  514. {
  515. }
  516. asmlinkage void __attribute__((weak)) mce_threshold_interrupt(void)
  517. {
  518. }
  519. /*
  520. * 'math_state_restore()' saves the current math information in the
  521. * old math state array, and gets the new ones from the current task
  522. *
  523. * Careful.. There are problems with IBM-designed IRQ13 behaviour.
  524. * Don't touch unless you *really* know how it works.
  525. */
  526. asmlinkage void math_state_restore(void)
  527. {
  528. struct thread_info *thread = current_thread_info();
  529. struct task_struct *tsk = thread->task;
  530. if (!tsk_used_math(tsk)) {
  531. local_irq_enable();
  532. /*
  533. * does a slab alloc which can sleep
  534. */
  535. if (init_fpu(tsk)) {
  536. /*
  537. * ran out of memory!
  538. */
  539. do_group_exit(SIGKILL);
  540. return;
  541. }
  542. local_irq_disable();
  543. }
  544. clts(); /* Allow maths ops (or we recurse) */
  545. /*
  546. * Paranoid restore. send a SIGSEGV if we fail to restore the state.
  547. */
  548. if (unlikely(restore_fpu_checking(tsk))) {
  549. stts();
  550. force_sig(SIGSEGV, tsk);
  551. return;
  552. }
  553. thread->status |= TS_USEDFPU; /* So we fnsave on switch_to() */
  554. tsk->fpu_counter++;
  555. }
  556. EXPORT_SYMBOL_GPL(math_state_restore);
  557. dotraplinkage void __kprobes
  558. do_device_not_available(struct pt_regs *regs, long error)
  559. {
  560. math_state_restore();
  561. }
  562. void __init trap_init(void)
  563. {
  564. set_intr_gate(0, &divide_error);
  565. set_intr_gate_ist(1, &debug, DEBUG_STACK);
  566. set_intr_gate_ist(2, &nmi, NMI_STACK);
  567. /* int3 can be called from all */
  568. set_system_intr_gate_ist(3, &int3, DEBUG_STACK);
  569. /* int4 can be called from all */
  570. set_system_intr_gate(4, &overflow);
  571. set_intr_gate(5, &bounds);
  572. set_intr_gate(6, &invalid_op);
  573. set_intr_gate(7, &device_not_available);
  574. set_intr_gate_ist(8, &double_fault, DOUBLEFAULT_STACK);
  575. set_intr_gate(9, &coprocessor_segment_overrun);
  576. set_intr_gate(10, &invalid_TSS);
  577. set_intr_gate(11, &segment_not_present);
  578. set_intr_gate_ist(12, &stack_segment, STACKFAULT_STACK);
  579. set_intr_gate(13, &general_protection);
  580. set_intr_gate(14, &page_fault);
  581. set_intr_gate(15, &spurious_interrupt_bug);
  582. set_intr_gate(16, &coprocessor_error);
  583. set_intr_gate(17, &alignment_check);
  584. #ifdef CONFIG_X86_MCE
  585. set_intr_gate_ist(18, &machine_check, MCE_STACK);
  586. #endif
  587. set_intr_gate(19, &simd_coprocessor_error);
  588. #ifdef CONFIG_IA32_EMULATION
  589. set_system_intr_gate(IA32_SYSCALL_VECTOR, ia32_syscall);
  590. #endif
  591. /*
  592. * Should be a barrier for any external CPU state:
  593. */
  594. cpu_init();
  595. }