head_booke.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __HEAD_BOOKE_H__
  3. #define __HEAD_BOOKE_H__
  4. #include <asm/ptrace.h> /* for STACK_FRAME_REGS_MARKER */
  5. #include <asm/kvm_asm.h>
  6. #include <asm/kvm_booke_hv_asm.h>
  7. #ifdef __ASSEMBLY__
  8. /*
  9. * Macros used for common Book-e exception handling
  10. */
  11. #define SET_IVOR(vector_number, vector_label) \
  12. li r26,vector_label@l; \
  13. mtspr SPRN_IVOR##vector_number,r26; \
  14. sync
  15. #if (THREAD_SHIFT < 15)
  16. #define ALLOC_STACK_FRAME(reg, val) \
  17. addi reg,reg,val
  18. #else
  19. #define ALLOC_STACK_FRAME(reg, val) \
  20. addis reg,reg,val@ha; \
  21. addi reg,reg,val@l
  22. #endif
  23. /*
  24. * Macro used to get to thread save registers.
  25. * Note that entries 0-3 are used for the prolog code, and the remaining
  26. * entries are available for specific exception use in the event a handler
  27. * requires more than 4 scratch registers.
  28. */
  29. #define THREAD_NORMSAVE(offset) (THREAD_NORMSAVES + (offset * 4))
  30. #ifdef CONFIG_PPC_E500
  31. #define BOOKE_CLEAR_BTB(reg) \
  32. START_BTB_FLUSH_SECTION \
  33. BTB_FLUSH(reg) \
  34. END_BTB_FLUSH_SECTION
  35. #else
  36. #define BOOKE_CLEAR_BTB(reg)
  37. #endif
  38. #define NORMAL_EXCEPTION_PROLOG(trapno, intno) \
  39. mtspr SPRN_SPRG_WSCRATCH0, r10; /* save one register */ \
  40. mfspr r10, SPRN_SPRG_THREAD; \
  41. stw r11, THREAD_NORMSAVE(0)(r10); \
  42. stw r13, THREAD_NORMSAVE(2)(r10); \
  43. mfcr r13; /* save CR in r13 for now */\
  44. mfspr r11, SPRN_SRR1; \
  45. DO_KVM BOOKE_INTERRUPT_##intno SPRN_SRR1; \
  46. andi. r11, r11, MSR_PR; /* check whether user or kernel */\
  47. LOAD_REG_IMMEDIATE(r11, MSR_KERNEL); \
  48. mtmsr r11; \
  49. mr r11, r1; \
  50. beq 1f; \
  51. BOOKE_CLEAR_BTB(r11) \
  52. /* if from user, start at top of this thread's kernel stack */ \
  53. lwz r11, TASK_STACK - THREAD(r10); \
  54. ALLOC_STACK_FRAME(r11, THREAD_SIZE); \
  55. 1 : subi r11, r11, INT_FRAME_SIZE; /* Allocate exception frame */ \
  56. stw r13, _CCR(r11); /* save various registers */ \
  57. stw r12,GPR12(r11); \
  58. stw r9,GPR9(r11); \
  59. mfspr r13, SPRN_SPRG_RSCRATCH0; \
  60. stw r13, GPR10(r11); \
  61. lwz r12, THREAD_NORMSAVE(0)(r10); \
  62. stw r12,GPR11(r11); \
  63. lwz r13, THREAD_NORMSAVE(2)(r10); /* restore r13 */ \
  64. mflr r10; \
  65. stw r10,_LINK(r11); \
  66. mfspr r12,SPRN_SRR0; \
  67. stw r1, GPR1(r11); \
  68. mfspr r9,SPRN_SRR1; \
  69. stw r1, 0(r11); \
  70. mr r1, r11; \
  71. rlwinm r9,r9,0,14,12; /* clear MSR_WE (necessary?) */\
  72. COMMON_EXCEPTION_PROLOG_END trapno
  73. .macro COMMON_EXCEPTION_PROLOG_END trapno
  74. stw r0,GPR0(r1)
  75. lis r10, STACK_FRAME_REGS_MARKER@ha /* exception frame marker */
  76. addi r10, r10, STACK_FRAME_REGS_MARKER@l
  77. stw r10, 8(r1)
  78. li r10, \trapno
  79. stw r10,_TRAP(r1)
  80. SAVE_GPRS(3, 8, r1)
  81. SAVE_NVGPRS(r1)
  82. stw r2,GPR2(r1)
  83. stw r12,_NIP(r1)
  84. stw r9,_MSR(r1)
  85. mfctr r10
  86. mfspr r2,SPRN_SPRG_THREAD
  87. stw r10,_CTR(r1)
  88. tovirt(r2, r2)
  89. mfspr r10,SPRN_XER
  90. addi r2, r2, -THREAD
  91. stw r10,_XER(r1)
  92. addi r3,r1,STACK_FRAME_OVERHEAD
  93. .endm
  94. .macro prepare_transfer_to_handler
  95. #ifdef CONFIG_PPC_E500
  96. andi. r12,r9,MSR_PR
  97. bne 777f
  98. bl prepare_transfer_to_handler
  99. 777:
  100. #endif
  101. .endm
  102. .macro SYSCALL_ENTRY trapno intno srr1
  103. mfspr r10, SPRN_SPRG_THREAD
  104. #ifdef CONFIG_KVM_BOOKE_HV
  105. BEGIN_FTR_SECTION
  106. mtspr SPRN_SPRG_WSCRATCH0, r10
  107. stw r11, THREAD_NORMSAVE(0)(r10)
  108. stw r13, THREAD_NORMSAVE(2)(r10)
  109. mfcr r13 /* save CR in r13 for now */
  110. mfspr r11, SPRN_SRR1
  111. mtocrf 0x80, r11 /* check MSR[GS] without clobbering reg */
  112. bf 3, 1975f
  113. b kvmppc_handler_\intno\()_\srr1
  114. 1975:
  115. mr r12, r13
  116. lwz r13, THREAD_NORMSAVE(2)(r10)
  117. FTR_SECTION_ELSE
  118. mfcr r12
  119. ALT_FTR_SECTION_END_IFSET(CPU_FTR_EMB_HV)
  120. #else
  121. mfcr r12
  122. #endif
  123. mfspr r9, SPRN_SRR1
  124. BOOKE_CLEAR_BTB(r11)
  125. mr r11, r1
  126. lwz r1, TASK_STACK - THREAD(r10)
  127. rlwinm r12,r12,0,4,2 /* Clear SO bit in CR */
  128. ALLOC_STACK_FRAME(r1, THREAD_SIZE - INT_FRAME_SIZE)
  129. stw r12, _CCR(r1)
  130. mfspr r12,SPRN_SRR0
  131. stw r12,_NIP(r1)
  132. b transfer_to_syscall /* jump to handler */
  133. .endm
  134. /* To handle the additional exception priority levels on 40x and Book-E
  135. * processors we allocate a stack per additional priority level.
  136. *
  137. * On 40x critical is the only additional level
  138. * On 44x/e500 we have critical and machine check
  139. *
  140. * Additionally we reserve a SPRG for each priority level so we can free up a
  141. * GPR to use as the base for indirect access to the exception stacks. This
  142. * is necessary since the MMU is always on, for Book-E parts, and the stacks
  143. * are offset from KERNELBASE.
  144. *
  145. * There is some space optimization to be had here if desired. However
  146. * to allow for a common kernel with support for debug exceptions either
  147. * going to critical or their own debug level we aren't currently
  148. * providing configurations that micro-optimize space usage.
  149. */
  150. #define MC_STACK_BASE mcheckirq_ctx
  151. #define CRIT_STACK_BASE critirq_ctx
  152. /* only on e500mc */
  153. #define DBG_STACK_BASE dbgirq_ctx
  154. #ifdef CONFIG_SMP
  155. #define BOOKE_LOAD_EXC_LEVEL_STACK(level) \
  156. mfspr r8,SPRN_PIR; \
  157. slwi r8,r8,2; \
  158. addis r8,r8,level##_STACK_BASE@ha; \
  159. lwz r8,level##_STACK_BASE@l(r8); \
  160. addi r8,r8,THREAD_SIZE - INT_FRAME_SIZE;
  161. #else
  162. #define BOOKE_LOAD_EXC_LEVEL_STACK(level) \
  163. lis r8,level##_STACK_BASE@ha; \
  164. lwz r8,level##_STACK_BASE@l(r8); \
  165. addi r8,r8,THREAD_SIZE - INT_FRAME_SIZE;
  166. #endif
  167. /*
  168. * Exception prolog for critical/machine check exceptions. This is a
  169. * little different from the normal exception prolog above since a
  170. * critical/machine check exception can potentially occur at any point
  171. * during normal exception processing. Thus we cannot use the same SPRG
  172. * registers as the normal prolog above. Instead we use a portion of the
  173. * critical/machine check exception stack at low physical addresses.
  174. */
  175. #define EXC_LEVEL_EXCEPTION_PROLOG(exc_level, trapno, intno, exc_level_srr0, exc_level_srr1) \
  176. mtspr SPRN_SPRG_WSCRATCH_##exc_level,r8; \
  177. BOOKE_LOAD_EXC_LEVEL_STACK(exc_level);/* r8 points to the exc_level stack*/ \
  178. stw r9,GPR9(r8); /* save various registers */\
  179. mfcr r9; /* save CR in r9 for now */\
  180. stw r10,GPR10(r8); \
  181. stw r11,GPR11(r8); \
  182. stw r9,_CCR(r8); /* save CR on stack */\
  183. mfspr r11,exc_level_srr1; /* check whether user or kernel */\
  184. DO_KVM BOOKE_INTERRUPT_##intno exc_level_srr1; \
  185. BOOKE_CLEAR_BTB(r10) \
  186. andi. r11,r11,MSR_PR; \
  187. LOAD_REG_IMMEDIATE(r11, MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)); \
  188. mtmsr r11; \
  189. mfspr r11,SPRN_SPRG_THREAD; /* if from user, start at top of */\
  190. lwz r11, TASK_STACK - THREAD(r11); /* this thread's kernel stack */\
  191. addi r11,r11,THREAD_SIZE - INT_FRAME_SIZE; /* allocate stack frame */\
  192. beq 1f; \
  193. /* COMING FROM USER MODE */ \
  194. stw r9,_CCR(r11); /* save CR */\
  195. lwz r10,GPR10(r8); /* copy regs from exception stack */\
  196. lwz r9,GPR9(r8); \
  197. stw r10,GPR10(r11); \
  198. lwz r10,GPR11(r8); \
  199. stw r9,GPR9(r11); \
  200. stw r10,GPR11(r11); \
  201. b 2f; \
  202. /* COMING FROM PRIV MODE */ \
  203. 1: mr r11, r8; \
  204. 2: mfspr r8,SPRN_SPRG_RSCRATCH_##exc_level; \
  205. stw r12,GPR12(r11); /* save various registers */\
  206. mflr r10; \
  207. stw r10,_LINK(r11); \
  208. mfspr r12,SPRN_DEAR; /* save DEAR and ESR in the frame */\
  209. stw r12,_DEAR(r11); /* since they may have had stuff */\
  210. mfspr r9,SPRN_ESR; /* in them at the point where the */\
  211. stw r9,_ESR(r11); /* exception was taken */\
  212. mfspr r12,exc_level_srr0; \
  213. stw r1,GPR1(r11); \
  214. mfspr r9,exc_level_srr1; \
  215. stw r1,0(r11); \
  216. mr r1,r11; \
  217. rlwinm r9,r9,0,14,12; /* clear MSR_WE (necessary?) */\
  218. COMMON_EXCEPTION_PROLOG_END trapno
  219. #define SAVE_xSRR(xSRR) \
  220. mfspr r0,SPRN_##xSRR##0; \
  221. stw r0,_##xSRR##0(r1); \
  222. mfspr r0,SPRN_##xSRR##1; \
  223. stw r0,_##xSRR##1(r1)
  224. .macro SAVE_MMU_REGS
  225. #ifdef CONFIG_PPC_E500
  226. mfspr r0,SPRN_MAS0
  227. stw r0,MAS0(r1)
  228. mfspr r0,SPRN_MAS1
  229. stw r0,MAS1(r1)
  230. mfspr r0,SPRN_MAS2
  231. stw r0,MAS2(r1)
  232. mfspr r0,SPRN_MAS3
  233. stw r0,MAS3(r1)
  234. mfspr r0,SPRN_MAS6
  235. stw r0,MAS6(r1)
  236. #ifdef CONFIG_PHYS_64BIT
  237. mfspr r0,SPRN_MAS7
  238. stw r0,MAS7(r1)
  239. #endif /* CONFIG_PHYS_64BIT */
  240. #endif /* CONFIG_PPC_E500 */
  241. #ifdef CONFIG_44x
  242. mfspr r0,SPRN_MMUCR
  243. stw r0,MMUCR(r1)
  244. #endif
  245. .endm
  246. #define CRITICAL_EXCEPTION_PROLOG(trapno, intno) \
  247. EXC_LEVEL_EXCEPTION_PROLOG(CRIT, trapno+2, intno, SPRN_CSRR0, SPRN_CSRR1)
  248. #define DEBUG_EXCEPTION_PROLOG(trapno) \
  249. EXC_LEVEL_EXCEPTION_PROLOG(DBG, trapno+8, DEBUG, SPRN_DSRR0, SPRN_DSRR1)
  250. #define MCHECK_EXCEPTION_PROLOG(trapno) \
  251. EXC_LEVEL_EXCEPTION_PROLOG(MC, trapno+4, MACHINE_CHECK, \
  252. SPRN_MCSRR0, SPRN_MCSRR1)
  253. /*
  254. * Guest Doorbell -- this is a bit odd in that uses GSRR0/1 despite
  255. * being delivered to the host. This exception can only happen
  256. * inside a KVM guest -- so we just handle up to the DO_KVM rather
  257. * than try to fit this into one of the existing prolog macros.
  258. */
  259. #define GUEST_DOORBELL_EXCEPTION \
  260. START_EXCEPTION(GuestDoorbell); \
  261. mtspr SPRN_SPRG_WSCRATCH0, r10; /* save one register */ \
  262. mfspr r10, SPRN_SPRG_THREAD; \
  263. stw r11, THREAD_NORMSAVE(0)(r10); \
  264. mfspr r11, SPRN_SRR1; \
  265. stw r13, THREAD_NORMSAVE(2)(r10); \
  266. mfcr r13; /* save CR in r13 for now */\
  267. DO_KVM BOOKE_INTERRUPT_GUEST_DBELL SPRN_GSRR1; \
  268. trap
  269. /*
  270. * Exception vectors.
  271. */
  272. #define START_EXCEPTION(label) \
  273. .align 5; \
  274. label:
  275. #define EXCEPTION(n, intno, label, hdlr) \
  276. START_EXCEPTION(label); \
  277. NORMAL_EXCEPTION_PROLOG(n, intno); \
  278. prepare_transfer_to_handler; \
  279. bl hdlr; \
  280. b interrupt_return
  281. #define CRITICAL_EXCEPTION(n, intno, label, hdlr) \
  282. START_EXCEPTION(label); \
  283. CRITICAL_EXCEPTION_PROLOG(n, intno); \
  284. SAVE_MMU_REGS; \
  285. SAVE_xSRR(SRR); \
  286. prepare_transfer_to_handler; \
  287. bl hdlr; \
  288. b ret_from_crit_exc
  289. #define MCHECK_EXCEPTION(n, label, hdlr) \
  290. START_EXCEPTION(label); \
  291. MCHECK_EXCEPTION_PROLOG(n); \
  292. mfspr r5,SPRN_ESR; \
  293. stw r5,_ESR(r11); \
  294. SAVE_xSRR(DSRR); \
  295. SAVE_xSRR(CSRR); \
  296. SAVE_MMU_REGS; \
  297. SAVE_xSRR(SRR); \
  298. prepare_transfer_to_handler; \
  299. bl hdlr; \
  300. b ret_from_mcheck_exc
  301. /* Check for a single step debug exception while in an exception
  302. * handler before state has been saved. This is to catch the case
  303. * where an instruction that we are trying to single step causes
  304. * an exception (eg ITLB/DTLB miss) and thus the first instruction of
  305. * the exception handler generates a single step debug exception.
  306. *
  307. * If we get a debug trap on the first instruction of an exception handler,
  308. * we reset the MSR_DE in the _exception handler's_ MSR (the debug trap is
  309. * a critical exception, so we are using SPRN_CSRR1 to manipulate the MSR).
  310. * The exception handler was handling a non-critical interrupt, so it will
  311. * save (and later restore) the MSR via SPRN_CSRR1, which will still have
  312. * the MSR_DE bit set.
  313. */
  314. #define DEBUG_DEBUG_EXCEPTION \
  315. START_EXCEPTION(DebugDebug); \
  316. DEBUG_EXCEPTION_PROLOG(2000); \
  317. \
  318. /* \
  319. * If there is a single step or branch-taken exception in an \
  320. * exception entry sequence, it was probably meant to apply to \
  321. * the code where the exception occurred (since exception entry \
  322. * doesn't turn off DE automatically). We simulate the effect \
  323. * of turning off DE on entry to an exception handler by turning \
  324. * off DE in the DSRR1 value and clearing the debug status. \
  325. */ \
  326. mfspr r10,SPRN_DBSR; /* check single-step/branch taken */ \
  327. andis. r10,r10,(DBSR_IC|DBSR_BT)@h; \
  328. beq+ 2f; \
  329. \
  330. lis r10,interrupt_base@h; /* check if exception in vectors */ \
  331. ori r10,r10,interrupt_base@l; \
  332. cmplw r12,r10; \
  333. blt+ 2f; /* addr below exception vectors */ \
  334. \
  335. lis r10,interrupt_end@h; \
  336. ori r10,r10,interrupt_end@l; \
  337. cmplw r12,r10; \
  338. bgt+ 2f; /* addr above exception vectors */ \
  339. \
  340. /* here it looks like we got an inappropriate debug exception. */ \
  341. 1: rlwinm r9,r9,0,~MSR_DE; /* clear DE in the CDRR1 value */ \
  342. lis r10,(DBSR_IC|DBSR_BT)@h; /* clear the IC event */ \
  343. mtspr SPRN_DBSR,r10; \
  344. /* restore state and get out */ \
  345. lwz r10,_CCR(r11); \
  346. lwz r0,GPR0(r11); \
  347. lwz r1,GPR1(r11); \
  348. mtcrf 0x80,r10; \
  349. mtspr SPRN_DSRR0,r12; \
  350. mtspr SPRN_DSRR1,r9; \
  351. lwz r9,GPR9(r11); \
  352. lwz r12,GPR12(r11); \
  353. mtspr SPRN_SPRG_WSCRATCH_DBG,r8; \
  354. BOOKE_LOAD_EXC_LEVEL_STACK(DBG); /* r8 points to the debug stack */ \
  355. lwz r10,GPR10(r8); \
  356. lwz r11,GPR11(r8); \
  357. mfspr r8,SPRN_SPRG_RSCRATCH_DBG; \
  358. \
  359. PPC_RFDI; \
  360. b .; \
  361. \
  362. /* continue normal handling for a debug exception... */ \
  363. 2: mfspr r4,SPRN_DBSR; \
  364. stw r4,_ESR(r11); /* DebugException takes DBSR in _ESR */\
  365. SAVE_xSRR(CSRR); \
  366. SAVE_MMU_REGS; \
  367. SAVE_xSRR(SRR); \
  368. prepare_transfer_to_handler; \
  369. bl DebugException; \
  370. b ret_from_debug_exc
  371. #define DEBUG_CRIT_EXCEPTION \
  372. START_EXCEPTION(DebugCrit); \
  373. CRITICAL_EXCEPTION_PROLOG(2000,DEBUG); \
  374. \
  375. /* \
  376. * If there is a single step or branch-taken exception in an \
  377. * exception entry sequence, it was probably meant to apply to \
  378. * the code where the exception occurred (since exception entry \
  379. * doesn't turn off DE automatically). We simulate the effect \
  380. * of turning off DE on entry to an exception handler by turning \
  381. * off DE in the CSRR1 value and clearing the debug status. \
  382. */ \
  383. mfspr r10,SPRN_DBSR; /* check single-step/branch taken */ \
  384. andis. r10,r10,(DBSR_IC|DBSR_BT)@h; \
  385. beq+ 2f; \
  386. \
  387. lis r10,interrupt_base@h; /* check if exception in vectors */ \
  388. ori r10,r10,interrupt_base@l; \
  389. cmplw r12,r10; \
  390. blt+ 2f; /* addr below exception vectors */ \
  391. \
  392. lis r10,interrupt_end@h; \
  393. ori r10,r10,interrupt_end@l; \
  394. cmplw r12,r10; \
  395. bgt+ 2f; /* addr above exception vectors */ \
  396. \
  397. /* here it looks like we got an inappropriate debug exception. */ \
  398. 1: rlwinm r9,r9,0,~MSR_DE; /* clear DE in the CSRR1 value */ \
  399. lis r10,(DBSR_IC|DBSR_BT)@h; /* clear the IC event */ \
  400. mtspr SPRN_DBSR,r10; \
  401. /* restore state and get out */ \
  402. lwz r10,_CCR(r11); \
  403. lwz r0,GPR0(r11); \
  404. lwz r1,GPR1(r11); \
  405. mtcrf 0x80,r10; \
  406. mtspr SPRN_CSRR0,r12; \
  407. mtspr SPRN_CSRR1,r9; \
  408. lwz r9,GPR9(r11); \
  409. lwz r12,GPR12(r11); \
  410. mtspr SPRN_SPRG_WSCRATCH_CRIT,r8; \
  411. BOOKE_LOAD_EXC_LEVEL_STACK(CRIT); /* r8 points to the debug stack */ \
  412. lwz r10,GPR10(r8); \
  413. lwz r11,GPR11(r8); \
  414. mfspr r8,SPRN_SPRG_RSCRATCH_CRIT; \
  415. \
  416. rfci; \
  417. b .; \
  418. \
  419. /* continue normal handling for a critical exception... */ \
  420. 2: mfspr r4,SPRN_DBSR; \
  421. stw r4,_ESR(r11); /* DebugException takes DBSR in _ESR */\
  422. SAVE_MMU_REGS; \
  423. SAVE_xSRR(SRR); \
  424. prepare_transfer_to_handler; \
  425. bl DebugException; \
  426. b ret_from_crit_exc
  427. #define DATA_STORAGE_EXCEPTION \
  428. START_EXCEPTION(DataStorage) \
  429. NORMAL_EXCEPTION_PROLOG(0x300, DATA_STORAGE); \
  430. mfspr r5,SPRN_ESR; /* Grab the ESR and save it */ \
  431. stw r5,_ESR(r11); \
  432. mfspr r4,SPRN_DEAR; /* Grab the DEAR */ \
  433. stw r4, _DEAR(r11); \
  434. prepare_transfer_to_handler; \
  435. bl do_page_fault; \
  436. b interrupt_return
  437. /*
  438. * Instruction TLB Error interrupt handlers may call InstructionStorage
  439. * directly without clearing ESR, so the ESR at this point may be left over
  440. * from a prior interrupt.
  441. *
  442. * In any case, do_page_fault for BOOK3E does not use ESR and always expects
  443. * dsisr to be 0. ESR_DST from a prior store in particular would confuse fault
  444. * handling.
  445. */
  446. #define INSTRUCTION_STORAGE_EXCEPTION \
  447. START_EXCEPTION(InstructionStorage) \
  448. NORMAL_EXCEPTION_PROLOG(0x400, INST_STORAGE); \
  449. li r5,0; /* Store 0 in regs->esr (dsisr) */ \
  450. stw r5,_ESR(r11); \
  451. stw r12, _DEAR(r11); /* Set regs->dear (dar) to SRR0 */ \
  452. prepare_transfer_to_handler; \
  453. bl do_page_fault; \
  454. b interrupt_return
  455. #define ALIGNMENT_EXCEPTION \
  456. START_EXCEPTION(Alignment) \
  457. NORMAL_EXCEPTION_PROLOG(0x600, ALIGNMENT); \
  458. mfspr r4,SPRN_DEAR; /* Grab the DEAR and save it */ \
  459. stw r4,_DEAR(r11); \
  460. prepare_transfer_to_handler; \
  461. bl alignment_exception; \
  462. REST_NVGPRS(r1); \
  463. b interrupt_return
  464. #define PROGRAM_EXCEPTION \
  465. START_EXCEPTION(Program) \
  466. NORMAL_EXCEPTION_PROLOG(0x700, PROGRAM); \
  467. mfspr r4,SPRN_ESR; /* Grab the ESR and save it */ \
  468. stw r4,_ESR(r11); \
  469. prepare_transfer_to_handler; \
  470. bl program_check_exception; \
  471. REST_NVGPRS(r1); \
  472. b interrupt_return
  473. #define DECREMENTER_EXCEPTION \
  474. START_EXCEPTION(Decrementer) \
  475. NORMAL_EXCEPTION_PROLOG(0x900, DECREMENTER); \
  476. lis r0,TSR_DIS@h; /* Setup the DEC interrupt mask */ \
  477. mtspr SPRN_TSR,r0; /* Clear the DEC interrupt */ \
  478. prepare_transfer_to_handler; \
  479. bl timer_interrupt; \
  480. b interrupt_return
  481. #define FP_UNAVAILABLE_EXCEPTION \
  482. START_EXCEPTION(FloatingPointUnavailable) \
  483. NORMAL_EXCEPTION_PROLOG(0x800, FP_UNAVAIL); \
  484. beq 1f; \
  485. bl load_up_fpu; /* if from user, just load it up */ \
  486. b fast_exception_return; \
  487. 1: prepare_transfer_to_handler; \
  488. bl kernel_fp_unavailable_exception; \
  489. b interrupt_return
  490. #endif /* __ASSEMBLY__ */
  491. #endif /* __HEAD_BOOKE_H__ */