process.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. /*
  2. * Copyright 2010 Tilera Corporation. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation, version 2.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  11. * NON INFRINGEMENT. See the GNU General Public License for
  12. * more details.
  13. */
  14. #include <linux/sched.h>
  15. #include <linux/preempt.h>
  16. #include <linux/module.h>
  17. #include <linux/fs.h>
  18. #include <linux/kprobes.h>
  19. #include <linux/elfcore.h>
  20. #include <linux/tick.h>
  21. #include <linux/init.h>
  22. #include <linux/mm.h>
  23. #include <linux/compat.h>
  24. #include <linux/hardirq.h>
  25. #include <linux/syscalls.h>
  26. #include <linux/kernel.h>
  27. #include <linux/tracehook.h>
  28. #include <linux/signal.h>
  29. #include <linux/context_tracking.h>
  30. #include <asm/stack.h>
  31. #include <asm/switch_to.h>
  32. #include <asm/homecache.h>
  33. #include <asm/syscalls.h>
  34. #include <asm/traps.h>
  35. #include <asm/setup.h>
  36. #include <asm/uaccess.h>
  37. #ifdef CONFIG_HARDWALL
  38. #include <asm/hardwall.h>
  39. #endif
  40. #include <arch/chip.h>
  41. #include <arch/abi.h>
  42. #include <arch/sim_def.h>
  43. /*
  44. * Use the (x86) "idle=poll" option to prefer low latency when leaving the
  45. * idle loop over low power while in the idle loop, e.g. if we have
  46. * one thread per core and we want to get threads out of futex waits fast.
  47. */
  48. static int __init idle_setup(char *str)
  49. {
  50. if (!str)
  51. return -EINVAL;
  52. if (!strcmp(str, "poll")) {
  53. pr_info("using polling idle threads\n");
  54. cpu_idle_poll_ctrl(true);
  55. return 0;
  56. } else if (!strcmp(str, "halt")) {
  57. return 0;
  58. }
  59. return -1;
  60. }
  61. early_param("idle", idle_setup);
  62. void arch_cpu_idle(void)
  63. {
  64. __this_cpu_write(irq_stat.idle_timestamp, jiffies);
  65. _cpu_idle();
  66. }
  67. /*
  68. * Release a thread_info structure
  69. */
  70. void arch_release_thread_info(struct thread_info *info)
  71. {
  72. struct single_step_state *step_state = info->step_state;
  73. if (step_state) {
  74. /*
  75. * FIXME: we don't munmap step_state->buffer
  76. * because the mm_struct for this process (info->task->mm)
  77. * has already been zeroed in exit_mm(). Keeping a
  78. * reference to it here seems like a bad move, so this
  79. * means we can't munmap() the buffer, and therefore if we
  80. * ptrace multiple threads in a process, we will slowly
  81. * leak user memory. (Note that as soon as the last
  82. * thread in a process dies, we will reclaim all user
  83. * memory including single-step buffers in the usual way.)
  84. * We should either assign a kernel VA to this buffer
  85. * somehow, or we should associate the buffer(s) with the
  86. * mm itself so we can clean them up that way.
  87. */
  88. kfree(step_state);
  89. }
  90. }
  91. static void save_arch_state(struct thread_struct *t);
  92. int copy_thread(unsigned long clone_flags, unsigned long sp,
  93. unsigned long arg, struct task_struct *p)
  94. {
  95. struct pt_regs *childregs = task_pt_regs(p);
  96. unsigned long ksp;
  97. unsigned long *callee_regs;
  98. /*
  99. * Set up the stack and stack pointer appropriately for the
  100. * new child to find itself woken up in __switch_to().
  101. * The callee-saved registers must be on the stack to be read;
  102. * the new task will then jump to assembly support to handle
  103. * calling schedule_tail(), etc., and (for userspace tasks)
  104. * returning to the context set up in the pt_regs.
  105. */
  106. ksp = (unsigned long) childregs;
  107. ksp -= C_ABI_SAVE_AREA_SIZE; /* interrupt-entry save area */
  108. ((long *)ksp)[0] = ((long *)ksp)[1] = 0;
  109. ksp -= CALLEE_SAVED_REGS_COUNT * sizeof(unsigned long);
  110. callee_regs = (unsigned long *)ksp;
  111. ksp -= C_ABI_SAVE_AREA_SIZE; /* __switch_to() save area */
  112. ((long *)ksp)[0] = ((long *)ksp)[1] = 0;
  113. p->thread.ksp = ksp;
  114. /* Record the pid of the task that created this one. */
  115. p->thread.creator_pid = current->pid;
  116. if (unlikely(p->flags & PF_KTHREAD)) {
  117. /* kernel thread */
  118. memset(childregs, 0, sizeof(struct pt_regs));
  119. memset(&callee_regs[2], 0,
  120. (CALLEE_SAVED_REGS_COUNT - 2) * sizeof(unsigned long));
  121. callee_regs[0] = sp; /* r30 = function */
  122. callee_regs[1] = arg; /* r31 = arg */
  123. childregs->ex1 = PL_ICS_EX1(KERNEL_PL, 0);
  124. p->thread.pc = (unsigned long) ret_from_kernel_thread;
  125. return 0;
  126. }
  127. /*
  128. * Start new thread in ret_from_fork so it schedules properly
  129. * and then return from interrupt like the parent.
  130. */
  131. p->thread.pc = (unsigned long) ret_from_fork;
  132. /*
  133. * Do not clone step state from the parent; each thread
  134. * must make its own lazily.
  135. */
  136. task_thread_info(p)->step_state = NULL;
  137. #ifdef __tilegx__
  138. /*
  139. * Do not clone unalign jit fixup from the parent; each thread
  140. * must allocate its own on demand.
  141. */
  142. task_thread_info(p)->unalign_jit_base = NULL;
  143. #endif
  144. /*
  145. * Copy the registers onto the kernel stack so the
  146. * return-from-interrupt code will reload it into registers.
  147. */
  148. *childregs = *current_pt_regs();
  149. childregs->regs[0] = 0; /* return value is zero */
  150. if (sp)
  151. childregs->sp = sp; /* override with new user stack pointer */
  152. memcpy(callee_regs, &childregs->regs[CALLEE_SAVED_FIRST_REG],
  153. CALLEE_SAVED_REGS_COUNT * sizeof(unsigned long));
  154. /* Save user stack top pointer so we can ID the stack vm area later. */
  155. p->thread.usp0 = childregs->sp;
  156. /*
  157. * If CLONE_SETTLS is set, set "tp" in the new task to "r4",
  158. * which is passed in as arg #5 to sys_clone().
  159. */
  160. if (clone_flags & CLONE_SETTLS)
  161. childregs->tp = childregs->regs[4];
  162. #if CHIP_HAS_TILE_DMA()
  163. /*
  164. * No DMA in the new thread. We model this on the fact that
  165. * fork() clears the pending signals, alarms, and aio for the child.
  166. */
  167. memset(&p->thread.tile_dma_state, 0, sizeof(struct tile_dma_state));
  168. memset(&p->thread.dma_async_tlb, 0, sizeof(struct async_tlb));
  169. #endif
  170. /* New thread has its miscellaneous processor state bits clear. */
  171. p->thread.proc_status = 0;
  172. #ifdef CONFIG_HARDWALL
  173. /* New thread does not own any networks. */
  174. memset(&p->thread.hardwall[0], 0,
  175. sizeof(struct hardwall_task) * HARDWALL_TYPES);
  176. #endif
  177. /*
  178. * Start the new thread with the current architecture state
  179. * (user interrupt masks, etc.).
  180. */
  181. save_arch_state(&p->thread);
  182. return 0;
  183. }
  184. int set_unalign_ctl(struct task_struct *tsk, unsigned int val)
  185. {
  186. task_thread_info(tsk)->align_ctl = val;
  187. return 0;
  188. }
  189. int get_unalign_ctl(struct task_struct *tsk, unsigned long adr)
  190. {
  191. return put_user(task_thread_info(tsk)->align_ctl,
  192. (unsigned int __user *)adr);
  193. }
  194. static struct task_struct corrupt_current = { .comm = "<corrupt>" };
  195. /*
  196. * Return "current" if it looks plausible, or else a pointer to a dummy.
  197. * This can be helpful if we are just trying to emit a clean panic.
  198. */
  199. struct task_struct *validate_current(void)
  200. {
  201. struct task_struct *tsk = current;
  202. if (unlikely((unsigned long)tsk < PAGE_OFFSET ||
  203. (high_memory && (void *)tsk > high_memory) ||
  204. ((unsigned long)tsk & (__alignof__(*tsk) - 1)) != 0)) {
  205. pr_err("Corrupt 'current' %p (sp %#lx)\n", tsk, stack_pointer);
  206. tsk = &corrupt_current;
  207. }
  208. return tsk;
  209. }
  210. /* Take and return the pointer to the previous task, for schedule_tail(). */
  211. struct task_struct *sim_notify_fork(struct task_struct *prev)
  212. {
  213. struct task_struct *tsk = current;
  214. __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_OS_FORK_PARENT |
  215. (tsk->thread.creator_pid << _SIM_CONTROL_OPERATOR_BITS));
  216. __insn_mtspr(SPR_SIM_CONTROL, SIM_CONTROL_OS_FORK |
  217. (tsk->pid << _SIM_CONTROL_OPERATOR_BITS));
  218. return prev;
  219. }
  220. int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs)
  221. {
  222. struct pt_regs *ptregs = task_pt_regs(tsk);
  223. elf_core_copy_regs(regs, ptregs);
  224. return 1;
  225. }
  226. #if CHIP_HAS_TILE_DMA()
  227. /* Allow user processes to access the DMA SPRs */
  228. void grant_dma_mpls(void)
  229. {
  230. #if CONFIG_KERNEL_PL == 2
  231. __insn_mtspr(SPR_MPL_DMA_CPL_SET_1, 1);
  232. __insn_mtspr(SPR_MPL_DMA_NOTIFY_SET_1, 1);
  233. #else
  234. __insn_mtspr(SPR_MPL_DMA_CPL_SET_0, 1);
  235. __insn_mtspr(SPR_MPL_DMA_NOTIFY_SET_0, 1);
  236. #endif
  237. }
  238. /* Forbid user processes from accessing the DMA SPRs */
  239. void restrict_dma_mpls(void)
  240. {
  241. #if CONFIG_KERNEL_PL == 2
  242. __insn_mtspr(SPR_MPL_DMA_CPL_SET_2, 1);
  243. __insn_mtspr(SPR_MPL_DMA_NOTIFY_SET_2, 1);
  244. #else
  245. __insn_mtspr(SPR_MPL_DMA_CPL_SET_1, 1);
  246. __insn_mtspr(SPR_MPL_DMA_NOTIFY_SET_1, 1);
  247. #endif
  248. }
  249. /* Pause the DMA engine, then save off its state registers. */
  250. static void save_tile_dma_state(struct tile_dma_state *dma)
  251. {
  252. unsigned long state = __insn_mfspr(SPR_DMA_USER_STATUS);
  253. unsigned long post_suspend_state;
  254. /* If we're running, suspend the engine. */
  255. if ((state & DMA_STATUS_MASK) == SPR_DMA_STATUS__RUNNING_MASK)
  256. __insn_mtspr(SPR_DMA_CTR, SPR_DMA_CTR__SUSPEND_MASK);
  257. /*
  258. * Wait for the engine to idle, then save regs. Note that we
  259. * want to record the "running" bit from before suspension,
  260. * and the "done" bit from after, so that we can properly
  261. * distinguish a case where the user suspended the engine from
  262. * the case where the kernel suspended as part of the context
  263. * swap.
  264. */
  265. do {
  266. post_suspend_state = __insn_mfspr(SPR_DMA_USER_STATUS);
  267. } while (post_suspend_state & SPR_DMA_STATUS__BUSY_MASK);
  268. dma->src = __insn_mfspr(SPR_DMA_SRC_ADDR);
  269. dma->src_chunk = __insn_mfspr(SPR_DMA_SRC_CHUNK_ADDR);
  270. dma->dest = __insn_mfspr(SPR_DMA_DST_ADDR);
  271. dma->dest_chunk = __insn_mfspr(SPR_DMA_DST_CHUNK_ADDR);
  272. dma->strides = __insn_mfspr(SPR_DMA_STRIDE);
  273. dma->chunk_size = __insn_mfspr(SPR_DMA_CHUNK_SIZE);
  274. dma->byte = __insn_mfspr(SPR_DMA_BYTE);
  275. dma->status = (state & SPR_DMA_STATUS__RUNNING_MASK) |
  276. (post_suspend_state & SPR_DMA_STATUS__DONE_MASK);
  277. }
  278. /* Restart a DMA that was running before we were context-switched out. */
  279. static void restore_tile_dma_state(struct thread_struct *t)
  280. {
  281. const struct tile_dma_state *dma = &t->tile_dma_state;
  282. /*
  283. * The only way to restore the done bit is to run a zero
  284. * length transaction.
  285. */
  286. if ((dma->status & SPR_DMA_STATUS__DONE_MASK) &&
  287. !(__insn_mfspr(SPR_DMA_USER_STATUS) & SPR_DMA_STATUS__DONE_MASK)) {
  288. __insn_mtspr(SPR_DMA_BYTE, 0);
  289. __insn_mtspr(SPR_DMA_CTR, SPR_DMA_CTR__REQUEST_MASK);
  290. while (__insn_mfspr(SPR_DMA_USER_STATUS) &
  291. SPR_DMA_STATUS__BUSY_MASK)
  292. ;
  293. }
  294. __insn_mtspr(SPR_DMA_SRC_ADDR, dma->src);
  295. __insn_mtspr(SPR_DMA_SRC_CHUNK_ADDR, dma->src_chunk);
  296. __insn_mtspr(SPR_DMA_DST_ADDR, dma->dest);
  297. __insn_mtspr(SPR_DMA_DST_CHUNK_ADDR, dma->dest_chunk);
  298. __insn_mtspr(SPR_DMA_STRIDE, dma->strides);
  299. __insn_mtspr(SPR_DMA_CHUNK_SIZE, dma->chunk_size);
  300. __insn_mtspr(SPR_DMA_BYTE, dma->byte);
  301. /*
  302. * Restart the engine if we were running and not done.
  303. * Clear a pending async DMA fault that we were waiting on return
  304. * to user space to execute, since we expect the DMA engine
  305. * to regenerate those faults for us now. Note that we don't
  306. * try to clear the TIF_ASYNC_TLB flag, since it's relatively
  307. * harmless if set, and it covers both DMA and the SN processor.
  308. */
  309. if ((dma->status & DMA_STATUS_MASK) == SPR_DMA_STATUS__RUNNING_MASK) {
  310. t->dma_async_tlb.fault_num = 0;
  311. __insn_mtspr(SPR_DMA_CTR, SPR_DMA_CTR__REQUEST_MASK);
  312. }
  313. }
  314. #endif
  315. static void save_arch_state(struct thread_struct *t)
  316. {
  317. #if CHIP_HAS_SPLIT_INTR_MASK()
  318. t->interrupt_mask = __insn_mfspr(SPR_INTERRUPT_MASK_0_0) |
  319. ((u64)__insn_mfspr(SPR_INTERRUPT_MASK_0_1) << 32);
  320. #else
  321. t->interrupt_mask = __insn_mfspr(SPR_INTERRUPT_MASK_0);
  322. #endif
  323. t->ex_context[0] = __insn_mfspr(SPR_EX_CONTEXT_0_0);
  324. t->ex_context[1] = __insn_mfspr(SPR_EX_CONTEXT_0_1);
  325. t->system_save[0] = __insn_mfspr(SPR_SYSTEM_SAVE_0_0);
  326. t->system_save[1] = __insn_mfspr(SPR_SYSTEM_SAVE_0_1);
  327. t->system_save[2] = __insn_mfspr(SPR_SYSTEM_SAVE_0_2);
  328. t->system_save[3] = __insn_mfspr(SPR_SYSTEM_SAVE_0_3);
  329. t->intctrl_0 = __insn_mfspr(SPR_INTCTRL_0_STATUS);
  330. t->proc_status = __insn_mfspr(SPR_PROC_STATUS);
  331. #if !CHIP_HAS_FIXED_INTVEC_BASE()
  332. t->interrupt_vector_base = __insn_mfspr(SPR_INTERRUPT_VECTOR_BASE_0);
  333. #endif
  334. t->tile_rtf_hwm = __insn_mfspr(SPR_TILE_RTF_HWM);
  335. #if CHIP_HAS_DSTREAM_PF()
  336. t->dstream_pf = __insn_mfspr(SPR_DSTREAM_PF);
  337. #endif
  338. }
  339. static void restore_arch_state(const struct thread_struct *t)
  340. {
  341. #if CHIP_HAS_SPLIT_INTR_MASK()
  342. __insn_mtspr(SPR_INTERRUPT_MASK_0_0, (u32) t->interrupt_mask);
  343. __insn_mtspr(SPR_INTERRUPT_MASK_0_1, t->interrupt_mask >> 32);
  344. #else
  345. __insn_mtspr(SPR_INTERRUPT_MASK_0, t->interrupt_mask);
  346. #endif
  347. __insn_mtspr(SPR_EX_CONTEXT_0_0, t->ex_context[0]);
  348. __insn_mtspr(SPR_EX_CONTEXT_0_1, t->ex_context[1]);
  349. __insn_mtspr(SPR_SYSTEM_SAVE_0_0, t->system_save[0]);
  350. __insn_mtspr(SPR_SYSTEM_SAVE_0_1, t->system_save[1]);
  351. __insn_mtspr(SPR_SYSTEM_SAVE_0_2, t->system_save[2]);
  352. __insn_mtspr(SPR_SYSTEM_SAVE_0_3, t->system_save[3]);
  353. __insn_mtspr(SPR_INTCTRL_0_STATUS, t->intctrl_0);
  354. __insn_mtspr(SPR_PROC_STATUS, t->proc_status);
  355. #if !CHIP_HAS_FIXED_INTVEC_BASE()
  356. __insn_mtspr(SPR_INTERRUPT_VECTOR_BASE_0, t->interrupt_vector_base);
  357. #endif
  358. __insn_mtspr(SPR_TILE_RTF_HWM, t->tile_rtf_hwm);
  359. #if CHIP_HAS_DSTREAM_PF()
  360. __insn_mtspr(SPR_DSTREAM_PF, t->dstream_pf);
  361. #endif
  362. }
  363. void _prepare_arch_switch(struct task_struct *next)
  364. {
  365. #if CHIP_HAS_TILE_DMA()
  366. struct tile_dma_state *dma = &current->thread.tile_dma_state;
  367. if (dma->enabled)
  368. save_tile_dma_state(dma);
  369. #endif
  370. }
  371. struct task_struct *__sched _switch_to(struct task_struct *prev,
  372. struct task_struct *next)
  373. {
  374. /* DMA state is already saved; save off other arch state. */
  375. save_arch_state(&prev->thread);
  376. #if CHIP_HAS_TILE_DMA()
  377. /*
  378. * Restore DMA in new task if desired.
  379. * Note that it is only safe to restart here since interrupts
  380. * are disabled, so we can't take any DMATLB miss or access
  381. * interrupts before we have finished switching stacks.
  382. */
  383. if (next->thread.tile_dma_state.enabled) {
  384. restore_tile_dma_state(&next->thread);
  385. grant_dma_mpls();
  386. } else {
  387. restrict_dma_mpls();
  388. }
  389. #endif
  390. /* Restore other arch state. */
  391. restore_arch_state(&next->thread);
  392. #ifdef CONFIG_HARDWALL
  393. /* Enable or disable access to the network registers appropriately. */
  394. hardwall_switch_tasks(prev, next);
  395. #endif
  396. /*
  397. * Switch kernel SP, PC, and callee-saved registers.
  398. * In the context of the new task, return the old task pointer
  399. * (i.e. the task that actually called __switch_to).
  400. * Pass the value to use for SYSTEM_SAVE_K_0 when we reset our sp.
  401. */
  402. return __switch_to(prev, next, next_current_ksp0(next));
  403. }
  404. /*
  405. * This routine is called on return from interrupt if any of the
  406. * TIF_WORK_MASK flags are set in thread_info->flags. It is
  407. * entered with interrupts disabled so we don't miss an event
  408. * that modified the thread_info flags. If any flag is set, we
  409. * handle it and return, and the calling assembly code will
  410. * re-disable interrupts, reload the thread flags, and call back
  411. * if more flags need to be handled.
  412. *
  413. * We return whether we need to check the thread_info flags again
  414. * or not. Note that we don't clear TIF_SINGLESTEP here, so it's
  415. * important that it be tested last, and then claim that we don't
  416. * need to recheck the flags.
  417. */
  418. int do_work_pending(struct pt_regs *regs, u32 thread_info_flags)
  419. {
  420. /* If we enter in kernel mode, do nothing and exit the caller loop. */
  421. if (!user_mode(regs))
  422. return 0;
  423. user_exit();
  424. /* Enable interrupts; they are disabled again on return to caller. */
  425. local_irq_enable();
  426. if (thread_info_flags & _TIF_NEED_RESCHED) {
  427. schedule();
  428. return 1;
  429. }
  430. #if CHIP_HAS_TILE_DMA()
  431. if (thread_info_flags & _TIF_ASYNC_TLB) {
  432. do_async_page_fault(regs);
  433. return 1;
  434. }
  435. #endif
  436. if (thread_info_flags & _TIF_SIGPENDING) {
  437. do_signal(regs);
  438. return 1;
  439. }
  440. if (thread_info_flags & _TIF_NOTIFY_RESUME) {
  441. clear_thread_flag(TIF_NOTIFY_RESUME);
  442. tracehook_notify_resume(regs);
  443. return 1;
  444. }
  445. if (thread_info_flags & _TIF_SINGLESTEP)
  446. single_step_once(regs);
  447. user_enter();
  448. return 0;
  449. }
  450. unsigned long get_wchan(struct task_struct *p)
  451. {
  452. struct KBacktraceIterator kbt;
  453. if (!p || p == current || p->state == TASK_RUNNING)
  454. return 0;
  455. for (KBacktraceIterator_init(&kbt, p, NULL);
  456. !KBacktraceIterator_end(&kbt);
  457. KBacktraceIterator_next(&kbt)) {
  458. if (!in_sched_functions(kbt.it.pc))
  459. return kbt.it.pc;
  460. }
  461. return 0;
  462. }
  463. /* Flush thread state. */
  464. void flush_thread(void)
  465. {
  466. /* Nothing */
  467. }
  468. /*
  469. * Free current thread data structures etc..
  470. */
  471. void exit_thread(void)
  472. {
  473. #ifdef CONFIG_HARDWALL
  474. /*
  475. * Remove the task from the list of tasks that are associated
  476. * with any live hardwalls. (If the task that is exiting held
  477. * the last reference to a hardwall fd, it would already have
  478. * been released and deactivated at this point.)
  479. */
  480. hardwall_deactivate_all(current);
  481. #endif
  482. }
  483. void show_regs(struct pt_regs *regs)
  484. {
  485. struct task_struct *tsk = validate_current();
  486. int i;
  487. if (tsk != &corrupt_current)
  488. show_regs_print_info(KERN_ERR);
  489. #ifdef __tilegx__
  490. for (i = 0; i < 17; i++)
  491. pr_err(" r%-2d: " REGFMT " r%-2d: " REGFMT " r%-2d: " REGFMT "\n",
  492. i, regs->regs[i], i+18, regs->regs[i+18],
  493. i+36, regs->regs[i+36]);
  494. pr_err(" r17: " REGFMT " r35: " REGFMT " tp : " REGFMT "\n",
  495. regs->regs[17], regs->regs[35], regs->tp);
  496. pr_err(" sp : " REGFMT " lr : " REGFMT "\n", regs->sp, regs->lr);
  497. #else
  498. for (i = 0; i < 13; i++)
  499. pr_err(" r%-2d: " REGFMT " r%-2d: " REGFMT " r%-2d: " REGFMT " r%-2d: " REGFMT "\n",
  500. i, regs->regs[i], i+14, regs->regs[i+14],
  501. i+27, regs->regs[i+27], i+40, regs->regs[i+40]);
  502. pr_err(" r13: " REGFMT " tp : " REGFMT " sp : " REGFMT " lr : " REGFMT "\n",
  503. regs->regs[13], regs->tp, regs->sp, regs->lr);
  504. #endif
  505. pr_err(" pc : " REGFMT " ex1: %ld faultnum: %ld\n",
  506. regs->pc, regs->ex1, regs->faultnum);
  507. dump_stack_regs(regs);
  508. }