traps.c 33 KB

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