traps.c 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286
  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. 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 *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 *)regs->eip - 43;
  347. if (eip < (u8 *)PAGE_OFFSET ||
  348. probe_kernel_address(eip, c)) {
  349. /* try starting at EIP */
  350. eip = (u8 *)regs->eip;
  351. code_bytes = 32;
  352. }
  353. for (i = 0; i < code_bytes; i++, eip++) {
  354. if (eip < (u8 *)PAGE_OFFSET ||
  355. probe_kernel_address(eip, c)) {
  356. printk(" Bad EIP value.");
  357. break;
  358. }
  359. if (eip == (u8 *)regs->eip)
  360. printk("<%02x> ", c);
  361. else
  362. printk("%02x ", c);
  363. }
  364. }
  365. printk("\n");
  366. }
  367. static void handle_BUG(struct pt_regs *regs)
  368. {
  369. unsigned long eip = regs->eip;
  370. unsigned short ud2;
  371. if (eip < PAGE_OFFSET)
  372. return;
  373. if (probe_kernel_address((unsigned short *)eip, ud2))
  374. return;
  375. if (ud2 != 0x0b0f)
  376. return;
  377. printk(KERN_EMERG "------------[ cut here ]------------\n");
  378. #ifdef CONFIG_DEBUG_BUGVERBOSE
  379. do {
  380. unsigned short line;
  381. char *file;
  382. char c;
  383. if (probe_kernel_address((unsigned short *)(eip + 2), line))
  384. break;
  385. if (probe_kernel_address((char **)(eip + 4), file) ||
  386. (unsigned long)file < PAGE_OFFSET ||
  387. probe_kernel_address(file, c))
  388. file = "<bad filename>";
  389. printk(KERN_EMERG "kernel BUG at %s:%d!\n", file, line);
  390. return;
  391. } while (0);
  392. #endif
  393. printk(KERN_EMERG "Kernel BUG at [verbose debug info unavailable]\n");
  394. }
  395. /* This is gone through when something in the kernel
  396. * has done something bad and is about to be terminated.
  397. */
  398. void die(const char * str, struct pt_regs * regs, long err)
  399. {
  400. static struct {
  401. spinlock_t lock;
  402. u32 lock_owner;
  403. int lock_owner_depth;
  404. } die = {
  405. .lock = SPIN_LOCK_UNLOCKED,
  406. .lock_owner = -1,
  407. .lock_owner_depth = 0
  408. };
  409. static int die_counter;
  410. unsigned long flags;
  411. oops_enter();
  412. if (die.lock_owner != raw_smp_processor_id()) {
  413. console_verbose();
  414. spin_lock_irqsave(&die.lock, flags);
  415. die.lock_owner = smp_processor_id();
  416. die.lock_owner_depth = 0;
  417. bust_spinlocks(1);
  418. }
  419. else
  420. local_save_flags(flags);
  421. if (++die.lock_owner_depth < 3) {
  422. int nl = 0;
  423. unsigned long esp;
  424. unsigned short ss;
  425. handle_BUG(regs);
  426. printk(KERN_EMERG "%s: %04lx [#%d]\n", str, err & 0xffff, ++die_counter);
  427. #ifdef CONFIG_PREEMPT
  428. printk(KERN_EMERG "PREEMPT ");
  429. nl = 1;
  430. #endif
  431. #ifdef CONFIG_SMP
  432. if (!nl)
  433. printk(KERN_EMERG);
  434. printk("SMP ");
  435. nl = 1;
  436. #endif
  437. #ifdef CONFIG_DEBUG_PAGEALLOC
  438. if (!nl)
  439. printk(KERN_EMERG);
  440. printk("DEBUG_PAGEALLOC");
  441. nl = 1;
  442. #endif
  443. if (nl)
  444. printk("\n");
  445. if (notify_die(DIE_OOPS, str, regs, err,
  446. current->thread.trap_no, SIGSEGV) !=
  447. NOTIFY_STOP) {
  448. show_registers(regs);
  449. /* Executive summary in case the oops scrolled away */
  450. esp = (unsigned long) (&regs->esp);
  451. savesegment(ss, ss);
  452. if (user_mode(regs)) {
  453. esp = regs->esp;
  454. ss = regs->xss & 0xffff;
  455. }
  456. printk(KERN_EMERG "EIP: [<%08lx>] ", regs->eip);
  457. print_symbol("%s", regs->eip);
  458. printk(" SS:ESP %04x:%08lx\n", ss, esp);
  459. }
  460. else
  461. regs = NULL;
  462. } else
  463. printk(KERN_EMERG "Recursive die() failure, output suppressed\n");
  464. bust_spinlocks(0);
  465. die.lock_owner = -1;
  466. spin_unlock_irqrestore(&die.lock, flags);
  467. if (!regs)
  468. return;
  469. if (kexec_should_crash(current))
  470. crash_kexec(regs);
  471. if (in_interrupt())
  472. panic("Fatal exception in interrupt");
  473. if (panic_on_oops)
  474. panic("Fatal exception");
  475. oops_exit();
  476. do_exit(SIGSEGV);
  477. }
  478. static inline void die_if_kernel(const char * str, struct pt_regs * regs, long err)
  479. {
  480. if (!user_mode_vm(regs))
  481. die(str, regs, err);
  482. }
  483. static void __kprobes do_trap(int trapnr, int signr, char *str, int vm86,
  484. struct pt_regs * regs, long error_code,
  485. siginfo_t *info)
  486. {
  487. struct task_struct *tsk = current;
  488. tsk->thread.error_code = error_code;
  489. tsk->thread.trap_no = trapnr;
  490. if (regs->eflags & VM_MASK) {
  491. if (vm86)
  492. goto vm86_trap;
  493. goto trap_signal;
  494. }
  495. if (!user_mode(regs))
  496. goto kernel_trap;
  497. trap_signal: {
  498. if (info)
  499. force_sig_info(signr, info, tsk);
  500. else
  501. force_sig(signr, tsk);
  502. return;
  503. }
  504. kernel_trap: {
  505. if (!fixup_exception(regs))
  506. die(str, regs, error_code);
  507. return;
  508. }
  509. vm86_trap: {
  510. int ret = handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code, trapnr);
  511. if (ret) goto trap_signal;
  512. return;
  513. }
  514. }
  515. #define DO_ERROR(trapnr, signr, str, name) \
  516. fastcall void do_##name(struct pt_regs * regs, long error_code) \
  517. { \
  518. if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
  519. == NOTIFY_STOP) \
  520. return; \
  521. do_trap(trapnr, signr, str, 0, regs, error_code, NULL); \
  522. }
  523. #define DO_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \
  524. fastcall void do_##name(struct pt_regs * regs, long error_code) \
  525. { \
  526. siginfo_t info; \
  527. info.si_signo = signr; \
  528. info.si_errno = 0; \
  529. info.si_code = sicode; \
  530. info.si_addr = (void __user *)siaddr; \
  531. if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
  532. == NOTIFY_STOP) \
  533. return; \
  534. do_trap(trapnr, signr, str, 0, regs, error_code, &info); \
  535. }
  536. #define DO_VM86_ERROR(trapnr, signr, str, name) \
  537. fastcall void do_##name(struct pt_regs * regs, long error_code) \
  538. { \
  539. if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
  540. == NOTIFY_STOP) \
  541. return; \
  542. do_trap(trapnr, signr, str, 1, regs, error_code, NULL); \
  543. }
  544. #define DO_VM86_ERROR_INFO(trapnr, signr, str, name, sicode, siaddr) \
  545. fastcall void do_##name(struct pt_regs * regs, long error_code) \
  546. { \
  547. siginfo_t info; \
  548. info.si_signo = signr; \
  549. info.si_errno = 0; \
  550. info.si_code = sicode; \
  551. info.si_addr = (void __user *)siaddr; \
  552. if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) \
  553. == NOTIFY_STOP) \
  554. return; \
  555. do_trap(trapnr, signr, str, 1, regs, error_code, &info); \
  556. }
  557. DO_VM86_ERROR_INFO( 0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->eip)
  558. #ifndef CONFIG_KPROBES
  559. DO_VM86_ERROR( 3, SIGTRAP, "int3", int3)
  560. #endif
  561. DO_VM86_ERROR( 4, SIGSEGV, "overflow", overflow)
  562. DO_VM86_ERROR( 5, SIGSEGV, "bounds", bounds)
  563. DO_ERROR_INFO( 6, SIGILL, "invalid opcode", invalid_op, ILL_ILLOPN, regs->eip)
  564. DO_ERROR( 9, SIGFPE, "coprocessor segment overrun", coprocessor_segment_overrun)
  565. DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS)
  566. DO_ERROR(11, SIGBUS, "segment not present", segment_not_present)
  567. DO_ERROR(12, SIGBUS, "stack segment", stack_segment)
  568. DO_ERROR_INFO(17, SIGBUS, "alignment check", alignment_check, BUS_ADRALN, 0)
  569. DO_ERROR_INFO(32, SIGSEGV, "iret exception", iret_error, ILL_BADSTK, 0)
  570. fastcall void __kprobes do_general_protection(struct pt_regs * regs,
  571. long error_code)
  572. {
  573. int cpu = get_cpu();
  574. struct tss_struct *tss = &per_cpu(init_tss, cpu);
  575. struct thread_struct *thread = &current->thread;
  576. /*
  577. * Perform the lazy TSS's I/O bitmap copy. If the TSS has an
  578. * invalid offset set (the LAZY one) and the faulting thread has
  579. * a valid I/O bitmap pointer, we copy the I/O bitmap in the TSS
  580. * and we set the offset field correctly. Then we let the CPU to
  581. * restart the faulting instruction.
  582. */
  583. if (tss->io_bitmap_base == INVALID_IO_BITMAP_OFFSET_LAZY &&
  584. thread->io_bitmap_ptr) {
  585. memcpy(tss->io_bitmap, thread->io_bitmap_ptr,
  586. thread->io_bitmap_max);
  587. /*
  588. * If the previously set map was extending to higher ports
  589. * than the current one, pad extra space with 0xff (no access).
  590. */
  591. if (thread->io_bitmap_max < tss->io_bitmap_max)
  592. memset((char *) tss->io_bitmap +
  593. thread->io_bitmap_max, 0xff,
  594. tss->io_bitmap_max - thread->io_bitmap_max);
  595. tss->io_bitmap_max = thread->io_bitmap_max;
  596. tss->io_bitmap_base = IO_BITMAP_OFFSET;
  597. tss->io_bitmap_owner = thread;
  598. put_cpu();
  599. return;
  600. }
  601. put_cpu();
  602. current->thread.error_code = error_code;
  603. current->thread.trap_no = 13;
  604. if (regs->eflags & VM_MASK)
  605. goto gp_in_vm86;
  606. if (!user_mode(regs))
  607. goto gp_in_kernel;
  608. current->thread.error_code = error_code;
  609. current->thread.trap_no = 13;
  610. force_sig(SIGSEGV, current);
  611. return;
  612. gp_in_vm86:
  613. local_irq_enable();
  614. handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
  615. return;
  616. gp_in_kernel:
  617. if (!fixup_exception(regs)) {
  618. if (notify_die(DIE_GPF, "general protection fault", regs,
  619. error_code, 13, SIGSEGV) == NOTIFY_STOP)
  620. return;
  621. die("general protection fault", regs, error_code);
  622. }
  623. }
  624. static __kprobes void
  625. mem_parity_error(unsigned char reason, struct pt_regs * regs)
  626. {
  627. printk(KERN_EMERG "Uhhuh. NMI received for unknown reason %02x on "
  628. "CPU %d.\n", reason, smp_processor_id());
  629. printk(KERN_EMERG "You have some hardware problem, likely on the PCI bus.\n");
  630. if (panic_on_unrecovered_nmi)
  631. panic("NMI: Not continuing");
  632. printk(KERN_EMERG "Dazed and confused, but trying to continue\n");
  633. /* Clear and disable the memory parity error line. */
  634. clear_mem_error(reason);
  635. }
  636. static __kprobes void
  637. io_check_error(unsigned char reason, struct pt_regs * regs)
  638. {
  639. unsigned long i;
  640. printk(KERN_EMERG "NMI: IOCK error (debug interrupt?)\n");
  641. show_registers(regs);
  642. /* Re-enable the IOCK line, wait for a few seconds */
  643. reason = (reason & 0xf) | 8;
  644. outb(reason, 0x61);
  645. i = 2000;
  646. while (--i) udelay(1000);
  647. reason &= ~8;
  648. outb(reason, 0x61);
  649. }
  650. static __kprobes void
  651. unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
  652. {
  653. #ifdef CONFIG_MCA
  654. /* Might actually be able to figure out what the guilty party
  655. * is. */
  656. if( MCA_bus ) {
  657. mca_handle_nmi();
  658. return;
  659. }
  660. #endif
  661. printk(KERN_EMERG "Uhhuh. NMI received for unknown reason %02x on "
  662. "CPU %d.\n", reason, smp_processor_id());
  663. printk(KERN_EMERG "Do you have a strange power saving mode enabled?\n");
  664. if (panic_on_unrecovered_nmi)
  665. panic("NMI: Not continuing");
  666. printk(KERN_EMERG "Dazed and confused, but trying to continue\n");
  667. }
  668. static DEFINE_SPINLOCK(nmi_print_lock);
  669. void __kprobes die_nmi(struct pt_regs *regs, const char *msg)
  670. {
  671. if (notify_die(DIE_NMIWATCHDOG, msg, regs, 0, 2, SIGINT) ==
  672. NOTIFY_STOP)
  673. return;
  674. spin_lock(&nmi_print_lock);
  675. /*
  676. * We are in trouble anyway, lets at least try
  677. * to get a message out.
  678. */
  679. bust_spinlocks(1);
  680. printk(KERN_EMERG "%s", msg);
  681. printk(" on CPU%d, eip %08lx, registers:\n",
  682. smp_processor_id(), regs->eip);
  683. show_registers(regs);
  684. console_silent();
  685. spin_unlock(&nmi_print_lock);
  686. bust_spinlocks(0);
  687. /* If we are in kernel we are probably nested up pretty bad
  688. * and might aswell get out now while we still can.
  689. */
  690. if (!user_mode_vm(regs)) {
  691. current->thread.trap_no = 2;
  692. crash_kexec(regs);
  693. }
  694. do_exit(SIGSEGV);
  695. }
  696. static __kprobes void default_do_nmi(struct pt_regs * regs)
  697. {
  698. unsigned char reason = 0;
  699. /* Only the BSP gets external NMIs from the system. */
  700. if (!smp_processor_id())
  701. reason = get_nmi_reason();
  702. if (!(reason & 0xc0)) {
  703. if (notify_die(DIE_NMI_IPI, "nmi_ipi", regs, reason, 2, SIGINT)
  704. == NOTIFY_STOP)
  705. return;
  706. #ifdef CONFIG_X86_LOCAL_APIC
  707. /*
  708. * Ok, so this is none of the documented NMI sources,
  709. * so it must be the NMI watchdog.
  710. */
  711. if (nmi_watchdog_tick(regs, reason))
  712. return;
  713. if (!do_nmi_callback(regs, smp_processor_id()))
  714. #endif
  715. unknown_nmi_error(reason, regs);
  716. return;
  717. }
  718. if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT) == NOTIFY_STOP)
  719. return;
  720. if (reason & 0x80)
  721. mem_parity_error(reason, regs);
  722. if (reason & 0x40)
  723. io_check_error(reason, regs);
  724. /*
  725. * Reassert NMI in case it became active meanwhile
  726. * as it's edge-triggered.
  727. */
  728. reassert_nmi();
  729. }
  730. fastcall __kprobes void do_nmi(struct pt_regs * regs, long error_code)
  731. {
  732. int cpu;
  733. nmi_enter();
  734. cpu = smp_processor_id();
  735. ++nmi_count(cpu);
  736. default_do_nmi(regs);
  737. nmi_exit();
  738. }
  739. #ifdef CONFIG_KPROBES
  740. fastcall void __kprobes do_int3(struct pt_regs *regs, long error_code)
  741. {
  742. if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP)
  743. == NOTIFY_STOP)
  744. return;
  745. /* This is an interrupt gate, because kprobes wants interrupts
  746. disabled. Normal trap handlers don't. */
  747. restore_interrupts(regs);
  748. do_trap(3, SIGTRAP, "int3", 1, regs, error_code, NULL);
  749. }
  750. #endif
  751. /*
  752. * Our handling of the processor debug registers is non-trivial.
  753. * We do not clear them on entry and exit from the kernel. Therefore
  754. * it is possible to get a watchpoint trap here from inside the kernel.
  755. * However, the code in ./ptrace.c has ensured that the user can
  756. * only set watchpoints on userspace addresses. Therefore the in-kernel
  757. * watchpoint trap can only occur in code which is reading/writing
  758. * from user space. Such code must not hold kernel locks (since it
  759. * can equally take a page fault), therefore it is safe to call
  760. * force_sig_info even though that claims and releases locks.
  761. *
  762. * Code in ./signal.c ensures that the debug control register
  763. * is restored before we deliver any signal, and therefore that
  764. * user code runs with the correct debug control register even though
  765. * we clear it here.
  766. *
  767. * Being careful here means that we don't have to be as careful in a
  768. * lot of more complicated places (task switching can be a bit lazy
  769. * about restoring all the debug state, and ptrace doesn't have to
  770. * find every occurrence of the TF bit that could be saved away even
  771. * by user code)
  772. */
  773. fastcall void __kprobes do_debug(struct pt_regs * regs, long error_code)
  774. {
  775. unsigned int condition;
  776. struct task_struct *tsk = current;
  777. get_debugreg(condition, 6);
  778. if (notify_die(DIE_DEBUG, "debug", regs, condition, error_code,
  779. SIGTRAP) == NOTIFY_STOP)
  780. return;
  781. /* It's safe to allow irq's after DR6 has been saved */
  782. if (regs->eflags & X86_EFLAGS_IF)
  783. local_irq_enable();
  784. /* Mask out spurious debug traps due to lazy DR7 setting */
  785. if (condition & (DR_TRAP0|DR_TRAP1|DR_TRAP2|DR_TRAP3)) {
  786. if (!tsk->thread.debugreg[7])
  787. goto clear_dr7;
  788. }
  789. if (regs->eflags & VM_MASK)
  790. goto debug_vm86;
  791. /* Save debug status register where ptrace can see it */
  792. tsk->thread.debugreg[6] = condition;
  793. /*
  794. * Single-stepping through TF: make sure we ignore any events in
  795. * kernel space (but re-enable TF when returning to user mode).
  796. */
  797. if (condition & DR_STEP) {
  798. /*
  799. * We already checked v86 mode above, so we can
  800. * check for kernel mode by just checking the CPL
  801. * of CS.
  802. */
  803. if (!user_mode(regs))
  804. goto clear_TF_reenable;
  805. }
  806. /* Ok, finally something we can handle */
  807. send_sigtrap(tsk, regs, error_code);
  808. /* Disable additional traps. They'll be re-enabled when
  809. * the signal is delivered.
  810. */
  811. clear_dr7:
  812. set_debugreg(0, 7);
  813. return;
  814. debug_vm86:
  815. handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code, 1);
  816. return;
  817. clear_TF_reenable:
  818. set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
  819. regs->eflags &= ~TF_MASK;
  820. return;
  821. }
  822. /*
  823. * Note that we play around with the 'TS' bit in an attempt to get
  824. * the correct behaviour even in the presence of the asynchronous
  825. * IRQ13 behaviour
  826. */
  827. void math_error(void __user *eip)
  828. {
  829. struct task_struct * task;
  830. siginfo_t info;
  831. unsigned short cwd, swd;
  832. /*
  833. * Save the info for the exception handler and clear the error.
  834. */
  835. task = current;
  836. save_init_fpu(task);
  837. task->thread.trap_no = 16;
  838. task->thread.error_code = 0;
  839. info.si_signo = SIGFPE;
  840. info.si_errno = 0;
  841. info.si_code = __SI_FAULT;
  842. info.si_addr = eip;
  843. /*
  844. * (~cwd & swd) will mask out exceptions that are not set to unmasked
  845. * status. 0x3f is the exception bits in these regs, 0x200 is the
  846. * C1 reg you need in case of a stack fault, 0x040 is the stack
  847. * fault bit. We should only be taking one exception at a time,
  848. * so if this combination doesn't produce any single exception,
  849. * then we have a bad program that isn't syncronizing its FPU usage
  850. * and it will suffer the consequences since we won't be able to
  851. * fully reproduce the context of the exception
  852. */
  853. cwd = get_fpu_cwd(task);
  854. swd = get_fpu_swd(task);
  855. switch (swd & ~cwd & 0x3f) {
  856. case 0x000: /* No unmasked exception */
  857. return;
  858. default: /* Multiple exceptions */
  859. break;
  860. case 0x001: /* Invalid Op */
  861. /*
  862. * swd & 0x240 == 0x040: Stack Underflow
  863. * swd & 0x240 == 0x240: Stack Overflow
  864. * User must clear the SF bit (0x40) if set
  865. */
  866. info.si_code = FPE_FLTINV;
  867. break;
  868. case 0x002: /* Denormalize */
  869. case 0x010: /* Underflow */
  870. info.si_code = FPE_FLTUND;
  871. break;
  872. case 0x004: /* Zero Divide */
  873. info.si_code = FPE_FLTDIV;
  874. break;
  875. case 0x008: /* Overflow */
  876. info.si_code = FPE_FLTOVF;
  877. break;
  878. case 0x020: /* Precision */
  879. info.si_code = FPE_FLTRES;
  880. break;
  881. }
  882. force_sig_info(SIGFPE, &info, task);
  883. }
  884. fastcall void do_coprocessor_error(struct pt_regs * regs, long error_code)
  885. {
  886. ignore_fpu_irq = 1;
  887. math_error((void __user *)regs->eip);
  888. }
  889. static void simd_math_error(void __user *eip)
  890. {
  891. struct task_struct * task;
  892. siginfo_t info;
  893. unsigned short mxcsr;
  894. /*
  895. * Save the info for the exception handler and clear the error.
  896. */
  897. task = current;
  898. save_init_fpu(task);
  899. task->thread.trap_no = 19;
  900. task->thread.error_code = 0;
  901. info.si_signo = SIGFPE;
  902. info.si_errno = 0;
  903. info.si_code = __SI_FAULT;
  904. info.si_addr = eip;
  905. /*
  906. * The SIMD FPU exceptions are handled a little differently, as there
  907. * is only a single status/control register. Thus, to determine which
  908. * unmasked exception was caught we must mask the exception mask bits
  909. * at 0x1f80, and then use these to mask the exception bits at 0x3f.
  910. */
  911. mxcsr = get_fpu_mxcsr(task);
  912. switch (~((mxcsr & 0x1f80) >> 7) & (mxcsr & 0x3f)) {
  913. case 0x000:
  914. default:
  915. break;
  916. case 0x001: /* Invalid Op */
  917. info.si_code = FPE_FLTINV;
  918. break;
  919. case 0x002: /* Denormalize */
  920. case 0x010: /* Underflow */
  921. info.si_code = FPE_FLTUND;
  922. break;
  923. case 0x004: /* Zero Divide */
  924. info.si_code = FPE_FLTDIV;
  925. break;
  926. case 0x008: /* Overflow */
  927. info.si_code = FPE_FLTOVF;
  928. break;
  929. case 0x020: /* Precision */
  930. info.si_code = FPE_FLTRES;
  931. break;
  932. }
  933. force_sig_info(SIGFPE, &info, task);
  934. }
  935. fastcall void do_simd_coprocessor_error(struct pt_regs * regs,
  936. long error_code)
  937. {
  938. if (cpu_has_xmm) {
  939. /* Handle SIMD FPU exceptions on PIII+ processors. */
  940. ignore_fpu_irq = 1;
  941. simd_math_error((void __user *)regs->eip);
  942. } else {
  943. /*
  944. * Handle strange cache flush from user space exception
  945. * in all other cases. This is undocumented behaviour.
  946. */
  947. if (regs->eflags & VM_MASK) {
  948. handle_vm86_fault((struct kernel_vm86_regs *)regs,
  949. error_code);
  950. return;
  951. }
  952. current->thread.trap_no = 19;
  953. current->thread.error_code = error_code;
  954. die_if_kernel("cache flush denied", regs, error_code);
  955. force_sig(SIGSEGV, current);
  956. }
  957. }
  958. fastcall void do_spurious_interrupt_bug(struct pt_regs * regs,
  959. long error_code)
  960. {
  961. #if 0
  962. /* No need to warn about this any longer. */
  963. printk("Ignoring P6 Local APIC Spurious Interrupt Bug...\n");
  964. #endif
  965. }
  966. fastcall unsigned long patch_espfix_desc(unsigned long uesp,
  967. unsigned long kesp)
  968. {
  969. int cpu = smp_processor_id();
  970. struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu);
  971. struct desc_struct *gdt = (struct desc_struct *)cpu_gdt_descr->address;
  972. unsigned long base = (kesp - uesp) & -THREAD_SIZE;
  973. unsigned long new_kesp = kesp - base;
  974. unsigned long lim_pages = (new_kesp | (THREAD_SIZE - 1)) >> PAGE_SHIFT;
  975. __u64 desc = *(__u64 *)&gdt[GDT_ENTRY_ESPFIX_SS];
  976. /* Set up base for espfix segment */
  977. desc &= 0x00f0ff0000000000ULL;
  978. desc |= ((((__u64)base) << 16) & 0x000000ffffff0000ULL) |
  979. ((((__u64)base) << 32) & 0xff00000000000000ULL) |
  980. ((((__u64)lim_pages) << 32) & 0x000f000000000000ULL) |
  981. (lim_pages & 0xffff);
  982. *(__u64 *)&gdt[GDT_ENTRY_ESPFIX_SS] = desc;
  983. return new_kesp;
  984. }
  985. /*
  986. * 'math_state_restore()' saves the current math information in the
  987. * old math state array, and gets the new ones from the current task
  988. *
  989. * Careful.. There are problems with IBM-designed IRQ13 behaviour.
  990. * Don't touch unless you *really* know how it works.
  991. *
  992. * Must be called with kernel preemption disabled (in this case,
  993. * local interrupts are disabled at the call-site in entry.S).
  994. */
  995. asmlinkage void math_state_restore(void)
  996. {
  997. struct thread_info *thread = current_thread_info();
  998. struct task_struct *tsk = thread->task;
  999. clts(); /* Allow maths ops (or we recurse) */
  1000. if (!tsk_used_math(tsk))
  1001. init_fpu(tsk);
  1002. restore_fpu(tsk);
  1003. thread->status |= TS_USEDFPU; /* So we fnsave on switch_to() */
  1004. tsk->fpu_counter++;
  1005. }
  1006. #ifndef CONFIG_MATH_EMULATION
  1007. asmlinkage void math_emulate(long arg)
  1008. {
  1009. printk(KERN_EMERG "math-emulation not enabled and no coprocessor found.\n");
  1010. printk(KERN_EMERG "killing %s.\n",current->comm);
  1011. force_sig(SIGFPE,current);
  1012. schedule();
  1013. }
  1014. #endif /* CONFIG_MATH_EMULATION */
  1015. #ifdef CONFIG_X86_F00F_BUG
  1016. void __init trap_init_f00f_bug(void)
  1017. {
  1018. __set_fixmap(FIX_F00F_IDT, __pa(&idt_table), PAGE_KERNEL_RO);
  1019. /*
  1020. * Update the IDT descriptor and reload the IDT so that
  1021. * it uses the read-only mapped virtual address.
  1022. */
  1023. idt_descr.address = fix_to_virt(FIX_F00F_IDT);
  1024. load_idt(&idt_descr);
  1025. }
  1026. #endif
  1027. /*
  1028. * This needs to use 'idt_table' rather than 'idt', and
  1029. * thus use the _nonmapped_ version of the IDT, as the
  1030. * Pentium F0 0F bugfix can have resulted in the mapped
  1031. * IDT being write-protected.
  1032. */
  1033. void set_intr_gate(unsigned int n, void *addr)
  1034. {
  1035. _set_gate(n, DESCTYPE_INT, addr, __KERNEL_CS);
  1036. }
  1037. /*
  1038. * This routine sets up an interrupt gate at directory privilege level 3.
  1039. */
  1040. static inline void set_system_intr_gate(unsigned int n, void *addr)
  1041. {
  1042. _set_gate(n, DESCTYPE_INT | DESCTYPE_DPL3, addr, __KERNEL_CS);
  1043. }
  1044. static void __init set_trap_gate(unsigned int n, void *addr)
  1045. {
  1046. _set_gate(n, DESCTYPE_TRAP, addr, __KERNEL_CS);
  1047. }
  1048. static void __init set_system_gate(unsigned int n, void *addr)
  1049. {
  1050. _set_gate(n, DESCTYPE_TRAP | DESCTYPE_DPL3, addr, __KERNEL_CS);
  1051. }
  1052. static void __init set_task_gate(unsigned int n, unsigned int gdt_entry)
  1053. {
  1054. _set_gate(n, DESCTYPE_TASK, (void *)0, (gdt_entry<<3));
  1055. }
  1056. void __init trap_init(void)
  1057. {
  1058. #ifdef CONFIG_EISA
  1059. void __iomem *p = ioremap(0x0FFFD9, 4);
  1060. if (readl(p) == 'E'+('I'<<8)+('S'<<16)+('A'<<24)) {
  1061. EISA_bus = 1;
  1062. }
  1063. iounmap(p);
  1064. #endif
  1065. #ifdef CONFIG_X86_LOCAL_APIC
  1066. init_apic_mappings();
  1067. #endif
  1068. set_trap_gate(0,&divide_error);
  1069. set_intr_gate(1,&debug);
  1070. set_intr_gate(2,&nmi);
  1071. set_system_intr_gate(3, &int3); /* int3/4 can be called from all */
  1072. set_system_gate(4,&overflow);
  1073. set_trap_gate(5,&bounds);
  1074. set_trap_gate(6,&invalid_op);
  1075. set_trap_gate(7,&device_not_available);
  1076. set_task_gate(8,GDT_ENTRY_DOUBLEFAULT_TSS);
  1077. set_trap_gate(9,&coprocessor_segment_overrun);
  1078. set_trap_gate(10,&invalid_TSS);
  1079. set_trap_gate(11,&segment_not_present);
  1080. set_trap_gate(12,&stack_segment);
  1081. set_trap_gate(13,&general_protection);
  1082. set_intr_gate(14,&page_fault);
  1083. set_trap_gate(15,&spurious_interrupt_bug);
  1084. set_trap_gate(16,&coprocessor_error);
  1085. set_trap_gate(17,&alignment_check);
  1086. #ifdef CONFIG_X86_MCE
  1087. set_trap_gate(18,&machine_check);
  1088. #endif
  1089. set_trap_gate(19,&simd_coprocessor_error);
  1090. if (cpu_has_fxsr) {
  1091. /*
  1092. * Verify that the FXSAVE/FXRSTOR data will be 16-byte aligned.
  1093. * Generates a compile-time "error: zero width for bit-field" if
  1094. * the alignment is wrong.
  1095. */
  1096. struct fxsrAlignAssert {
  1097. int _:!(offsetof(struct task_struct,
  1098. thread.i387.fxsave) & 15);
  1099. };
  1100. printk(KERN_INFO "Enabling fast FPU save and restore... ");
  1101. set_in_cr4(X86_CR4_OSFXSR);
  1102. printk("done.\n");
  1103. }
  1104. if (cpu_has_xmm) {
  1105. printk(KERN_INFO "Enabling unmasked SIMD FPU exception "
  1106. "support... ");
  1107. set_in_cr4(X86_CR4_OSXMMEXCPT);
  1108. printk("done.\n");
  1109. }
  1110. set_system_gate(SYSCALL_VECTOR,&system_call);
  1111. /*
  1112. * Should be a barrier for any external CPU state.
  1113. */
  1114. cpu_init();
  1115. trap_init_hook();
  1116. }
  1117. static int __init kstack_setup(char *s)
  1118. {
  1119. kstack_depth_to_print = simple_strtoul(s, NULL, 0);
  1120. return 1;
  1121. }
  1122. __setup("kstack=", kstack_setup);
  1123. #ifdef CONFIG_STACK_UNWIND
  1124. static int __init call_trace_setup(char *s)
  1125. {
  1126. if (strcmp(s, "old") == 0)
  1127. call_trace = -1;
  1128. else if (strcmp(s, "both") == 0)
  1129. call_trace = 0;
  1130. else if (strcmp(s, "newfallback") == 0)
  1131. call_trace = 1;
  1132. else if (strcmp(s, "new") == 2)
  1133. call_trace = 2;
  1134. return 1;
  1135. }
  1136. __setup("call_trace=", call_trace_setup);
  1137. #endif