traps_32.c 32 KB

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