traps.c 32 KB

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