entry_32.S 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164
  1. /*
  2. * PowerPC version
  3. * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
  4. * Rewritten by Cort Dougan (cort@fsmlabs.com) for PReP
  5. * Copyright (C) 1996 Cort Dougan <cort@fsmlabs.com>
  6. * Adapted for Power Macintosh by Paul Mackerras.
  7. * Low-level exception handlers and MMU support
  8. * rewritten by Paul Mackerras.
  9. * Copyright (C) 1996 Paul Mackerras.
  10. * MPC8xx modifications Copyright (C) 1997 Dan Malek (dmalek@jlc.net).
  11. *
  12. * This file contains the system call entry code, context switch
  13. * code, and exception/interrupt return code for PowerPC.
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License
  17. * as published by the Free Software Foundation; either version
  18. * 2 of the License, or (at your option) any later version.
  19. *
  20. */
  21. #include <linux/errno.h>
  22. #include <linux/sys.h>
  23. #include <linux/threads.h>
  24. #include <asm/reg.h>
  25. #include <asm/page.h>
  26. #include <asm/mmu.h>
  27. #include <asm/cputable.h>
  28. #include <asm/thread_info.h>
  29. #include <asm/ppc_asm.h>
  30. #include <asm/asm-offsets.h>
  31. #include <asm/unistd.h>
  32. #include <asm/ftrace.h>
  33. #undef SHOW_SYSCALLS
  34. #undef SHOW_SYSCALLS_TASK
  35. /*
  36. * MSR_KERNEL is > 0x10000 on 4xx/Book-E since it include MSR_CE.
  37. */
  38. #if MSR_KERNEL >= 0x10000
  39. #define LOAD_MSR_KERNEL(r, x) lis r,(x)@h; ori r,r,(x)@l
  40. #else
  41. #define LOAD_MSR_KERNEL(r, x) li r,(x)
  42. #endif
  43. #ifdef CONFIG_BOOKE
  44. #include "head_booke.h"
  45. #define TRANSFER_TO_HANDLER_EXC_LEVEL(exc_level) \
  46. mtspr exc_level##_SPRG,r8; \
  47. BOOKE_LOAD_EXC_LEVEL_STACK(exc_level); \
  48. lwz r0,GPR10-INT_FRAME_SIZE(r8); \
  49. stw r0,GPR10(r11); \
  50. lwz r0,GPR11-INT_FRAME_SIZE(r8); \
  51. stw r0,GPR11(r11); \
  52. mfspr r8,exc_level##_SPRG
  53. .globl mcheck_transfer_to_handler
  54. mcheck_transfer_to_handler:
  55. TRANSFER_TO_HANDLER_EXC_LEVEL(MCHECK)
  56. b transfer_to_handler_full
  57. .globl debug_transfer_to_handler
  58. debug_transfer_to_handler:
  59. TRANSFER_TO_HANDLER_EXC_LEVEL(DEBUG)
  60. b transfer_to_handler_full
  61. .globl crit_transfer_to_handler
  62. crit_transfer_to_handler:
  63. TRANSFER_TO_HANDLER_EXC_LEVEL(CRIT)
  64. /* fall through */
  65. #endif
  66. #ifdef CONFIG_40x
  67. .globl crit_transfer_to_handler
  68. crit_transfer_to_handler:
  69. lwz r0,crit_r10@l(0)
  70. stw r0,GPR10(r11)
  71. lwz r0,crit_r11@l(0)
  72. stw r0,GPR11(r11)
  73. /* fall through */
  74. #endif
  75. /*
  76. * This code finishes saving the registers to the exception frame
  77. * and jumps to the appropriate handler for the exception, turning
  78. * on address translation.
  79. * Note that we rely on the caller having set cr0.eq iff the exception
  80. * occurred in kernel mode (i.e. MSR:PR = 0).
  81. */
  82. .globl transfer_to_handler_full
  83. transfer_to_handler_full:
  84. SAVE_NVGPRS(r11)
  85. /* fall through */
  86. .globl transfer_to_handler
  87. transfer_to_handler:
  88. stw r2,GPR2(r11)
  89. stw r12,_NIP(r11)
  90. stw r9,_MSR(r11)
  91. andi. r2,r9,MSR_PR
  92. mfctr r12
  93. mfspr r2,SPRN_XER
  94. stw r12,_CTR(r11)
  95. stw r2,_XER(r11)
  96. mfspr r12,SPRN_SPRG3
  97. addi r2,r12,-THREAD
  98. tovirt(r2,r2) /* set r2 to current */
  99. beq 2f /* if from user, fix up THREAD.regs */
  100. addi r11,r1,STACK_FRAME_OVERHEAD
  101. stw r11,PT_REGS(r12)
  102. #if defined(CONFIG_40x) || defined(CONFIG_BOOKE)
  103. /* Check to see if the dbcr0 register is set up to debug. Use the
  104. internal debug mode bit to do this. */
  105. lwz r12,THREAD_DBCR0(r12)
  106. andis. r12,r12,DBCR0_IDM@h
  107. beq+ 3f
  108. /* From user and task is ptraced - load up global dbcr0 */
  109. li r12,-1 /* clear all pending debug events */
  110. mtspr SPRN_DBSR,r12
  111. lis r11,global_dbcr0@ha
  112. tophys(r11,r11)
  113. addi r11,r11,global_dbcr0@l
  114. #ifdef CONFIG_SMP
  115. rlwinm r9,r1,0,0,(31-THREAD_SHIFT)
  116. lwz r9,TI_CPU(r9)
  117. slwi r9,r9,3
  118. add r11,r11,r9
  119. #endif
  120. lwz r12,0(r11)
  121. mtspr SPRN_DBCR0,r12
  122. lwz r12,4(r11)
  123. addi r12,r12,-1
  124. stw r12,4(r11)
  125. #endif
  126. b 3f
  127. 2: /* if from kernel, check interrupted DOZE/NAP mode and
  128. * check for stack overflow
  129. */
  130. lwz r9,KSP_LIMIT(r12)
  131. cmplw r1,r9 /* if r1 <= ksp_limit */
  132. ble- stack_ovf /* then the kernel stack overflowed */
  133. 5:
  134. #ifdef CONFIG_6xx
  135. rlwinm r9,r1,0,0,31-THREAD_SHIFT
  136. tophys(r9,r9) /* check local flags */
  137. lwz r12,TI_LOCAL_FLAGS(r9)
  138. mtcrf 0x01,r12
  139. bt- 31-TLF_NAPPING,4f
  140. #endif /* CONFIG_6xx */
  141. .globl transfer_to_handler_cont
  142. transfer_to_handler_cont:
  143. 3:
  144. mflr r9
  145. lwz r11,0(r9) /* virtual address of handler */
  146. lwz r9,4(r9) /* where to go when done */
  147. mtspr SPRN_SRR0,r11
  148. mtspr SPRN_SRR1,r10
  149. mtlr r9
  150. SYNC
  151. RFI /* jump to handler, enable MMU */
  152. #ifdef CONFIG_6xx
  153. 4: rlwinm r12,r12,0,~_TLF_NAPPING
  154. stw r12,TI_LOCAL_FLAGS(r9)
  155. b power_save_6xx_restore
  156. #endif
  157. /*
  158. * On kernel stack overflow, load up an initial stack pointer
  159. * and call StackOverflow(regs), which should not return.
  160. */
  161. stack_ovf:
  162. /* sometimes we use a statically-allocated stack, which is OK. */
  163. lis r12,_end@h
  164. ori r12,r12,_end@l
  165. cmplw r1,r12
  166. ble 5b /* r1 <= &_end is OK */
  167. SAVE_NVGPRS(r11)
  168. addi r3,r1,STACK_FRAME_OVERHEAD
  169. lis r1,init_thread_union@ha
  170. addi r1,r1,init_thread_union@l
  171. addi r1,r1,THREAD_SIZE-STACK_FRAME_OVERHEAD
  172. lis r9,StackOverflow@ha
  173. addi r9,r9,StackOverflow@l
  174. LOAD_MSR_KERNEL(r10,MSR_KERNEL)
  175. FIX_SRR1(r10,r12)
  176. mtspr SPRN_SRR0,r9
  177. mtspr SPRN_SRR1,r10
  178. SYNC
  179. RFI
  180. /*
  181. * Handle a system call.
  182. */
  183. .stabs "arch/powerpc/kernel/",N_SO,0,0,0f
  184. .stabs "entry_32.S",N_SO,0,0,0f
  185. 0:
  186. _GLOBAL(DoSyscall)
  187. stw r3,ORIG_GPR3(r1)
  188. li r12,0
  189. stw r12,RESULT(r1)
  190. lwz r11,_CCR(r1) /* Clear SO bit in CR */
  191. rlwinm r11,r11,0,4,2
  192. stw r11,_CCR(r1)
  193. #ifdef SHOW_SYSCALLS
  194. bl do_show_syscall
  195. #endif /* SHOW_SYSCALLS */
  196. rlwinm r10,r1,0,0,(31-THREAD_SHIFT) /* current_thread_info() */
  197. lwz r11,TI_FLAGS(r10)
  198. andi. r11,r11,_TIF_SYSCALL_T_OR_A
  199. bne- syscall_dotrace
  200. syscall_dotrace_cont:
  201. cmplwi 0,r0,NR_syscalls
  202. lis r10,sys_call_table@h
  203. ori r10,r10,sys_call_table@l
  204. slwi r0,r0,2
  205. bge- 66f
  206. lwzx r10,r10,r0 /* Fetch system call handler [ptr] */
  207. mtlr r10
  208. addi r9,r1,STACK_FRAME_OVERHEAD
  209. PPC440EP_ERR42
  210. blrl /* Call handler */
  211. .globl ret_from_syscall
  212. ret_from_syscall:
  213. #ifdef SHOW_SYSCALLS
  214. bl do_show_syscall_exit
  215. #endif
  216. mr r6,r3
  217. rlwinm r12,r1,0,0,(31-THREAD_SHIFT) /* current_thread_info() */
  218. /* disable interrupts so current_thread_info()->flags can't change */
  219. LOAD_MSR_KERNEL(r10,MSR_KERNEL) /* doesn't include MSR_EE */
  220. SYNC
  221. MTMSRD(r10)
  222. lwz r9,TI_FLAGS(r12)
  223. li r8,-_LAST_ERRNO
  224. andi. r0,r9,(_TIF_SYSCALL_T_OR_A|_TIF_SINGLESTEP|_TIF_USER_WORK_MASK|_TIF_PERSYSCALL_MASK)
  225. bne- syscall_exit_work
  226. cmplw 0,r3,r8
  227. blt+ syscall_exit_cont
  228. lwz r11,_CCR(r1) /* Load CR */
  229. neg r3,r3
  230. oris r11,r11,0x1000 /* Set SO bit in CR */
  231. stw r11,_CCR(r1)
  232. syscall_exit_cont:
  233. #if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
  234. /* If the process has its own DBCR0 value, load it up. The internal
  235. debug mode bit tells us that dbcr0 should be loaded. */
  236. lwz r0,THREAD+THREAD_DBCR0(r2)
  237. andis. r10,r0,DBCR0_IDM@h
  238. bnel- load_dbcr0
  239. #endif
  240. #ifdef CONFIG_44x
  241. lis r4,icache_44x_need_flush@ha
  242. lwz r5,icache_44x_need_flush@l(r4)
  243. cmplwi cr0,r5,0
  244. bne- 2f
  245. 1:
  246. #endif /* CONFIG_44x */
  247. BEGIN_FTR_SECTION
  248. lwarx r7,0,r1
  249. END_FTR_SECTION_IFSET(CPU_FTR_NEED_PAIRED_STWCX)
  250. stwcx. r0,0,r1 /* to clear the reservation */
  251. lwz r4,_LINK(r1)
  252. lwz r5,_CCR(r1)
  253. mtlr r4
  254. mtcr r5
  255. lwz r7,_NIP(r1)
  256. lwz r8,_MSR(r1)
  257. FIX_SRR1(r8, r0)
  258. lwz r2,GPR2(r1)
  259. lwz r1,GPR1(r1)
  260. mtspr SPRN_SRR0,r7
  261. mtspr SPRN_SRR1,r8
  262. SYNC
  263. RFI
  264. #ifdef CONFIG_44x
  265. 2: li r7,0
  266. iccci r0,r0
  267. stw r7,icache_44x_need_flush@l(r4)
  268. b 1b
  269. #endif /* CONFIG_44x */
  270. 66: li r3,-ENOSYS
  271. b ret_from_syscall
  272. .globl ret_from_fork
  273. ret_from_fork:
  274. REST_NVGPRS(r1)
  275. bl schedule_tail
  276. li r3,0
  277. b ret_from_syscall
  278. /* Traced system call support */
  279. syscall_dotrace:
  280. SAVE_NVGPRS(r1)
  281. li r0,0xc00
  282. stw r0,_TRAP(r1)
  283. addi r3,r1,STACK_FRAME_OVERHEAD
  284. bl do_syscall_trace_enter
  285. lwz r0,GPR0(r1) /* Restore original registers */
  286. lwz r3,GPR3(r1)
  287. lwz r4,GPR4(r1)
  288. lwz r5,GPR5(r1)
  289. lwz r6,GPR6(r1)
  290. lwz r7,GPR7(r1)
  291. lwz r8,GPR8(r1)
  292. REST_NVGPRS(r1)
  293. b syscall_dotrace_cont
  294. syscall_exit_work:
  295. andi. r0,r9,_TIF_RESTOREALL
  296. beq+ 0f
  297. REST_NVGPRS(r1)
  298. b 2f
  299. 0: cmplw 0,r3,r8
  300. blt+ 1f
  301. andi. r0,r9,_TIF_NOERROR
  302. bne- 1f
  303. lwz r11,_CCR(r1) /* Load CR */
  304. neg r3,r3
  305. oris r11,r11,0x1000 /* Set SO bit in CR */
  306. stw r11,_CCR(r1)
  307. 1: stw r6,RESULT(r1) /* Save result */
  308. stw r3,GPR3(r1) /* Update return value */
  309. 2: andi. r0,r9,(_TIF_PERSYSCALL_MASK)
  310. beq 4f
  311. /* Clear per-syscall TIF flags if any are set. */
  312. li r11,_TIF_PERSYSCALL_MASK
  313. addi r12,r12,TI_FLAGS
  314. 3: lwarx r8,0,r12
  315. andc r8,r8,r11
  316. #ifdef CONFIG_IBM405_ERR77
  317. dcbt 0,r12
  318. #endif
  319. stwcx. r8,0,r12
  320. bne- 3b
  321. subi r12,r12,TI_FLAGS
  322. 4: /* Anything which requires enabling interrupts? */
  323. andi. r0,r9,(_TIF_SYSCALL_T_OR_A|_TIF_SINGLESTEP)
  324. beq ret_from_except
  325. /* Re-enable interrupts */
  326. ori r10,r10,MSR_EE
  327. SYNC
  328. MTMSRD(r10)
  329. /* Save NVGPRS if they're not saved already */
  330. lwz r4,_TRAP(r1)
  331. andi. r4,r4,1
  332. beq 5f
  333. SAVE_NVGPRS(r1)
  334. li r4,0xc00
  335. stw r4,_TRAP(r1)
  336. 5:
  337. addi r3,r1,STACK_FRAME_OVERHEAD
  338. bl do_syscall_trace_leave
  339. b ret_from_except_full
  340. #ifdef SHOW_SYSCALLS
  341. do_show_syscall:
  342. #ifdef SHOW_SYSCALLS_TASK
  343. lis r11,show_syscalls_task@ha
  344. lwz r11,show_syscalls_task@l(r11)
  345. cmp 0,r2,r11
  346. bnelr
  347. #endif
  348. stw r31,GPR31(r1)
  349. mflr r31
  350. lis r3,7f@ha
  351. addi r3,r3,7f@l
  352. lwz r4,GPR0(r1)
  353. lwz r5,GPR3(r1)
  354. lwz r6,GPR4(r1)
  355. lwz r7,GPR5(r1)
  356. lwz r8,GPR6(r1)
  357. lwz r9,GPR7(r1)
  358. bl printk
  359. lis r3,77f@ha
  360. addi r3,r3,77f@l
  361. lwz r4,GPR8(r1)
  362. mr r5,r2
  363. bl printk
  364. lwz r0,GPR0(r1)
  365. lwz r3,GPR3(r1)
  366. lwz r4,GPR4(r1)
  367. lwz r5,GPR5(r1)
  368. lwz r6,GPR6(r1)
  369. lwz r7,GPR7(r1)
  370. lwz r8,GPR8(r1)
  371. mtlr r31
  372. lwz r31,GPR31(r1)
  373. blr
  374. do_show_syscall_exit:
  375. #ifdef SHOW_SYSCALLS_TASK
  376. lis r11,show_syscalls_task@ha
  377. lwz r11,show_syscalls_task@l(r11)
  378. cmp 0,r2,r11
  379. bnelr
  380. #endif
  381. stw r31,GPR31(r1)
  382. mflr r31
  383. stw r3,RESULT(r1) /* Save result */
  384. mr r4,r3
  385. lis r3,79f@ha
  386. addi r3,r3,79f@l
  387. bl printk
  388. lwz r3,RESULT(r1)
  389. mtlr r31
  390. lwz r31,GPR31(r1)
  391. blr
  392. 7: .string "syscall %d(%x, %x, %x, %x, %x, "
  393. 77: .string "%x), current=%p\n"
  394. 79: .string " -> %x\n"
  395. .align 2,0
  396. #ifdef SHOW_SYSCALLS_TASK
  397. .data
  398. .globl show_syscalls_task
  399. show_syscalls_task:
  400. .long -1
  401. .text
  402. #endif
  403. #endif /* SHOW_SYSCALLS */
  404. /*
  405. * The fork/clone functions need to copy the full register set into
  406. * the child process. Therefore we need to save all the nonvolatile
  407. * registers (r13 - r31) before calling the C code.
  408. */
  409. .globl ppc_fork
  410. ppc_fork:
  411. SAVE_NVGPRS(r1)
  412. lwz r0,_TRAP(r1)
  413. rlwinm r0,r0,0,0,30 /* clear LSB to indicate full */
  414. stw r0,_TRAP(r1) /* register set saved */
  415. b sys_fork
  416. .globl ppc_vfork
  417. ppc_vfork:
  418. SAVE_NVGPRS(r1)
  419. lwz r0,_TRAP(r1)
  420. rlwinm r0,r0,0,0,30 /* clear LSB to indicate full */
  421. stw r0,_TRAP(r1) /* register set saved */
  422. b sys_vfork
  423. .globl ppc_clone
  424. ppc_clone:
  425. SAVE_NVGPRS(r1)
  426. lwz r0,_TRAP(r1)
  427. rlwinm r0,r0,0,0,30 /* clear LSB to indicate full */
  428. stw r0,_TRAP(r1) /* register set saved */
  429. b sys_clone
  430. .globl ppc_swapcontext
  431. ppc_swapcontext:
  432. SAVE_NVGPRS(r1)
  433. lwz r0,_TRAP(r1)
  434. rlwinm r0,r0,0,0,30 /* clear LSB to indicate full */
  435. stw r0,_TRAP(r1) /* register set saved */
  436. b sys_swapcontext
  437. /*
  438. * Top-level page fault handling.
  439. * This is in assembler because if do_page_fault tells us that
  440. * it is a bad kernel page fault, we want to save the non-volatile
  441. * registers before calling bad_page_fault.
  442. */
  443. .globl handle_page_fault
  444. handle_page_fault:
  445. stw r4,_DAR(r1)
  446. addi r3,r1,STACK_FRAME_OVERHEAD
  447. bl do_page_fault
  448. cmpwi r3,0
  449. beq+ ret_from_except
  450. SAVE_NVGPRS(r1)
  451. lwz r0,_TRAP(r1)
  452. clrrwi r0,r0,1
  453. stw r0,_TRAP(r1)
  454. mr r5,r3
  455. addi r3,r1,STACK_FRAME_OVERHEAD
  456. lwz r4,_DAR(r1)
  457. bl bad_page_fault
  458. b ret_from_except_full
  459. /*
  460. * This routine switches between two different tasks. The process
  461. * state of one is saved on its kernel stack. Then the state
  462. * of the other is restored from its kernel stack. The memory
  463. * management hardware is updated to the second process's state.
  464. * Finally, we can return to the second process.
  465. * On entry, r3 points to the THREAD for the current task, r4
  466. * points to the THREAD for the new task.
  467. *
  468. * This routine is always called with interrupts disabled.
  469. *
  470. * Note: there are two ways to get to the "going out" portion
  471. * of this code; either by coming in via the entry (_switch)
  472. * or via "fork" which must set up an environment equivalent
  473. * to the "_switch" path. If you change this , you'll have to
  474. * change the fork code also.
  475. *
  476. * The code which creates the new task context is in 'copy_thread'
  477. * in arch/ppc/kernel/process.c
  478. */
  479. _GLOBAL(_switch)
  480. stwu r1,-INT_FRAME_SIZE(r1)
  481. mflr r0
  482. stw r0,INT_FRAME_SIZE+4(r1)
  483. /* r3-r12 are caller saved -- Cort */
  484. SAVE_NVGPRS(r1)
  485. stw r0,_NIP(r1) /* Return to switch caller */
  486. mfmsr r11
  487. li r0,MSR_FP /* Disable floating-point */
  488. #ifdef CONFIG_ALTIVEC
  489. BEGIN_FTR_SECTION
  490. oris r0,r0,MSR_VEC@h /* Disable altivec */
  491. mfspr r12,SPRN_VRSAVE /* save vrsave register value */
  492. stw r12,THREAD+THREAD_VRSAVE(r2)
  493. END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
  494. #endif /* CONFIG_ALTIVEC */
  495. #ifdef CONFIG_SPE
  496. BEGIN_FTR_SECTION
  497. oris r0,r0,MSR_SPE@h /* Disable SPE */
  498. mfspr r12,SPRN_SPEFSCR /* save spefscr register value */
  499. stw r12,THREAD+THREAD_SPEFSCR(r2)
  500. END_FTR_SECTION_IFSET(CPU_FTR_SPE)
  501. #endif /* CONFIG_SPE */
  502. and. r0,r0,r11 /* FP or altivec or SPE enabled? */
  503. beq+ 1f
  504. andc r11,r11,r0
  505. MTMSRD(r11)
  506. isync
  507. 1: stw r11,_MSR(r1)
  508. mfcr r10
  509. stw r10,_CCR(r1)
  510. stw r1,KSP(r3) /* Set old stack pointer */
  511. #ifdef CONFIG_SMP
  512. /* We need a sync somewhere here to make sure that if the
  513. * previous task gets rescheduled on another CPU, it sees all
  514. * stores it has performed on this one.
  515. */
  516. sync
  517. #endif /* CONFIG_SMP */
  518. tophys(r0,r4)
  519. CLR_TOP32(r0)
  520. mtspr SPRN_SPRG3,r0 /* Update current THREAD phys addr */
  521. lwz r1,KSP(r4) /* Load new stack pointer */
  522. /* save the old current 'last' for return value */
  523. mr r3,r2
  524. addi r2,r4,-THREAD /* Update current */
  525. #ifdef CONFIG_ALTIVEC
  526. BEGIN_FTR_SECTION
  527. lwz r0,THREAD+THREAD_VRSAVE(r2)
  528. mtspr SPRN_VRSAVE,r0 /* if G4, restore VRSAVE reg */
  529. END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
  530. #endif /* CONFIG_ALTIVEC */
  531. #ifdef CONFIG_SPE
  532. BEGIN_FTR_SECTION
  533. lwz r0,THREAD+THREAD_SPEFSCR(r2)
  534. mtspr SPRN_SPEFSCR,r0 /* restore SPEFSCR reg */
  535. END_FTR_SECTION_IFSET(CPU_FTR_SPE)
  536. #endif /* CONFIG_SPE */
  537. lwz r0,_CCR(r1)
  538. mtcrf 0xFF,r0
  539. /* r3-r12 are destroyed -- Cort */
  540. REST_NVGPRS(r1)
  541. lwz r4,_NIP(r1) /* Return to _switch caller in new task */
  542. mtlr r4
  543. addi r1,r1,INT_FRAME_SIZE
  544. blr
  545. .globl fast_exception_return
  546. fast_exception_return:
  547. #if !(defined(CONFIG_4xx) || defined(CONFIG_BOOKE))
  548. andi. r10,r9,MSR_RI /* check for recoverable interrupt */
  549. beq 1f /* if not, we've got problems */
  550. #endif
  551. 2: REST_4GPRS(3, r11)
  552. lwz r10,_CCR(r11)
  553. REST_GPR(1, r11)
  554. mtcr r10
  555. lwz r10,_LINK(r11)
  556. mtlr r10
  557. REST_GPR(10, r11)
  558. mtspr SPRN_SRR1,r9
  559. mtspr SPRN_SRR0,r12
  560. REST_GPR(9, r11)
  561. REST_GPR(12, r11)
  562. lwz r11,GPR11(r11)
  563. SYNC
  564. RFI
  565. #if !(defined(CONFIG_4xx) || defined(CONFIG_BOOKE))
  566. /* check if the exception happened in a restartable section */
  567. 1: lis r3,exc_exit_restart_end@ha
  568. addi r3,r3,exc_exit_restart_end@l
  569. cmplw r12,r3
  570. bge 3f
  571. lis r4,exc_exit_restart@ha
  572. addi r4,r4,exc_exit_restart@l
  573. cmplw r12,r4
  574. blt 3f
  575. lis r3,fee_restarts@ha
  576. tophys(r3,r3)
  577. lwz r5,fee_restarts@l(r3)
  578. addi r5,r5,1
  579. stw r5,fee_restarts@l(r3)
  580. mr r12,r4 /* restart at exc_exit_restart */
  581. b 2b
  582. .section .bss
  583. .align 2
  584. fee_restarts:
  585. .space 4
  586. .previous
  587. /* aargh, a nonrecoverable interrupt, panic */
  588. /* aargh, we don't know which trap this is */
  589. /* but the 601 doesn't implement the RI bit, so assume it's OK */
  590. 3:
  591. BEGIN_FTR_SECTION
  592. b 2b
  593. END_FTR_SECTION_IFSET(CPU_FTR_601)
  594. li r10,-1
  595. stw r10,_TRAP(r11)
  596. addi r3,r1,STACK_FRAME_OVERHEAD
  597. lis r10,MSR_KERNEL@h
  598. ori r10,r10,MSR_KERNEL@l
  599. bl transfer_to_handler_full
  600. .long nonrecoverable_exception
  601. .long ret_from_except
  602. #endif
  603. .globl ret_from_except_full
  604. ret_from_except_full:
  605. REST_NVGPRS(r1)
  606. /* fall through */
  607. .globl ret_from_except
  608. ret_from_except:
  609. /* Hard-disable interrupts so that current_thread_info()->flags
  610. * can't change between when we test it and when we return
  611. * from the interrupt. */
  612. LOAD_MSR_KERNEL(r10,MSR_KERNEL)
  613. SYNC /* Some chip revs have problems here... */
  614. MTMSRD(r10) /* disable interrupts */
  615. lwz r3,_MSR(r1) /* Returning to user mode? */
  616. andi. r0,r3,MSR_PR
  617. beq resume_kernel
  618. user_exc_return: /* r10 contains MSR_KERNEL here */
  619. /* Check current_thread_info()->flags */
  620. rlwinm r9,r1,0,0,(31-THREAD_SHIFT)
  621. lwz r9,TI_FLAGS(r9)
  622. andi. r0,r9,(_TIF_SIGPENDING|_TIF_RESTORE_SIGMASK|_TIF_NEED_RESCHED)
  623. bne do_work
  624. restore_user:
  625. #if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
  626. /* Check whether this process has its own DBCR0 value. The internal
  627. debug mode bit tells us that dbcr0 should be loaded. */
  628. lwz r0,THREAD+THREAD_DBCR0(r2)
  629. andis. r10,r0,DBCR0_IDM@h
  630. bnel- load_dbcr0
  631. #endif
  632. #ifdef CONFIG_PREEMPT
  633. b restore
  634. /* N.B. the only way to get here is from the beq following ret_from_except. */
  635. resume_kernel:
  636. /* check current_thread_info->preempt_count */
  637. rlwinm r9,r1,0,0,(31-THREAD_SHIFT)
  638. lwz r0,TI_PREEMPT(r9)
  639. cmpwi 0,r0,0 /* if non-zero, just restore regs and return */
  640. bne restore
  641. lwz r0,TI_FLAGS(r9)
  642. andi. r0,r0,_TIF_NEED_RESCHED
  643. beq+ restore
  644. andi. r0,r3,MSR_EE /* interrupts off? */
  645. beq restore /* don't schedule if so */
  646. 1: bl preempt_schedule_irq
  647. rlwinm r9,r1,0,0,(31-THREAD_SHIFT)
  648. lwz r3,TI_FLAGS(r9)
  649. andi. r0,r3,_TIF_NEED_RESCHED
  650. bne- 1b
  651. #else
  652. resume_kernel:
  653. #endif /* CONFIG_PREEMPT */
  654. /* interrupts are hard-disabled at this point */
  655. restore:
  656. #ifdef CONFIG_44x
  657. lis r4,icache_44x_need_flush@ha
  658. lwz r5,icache_44x_need_flush@l(r4)
  659. cmplwi cr0,r5,0
  660. beq+ 1f
  661. li r6,0
  662. iccci r0,r0
  663. stw r6,icache_44x_need_flush@l(r4)
  664. 1:
  665. #endif /* CONFIG_44x */
  666. lwz r0,GPR0(r1)
  667. lwz r2,GPR2(r1)
  668. REST_4GPRS(3, r1)
  669. REST_2GPRS(7, r1)
  670. lwz r10,_XER(r1)
  671. lwz r11,_CTR(r1)
  672. mtspr SPRN_XER,r10
  673. mtctr r11
  674. PPC405_ERR77(0,r1)
  675. BEGIN_FTR_SECTION
  676. lwarx r11,0,r1
  677. END_FTR_SECTION_IFSET(CPU_FTR_NEED_PAIRED_STWCX)
  678. stwcx. r0,0,r1 /* to clear the reservation */
  679. #if !(defined(CONFIG_4xx) || defined(CONFIG_BOOKE))
  680. lwz r9,_MSR(r1)
  681. andi. r10,r9,MSR_RI /* check if this exception occurred */
  682. beql nonrecoverable /* at a bad place (MSR:RI = 0) */
  683. lwz r10,_CCR(r1)
  684. lwz r11,_LINK(r1)
  685. mtcrf 0xFF,r10
  686. mtlr r11
  687. /*
  688. * Once we put values in SRR0 and SRR1, we are in a state
  689. * where exceptions are not recoverable, since taking an
  690. * exception will trash SRR0 and SRR1. Therefore we clear the
  691. * MSR:RI bit to indicate this. If we do take an exception,
  692. * we can't return to the point of the exception but we
  693. * can restart the exception exit path at the label
  694. * exc_exit_restart below. -- paulus
  695. */
  696. LOAD_MSR_KERNEL(r10,MSR_KERNEL & ~MSR_RI)
  697. SYNC
  698. MTMSRD(r10) /* clear the RI bit */
  699. .globl exc_exit_restart
  700. exc_exit_restart:
  701. lwz r9,_MSR(r1)
  702. lwz r12,_NIP(r1)
  703. FIX_SRR1(r9,r10)
  704. mtspr SPRN_SRR0,r12
  705. mtspr SPRN_SRR1,r9
  706. REST_4GPRS(9, r1)
  707. lwz r1,GPR1(r1)
  708. .globl exc_exit_restart_end
  709. exc_exit_restart_end:
  710. SYNC
  711. RFI
  712. #else /* !(CONFIG_4xx || CONFIG_BOOKE) */
  713. /*
  714. * This is a bit different on 4xx/Book-E because it doesn't have
  715. * the RI bit in the MSR.
  716. * The TLB miss handler checks if we have interrupted
  717. * the exception exit path and restarts it if so
  718. * (well maybe one day it will... :).
  719. */
  720. lwz r11,_LINK(r1)
  721. mtlr r11
  722. lwz r10,_CCR(r1)
  723. mtcrf 0xff,r10
  724. REST_2GPRS(9, r1)
  725. .globl exc_exit_restart
  726. exc_exit_restart:
  727. lwz r11,_NIP(r1)
  728. lwz r12,_MSR(r1)
  729. exc_exit_start:
  730. mtspr SPRN_SRR0,r11
  731. mtspr SPRN_SRR1,r12
  732. REST_2GPRS(11, r1)
  733. lwz r1,GPR1(r1)
  734. .globl exc_exit_restart_end
  735. exc_exit_restart_end:
  736. PPC405_ERR77_SYNC
  737. rfi
  738. b . /* prevent prefetch past rfi */
  739. /*
  740. * Returning from a critical interrupt in user mode doesn't need
  741. * to be any different from a normal exception. For a critical
  742. * interrupt in the kernel, we just return (without checking for
  743. * preemption) since the interrupt may have happened at some crucial
  744. * place (e.g. inside the TLB miss handler), and because we will be
  745. * running with r1 pointing into critical_stack, not the current
  746. * process's kernel stack (and therefore current_thread_info() will
  747. * give the wrong answer).
  748. * We have to restore various SPRs that may have been in use at the
  749. * time of the critical interrupt.
  750. *
  751. */
  752. #ifdef CONFIG_40x
  753. #define PPC_40x_TURN_OFF_MSR_DR \
  754. /* avoid any possible TLB misses here by turning off MSR.DR, we \
  755. * assume the instructions here are mapped by a pinned TLB entry */ \
  756. li r10,MSR_IR; \
  757. mtmsr r10; \
  758. isync; \
  759. tophys(r1, r1);
  760. #else
  761. #define PPC_40x_TURN_OFF_MSR_DR
  762. #endif
  763. #define RET_FROM_EXC_LEVEL(exc_lvl_srr0, exc_lvl_srr1, exc_lvl_rfi) \
  764. REST_NVGPRS(r1); \
  765. lwz r3,_MSR(r1); \
  766. andi. r3,r3,MSR_PR; \
  767. LOAD_MSR_KERNEL(r10,MSR_KERNEL); \
  768. bne user_exc_return; \
  769. lwz r0,GPR0(r1); \
  770. lwz r2,GPR2(r1); \
  771. REST_4GPRS(3, r1); \
  772. REST_2GPRS(7, r1); \
  773. lwz r10,_XER(r1); \
  774. lwz r11,_CTR(r1); \
  775. mtspr SPRN_XER,r10; \
  776. mtctr r11; \
  777. PPC405_ERR77(0,r1); \
  778. stwcx. r0,0,r1; /* to clear the reservation */ \
  779. lwz r11,_LINK(r1); \
  780. mtlr r11; \
  781. lwz r10,_CCR(r1); \
  782. mtcrf 0xff,r10; \
  783. PPC_40x_TURN_OFF_MSR_DR; \
  784. lwz r9,_DEAR(r1); \
  785. lwz r10,_ESR(r1); \
  786. mtspr SPRN_DEAR,r9; \
  787. mtspr SPRN_ESR,r10; \
  788. lwz r11,_NIP(r1); \
  789. lwz r12,_MSR(r1); \
  790. mtspr exc_lvl_srr0,r11; \
  791. mtspr exc_lvl_srr1,r12; \
  792. lwz r9,GPR9(r1); \
  793. lwz r12,GPR12(r1); \
  794. lwz r10,GPR10(r1); \
  795. lwz r11,GPR11(r1); \
  796. lwz r1,GPR1(r1); \
  797. PPC405_ERR77_SYNC; \
  798. exc_lvl_rfi; \
  799. b .; /* prevent prefetch past exc_lvl_rfi */
  800. .globl ret_from_crit_exc
  801. ret_from_crit_exc:
  802. RET_FROM_EXC_LEVEL(SPRN_CSRR0, SPRN_CSRR1, RFCI)
  803. #ifdef CONFIG_BOOKE
  804. .globl ret_from_debug_exc
  805. ret_from_debug_exc:
  806. RET_FROM_EXC_LEVEL(SPRN_DSRR0, SPRN_DSRR1, RFDI)
  807. .globl ret_from_mcheck_exc
  808. ret_from_mcheck_exc:
  809. RET_FROM_EXC_LEVEL(SPRN_MCSRR0, SPRN_MCSRR1, RFMCI)
  810. #endif /* CONFIG_BOOKE */
  811. /*
  812. * Load the DBCR0 value for a task that is being ptraced,
  813. * having first saved away the global DBCR0. Note that r0
  814. * has the dbcr0 value to set upon entry to this.
  815. */
  816. load_dbcr0:
  817. mfmsr r10 /* first disable debug exceptions */
  818. rlwinm r10,r10,0,~MSR_DE
  819. mtmsr r10
  820. isync
  821. mfspr r10,SPRN_DBCR0
  822. lis r11,global_dbcr0@ha
  823. addi r11,r11,global_dbcr0@l
  824. #ifdef CONFIG_SMP
  825. rlwinm r9,r1,0,0,(31-THREAD_SHIFT)
  826. lwz r9,TI_CPU(r9)
  827. slwi r9,r9,3
  828. add r11,r11,r9
  829. #endif
  830. stw r10,0(r11)
  831. mtspr SPRN_DBCR0,r0
  832. lwz r10,4(r11)
  833. addi r10,r10,1
  834. stw r10,4(r11)
  835. li r11,-1
  836. mtspr SPRN_DBSR,r11 /* clear all pending debug events */
  837. blr
  838. .section .bss
  839. .align 4
  840. global_dbcr0:
  841. .space 8*NR_CPUS
  842. .previous
  843. #endif /* !(CONFIG_4xx || CONFIG_BOOKE) */
  844. do_work: /* r10 contains MSR_KERNEL here */
  845. andi. r0,r9,_TIF_NEED_RESCHED
  846. beq do_user_signal
  847. do_resched: /* r10 contains MSR_KERNEL here */
  848. ori r10,r10,MSR_EE
  849. SYNC
  850. MTMSRD(r10) /* hard-enable interrupts */
  851. bl schedule
  852. recheck:
  853. LOAD_MSR_KERNEL(r10,MSR_KERNEL)
  854. SYNC
  855. MTMSRD(r10) /* disable interrupts */
  856. rlwinm r9,r1,0,0,(31-THREAD_SHIFT)
  857. lwz r9,TI_FLAGS(r9)
  858. andi. r0,r9,_TIF_NEED_RESCHED
  859. bne- do_resched
  860. andi. r0,r9,_TIF_SIGPENDING|_TIF_RESTORE_SIGMASK
  861. beq restore_user
  862. do_user_signal: /* r10 contains MSR_KERNEL here */
  863. ori r10,r10,MSR_EE
  864. SYNC
  865. MTMSRD(r10) /* hard-enable interrupts */
  866. /* save r13-r31 in the exception frame, if not already done */
  867. lwz r3,_TRAP(r1)
  868. andi. r0,r3,1
  869. beq 2f
  870. SAVE_NVGPRS(r1)
  871. rlwinm r3,r3,0,0,30
  872. stw r3,_TRAP(r1)
  873. 2: li r3,0
  874. addi r4,r1,STACK_FRAME_OVERHEAD
  875. bl do_signal
  876. REST_NVGPRS(r1)
  877. b recheck
  878. /*
  879. * We come here when we are at the end of handling an exception
  880. * that occurred at a place where taking an exception will lose
  881. * state information, such as the contents of SRR0 and SRR1.
  882. */
  883. nonrecoverable:
  884. lis r10,exc_exit_restart_end@ha
  885. addi r10,r10,exc_exit_restart_end@l
  886. cmplw r12,r10
  887. bge 3f
  888. lis r11,exc_exit_restart@ha
  889. addi r11,r11,exc_exit_restart@l
  890. cmplw r12,r11
  891. blt 3f
  892. lis r10,ee_restarts@ha
  893. lwz r12,ee_restarts@l(r10)
  894. addi r12,r12,1
  895. stw r12,ee_restarts@l(r10)
  896. mr r12,r11 /* restart at exc_exit_restart */
  897. blr
  898. 3: /* OK, we can't recover, kill this process */
  899. /* but the 601 doesn't implement the RI bit, so assume it's OK */
  900. BEGIN_FTR_SECTION
  901. blr
  902. END_FTR_SECTION_IFSET(CPU_FTR_601)
  903. lwz r3,_TRAP(r1)
  904. andi. r0,r3,1
  905. beq 4f
  906. SAVE_NVGPRS(r1)
  907. rlwinm r3,r3,0,0,30
  908. stw r3,_TRAP(r1)
  909. 4: addi r3,r1,STACK_FRAME_OVERHEAD
  910. bl nonrecoverable_exception
  911. /* shouldn't return */
  912. b 4b
  913. .section .bss
  914. .align 2
  915. ee_restarts:
  916. .space 4
  917. .previous
  918. /*
  919. * PROM code for specific machines follows. Put it
  920. * here so it's easy to add arch-specific sections later.
  921. * -- Cort
  922. */
  923. #ifdef CONFIG_PPC_RTAS
  924. /*
  925. * On CHRP, the Run-Time Abstraction Services (RTAS) have to be
  926. * called with the MMU off.
  927. */
  928. _GLOBAL(enter_rtas)
  929. stwu r1,-INT_FRAME_SIZE(r1)
  930. mflr r0
  931. stw r0,INT_FRAME_SIZE+4(r1)
  932. LOAD_REG_ADDR(r4, rtas)
  933. lis r6,1f@ha /* physical return address for rtas */
  934. addi r6,r6,1f@l
  935. tophys(r6,r6)
  936. tophys(r7,r1)
  937. lwz r8,RTASENTRY(r4)
  938. lwz r4,RTASBASE(r4)
  939. mfmsr r9
  940. stw r9,8(r1)
  941. LOAD_MSR_KERNEL(r0,MSR_KERNEL)
  942. SYNC /* disable interrupts so SRR0/1 */
  943. MTMSRD(r0) /* don't get trashed */
  944. li r9,MSR_KERNEL & ~(MSR_IR|MSR_DR)
  945. mtlr r6
  946. mtspr SPRN_SPRG2,r7
  947. mtspr SPRN_SRR0,r8
  948. mtspr SPRN_SRR1,r9
  949. RFI
  950. 1: tophys(r9,r1)
  951. lwz r8,INT_FRAME_SIZE+4(r9) /* get return address */
  952. lwz r9,8(r9) /* original msr value */
  953. FIX_SRR1(r9,r0)
  954. addi r1,r1,INT_FRAME_SIZE
  955. li r0,0
  956. mtspr SPRN_SPRG2,r0
  957. mtspr SPRN_SRR0,r8
  958. mtspr SPRN_SRR1,r9
  959. RFI /* return to caller */
  960. .globl machine_check_in_rtas
  961. machine_check_in_rtas:
  962. twi 31,0,0
  963. /* XXX load up BATs and panic */
  964. #endif /* CONFIG_PPC_RTAS */
  965. #ifdef CONFIG_FTRACE
  966. #ifdef CONFIG_DYNAMIC_FTRACE
  967. _GLOBAL(mcount)
  968. _GLOBAL(_mcount)
  969. stwu r1,-48(r1)
  970. stw r3, 12(r1)
  971. stw r4, 16(r1)
  972. stw r5, 20(r1)
  973. stw r6, 24(r1)
  974. mflr r3
  975. stw r7, 28(r1)
  976. mfcr r5
  977. stw r8, 32(r1)
  978. stw r9, 36(r1)
  979. stw r10,40(r1)
  980. stw r3, 44(r1)
  981. stw r5, 8(r1)
  982. subi r3, r3, MCOUNT_INSN_SIZE
  983. .globl mcount_call
  984. mcount_call:
  985. bl ftrace_stub
  986. nop
  987. lwz r6, 8(r1)
  988. lwz r0, 44(r1)
  989. lwz r3, 12(r1)
  990. mtctr r0
  991. lwz r4, 16(r1)
  992. mtcr r6
  993. lwz r5, 20(r1)
  994. lwz r6, 24(r1)
  995. lwz r0, 52(r1)
  996. lwz r7, 28(r1)
  997. lwz r8, 32(r1)
  998. mtlr r0
  999. lwz r9, 36(r1)
  1000. lwz r10,40(r1)
  1001. addi r1, r1, 48
  1002. bctr
  1003. _GLOBAL(ftrace_caller)
  1004. /* Based off of objdump optput from glibc */
  1005. stwu r1,-48(r1)
  1006. stw r3, 12(r1)
  1007. stw r4, 16(r1)
  1008. stw r5, 20(r1)
  1009. stw r6, 24(r1)
  1010. mflr r3
  1011. lwz r4, 52(r1)
  1012. mfcr r5
  1013. stw r7, 28(r1)
  1014. stw r8, 32(r1)
  1015. stw r9, 36(r1)
  1016. stw r10,40(r1)
  1017. stw r3, 44(r1)
  1018. stw r5, 8(r1)
  1019. subi r3, r3, MCOUNT_INSN_SIZE
  1020. .globl ftrace_call
  1021. ftrace_call:
  1022. bl ftrace_stub
  1023. nop
  1024. lwz r6, 8(r1)
  1025. lwz r0, 44(r1)
  1026. lwz r3, 12(r1)
  1027. mtctr r0
  1028. lwz r4, 16(r1)
  1029. mtcr r6
  1030. lwz r5, 20(r1)
  1031. lwz r6, 24(r1)
  1032. lwz r0, 52(r1)
  1033. lwz r7, 28(r1)
  1034. lwz r8, 32(r1)
  1035. mtlr r0
  1036. lwz r9, 36(r1)
  1037. lwz r10,40(r1)
  1038. addi r1, r1, 48
  1039. bctr
  1040. #else
  1041. _GLOBAL(mcount)
  1042. _GLOBAL(_mcount)
  1043. stwu r1,-48(r1)
  1044. stw r3, 12(r1)
  1045. stw r4, 16(r1)
  1046. stw r5, 20(r1)
  1047. stw r6, 24(r1)
  1048. mflr r3
  1049. lwz r4, 52(r1)
  1050. mfcr r5
  1051. stw r7, 28(r1)
  1052. stw r8, 32(r1)
  1053. stw r9, 36(r1)
  1054. stw r10,40(r1)
  1055. stw r3, 44(r1)
  1056. stw r5, 8(r1)
  1057. subi r3, r3, MCOUNT_INSN_SIZE
  1058. LOAD_REG_ADDR(r5, ftrace_trace_function)
  1059. lwz r5,0(r5)
  1060. mtctr r5
  1061. bctrl
  1062. nop
  1063. lwz r6, 8(r1)
  1064. lwz r0, 44(r1)
  1065. lwz r3, 12(r1)
  1066. mtctr r0
  1067. lwz r4, 16(r1)
  1068. mtcr r6
  1069. lwz r5, 20(r1)
  1070. lwz r6, 24(r1)
  1071. lwz r0, 52(r1)
  1072. lwz r7, 28(r1)
  1073. lwz r8, 32(r1)
  1074. mtlr r0
  1075. lwz r9, 36(r1)
  1076. lwz r10,40(r1)
  1077. addi r1, r1, 48
  1078. bctr
  1079. #endif
  1080. _GLOBAL(ftrace_stub)
  1081. blr
  1082. #endif /* CONFIG_MCOUNT */