traps.c 32 KB

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