process_64.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. /*
  2. * arch/sh/kernel/process_64.c
  3. *
  4. * This file handles the architecture-dependent parts of process handling..
  5. *
  6. * Copyright (C) 2000, 2001 Paolo Alberelli
  7. * Copyright (C) 2003 - 2007 Paul Mundt
  8. * Copyright (C) 2003, 2004 Richard Curnow
  9. *
  10. * Started from SH3/4 version:
  11. * Copyright (C) 1999, 2000 Niibe Yutaka & Kaz Kojima
  12. *
  13. * In turn started from i386 version:
  14. * Copyright (C) 1995 Linus Torvalds
  15. *
  16. * This file is subject to the terms and conditions of the GNU General Public
  17. * License. See the file "COPYING" in the main directory of this archive
  18. * for more details.
  19. */
  20. #include <linux/mm.h>
  21. #include <linux/fs.h>
  22. #include <linux/ptrace.h>
  23. #include <linux/reboot.h>
  24. #include <linux/slab.h>
  25. #include <linux/init.h>
  26. #include <linux/module.h>
  27. #include <linux/io.h>
  28. #include <asm/syscalls.h>
  29. #include <asm/uaccess.h>
  30. #include <asm/pgtable.h>
  31. #include <asm/mmu_context.h>
  32. #include <asm/fpu.h>
  33. struct task_struct *last_task_used_math = NULL;
  34. void show_regs(struct pt_regs *regs)
  35. {
  36. unsigned long long ah, al, bh, bl, ch, cl;
  37. printk("\n");
  38. ah = (regs->pc) >> 32;
  39. al = (regs->pc) & 0xffffffff;
  40. bh = (regs->regs[18]) >> 32;
  41. bl = (regs->regs[18]) & 0xffffffff;
  42. ch = (regs->regs[15]) >> 32;
  43. cl = (regs->regs[15]) & 0xffffffff;
  44. printk("PC : %08Lx%08Lx LINK: %08Lx%08Lx SP : %08Lx%08Lx\n",
  45. ah, al, bh, bl, ch, cl);
  46. ah = (regs->sr) >> 32;
  47. al = (regs->sr) & 0xffffffff;
  48. asm volatile ("getcon " __TEA ", %0" : "=r" (bh));
  49. asm volatile ("getcon " __TEA ", %0" : "=r" (bl));
  50. bh = (bh) >> 32;
  51. bl = (bl) & 0xffffffff;
  52. asm volatile ("getcon " __KCR0 ", %0" : "=r" (ch));
  53. asm volatile ("getcon " __KCR0 ", %0" : "=r" (cl));
  54. ch = (ch) >> 32;
  55. cl = (cl) & 0xffffffff;
  56. printk("SR : %08Lx%08Lx TEA : %08Lx%08Lx KCR0: %08Lx%08Lx\n",
  57. ah, al, bh, bl, ch, cl);
  58. ah = (regs->regs[0]) >> 32;
  59. al = (regs->regs[0]) & 0xffffffff;
  60. bh = (regs->regs[1]) >> 32;
  61. bl = (regs->regs[1]) & 0xffffffff;
  62. ch = (regs->regs[2]) >> 32;
  63. cl = (regs->regs[2]) & 0xffffffff;
  64. printk("R0 : %08Lx%08Lx R1 : %08Lx%08Lx R2 : %08Lx%08Lx\n",
  65. ah, al, bh, bl, ch, cl);
  66. ah = (regs->regs[3]) >> 32;
  67. al = (regs->regs[3]) & 0xffffffff;
  68. bh = (regs->regs[4]) >> 32;
  69. bl = (regs->regs[4]) & 0xffffffff;
  70. ch = (regs->regs[5]) >> 32;
  71. cl = (regs->regs[5]) & 0xffffffff;
  72. printk("R3 : %08Lx%08Lx R4 : %08Lx%08Lx R5 : %08Lx%08Lx\n",
  73. ah, al, bh, bl, ch, cl);
  74. ah = (regs->regs[6]) >> 32;
  75. al = (regs->regs[6]) & 0xffffffff;
  76. bh = (regs->regs[7]) >> 32;
  77. bl = (regs->regs[7]) & 0xffffffff;
  78. ch = (regs->regs[8]) >> 32;
  79. cl = (regs->regs[8]) & 0xffffffff;
  80. printk("R6 : %08Lx%08Lx R7 : %08Lx%08Lx R8 : %08Lx%08Lx\n",
  81. ah, al, bh, bl, ch, cl);
  82. ah = (regs->regs[9]) >> 32;
  83. al = (regs->regs[9]) & 0xffffffff;
  84. bh = (regs->regs[10]) >> 32;
  85. bl = (regs->regs[10]) & 0xffffffff;
  86. ch = (regs->regs[11]) >> 32;
  87. cl = (regs->regs[11]) & 0xffffffff;
  88. printk("R9 : %08Lx%08Lx R10 : %08Lx%08Lx R11 : %08Lx%08Lx\n",
  89. ah, al, bh, bl, ch, cl);
  90. ah = (regs->regs[12]) >> 32;
  91. al = (regs->regs[12]) & 0xffffffff;
  92. bh = (regs->regs[13]) >> 32;
  93. bl = (regs->regs[13]) & 0xffffffff;
  94. ch = (regs->regs[14]) >> 32;
  95. cl = (regs->regs[14]) & 0xffffffff;
  96. printk("R12 : %08Lx%08Lx R13 : %08Lx%08Lx R14 : %08Lx%08Lx\n",
  97. ah, al, bh, bl, ch, cl);
  98. ah = (regs->regs[16]) >> 32;
  99. al = (regs->regs[16]) & 0xffffffff;
  100. bh = (regs->regs[17]) >> 32;
  101. bl = (regs->regs[17]) & 0xffffffff;
  102. ch = (regs->regs[19]) >> 32;
  103. cl = (regs->regs[19]) & 0xffffffff;
  104. printk("R16 : %08Lx%08Lx R17 : %08Lx%08Lx R19 : %08Lx%08Lx\n",
  105. ah, al, bh, bl, ch, cl);
  106. ah = (regs->regs[20]) >> 32;
  107. al = (regs->regs[20]) & 0xffffffff;
  108. bh = (regs->regs[21]) >> 32;
  109. bl = (regs->regs[21]) & 0xffffffff;
  110. ch = (regs->regs[22]) >> 32;
  111. cl = (regs->regs[22]) & 0xffffffff;
  112. printk("R20 : %08Lx%08Lx R21 : %08Lx%08Lx R22 : %08Lx%08Lx\n",
  113. ah, al, bh, bl, ch, cl);
  114. ah = (regs->regs[23]) >> 32;
  115. al = (regs->regs[23]) & 0xffffffff;
  116. bh = (regs->regs[24]) >> 32;
  117. bl = (regs->regs[24]) & 0xffffffff;
  118. ch = (regs->regs[25]) >> 32;
  119. cl = (regs->regs[25]) & 0xffffffff;
  120. printk("R23 : %08Lx%08Lx R24 : %08Lx%08Lx R25 : %08Lx%08Lx\n",
  121. ah, al, bh, bl, ch, cl);
  122. ah = (regs->regs[26]) >> 32;
  123. al = (regs->regs[26]) & 0xffffffff;
  124. bh = (regs->regs[27]) >> 32;
  125. bl = (regs->regs[27]) & 0xffffffff;
  126. ch = (regs->regs[28]) >> 32;
  127. cl = (regs->regs[28]) & 0xffffffff;
  128. printk("R26 : %08Lx%08Lx R27 : %08Lx%08Lx R28 : %08Lx%08Lx\n",
  129. ah, al, bh, bl, ch, cl);
  130. ah = (regs->regs[29]) >> 32;
  131. al = (regs->regs[29]) & 0xffffffff;
  132. bh = (regs->regs[30]) >> 32;
  133. bl = (regs->regs[30]) & 0xffffffff;
  134. ch = (regs->regs[31]) >> 32;
  135. cl = (regs->regs[31]) & 0xffffffff;
  136. printk("R29 : %08Lx%08Lx R30 : %08Lx%08Lx R31 : %08Lx%08Lx\n",
  137. ah, al, bh, bl, ch, cl);
  138. ah = (regs->regs[32]) >> 32;
  139. al = (regs->regs[32]) & 0xffffffff;
  140. bh = (regs->regs[33]) >> 32;
  141. bl = (regs->regs[33]) & 0xffffffff;
  142. ch = (regs->regs[34]) >> 32;
  143. cl = (regs->regs[34]) & 0xffffffff;
  144. printk("R32 : %08Lx%08Lx R33 : %08Lx%08Lx R34 : %08Lx%08Lx\n",
  145. ah, al, bh, bl, ch, cl);
  146. ah = (regs->regs[35]) >> 32;
  147. al = (regs->regs[35]) & 0xffffffff;
  148. bh = (regs->regs[36]) >> 32;
  149. bl = (regs->regs[36]) & 0xffffffff;
  150. ch = (regs->regs[37]) >> 32;
  151. cl = (regs->regs[37]) & 0xffffffff;
  152. printk("R35 : %08Lx%08Lx R36 : %08Lx%08Lx R37 : %08Lx%08Lx\n",
  153. ah, al, bh, bl, ch, cl);
  154. ah = (regs->regs[38]) >> 32;
  155. al = (regs->regs[38]) & 0xffffffff;
  156. bh = (regs->regs[39]) >> 32;
  157. bl = (regs->regs[39]) & 0xffffffff;
  158. ch = (regs->regs[40]) >> 32;
  159. cl = (regs->regs[40]) & 0xffffffff;
  160. printk("R38 : %08Lx%08Lx R39 : %08Lx%08Lx R40 : %08Lx%08Lx\n",
  161. ah, al, bh, bl, ch, cl);
  162. ah = (regs->regs[41]) >> 32;
  163. al = (regs->regs[41]) & 0xffffffff;
  164. bh = (regs->regs[42]) >> 32;
  165. bl = (regs->regs[42]) & 0xffffffff;
  166. ch = (regs->regs[43]) >> 32;
  167. cl = (regs->regs[43]) & 0xffffffff;
  168. printk("R41 : %08Lx%08Lx R42 : %08Lx%08Lx R43 : %08Lx%08Lx\n",
  169. ah, al, bh, bl, ch, cl);
  170. ah = (regs->regs[44]) >> 32;
  171. al = (regs->regs[44]) & 0xffffffff;
  172. bh = (regs->regs[45]) >> 32;
  173. bl = (regs->regs[45]) & 0xffffffff;
  174. ch = (regs->regs[46]) >> 32;
  175. cl = (regs->regs[46]) & 0xffffffff;
  176. printk("R44 : %08Lx%08Lx R45 : %08Lx%08Lx R46 : %08Lx%08Lx\n",
  177. ah, al, bh, bl, ch, cl);
  178. ah = (regs->regs[47]) >> 32;
  179. al = (regs->regs[47]) & 0xffffffff;
  180. bh = (regs->regs[48]) >> 32;
  181. bl = (regs->regs[48]) & 0xffffffff;
  182. ch = (regs->regs[49]) >> 32;
  183. cl = (regs->regs[49]) & 0xffffffff;
  184. printk("R47 : %08Lx%08Lx R48 : %08Lx%08Lx R49 : %08Lx%08Lx\n",
  185. ah, al, bh, bl, ch, cl);
  186. ah = (regs->regs[50]) >> 32;
  187. al = (regs->regs[50]) & 0xffffffff;
  188. bh = (regs->regs[51]) >> 32;
  189. bl = (regs->regs[51]) & 0xffffffff;
  190. ch = (regs->regs[52]) >> 32;
  191. cl = (regs->regs[52]) & 0xffffffff;
  192. printk("R50 : %08Lx%08Lx R51 : %08Lx%08Lx R52 : %08Lx%08Lx\n",
  193. ah, al, bh, bl, ch, cl);
  194. ah = (regs->regs[53]) >> 32;
  195. al = (regs->regs[53]) & 0xffffffff;
  196. bh = (regs->regs[54]) >> 32;
  197. bl = (regs->regs[54]) & 0xffffffff;
  198. ch = (regs->regs[55]) >> 32;
  199. cl = (regs->regs[55]) & 0xffffffff;
  200. printk("R53 : %08Lx%08Lx R54 : %08Lx%08Lx R55 : %08Lx%08Lx\n",
  201. ah, al, bh, bl, ch, cl);
  202. ah = (regs->regs[56]) >> 32;
  203. al = (regs->regs[56]) & 0xffffffff;
  204. bh = (regs->regs[57]) >> 32;
  205. bl = (regs->regs[57]) & 0xffffffff;
  206. ch = (regs->regs[58]) >> 32;
  207. cl = (regs->regs[58]) & 0xffffffff;
  208. printk("R56 : %08Lx%08Lx R57 : %08Lx%08Lx R58 : %08Lx%08Lx\n",
  209. ah, al, bh, bl, ch, cl);
  210. ah = (regs->regs[59]) >> 32;
  211. al = (regs->regs[59]) & 0xffffffff;
  212. bh = (regs->regs[60]) >> 32;
  213. bl = (regs->regs[60]) & 0xffffffff;
  214. ch = (regs->regs[61]) >> 32;
  215. cl = (regs->regs[61]) & 0xffffffff;
  216. printk("R59 : %08Lx%08Lx R60 : %08Lx%08Lx R61 : %08Lx%08Lx\n",
  217. ah, al, bh, bl, ch, cl);
  218. ah = (regs->regs[62]) >> 32;
  219. al = (regs->regs[62]) & 0xffffffff;
  220. bh = (regs->tregs[0]) >> 32;
  221. bl = (regs->tregs[0]) & 0xffffffff;
  222. ch = (regs->tregs[1]) >> 32;
  223. cl = (regs->tregs[1]) & 0xffffffff;
  224. printk("R62 : %08Lx%08Lx T0 : %08Lx%08Lx T1 : %08Lx%08Lx\n",
  225. ah, al, bh, bl, ch, cl);
  226. ah = (regs->tregs[2]) >> 32;
  227. al = (regs->tregs[2]) & 0xffffffff;
  228. bh = (regs->tregs[3]) >> 32;
  229. bl = (regs->tregs[3]) & 0xffffffff;
  230. ch = (regs->tregs[4]) >> 32;
  231. cl = (regs->tregs[4]) & 0xffffffff;
  232. printk("T2 : %08Lx%08Lx T3 : %08Lx%08Lx T4 : %08Lx%08Lx\n",
  233. ah, al, bh, bl, ch, cl);
  234. ah = (regs->tregs[5]) >> 32;
  235. al = (regs->tregs[5]) & 0xffffffff;
  236. bh = (regs->tregs[6]) >> 32;
  237. bl = (regs->tregs[6]) & 0xffffffff;
  238. ch = (regs->tregs[7]) >> 32;
  239. cl = (regs->tregs[7]) & 0xffffffff;
  240. printk("T5 : %08Lx%08Lx T6 : %08Lx%08Lx T7 : %08Lx%08Lx\n",
  241. ah, al, bh, bl, ch, cl);
  242. /*
  243. * If we're in kernel mode, dump the stack too..
  244. */
  245. if (!user_mode(regs)) {
  246. void show_stack(struct task_struct *tsk, unsigned long *sp);
  247. unsigned long sp = regs->regs[15] & 0xffffffff;
  248. struct task_struct *tsk = get_current();
  249. tsk->thread.kregs = regs;
  250. show_stack(tsk, (unsigned long *)sp);
  251. }
  252. }
  253. /*
  254. * Create a kernel thread
  255. */
  256. ATTRIB_NORET void kernel_thread_helper(void *arg, int (*fn)(void *))
  257. {
  258. do_exit(fn(arg));
  259. }
  260. /*
  261. * This is the mechanism for creating a new kernel thread.
  262. *
  263. * NOTE! Only a kernel-only process(ie the swapper or direct descendants
  264. * who haven't done an "execve()") should use this: it will work within
  265. * a system call from a "real" process, but the process memory space will
  266. * not be freed until both the parent and the child have exited.
  267. */
  268. int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
  269. {
  270. struct pt_regs regs;
  271. memset(&regs, 0, sizeof(regs));
  272. regs.regs[2] = (unsigned long)arg;
  273. regs.regs[3] = (unsigned long)fn;
  274. regs.pc = (unsigned long)kernel_thread_helper;
  275. regs.sr = (1 << 30);
  276. /* Ok, create the new process.. */
  277. return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
  278. &regs, 0, NULL, NULL);
  279. }
  280. EXPORT_SYMBOL(kernel_thread);
  281. /*
  282. * Free current thread data structures etc..
  283. */
  284. void exit_thread(void)
  285. {
  286. /*
  287. * See arch/sparc/kernel/process.c for the precedent for doing
  288. * this -- RPC.
  289. *
  290. * The SH-5 FPU save/restore approach relies on
  291. * last_task_used_math pointing to a live task_struct. When
  292. * another task tries to use the FPU for the 1st time, the FPUDIS
  293. * trap handling (see arch/sh/kernel/cpu/sh5/fpu.c) will save the
  294. * existing FPU state to the FP regs field within
  295. * last_task_used_math before re-loading the new task's FPU state
  296. * (or initialising it if the FPU has been used before). So if
  297. * last_task_used_math is stale, and its page has already been
  298. * re-allocated for another use, the consequences are rather
  299. * grim. Unless we null it here, there is no other path through
  300. * which it would get safely nulled.
  301. */
  302. #ifdef CONFIG_SH_FPU
  303. if (last_task_used_math == current) {
  304. last_task_used_math = NULL;
  305. }
  306. #endif
  307. }
  308. void flush_thread(void)
  309. {
  310. /* Called by fs/exec.c (setup_new_exec) to remove traces of a
  311. * previously running executable. */
  312. #ifdef CONFIG_SH_FPU
  313. if (last_task_used_math == current) {
  314. last_task_used_math = NULL;
  315. }
  316. /* Force FPU state to be reinitialised after exec */
  317. clear_used_math();
  318. #endif
  319. /* if we are a kernel thread, about to change to user thread,
  320. * update kreg
  321. */
  322. if(current->thread.kregs==&fake_swapper_regs) {
  323. current->thread.kregs =
  324. ((struct pt_regs *)(THREAD_SIZE + (unsigned long) current) - 1);
  325. current->thread.uregs = current->thread.kregs;
  326. }
  327. }
  328. void release_thread(struct task_struct *dead_task)
  329. {
  330. /* do nothing */
  331. }
  332. /* Fill in the fpu structure for a core dump.. */
  333. int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
  334. {
  335. #ifdef CONFIG_SH_FPU
  336. int fpvalid;
  337. struct task_struct *tsk = current;
  338. fpvalid = !!tsk_used_math(tsk);
  339. if (fpvalid) {
  340. if (current == last_task_used_math) {
  341. enable_fpu();
  342. save_fpu(tsk);
  343. disable_fpu();
  344. last_task_used_math = 0;
  345. regs->sr |= SR_FD;
  346. }
  347. memcpy(fpu, &tsk->thread.xstate->hardfpu, sizeof(*fpu));
  348. }
  349. return fpvalid;
  350. #else
  351. return 0; /* Task didn't use the fpu at all. */
  352. #endif
  353. }
  354. EXPORT_SYMBOL(dump_fpu);
  355. asmlinkage void ret_from_fork(void);
  356. int copy_thread(unsigned long clone_flags, unsigned long usp,
  357. unsigned long unused,
  358. struct task_struct *p, struct pt_regs *regs)
  359. {
  360. struct pt_regs *childregs;
  361. #ifdef CONFIG_SH_FPU
  362. if(last_task_used_math == current) {
  363. enable_fpu();
  364. save_fpu(current);
  365. disable_fpu();
  366. last_task_used_math = NULL;
  367. regs->sr |= SR_FD;
  368. }
  369. #endif
  370. /* Copy from sh version */
  371. childregs = (struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1;
  372. *childregs = *regs;
  373. /*
  374. * Sign extend the edited stack.
  375. * Note that thread.pc and thread.pc will stay
  376. * 32-bit wide and context switch must take care
  377. * of NEFF sign extension.
  378. */
  379. if (user_mode(regs)) {
  380. childregs->regs[15] = neff_sign_extend(usp);
  381. p->thread.uregs = childregs;
  382. } else {
  383. childregs->regs[15] =
  384. neff_sign_extend((unsigned long)task_stack_page(p) +
  385. THREAD_SIZE);
  386. }
  387. childregs->regs[9] = 0; /* Set return value for child */
  388. childregs->sr |= SR_FD; /* Invalidate FPU flag */
  389. p->thread.sp = (unsigned long) childregs;
  390. p->thread.pc = (unsigned long) ret_from_fork;
  391. return 0;
  392. }
  393. asmlinkage int sys_fork(unsigned long r2, unsigned long r3,
  394. unsigned long r4, unsigned long r5,
  395. unsigned long r6, unsigned long r7,
  396. struct pt_regs *pregs)
  397. {
  398. return do_fork(SIGCHLD, pregs->regs[15], pregs, 0, 0, 0);
  399. }
  400. asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
  401. unsigned long r4, unsigned long r5,
  402. unsigned long r6, unsigned long r7,
  403. struct pt_regs *pregs)
  404. {
  405. if (!newsp)
  406. newsp = pregs->regs[15];
  407. return do_fork(clone_flags, newsp, pregs, 0, 0, 0);
  408. }
  409. /*
  410. * This is trivial, and on the face of it looks like it
  411. * could equally well be done in user mode.
  412. *
  413. * Not so, for quite unobvious reasons - register pressure.
  414. * In user mode vfork() cannot have a stack frame, and if
  415. * done by calling the "clone()" system call directly, you
  416. * do not have enough call-clobbered registers to hold all
  417. * the information you need.
  418. */
  419. asmlinkage int sys_vfork(unsigned long r2, unsigned long r3,
  420. unsigned long r4, unsigned long r5,
  421. unsigned long r6, unsigned long r7,
  422. struct pt_regs *pregs)
  423. {
  424. return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, pregs->regs[15], pregs, 0, 0, 0);
  425. }
  426. /*
  427. * sys_execve() executes a new program.
  428. */
  429. asmlinkage int sys_execve(const char *ufilename, char **uargv,
  430. char **uenvp, unsigned long r5,
  431. unsigned long r6, unsigned long r7,
  432. struct pt_regs *pregs)
  433. {
  434. int error;
  435. char *filename;
  436. filename = getname((char __user *)ufilename);
  437. error = PTR_ERR(filename);
  438. if (IS_ERR(filename))
  439. goto out;
  440. error = do_execve(filename,
  441. (const char __user *const __user *)uargv,
  442. (const char __user *const __user *)uenvp,
  443. pregs);
  444. putname(filename);
  445. out:
  446. return error;
  447. }
  448. #ifdef CONFIG_FRAME_POINTER
  449. static int in_sh64_switch_to(unsigned long pc)
  450. {
  451. extern char __sh64_switch_to_end;
  452. /* For a sleeping task, the PC is somewhere in the middle of the function,
  453. so we don't have to worry about masking the LSB off */
  454. return (pc >= (unsigned long) sh64_switch_to) &&
  455. (pc < (unsigned long) &__sh64_switch_to_end);
  456. }
  457. #endif
  458. unsigned long get_wchan(struct task_struct *p)
  459. {
  460. unsigned long pc;
  461. if (!p || p == current || p->state == TASK_RUNNING)
  462. return 0;
  463. /*
  464. * The same comment as on the Alpha applies here, too ...
  465. */
  466. pc = thread_saved_pc(p);
  467. #ifdef CONFIG_FRAME_POINTER
  468. if (in_sh64_switch_to(pc)) {
  469. unsigned long schedule_fp;
  470. unsigned long sh64_switch_to_fp;
  471. unsigned long schedule_caller_pc;
  472. sh64_switch_to_fp = (long) p->thread.sp;
  473. /* r14 is saved at offset 4 in the sh64_switch_to frame */
  474. schedule_fp = *(unsigned long *) (long)(sh64_switch_to_fp + 4);
  475. /* and the caller of 'schedule' is (currently!) saved at offset 24
  476. in the frame of schedule (from disasm) */
  477. schedule_caller_pc = *(unsigned long *) (long)(schedule_fp + 24);
  478. return schedule_caller_pc;
  479. }
  480. #endif
  481. return pc;
  482. }