traps.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Architecture-specific trap handling.
  4. *
  5. * Copyright (C) 1998-2003 Hewlett-Packard Co
  6. * David Mosberger-Tang <davidm@hpl.hp.com>
  7. *
  8. * 05/12/00 grao <goutham.rao@intel.com> : added isr in siginfo for SIGFPE
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/sched/signal.h>
  13. #include <linux/sched/debug.h>
  14. #include <linux/tty.h>
  15. #include <linux/vt_kern.h> /* For unblank_screen() */
  16. #include <linux/export.h>
  17. #include <linux/extable.h>
  18. #include <linux/hardirq.h>
  19. #include <linux/kprobes.h>
  20. #include <linux/delay.h> /* for ssleep() */
  21. #include <linux/kdebug.h>
  22. #include <linux/uaccess.h>
  23. #include <asm/fpswa.h>
  24. #include <asm/intrinsics.h>
  25. #include <asm/processor.h>
  26. #include <asm/exception.h>
  27. #include <asm/setup.h>
  28. fpswa_interface_t *fpswa_interface;
  29. EXPORT_SYMBOL(fpswa_interface);
  30. void __init
  31. trap_init (void)
  32. {
  33. if (ia64_boot_param->fpswa)
  34. /* FPSWA fixup: make the interface pointer a kernel virtual address: */
  35. fpswa_interface = __va(ia64_boot_param->fpswa);
  36. }
  37. int
  38. die (const char *str, struct pt_regs *regs, long err)
  39. {
  40. static struct {
  41. spinlock_t lock;
  42. u32 lock_owner;
  43. int lock_owner_depth;
  44. } die = {
  45. .lock = __SPIN_LOCK_UNLOCKED(die.lock),
  46. .lock_owner = -1,
  47. .lock_owner_depth = 0
  48. };
  49. static int die_counter;
  50. int cpu = get_cpu();
  51. if (die.lock_owner != cpu) {
  52. console_verbose();
  53. spin_lock_irq(&die.lock);
  54. die.lock_owner = cpu;
  55. die.lock_owner_depth = 0;
  56. bust_spinlocks(1);
  57. }
  58. put_cpu();
  59. if (++die.lock_owner_depth < 3) {
  60. printk("%s[%d]: %s %ld [%d]\n",
  61. current->comm, task_pid_nr(current), str, err, ++die_counter);
  62. if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
  63. != NOTIFY_STOP)
  64. show_regs(regs);
  65. else
  66. regs = NULL;
  67. } else
  68. printk(KERN_ERR "Recursive die() failure, output suppressed\n");
  69. bust_spinlocks(0);
  70. die.lock_owner = -1;
  71. add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
  72. spin_unlock_irq(&die.lock);
  73. if (!regs)
  74. return 1;
  75. if (panic_on_oops)
  76. panic("Fatal exception");
  77. do_exit(SIGSEGV);
  78. return 0;
  79. }
  80. int
  81. die_if_kernel (char *str, struct pt_regs *regs, long err)
  82. {
  83. if (!user_mode(regs))
  84. return die(str, regs, err);
  85. return 0;
  86. }
  87. void
  88. __kprobes ia64_bad_break (unsigned long break_num, struct pt_regs *regs)
  89. {
  90. siginfo_t siginfo;
  91. int sig, code;
  92. /* SIGILL, SIGFPE, SIGSEGV, and SIGBUS want these field initialized: */
  93. clear_siginfo(&siginfo);
  94. siginfo.si_addr = (void __user *) (regs->cr_iip + ia64_psr(regs)->ri);
  95. siginfo.si_imm = break_num;
  96. siginfo.si_flags = 0; /* clear __ISR_VALID */
  97. siginfo.si_isr = 0;
  98. switch (break_num) {
  99. case 0: /* unknown error (used by GCC for __builtin_abort()) */
  100. if (notify_die(DIE_BREAK, "break 0", regs, break_num, TRAP_BRKPT, SIGTRAP)
  101. == NOTIFY_STOP)
  102. return;
  103. if (die_if_kernel("bugcheck!", regs, break_num))
  104. return;
  105. sig = SIGILL; code = ILL_ILLOPC;
  106. break;
  107. case 1: /* integer divide by zero */
  108. sig = SIGFPE; code = FPE_INTDIV;
  109. break;
  110. case 2: /* integer overflow */
  111. sig = SIGFPE; code = FPE_INTOVF;
  112. break;
  113. case 3: /* range check/bounds check */
  114. sig = SIGFPE; code = FPE_FLTSUB;
  115. break;
  116. case 4: /* null pointer dereference */
  117. sig = SIGSEGV; code = SEGV_MAPERR;
  118. break;
  119. case 5: /* misaligned data */
  120. sig = SIGSEGV; code = BUS_ADRALN;
  121. break;
  122. case 6: /* decimal overflow */
  123. sig = SIGFPE; code = __FPE_DECOVF;
  124. break;
  125. case 7: /* decimal divide by zero */
  126. sig = SIGFPE; code = __FPE_DECDIV;
  127. break;
  128. case 8: /* packed decimal error */
  129. sig = SIGFPE; code = __FPE_DECERR;
  130. break;
  131. case 9: /* invalid ASCII digit */
  132. sig = SIGFPE; code = __FPE_INVASC;
  133. break;
  134. case 10: /* invalid decimal digit */
  135. sig = SIGFPE; code = __FPE_INVDEC;
  136. break;
  137. case 11: /* paragraph stack overflow */
  138. sig = SIGSEGV; code = __SEGV_PSTKOVF;
  139. break;
  140. case 0x3f000 ... 0x3ffff: /* bundle-update in progress */
  141. sig = SIGILL; code = __ILL_BNDMOD;
  142. break;
  143. default:
  144. if ((break_num < 0x40000 || break_num > 0x100000)
  145. && die_if_kernel("Bad break", regs, break_num))
  146. return;
  147. if (break_num < 0x80000) {
  148. sig = SIGILL; code = __ILL_BREAK;
  149. } else {
  150. if (notify_die(DIE_BREAK, "bad break", regs, break_num, TRAP_BRKPT, SIGTRAP)
  151. == NOTIFY_STOP)
  152. return;
  153. sig = SIGTRAP; code = TRAP_BRKPT;
  154. }
  155. }
  156. siginfo.si_signo = sig;
  157. siginfo.si_errno = 0;
  158. siginfo.si_code = code;
  159. force_sig_info(sig, &siginfo, current);
  160. }
  161. /*
  162. * disabled_fph_fault() is called when a user-level process attempts to access f32..f127
  163. * and it doesn't own the fp-high register partition. When this happens, we save the
  164. * current fph partition in the task_struct of the fpu-owner (if necessary) and then load
  165. * the fp-high partition of the current task (if necessary). Note that the kernel has
  166. * access to fph by the time we get here, as the IVT's "Disabled FP-Register" handler takes
  167. * care of clearing psr.dfh.
  168. */
  169. static inline void
  170. disabled_fph_fault (struct pt_regs *regs)
  171. {
  172. struct ia64_psr *psr = ia64_psr(regs);
  173. /* first, grant user-level access to fph partition: */
  174. psr->dfh = 0;
  175. /*
  176. * Make sure that no other task gets in on this processor
  177. * while we're claiming the FPU
  178. */
  179. preempt_disable();
  180. #ifndef CONFIG_SMP
  181. {
  182. struct task_struct *fpu_owner
  183. = (struct task_struct *)ia64_get_kr(IA64_KR_FPU_OWNER);
  184. if (ia64_is_local_fpu_owner(current)) {
  185. preempt_enable_no_resched();
  186. return;
  187. }
  188. if (fpu_owner)
  189. ia64_flush_fph(fpu_owner);
  190. }
  191. #endif /* !CONFIG_SMP */
  192. ia64_set_local_fpu_owner(current);
  193. if ((current->thread.flags & IA64_THREAD_FPH_VALID) != 0) {
  194. __ia64_load_fpu(current->thread.fph);
  195. psr->mfh = 0;
  196. } else {
  197. __ia64_init_fpu();
  198. /*
  199. * Set mfh because the state in thread.fph does not match the state in
  200. * the fph partition.
  201. */
  202. psr->mfh = 1;
  203. }
  204. preempt_enable_no_resched();
  205. }
  206. static inline int
  207. fp_emulate (int fp_fault, void *bundle, long *ipsr, long *fpsr, long *isr, long *pr, long *ifs,
  208. struct pt_regs *regs)
  209. {
  210. fp_state_t fp_state;
  211. fpswa_ret_t ret;
  212. if (!fpswa_interface)
  213. return -1;
  214. memset(&fp_state, 0, sizeof(fp_state_t));
  215. /*
  216. * compute fp_state. only FP registers f6 - f11 are used by the
  217. * kernel, so set those bits in the mask and set the low volatile
  218. * pointer to point to these registers.
  219. */
  220. fp_state.bitmask_low64 = 0xfc0; /* bit6..bit11 */
  221. fp_state.fp_state_low_volatile = (fp_state_low_volatile_t *) &regs->f6;
  222. /*
  223. * unsigned long (*EFI_FPSWA) (
  224. * unsigned long trap_type,
  225. * void *Bundle,
  226. * unsigned long *pipsr,
  227. * unsigned long *pfsr,
  228. * unsigned long *pisr,
  229. * unsigned long *ppreds,
  230. * unsigned long *pifs,
  231. * void *fp_state);
  232. */
  233. ret = (*fpswa_interface->fpswa)((unsigned long) fp_fault, bundle,
  234. (unsigned long *) ipsr, (unsigned long *) fpsr,
  235. (unsigned long *) isr, (unsigned long *) pr,
  236. (unsigned long *) ifs, &fp_state);
  237. return ret.status;
  238. }
  239. struct fpu_swa_msg {
  240. unsigned long count;
  241. unsigned long time;
  242. };
  243. static DEFINE_PER_CPU(struct fpu_swa_msg, cpulast);
  244. DECLARE_PER_CPU(struct fpu_swa_msg, cpulast);
  245. static struct fpu_swa_msg last __cacheline_aligned;
  246. /*
  247. * Handle floating-point assist faults and traps.
  248. */
  249. static int
  250. handle_fpu_swa (int fp_fault, struct pt_regs *regs, unsigned long isr)
  251. {
  252. long exception, bundle[2];
  253. unsigned long fault_ip;
  254. fault_ip = regs->cr_iip;
  255. if (!fp_fault && (ia64_psr(regs)->ri == 0))
  256. fault_ip -= 16;
  257. if (copy_from_user(bundle, (void __user *) fault_ip, sizeof(bundle)))
  258. return -1;
  259. if (!(current->thread.flags & IA64_THREAD_FPEMU_NOPRINT)) {
  260. unsigned long count, current_jiffies = jiffies;
  261. struct fpu_swa_msg *cp = this_cpu_ptr(&cpulast);
  262. if (unlikely(current_jiffies > cp->time))
  263. cp->count = 0;
  264. if (unlikely(cp->count < 5)) {
  265. cp->count++;
  266. cp->time = current_jiffies + 5 * HZ;
  267. /* minimize races by grabbing a copy of count BEFORE checking last.time. */
  268. count = last.count;
  269. barrier();
  270. /*
  271. * Lower 4 bits are used as a count. Upper bits are a sequence
  272. * number that is updated when count is reset. The cmpxchg will
  273. * fail is seqno has changed. This minimizes mutiple cpus
  274. * resetting the count.
  275. */
  276. if (current_jiffies > last.time)
  277. (void) cmpxchg_acq(&last.count, count, 16 + (count & ~15));
  278. /* used fetchadd to atomically update the count */
  279. if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
  280. last.time = current_jiffies + 5 * HZ;
  281. printk(KERN_WARNING
  282. "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
  283. current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
  284. }
  285. }
  286. }
  287. exception = fp_emulate(fp_fault, bundle, &regs->cr_ipsr, &regs->ar_fpsr, &isr, &regs->pr,
  288. &regs->cr_ifs, regs);
  289. if (fp_fault) {
  290. if (exception == 0) {
  291. /* emulation was successful */
  292. ia64_increment_ip(regs);
  293. } else if (exception == -1) {
  294. printk(KERN_ERR "handle_fpu_swa: fp_emulate() returned -1\n");
  295. return -1;
  296. } else {
  297. struct siginfo siginfo;
  298. /* is next instruction a trap? */
  299. if (exception & 2) {
  300. ia64_increment_ip(regs);
  301. }
  302. clear_siginfo(&siginfo);
  303. siginfo.si_signo = SIGFPE;
  304. siginfo.si_errno = 0;
  305. siginfo.si_code = FPE_FLTUNK; /* default code */
  306. siginfo.si_addr = (void __user *) (regs->cr_iip + ia64_psr(regs)->ri);
  307. if (isr & 0x11) {
  308. siginfo.si_code = FPE_FLTINV;
  309. } else if (isr & 0x22) {
  310. /* denormal operand gets the same si_code as underflow
  311. * see arch/i386/kernel/traps.c:math_error() */
  312. siginfo.si_code = FPE_FLTUND;
  313. } else if (isr & 0x44) {
  314. siginfo.si_code = FPE_FLTDIV;
  315. }
  316. siginfo.si_isr = isr;
  317. siginfo.si_flags = __ISR_VALID;
  318. siginfo.si_imm = 0;
  319. force_sig_info(SIGFPE, &siginfo, current);
  320. }
  321. } else {
  322. if (exception == -1) {
  323. printk(KERN_ERR "handle_fpu_swa: fp_emulate() returned -1\n");
  324. return -1;
  325. } else if (exception != 0) {
  326. /* raise exception */
  327. struct siginfo siginfo;
  328. clear_siginfo(&siginfo);
  329. siginfo.si_signo = SIGFPE;
  330. siginfo.si_errno = 0;
  331. siginfo.si_code = FPE_FLTUNK; /* default code */
  332. siginfo.si_addr = (void __user *) (regs->cr_iip + ia64_psr(regs)->ri);
  333. if (isr & 0x880) {
  334. siginfo.si_code = FPE_FLTOVF;
  335. } else if (isr & 0x1100) {
  336. siginfo.si_code = FPE_FLTUND;
  337. } else if (isr & 0x2200) {
  338. siginfo.si_code = FPE_FLTRES;
  339. }
  340. siginfo.si_isr = isr;
  341. siginfo.si_flags = __ISR_VALID;
  342. siginfo.si_imm = 0;
  343. force_sig_info(SIGFPE, &siginfo, current);
  344. }
  345. }
  346. return 0;
  347. }
  348. struct illegal_op_return {
  349. unsigned long fkt, arg1, arg2, arg3;
  350. };
  351. struct illegal_op_return
  352. ia64_illegal_op_fault (unsigned long ec, long arg1, long arg2, long arg3,
  353. long arg4, long arg5, long arg6, long arg7,
  354. struct pt_regs regs)
  355. {
  356. struct illegal_op_return rv;
  357. struct siginfo si;
  358. char buf[128];
  359. #ifdef CONFIG_IA64_BRL_EMU
  360. {
  361. extern struct illegal_op_return ia64_emulate_brl (struct pt_regs *, unsigned long);
  362. rv = ia64_emulate_brl(&regs, ec);
  363. if (rv.fkt != (unsigned long) -1)
  364. return rv;
  365. }
  366. #endif
  367. sprintf(buf, "IA-64 Illegal operation fault");
  368. rv.fkt = 0;
  369. if (die_if_kernel(buf, &regs, 0))
  370. return rv;
  371. clear_siginfo(&si);
  372. si.si_signo = SIGILL;
  373. si.si_code = ILL_ILLOPC;
  374. si.si_addr = (void __user *) (regs.cr_iip + ia64_psr(&regs)->ri);
  375. force_sig_info(SIGILL, &si, current);
  376. return rv;
  377. }
  378. void __kprobes
  379. ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa,
  380. unsigned long iim, unsigned long itir, long arg5, long arg6,
  381. long arg7, struct pt_regs regs)
  382. {
  383. unsigned long code, error = isr, iip;
  384. char buf[128];
  385. int result, sig;
  386. static const char *reason[] = {
  387. "IA-64 Illegal Operation fault",
  388. "IA-64 Privileged Operation fault",
  389. "IA-64 Privileged Register fault",
  390. "IA-64 Reserved Register/Field fault",
  391. "Disabled Instruction Set Transition fault",
  392. "Unknown fault 5", "Unknown fault 6", "Unknown fault 7", "Illegal Hazard fault",
  393. "Unknown fault 9", "Unknown fault 10", "Unknown fault 11", "Unknown fault 12",
  394. "Unknown fault 13", "Unknown fault 14", "Unknown fault 15"
  395. };
  396. if ((isr & IA64_ISR_NA) && ((isr & IA64_ISR_CODE_MASK) == IA64_ISR_CODE_LFETCH)) {
  397. /*
  398. * This fault was due to lfetch.fault, set "ed" bit in the psr to cancel
  399. * the lfetch.
  400. */
  401. ia64_psr(&regs)->ed = 1;
  402. return;
  403. }
  404. iip = regs.cr_iip + ia64_psr(&regs)->ri;
  405. switch (vector) {
  406. case 24: /* General Exception */
  407. code = (isr >> 4) & 0xf;
  408. sprintf(buf, "General Exception: %s%s", reason[code],
  409. (code == 3) ? ((isr & (1UL << 37))
  410. ? " (RSE access)" : " (data access)") : "");
  411. if (code == 8) {
  412. # ifdef CONFIG_IA64_PRINT_HAZARDS
  413. printk("%s[%d]: possible hazard @ ip=%016lx (pr = %016lx)\n",
  414. current->comm, task_pid_nr(current),
  415. regs.cr_iip + ia64_psr(&regs)->ri, regs.pr);
  416. # endif
  417. return;
  418. }
  419. break;
  420. case 25: /* Disabled FP-Register */
  421. if (isr & 2) {
  422. disabled_fph_fault(&regs);
  423. return;
  424. }
  425. sprintf(buf, "Disabled FPL fault---not supposed to happen!");
  426. break;
  427. case 26: /* NaT Consumption */
  428. if (user_mode(&regs)) {
  429. struct siginfo siginfo;
  430. void __user *addr;
  431. if (((isr >> 4) & 0xf) == 2) {
  432. /* NaT page consumption */
  433. sig = SIGSEGV;
  434. code = SEGV_ACCERR;
  435. addr = (void __user *) ifa;
  436. } else {
  437. /* register NaT consumption */
  438. sig = SIGILL;
  439. code = ILL_ILLOPN;
  440. addr = (void __user *) (regs.cr_iip
  441. + ia64_psr(&regs)->ri);
  442. }
  443. clear_siginfo(&siginfo);
  444. siginfo.si_signo = sig;
  445. siginfo.si_code = code;
  446. siginfo.si_errno = 0;
  447. siginfo.si_addr = addr;
  448. siginfo.si_imm = vector;
  449. siginfo.si_flags = __ISR_VALID;
  450. siginfo.si_isr = isr;
  451. force_sig_info(sig, &siginfo, current);
  452. return;
  453. } else if (ia64_done_with_exception(&regs))
  454. return;
  455. sprintf(buf, "NaT consumption");
  456. break;
  457. case 31: /* Unsupported Data Reference */
  458. if (user_mode(&regs)) {
  459. struct siginfo siginfo;
  460. clear_siginfo(&siginfo);
  461. siginfo.si_signo = SIGILL;
  462. siginfo.si_code = ILL_ILLOPN;
  463. siginfo.si_errno = 0;
  464. siginfo.si_addr = (void __user *) iip;
  465. siginfo.si_imm = vector;
  466. siginfo.si_flags = __ISR_VALID;
  467. siginfo.si_isr = isr;
  468. force_sig_info(SIGILL, &siginfo, current);
  469. return;
  470. }
  471. sprintf(buf, "Unsupported data reference");
  472. break;
  473. case 29: /* Debug */
  474. case 35: /* Taken Branch Trap */
  475. case 36: /* Single Step Trap */
  476. {
  477. struct siginfo siginfo;
  478. clear_siginfo(&siginfo);
  479. if (fsys_mode(current, &regs)) {
  480. extern char __kernel_syscall_via_break[];
  481. /*
  482. * Got a trap in fsys-mode: Taken Branch Trap
  483. * and Single Step trap need special handling;
  484. * Debug trap is ignored (we disable it here
  485. * and re-enable it in the lower-privilege trap).
  486. */
  487. if (unlikely(vector == 29)) {
  488. set_thread_flag(TIF_DB_DISABLED);
  489. ia64_psr(&regs)->db = 0;
  490. ia64_psr(&regs)->lp = 1;
  491. return;
  492. }
  493. /* re-do the system call via break 0x100000: */
  494. regs.cr_iip = (unsigned long) __kernel_syscall_via_break;
  495. ia64_psr(&regs)->ri = 0;
  496. ia64_psr(&regs)->cpl = 3;
  497. return;
  498. }
  499. switch (vector) {
  500. default:
  501. case 29:
  502. siginfo.si_code = TRAP_HWBKPT;
  503. #ifdef CONFIG_ITANIUM
  504. /*
  505. * Erratum 10 (IFA may contain incorrect address) now has
  506. * "NoFix" status. There are no plans for fixing this.
  507. */
  508. if (ia64_psr(&regs)->is == 0)
  509. ifa = regs.cr_iip;
  510. #endif
  511. break;
  512. case 35: siginfo.si_code = TRAP_BRANCH; ifa = 0; break;
  513. case 36: siginfo.si_code = TRAP_TRACE; ifa = 0; break;
  514. }
  515. if (notify_die(DIE_FAULT, "ia64_fault", &regs, vector, siginfo.si_code, SIGTRAP)
  516. == NOTIFY_STOP)
  517. return;
  518. siginfo.si_signo = SIGTRAP;
  519. siginfo.si_errno = 0;
  520. siginfo.si_addr = (void __user *) ifa;
  521. siginfo.si_imm = 0;
  522. siginfo.si_flags = __ISR_VALID;
  523. siginfo.si_isr = isr;
  524. force_sig_info(SIGTRAP, &siginfo, current);
  525. return;
  526. }
  527. case 32: /* fp fault */
  528. case 33: /* fp trap */
  529. result = handle_fpu_swa((vector == 32) ? 1 : 0, &regs, isr);
  530. if ((result < 0) || (current->thread.flags & IA64_THREAD_FPEMU_SIGFPE)) {
  531. struct siginfo siginfo;
  532. clear_siginfo(&siginfo);
  533. siginfo.si_signo = SIGFPE;
  534. siginfo.si_errno = 0;
  535. siginfo.si_code = FPE_FLTINV;
  536. siginfo.si_addr = (void __user *) iip;
  537. siginfo.si_flags = __ISR_VALID;
  538. siginfo.si_isr = isr;
  539. siginfo.si_imm = 0;
  540. force_sig_info(SIGFPE, &siginfo, current);
  541. }
  542. return;
  543. case 34:
  544. if (isr & 0x2) {
  545. /* Lower-Privilege Transfer Trap */
  546. /* If we disabled debug traps during an fsyscall,
  547. * re-enable them here.
  548. */
  549. if (test_thread_flag(TIF_DB_DISABLED)) {
  550. clear_thread_flag(TIF_DB_DISABLED);
  551. ia64_psr(&regs)->db = 1;
  552. }
  553. /*
  554. * Just clear PSR.lp and then return immediately:
  555. * all the interesting work (e.g., signal delivery)
  556. * is done in the kernel exit path.
  557. */
  558. ia64_psr(&regs)->lp = 0;
  559. return;
  560. } else {
  561. /* Unimplemented Instr. Address Trap */
  562. if (user_mode(&regs)) {
  563. struct siginfo siginfo;
  564. clear_siginfo(&siginfo);
  565. siginfo.si_signo = SIGILL;
  566. siginfo.si_code = ILL_BADIADDR;
  567. siginfo.si_errno = 0;
  568. siginfo.si_flags = 0;
  569. siginfo.si_isr = 0;
  570. siginfo.si_imm = 0;
  571. siginfo.si_addr = (void __user *) iip;
  572. force_sig_info(SIGILL, &siginfo, current);
  573. return;
  574. }
  575. sprintf(buf, "Unimplemented Instruction Address fault");
  576. }
  577. break;
  578. case 45:
  579. printk(KERN_ERR "Unexpected IA-32 exception (Trap 45)\n");
  580. printk(KERN_ERR " iip - 0x%lx, ifa - 0x%lx, isr - 0x%lx\n",
  581. iip, ifa, isr);
  582. force_sig(SIGSEGV, current);
  583. return;
  584. case 46:
  585. printk(KERN_ERR "Unexpected IA-32 intercept trap (Trap 46)\n");
  586. printk(KERN_ERR " iip - 0x%lx, ifa - 0x%lx, isr - 0x%lx, iim - 0x%lx\n",
  587. iip, ifa, isr, iim);
  588. force_sig(SIGSEGV, current);
  589. return;
  590. case 47:
  591. sprintf(buf, "IA-32 Interruption Fault (int 0x%lx)", isr >> 16);
  592. break;
  593. default:
  594. sprintf(buf, "Fault %lu", vector);
  595. break;
  596. }
  597. if (!die_if_kernel(buf, &regs, error))
  598. force_sig(SIGILL, current);
  599. }