exceptions-64e.S 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Boot code and exception vectors for Book3E processors
  4. *
  5. * Copyright (C) 2007 Ben. Herrenschmidt (benh@kernel.crashing.org), IBM Corp.
  6. */
  7. #include <linux/linkage.h>
  8. #include <linux/threads.h>
  9. #include <asm/reg.h>
  10. #include <asm/page.h>
  11. #include <asm/ppc_asm.h>
  12. #include <asm/asm-offsets.h>
  13. #include <asm/cputable.h>
  14. #include <asm/setup.h>
  15. #include <asm/thread_info.h>
  16. #include <asm/exception-64e.h>
  17. #include <asm/bug.h>
  18. #include <asm/irqflags.h>
  19. #include <asm/ptrace.h>
  20. #include <asm/ppc-opcode.h>
  21. #include <asm/mmu.h>
  22. #include <asm/hw_irq.h>
  23. #include <asm/kvm_asm.h>
  24. #include <asm/kvm_booke_hv_asm.h>
  25. #include <asm/feature-fixups.h>
  26. #include <asm/context_tracking.h>
  27. /* 64e interrupt returns always use SRR registers */
  28. #define fast_interrupt_return fast_interrupt_return_srr
  29. #define interrupt_return interrupt_return_srr
  30. /* XXX This will ultimately add space for a special exception save
  31. * structure used to save things like SRR0/SRR1, SPRGs, MAS, etc...
  32. * when taking special interrupts. For now we don't support that,
  33. * special interrupts from within a non-standard level will probably
  34. * blow you up
  35. */
  36. #define SPECIAL_EXC_SRR0 0
  37. #define SPECIAL_EXC_SRR1 1
  38. #define SPECIAL_EXC_SPRG_GEN 2
  39. #define SPECIAL_EXC_SPRG_TLB 3
  40. #define SPECIAL_EXC_MAS0 4
  41. #define SPECIAL_EXC_MAS1 5
  42. #define SPECIAL_EXC_MAS2 6
  43. #define SPECIAL_EXC_MAS3 7
  44. #define SPECIAL_EXC_MAS6 8
  45. #define SPECIAL_EXC_MAS7 9
  46. #define SPECIAL_EXC_MAS5 10 /* E.HV only */
  47. #define SPECIAL_EXC_MAS8 11 /* E.HV only */
  48. #define SPECIAL_EXC_IRQHAPPENED 12
  49. #define SPECIAL_EXC_DEAR 13
  50. #define SPECIAL_EXC_ESR 14
  51. #define SPECIAL_EXC_SOFTE 15
  52. #define SPECIAL_EXC_CSRR0 16
  53. #define SPECIAL_EXC_CSRR1 17
  54. /* must be even to keep 16-byte stack alignment */
  55. #define SPECIAL_EXC_END 18
  56. #define SPECIAL_EXC_FRAME_SIZE (INT_FRAME_SIZE + SPECIAL_EXC_END * 8)
  57. #define SPECIAL_EXC_FRAME_OFFS (INT_FRAME_SIZE - 288)
  58. #define SPECIAL_EXC_STORE(reg, name) \
  59. std reg, (SPECIAL_EXC_##name * 8 + SPECIAL_EXC_FRAME_OFFS)(r1)
  60. #define SPECIAL_EXC_LOAD(reg, name) \
  61. ld reg, (SPECIAL_EXC_##name * 8 + SPECIAL_EXC_FRAME_OFFS)(r1)
  62. SYM_CODE_START_LOCAL(special_reg_save)
  63. /*
  64. * We only need (or have stack space) to save this stuff if
  65. * we interrupted the kernel.
  66. */
  67. ld r3,_MSR(r1)
  68. andi. r3,r3,MSR_PR
  69. bnelr
  70. /*
  71. * Advance to the next TLB exception frame for handler
  72. * types that don't do it automatically.
  73. */
  74. LOAD_REG_ADDR(r11,extlb_level_exc)
  75. lwz r12,0(r11)
  76. mfspr r10,SPRN_SPRG_TLB_EXFRAME
  77. add r10,r10,r12
  78. mtspr SPRN_SPRG_TLB_EXFRAME,r10
  79. /*
  80. * Save registers needed to allow nesting of certain exceptions
  81. * (such as TLB misses) inside special exception levels
  82. */
  83. mfspr r10,SPRN_SRR0
  84. SPECIAL_EXC_STORE(r10,SRR0)
  85. mfspr r10,SPRN_SRR1
  86. SPECIAL_EXC_STORE(r10,SRR1)
  87. mfspr r10,SPRN_SPRG_GEN_SCRATCH
  88. SPECIAL_EXC_STORE(r10,SPRG_GEN)
  89. mfspr r10,SPRN_SPRG_TLB_SCRATCH
  90. SPECIAL_EXC_STORE(r10,SPRG_TLB)
  91. mfspr r10,SPRN_MAS0
  92. SPECIAL_EXC_STORE(r10,MAS0)
  93. mfspr r10,SPRN_MAS1
  94. SPECIAL_EXC_STORE(r10,MAS1)
  95. mfspr r10,SPRN_MAS2
  96. SPECIAL_EXC_STORE(r10,MAS2)
  97. mfspr r10,SPRN_MAS3
  98. SPECIAL_EXC_STORE(r10,MAS3)
  99. mfspr r10,SPRN_MAS6
  100. SPECIAL_EXC_STORE(r10,MAS6)
  101. mfspr r10,SPRN_MAS7
  102. SPECIAL_EXC_STORE(r10,MAS7)
  103. BEGIN_FTR_SECTION
  104. mfspr r10,SPRN_MAS5
  105. SPECIAL_EXC_STORE(r10,MAS5)
  106. mfspr r10,SPRN_MAS8
  107. SPECIAL_EXC_STORE(r10,MAS8)
  108. /* MAS5/8 could have inappropriate values if we interrupted KVM code */
  109. li r10,0
  110. mtspr SPRN_MAS5,r10
  111. mtspr SPRN_MAS8,r10
  112. END_FTR_SECTION_IFSET(CPU_FTR_EMB_HV)
  113. mfspr r10,SPRN_DEAR
  114. SPECIAL_EXC_STORE(r10,DEAR)
  115. mfspr r10,SPRN_ESR
  116. SPECIAL_EXC_STORE(r10,ESR)
  117. ld r10,_NIP(r1)
  118. SPECIAL_EXC_STORE(r10,CSRR0)
  119. ld r10,_MSR(r1)
  120. SPECIAL_EXC_STORE(r10,CSRR1)
  121. blr
  122. SYM_CODE_END(special_reg_save)
  123. SYM_CODE_START_LOCAL(ret_from_level_except)
  124. ld r3,_MSR(r1)
  125. andi. r3,r3,MSR_PR
  126. beq 1f
  127. REST_NVGPRS(r1)
  128. b interrupt_return
  129. 1:
  130. LOAD_REG_ADDR(r11,extlb_level_exc)
  131. lwz r12,0(r11)
  132. mfspr r10,SPRN_SPRG_TLB_EXFRAME
  133. sub r10,r10,r12
  134. mtspr SPRN_SPRG_TLB_EXFRAME,r10
  135. /*
  136. * It's possible that the special level exception interrupted a
  137. * TLB miss handler, and inserted the same entry that the
  138. * interrupted handler was about to insert. On CPUs without TLB
  139. * write conditional, this can result in a duplicate TLB entry.
  140. * Wipe all non-bolted entries to be safe.
  141. *
  142. * Note that this doesn't protect against any TLB misses
  143. * we may take accessing the stack from here to the end of
  144. * the special level exception. It's not clear how we can
  145. * reasonably protect against that, but only CPUs with
  146. * neither TLB write conditional nor bolted kernel memory
  147. * are affected. Do any such CPUs even exist?
  148. */
  149. PPC_TLBILX_ALL(0,R0)
  150. REST_NVGPRS(r1)
  151. SPECIAL_EXC_LOAD(r10,SRR0)
  152. mtspr SPRN_SRR0,r10
  153. SPECIAL_EXC_LOAD(r10,SRR1)
  154. mtspr SPRN_SRR1,r10
  155. SPECIAL_EXC_LOAD(r10,SPRG_GEN)
  156. mtspr SPRN_SPRG_GEN_SCRATCH,r10
  157. SPECIAL_EXC_LOAD(r10,SPRG_TLB)
  158. mtspr SPRN_SPRG_TLB_SCRATCH,r10
  159. SPECIAL_EXC_LOAD(r10,MAS0)
  160. mtspr SPRN_MAS0,r10
  161. SPECIAL_EXC_LOAD(r10,MAS1)
  162. mtspr SPRN_MAS1,r10
  163. SPECIAL_EXC_LOAD(r10,MAS2)
  164. mtspr SPRN_MAS2,r10
  165. SPECIAL_EXC_LOAD(r10,MAS3)
  166. mtspr SPRN_MAS3,r10
  167. SPECIAL_EXC_LOAD(r10,MAS6)
  168. mtspr SPRN_MAS6,r10
  169. SPECIAL_EXC_LOAD(r10,MAS7)
  170. mtspr SPRN_MAS7,r10
  171. BEGIN_FTR_SECTION
  172. SPECIAL_EXC_LOAD(r10,MAS5)
  173. mtspr SPRN_MAS5,r10
  174. SPECIAL_EXC_LOAD(r10,MAS8)
  175. mtspr SPRN_MAS8,r10
  176. END_FTR_SECTION_IFSET(CPU_FTR_EMB_HV)
  177. SPECIAL_EXC_LOAD(r10,DEAR)
  178. mtspr SPRN_DEAR,r10
  179. SPECIAL_EXC_LOAD(r10,ESR)
  180. mtspr SPRN_ESR,r10
  181. stdcx. r0,0,r1 /* to clear the reservation */
  182. REST_GPRS(2, 9, r1)
  183. ld r10,_CTR(r1)
  184. ld r11,_XER(r1)
  185. mtctr r10
  186. mtxer r11
  187. blr
  188. SYM_CODE_END(ret_from_level_except)
  189. .macro ret_from_level srr0 srr1 paca_ex scratch
  190. bl ret_from_level_except
  191. ld r10,_LINK(r1)
  192. ld r11,_CCR(r1)
  193. ld r0,GPR13(r1)
  194. mtlr r10
  195. mtcr r11
  196. REST_GPRS(10, 12, r1)
  197. mtspr \scratch,r0
  198. std r10,\paca_ex+EX_R10(r13);
  199. std r11,\paca_ex+EX_R11(r13);
  200. ld r10,_NIP(r1)
  201. ld r11,_MSR(r1)
  202. REST_GPR(0, r1)
  203. REST_GPR(1, r1)
  204. mtspr \srr0,r10
  205. mtspr \srr1,r11
  206. ld r10,\paca_ex+EX_R10(r13)
  207. ld r11,\paca_ex+EX_R11(r13)
  208. mfspr r13,\scratch
  209. .endm
  210. SYM_CODE_START_LOCAL(ret_from_crit_except)
  211. ret_from_level SPRN_CSRR0 SPRN_CSRR1 PACA_EXCRIT SPRN_SPRG_CRIT_SCRATCH
  212. rfci
  213. SYM_CODE_END(ret_from_crit_except)
  214. SYM_CODE_START_LOCAL(ret_from_mc_except)
  215. ret_from_level SPRN_MCSRR0 SPRN_MCSRR1 PACA_EXMC SPRN_SPRG_MC_SCRATCH
  216. rfmci
  217. SYM_CODE_END(ret_from_mc_except)
  218. /* Exception prolog code for all exceptions */
  219. #define EXCEPTION_PROLOG(n, intnum, type, addition) \
  220. mtspr SPRN_SPRG_##type##_SCRATCH,r13; /* get spare registers */ \
  221. mfspr r13,SPRN_SPRG_PACA; /* get PACA */ \
  222. std r10,PACA_EX##type+EX_R10(r13); \
  223. std r11,PACA_EX##type+EX_R11(r13); \
  224. mfcr r10; /* save CR */ \
  225. mfspr r11,SPRN_##type##_SRR1;/* what are we coming from */ \
  226. DO_KVM intnum,SPRN_##type##_SRR1; /* KVM hook */ \
  227. stw r10,PACA_EX##type+EX_CR(r13); /* save old CR in the PACA */ \
  228. addition; /* additional code for that exc. */ \
  229. std r1,PACA_EX##type+EX_R1(r13); /* save old r1 in the PACA */ \
  230. type##_SET_KSTACK; /* get special stack if necessary */\
  231. andi. r10,r11,MSR_PR; /* save stack pointer */ \
  232. beq 1f; /* branch around if supervisor */ \
  233. ld r1,PACAKSAVE(r13); /* get kernel stack coming from usr */\
  234. 1: type##_BTB_FLUSH \
  235. cmpdi cr1,r1,0; /* check if SP makes sense */ \
  236. bge- cr1,exc_##n##_bad_stack;/* bad stack (TODO: out of line) */ \
  237. mfspr r10,SPRN_##type##_SRR0; /* read SRR0 before touching stack */
  238. /* Exception type-specific macros */
  239. #define GEN_SET_KSTACK \
  240. subi r1,r1,INT_FRAME_SIZE; /* alloc frame on kernel stack */
  241. #define SPRN_GEN_SRR0 SPRN_SRR0
  242. #define SPRN_GEN_SRR1 SPRN_SRR1
  243. #define GDBELL_SET_KSTACK GEN_SET_KSTACK
  244. #define SPRN_GDBELL_SRR0 SPRN_GSRR0
  245. #define SPRN_GDBELL_SRR1 SPRN_GSRR1
  246. #define CRIT_SET_KSTACK \
  247. ld r1,PACA_CRIT_STACK(r13); \
  248. subi r1,r1,SPECIAL_EXC_FRAME_SIZE
  249. #define SPRN_CRIT_SRR0 SPRN_CSRR0
  250. #define SPRN_CRIT_SRR1 SPRN_CSRR1
  251. #define DBG_SET_KSTACK \
  252. ld r1,PACA_DBG_STACK(r13); \
  253. subi r1,r1,SPECIAL_EXC_FRAME_SIZE
  254. #define SPRN_DBG_SRR0 SPRN_DSRR0
  255. #define SPRN_DBG_SRR1 SPRN_DSRR1
  256. #define MC_SET_KSTACK \
  257. ld r1,PACA_MC_STACK(r13); \
  258. subi r1,r1,SPECIAL_EXC_FRAME_SIZE
  259. #define SPRN_MC_SRR0 SPRN_MCSRR0
  260. #define SPRN_MC_SRR1 SPRN_MCSRR1
  261. #define GEN_BTB_FLUSH \
  262. START_BTB_FLUSH_SECTION \
  263. beq 1f; \
  264. BTB_FLUSH(r10) \
  265. 1: \
  266. END_BTB_FLUSH_SECTION
  267. #define CRIT_BTB_FLUSH \
  268. START_BTB_FLUSH_SECTION \
  269. BTB_FLUSH(r10) \
  270. END_BTB_FLUSH_SECTION
  271. #define DBG_BTB_FLUSH CRIT_BTB_FLUSH
  272. #define MC_BTB_FLUSH CRIT_BTB_FLUSH
  273. #define GDBELL_BTB_FLUSH GEN_BTB_FLUSH
  274. #define NORMAL_EXCEPTION_PROLOG(n, intnum, addition) \
  275. EXCEPTION_PROLOG(n, intnum, GEN, addition##_GEN(n))
  276. #define CRIT_EXCEPTION_PROLOG(n, intnum, addition) \
  277. EXCEPTION_PROLOG(n, intnum, CRIT, addition##_CRIT(n))
  278. #define DBG_EXCEPTION_PROLOG(n, intnum, addition) \
  279. EXCEPTION_PROLOG(n, intnum, DBG, addition##_DBG(n))
  280. #define MC_EXCEPTION_PROLOG(n, intnum, addition) \
  281. EXCEPTION_PROLOG(n, intnum, MC, addition##_MC(n))
  282. #define GDBELL_EXCEPTION_PROLOG(n, intnum, addition) \
  283. EXCEPTION_PROLOG(n, intnum, GDBELL, addition##_GDBELL(n))
  284. /* Variants of the "addition" argument for the prolog
  285. */
  286. #define PROLOG_ADDITION_NONE_GEN(n)
  287. #define PROLOG_ADDITION_NONE_GDBELL(n)
  288. #define PROLOG_ADDITION_NONE_CRIT(n)
  289. #define PROLOG_ADDITION_NONE_DBG(n)
  290. #define PROLOG_ADDITION_NONE_MC(n)
  291. #define PROLOG_ADDITION_MASKABLE_GEN(n) \
  292. lbz r10,PACAIRQSOFTMASK(r13); /* are irqs soft-masked? */ \
  293. andi. r10,r10,IRQS_DISABLED; /* yes -> go out of line */ \
  294. bne masked_interrupt_book3e_##n
  295. /*
  296. * Additional regs must be re-loaded from paca before EXCEPTION_COMMON* is
  297. * called, because that does SAVE_NVGPRS which must see the original register
  298. * values, otherwise the scratch values might be restored when exiting the
  299. * interrupt.
  300. */
  301. #define PROLOG_ADDITION_2REGS_GEN(n) \
  302. std r14,PACA_EXGEN+EX_R14(r13); \
  303. std r15,PACA_EXGEN+EX_R15(r13)
  304. #define PROLOG_ADDITION_1REG_GEN(n) \
  305. std r14,PACA_EXGEN+EX_R14(r13);
  306. #define PROLOG_ADDITION_2REGS_CRIT(n) \
  307. std r14,PACA_EXCRIT+EX_R14(r13); \
  308. std r15,PACA_EXCRIT+EX_R15(r13)
  309. #define PROLOG_ADDITION_2REGS_DBG(n) \
  310. std r14,PACA_EXDBG+EX_R14(r13); \
  311. std r15,PACA_EXDBG+EX_R15(r13)
  312. #define PROLOG_ADDITION_2REGS_MC(n) \
  313. std r14,PACA_EXMC+EX_R14(r13); \
  314. std r15,PACA_EXMC+EX_R15(r13)
  315. /* Core exception code for all exceptions except TLB misses. */
  316. #define EXCEPTION_COMMON_LVL(n, scratch, excf) \
  317. exc_##n##_common: \
  318. SAVE_GPR(0, r1); /* save r0 in stackframe */ \
  319. SAVE_GPRS(2, 9, r1); /* save r2 - r9 in stackframe */ \
  320. std r10,_NIP(r1); /* save SRR0 to stackframe */ \
  321. std r11,_MSR(r1); /* save SRR1 to stackframe */ \
  322. beq 2f; /* if from kernel mode */ \
  323. 2: ld r3,excf+EX_R10(r13); /* get back r10 */ \
  324. ld r4,excf+EX_R11(r13); /* get back r11 */ \
  325. mfspr r5,scratch; /* get back r13 */ \
  326. SAVE_GPR(12, r1); /* save r12 in stackframe */ \
  327. LOAD_PACA_TOC(); /* get kernel TOC into r2 */ \
  328. mflr r6; /* save LR in stackframe */ \
  329. mfctr r7; /* save CTR in stackframe */ \
  330. mfspr r8,SPRN_XER; /* save XER in stackframe */ \
  331. ld r9,excf+EX_R1(r13); /* load orig r1 back from PACA */ \
  332. lwz r10,excf+EX_CR(r13); /* load orig CR back from PACA */ \
  333. lbz r11,PACAIRQSOFTMASK(r13); /* get current IRQ softe */ \
  334. LOAD_REG_IMMEDIATE(r12, STACK_FRAME_REGS_MARKER); \
  335. ZEROIZE_GPR(0); \
  336. std r3,GPR10(r1); /* save r10 to stackframe */ \
  337. std r4,GPR11(r1); /* save r11 to stackframe */ \
  338. std r5,GPR13(r1); /* save it to stackframe */ \
  339. std r6,_LINK(r1); \
  340. std r7,_CTR(r1); \
  341. std r8,_XER(r1); \
  342. li r3,(n); /* regs.trap vector */ \
  343. std r9,0(r1); /* store stack frame back link */ \
  344. std r10,_CCR(r1); /* store orig CR in stackframe */ \
  345. std r9,GPR1(r1); /* store stack frame back link */ \
  346. std r11,SOFTE(r1); /* and save it to stackframe */ \
  347. std r12,STACK_INT_FRAME_MARKER(r1); /* mark the frame */ \
  348. std r3,_TRAP(r1); /* set trap number */ \
  349. std r0,RESULT(r1); /* clear regs->result */ \
  350. SAVE_NVGPRS(r1); \
  351. SANITIZE_NVGPRS(); /* minimise speculation influence */
  352. #define EXCEPTION_COMMON(n) \
  353. EXCEPTION_COMMON_LVL(n, SPRN_SPRG_GEN_SCRATCH, PACA_EXGEN)
  354. #define EXCEPTION_COMMON_CRIT(n) \
  355. EXCEPTION_COMMON_LVL(n, SPRN_SPRG_CRIT_SCRATCH, PACA_EXCRIT)
  356. #define EXCEPTION_COMMON_MC(n) \
  357. EXCEPTION_COMMON_LVL(n, SPRN_SPRG_MC_SCRATCH, PACA_EXMC)
  358. #define EXCEPTION_COMMON_DBG(n) \
  359. EXCEPTION_COMMON_LVL(n, SPRN_SPRG_DBG_SCRATCH, PACA_EXDBG)
  360. /* XXX FIXME: Restore r14/r15 when necessary */
  361. #define BAD_STACK_TRAMPOLINE(n) \
  362. exc_##n##_bad_stack: \
  363. li r1,(n); /* get exception number */ \
  364. sth r1,PACA_TRAP_SAVE(r13); /* store trap */ \
  365. b bad_stack_book3e; /* bad stack error */
  366. /* WARNING: If you change the layout of this stub, make sure you check
  367. * the debug exception handler which handles single stepping
  368. * into exceptions from userspace, and the MM code in
  369. * arch/powerpc/mm/tlb_nohash.c which patches the branch here
  370. * and would need to be updated if that branch is moved
  371. */
  372. #define EXCEPTION_STUB(loc, label) \
  373. . = interrupt_base_book3e + loc; \
  374. nop; /* To make debug interrupts happy */ \
  375. b exc_##label##_book3e;
  376. #define ACK_NONE(r)
  377. #define ACK_DEC(r) \
  378. lis r,TSR_DIS@h; \
  379. mtspr SPRN_TSR,r
  380. #define ACK_FIT(r) \
  381. lis r,TSR_FIS@h; \
  382. mtspr SPRN_TSR,r
  383. /* Used by asynchronous interrupt that may happen in the idle loop.
  384. *
  385. * This check if the thread was in the idle loop, and if yes, returns
  386. * to the caller rather than the PC. This is to avoid a race if
  387. * interrupts happen before the wait instruction.
  388. */
  389. #define CHECK_NAPPING() \
  390. ld r11, PACA_THREAD_INFO(r13); \
  391. ld r10,TI_LOCAL_FLAGS(r11); \
  392. andi. r9,r10,_TLF_NAPPING; \
  393. beq+ 1f; \
  394. ld r8,_LINK(r1); \
  395. rlwinm r7,r10,0,~_TLF_NAPPING; \
  396. std r8,_NIP(r1); \
  397. std r7,TI_LOCAL_FLAGS(r11); \
  398. 1:
  399. #define MASKABLE_EXCEPTION(trapnum, intnum, label, hdlr, ack) \
  400. START_EXCEPTION(label); \
  401. NORMAL_EXCEPTION_PROLOG(trapnum, intnum, PROLOG_ADDITION_MASKABLE)\
  402. EXCEPTION_COMMON(trapnum) \
  403. ack(r8); \
  404. CHECK_NAPPING(); \
  405. addi r3,r1,STACK_INT_FRAME_REGS; \
  406. bl hdlr; \
  407. b interrupt_return
  408. /*
  409. * And here we have the exception vectors !
  410. */
  411. .text
  412. .balign 0x1000
  413. .globl interrupt_base_book3e
  414. interrupt_base_book3e: /* fake trap */
  415. EXCEPTION_STUB(0x000, machine_check)
  416. EXCEPTION_STUB(0x020, critical_input) /* 0x0100 */
  417. EXCEPTION_STUB(0x040, debug_crit) /* 0x0d00 */
  418. EXCEPTION_STUB(0x060, data_storage) /* 0x0300 */
  419. EXCEPTION_STUB(0x080, instruction_storage) /* 0x0400 */
  420. EXCEPTION_STUB(0x0a0, external_input) /* 0x0500 */
  421. EXCEPTION_STUB(0x0c0, alignment) /* 0x0600 */
  422. EXCEPTION_STUB(0x0e0, program) /* 0x0700 */
  423. EXCEPTION_STUB(0x100, fp_unavailable) /* 0x0800 */
  424. EXCEPTION_STUB(0x120, system_call) /* 0x0c00 */
  425. EXCEPTION_STUB(0x140, ap_unavailable) /* 0x0f20 */
  426. EXCEPTION_STUB(0x160, decrementer) /* 0x0900 */
  427. EXCEPTION_STUB(0x180, fixed_interval) /* 0x0980 */
  428. EXCEPTION_STUB(0x1a0, watchdog) /* 0x09f0 */
  429. EXCEPTION_STUB(0x1c0, data_tlb_miss_bolted)
  430. EXCEPTION_STUB(0x1e0, instruction_tlb_miss_bolted)
  431. EXCEPTION_STUB(0x200, altivec_unavailable)
  432. EXCEPTION_STUB(0x220, altivec_assist)
  433. EXCEPTION_STUB(0x260, perfmon)
  434. EXCEPTION_STUB(0x280, doorbell)
  435. EXCEPTION_STUB(0x2a0, doorbell_crit)
  436. EXCEPTION_STUB(0x2c0, guest_doorbell)
  437. EXCEPTION_STUB(0x2e0, guest_doorbell_crit)
  438. EXCEPTION_STUB(0x300, hypercall)
  439. EXCEPTION_STUB(0x320, ehpriv)
  440. EXCEPTION_STUB(0x340, lrat_error)
  441. .globl __end_interrupts
  442. __end_interrupts:
  443. /* Critical Input Interrupt */
  444. START_EXCEPTION(critical_input);
  445. CRIT_EXCEPTION_PROLOG(0x100, BOOKE_INTERRUPT_CRITICAL,
  446. PROLOG_ADDITION_NONE)
  447. EXCEPTION_COMMON_CRIT(0x100)
  448. bl special_reg_save
  449. CHECK_NAPPING();
  450. addi r3,r1,STACK_INT_FRAME_REGS
  451. bl unknown_nmi_exception
  452. b ret_from_crit_except
  453. /* Machine Check Interrupt */
  454. START_EXCEPTION(machine_check);
  455. MC_EXCEPTION_PROLOG(0x000, BOOKE_INTERRUPT_MACHINE_CHECK,
  456. PROLOG_ADDITION_NONE)
  457. EXCEPTION_COMMON_MC(0x000)
  458. bl special_reg_save
  459. CHECK_NAPPING();
  460. addi r3,r1,STACK_INT_FRAME_REGS
  461. bl machine_check_exception
  462. b ret_from_mc_except
  463. /* Data Storage Interrupt */
  464. START_EXCEPTION(data_storage)
  465. NORMAL_EXCEPTION_PROLOG(0x300, BOOKE_INTERRUPT_DATA_STORAGE,
  466. PROLOG_ADDITION_2REGS)
  467. mfspr r14,SPRN_DEAR
  468. mfspr r15,SPRN_ESR
  469. std r14,_DEAR(r1)
  470. std r15,_ESR(r1)
  471. ld r14,PACA_EXGEN+EX_R14(r13)
  472. ld r15,PACA_EXGEN+EX_R15(r13)
  473. EXCEPTION_COMMON(0x300)
  474. b storage_fault_common
  475. /* Instruction Storage Interrupt */
  476. START_EXCEPTION(instruction_storage);
  477. NORMAL_EXCEPTION_PROLOG(0x400, BOOKE_INTERRUPT_INST_STORAGE,
  478. PROLOG_ADDITION_2REGS)
  479. li r15,0
  480. mr r14,r10
  481. std r14,_DEAR(r1)
  482. std r15,_ESR(r1)
  483. ld r14,PACA_EXGEN+EX_R14(r13)
  484. ld r15,PACA_EXGEN+EX_R15(r13)
  485. EXCEPTION_COMMON(0x400)
  486. b storage_fault_common
  487. /* External Input Interrupt */
  488. MASKABLE_EXCEPTION(0x500, BOOKE_INTERRUPT_EXTERNAL,
  489. external_input, do_IRQ, ACK_NONE)
  490. /* Alignment */
  491. START_EXCEPTION(alignment);
  492. NORMAL_EXCEPTION_PROLOG(0x600, BOOKE_INTERRUPT_ALIGNMENT,
  493. PROLOG_ADDITION_2REGS)
  494. mfspr r14,SPRN_DEAR
  495. mfspr r15,SPRN_ESR
  496. std r14,_DEAR(r1)
  497. std r15,_ESR(r1)
  498. ld r14,PACA_EXGEN+EX_R14(r13)
  499. ld r15,PACA_EXGEN+EX_R15(r13)
  500. EXCEPTION_COMMON(0x600)
  501. b alignment_more /* no room, go out of line */
  502. /* Program Interrupt */
  503. START_EXCEPTION(program);
  504. NORMAL_EXCEPTION_PROLOG(0x700, BOOKE_INTERRUPT_PROGRAM,
  505. PROLOG_ADDITION_1REG)
  506. mfspr r14,SPRN_ESR
  507. std r14,_ESR(r1)
  508. ld r14,PACA_EXGEN+EX_R14(r13)
  509. EXCEPTION_COMMON(0x700)
  510. addi r3,r1,STACK_INT_FRAME_REGS
  511. bl program_check_exception
  512. REST_NVGPRS(r1)
  513. b interrupt_return
  514. /* Floating Point Unavailable Interrupt */
  515. START_EXCEPTION(fp_unavailable);
  516. NORMAL_EXCEPTION_PROLOG(0x800, BOOKE_INTERRUPT_FP_UNAVAIL,
  517. PROLOG_ADDITION_NONE)
  518. /* we can probably do a shorter exception entry for that one... */
  519. EXCEPTION_COMMON(0x800)
  520. ld r12,_MSR(r1)
  521. andi. r0,r12,MSR_PR;
  522. beq- 1f
  523. bl load_up_fpu
  524. b fast_interrupt_return
  525. 1: addi r3,r1,STACK_INT_FRAME_REGS
  526. bl kernel_fp_unavailable_exception
  527. b interrupt_return
  528. /* Altivec Unavailable Interrupt */
  529. START_EXCEPTION(altivec_unavailable);
  530. NORMAL_EXCEPTION_PROLOG(0x200, BOOKE_INTERRUPT_ALTIVEC_UNAVAIL,
  531. PROLOG_ADDITION_NONE)
  532. /* we can probably do a shorter exception entry for that one... */
  533. EXCEPTION_COMMON(0x200)
  534. #ifdef CONFIG_ALTIVEC
  535. BEGIN_FTR_SECTION
  536. ld r12,_MSR(r1)
  537. andi. r0,r12,MSR_PR;
  538. beq- 1f
  539. bl load_up_altivec
  540. b fast_interrupt_return
  541. 1:
  542. END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
  543. #endif
  544. addi r3,r1,STACK_INT_FRAME_REGS
  545. bl altivec_unavailable_exception
  546. b interrupt_return
  547. /* AltiVec Assist */
  548. START_EXCEPTION(altivec_assist);
  549. NORMAL_EXCEPTION_PROLOG(0x220,
  550. BOOKE_INTERRUPT_ALTIVEC_ASSIST,
  551. PROLOG_ADDITION_NONE)
  552. EXCEPTION_COMMON(0x220)
  553. addi r3,r1,STACK_INT_FRAME_REGS
  554. #ifdef CONFIG_ALTIVEC
  555. BEGIN_FTR_SECTION
  556. bl altivec_assist_exception
  557. END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
  558. REST_NVGPRS(r1)
  559. #else
  560. bl unknown_exception
  561. #endif
  562. b interrupt_return
  563. /* Decrementer Interrupt */
  564. MASKABLE_EXCEPTION(0x900, BOOKE_INTERRUPT_DECREMENTER,
  565. decrementer, timer_interrupt, ACK_DEC)
  566. /* Fixed Interval Timer Interrupt */
  567. MASKABLE_EXCEPTION(0x980, BOOKE_INTERRUPT_FIT,
  568. fixed_interval, unknown_exception, ACK_FIT)
  569. /* Watchdog Timer Interrupt */
  570. START_EXCEPTION(watchdog);
  571. CRIT_EXCEPTION_PROLOG(0x9f0, BOOKE_INTERRUPT_WATCHDOG,
  572. PROLOG_ADDITION_NONE)
  573. EXCEPTION_COMMON_CRIT(0x9f0)
  574. bl special_reg_save
  575. CHECK_NAPPING();
  576. addi r3,r1,STACK_INT_FRAME_REGS
  577. #ifdef CONFIG_BOOKE_WDT
  578. bl WatchdogException
  579. #else
  580. bl unknown_nmi_exception
  581. #endif
  582. b ret_from_crit_except
  583. /* System Call Interrupt */
  584. START_EXCEPTION(system_call)
  585. mr r9,r13 /* keep a copy of userland r13 */
  586. mfspr r11,SPRN_SRR0 /* get return address */
  587. mfspr r12,SPRN_SRR1 /* get previous MSR */
  588. mfspr r13,SPRN_SPRG_PACA /* get our PACA */
  589. b system_call_common
  590. /* Auxiliary Processor Unavailable Interrupt */
  591. START_EXCEPTION(ap_unavailable);
  592. NORMAL_EXCEPTION_PROLOG(0xf20, BOOKE_INTERRUPT_AP_UNAVAIL,
  593. PROLOG_ADDITION_NONE)
  594. EXCEPTION_COMMON(0xf20)
  595. addi r3,r1,STACK_INT_FRAME_REGS
  596. bl unknown_exception
  597. b interrupt_return
  598. /* Debug exception as a critical interrupt*/
  599. START_EXCEPTION(debug_crit);
  600. CRIT_EXCEPTION_PROLOG(0xd00, BOOKE_INTERRUPT_DEBUG,
  601. PROLOG_ADDITION_2REGS)
  602. /*
  603. * If there is a single step or branch-taken exception in an
  604. * exception entry sequence, it was probably meant to apply to
  605. * the code where the exception occurred (since exception entry
  606. * doesn't turn off DE automatically). We simulate the effect
  607. * of turning off DE on entry to an exception handler by turning
  608. * off DE in the CSRR1 value and clearing the debug status.
  609. */
  610. mfspr r14,SPRN_DBSR /* check single-step/branch taken */
  611. andis. r15,r14,(DBSR_IC|DBSR_BT)@h
  612. beq+ 1f
  613. #ifdef CONFIG_RELOCATABLE
  614. __LOAD_PACA_TOC(r15)
  615. LOAD_REG_ADDR_ALTTOC(r14, r15, interrupt_base_book3e)
  616. LOAD_REG_ADDR_ALTTOC(r15, r15, __end_interrupts)
  617. cmpld cr0,r10,r14
  618. cmpld cr1,r10,r15
  619. #else
  620. LOAD_REG_IMMEDIATE_SYM(r14, r15, interrupt_base_book3e)
  621. cmpld cr0, r10, r14
  622. LOAD_REG_IMMEDIATE_SYM(r14, r15, __end_interrupts)
  623. cmpld cr1, r10, r14
  624. #endif
  625. blt+ cr0,1f
  626. bge+ cr1,1f
  627. /* here it looks like we got an inappropriate debug exception. */
  628. lis r14,(DBSR_IC|DBSR_BT)@h /* clear the event */
  629. rlwinm r11,r11,0,~MSR_DE /* clear DE in the CSRR1 value */
  630. mtspr SPRN_DBSR,r14
  631. mtspr SPRN_CSRR1,r11
  632. lwz r10,PACA_EXCRIT+EX_CR(r13) /* restore registers */
  633. ld r1,PACA_EXCRIT+EX_R1(r13)
  634. ld r14,PACA_EXCRIT+EX_R14(r13)
  635. ld r15,PACA_EXCRIT+EX_R15(r13)
  636. mtcr r10
  637. ld r10,PACA_EXCRIT+EX_R10(r13) /* restore registers */
  638. ld r11,PACA_EXCRIT+EX_R11(r13)
  639. mfspr r13,SPRN_SPRG_CRIT_SCRATCH
  640. rfci
  641. /* Normal debug exception */
  642. /* XXX We only handle coming from userspace for now since we can't
  643. * quite save properly an interrupted kernel state yet
  644. */
  645. 1: andi. r14,r11,MSR_PR; /* check for userspace again */
  646. beq kernel_dbg_exc; /* if from kernel mode */
  647. /* Now we mash up things to make it look like we are coming on a
  648. * normal exception
  649. */
  650. mfspr r14,SPRN_DBSR
  651. std r14,_DSISR(r1)
  652. ld r14,PACA_EXCRIT+EX_R14(r13)
  653. ld r15,PACA_EXCRIT+EX_R15(r13)
  654. EXCEPTION_COMMON_CRIT(0xd00)
  655. addi r3,r1,STACK_INT_FRAME_REGS
  656. bl DebugException
  657. REST_NVGPRS(r1)
  658. b interrupt_return
  659. kernel_dbg_exc:
  660. b . /* NYI */
  661. /* Debug exception as a debug interrupt*/
  662. START_EXCEPTION(debug_debug);
  663. DBG_EXCEPTION_PROLOG(0xd00, BOOKE_INTERRUPT_DEBUG,
  664. PROLOG_ADDITION_2REGS)
  665. /*
  666. * If there is a single step or branch-taken exception in an
  667. * exception entry sequence, it was probably meant to apply to
  668. * the code where the exception occurred (since exception entry
  669. * doesn't turn off DE automatically). We simulate the effect
  670. * of turning off DE on entry to an exception handler by turning
  671. * off DE in the DSRR1 value and clearing the debug status.
  672. */
  673. mfspr r14,SPRN_DBSR /* check single-step/branch taken */
  674. andis. r15,r14,(DBSR_IC|DBSR_BT)@h
  675. beq+ 1f
  676. #ifdef CONFIG_RELOCATABLE
  677. __LOAD_PACA_TOC(r15)
  678. LOAD_REG_ADDR_ALTTOC(r14, r15, interrupt_base_book3e)
  679. LOAD_REG_ADDR_ALTTOC(r15, r15, __end_interrupts)
  680. cmpld cr0,r10,r14
  681. cmpld cr1,r10,r15
  682. #else
  683. LOAD_REG_IMMEDIATE_SYM(r14, r15, interrupt_base_book3e)
  684. cmpld cr0, r10, r14
  685. LOAD_REG_IMMEDIATE_SYM(r14, r15,__end_interrupts)
  686. cmpld cr1, r10, r14
  687. #endif
  688. blt+ cr0,1f
  689. bge+ cr1,1f
  690. /* here it looks like we got an inappropriate debug exception. */
  691. lis r14,(DBSR_IC|DBSR_BT)@h /* clear the event */
  692. rlwinm r11,r11,0,~MSR_DE /* clear DE in the DSRR1 value */
  693. mtspr SPRN_DBSR,r14
  694. mtspr SPRN_DSRR1,r11
  695. lwz r10,PACA_EXDBG+EX_CR(r13) /* restore registers */
  696. ld r1,PACA_EXDBG+EX_R1(r13)
  697. ld r14,PACA_EXDBG+EX_R14(r13)
  698. ld r15,PACA_EXDBG+EX_R15(r13)
  699. mtcr r10
  700. ld r10,PACA_EXDBG+EX_R10(r13) /* restore registers */
  701. ld r11,PACA_EXDBG+EX_R11(r13)
  702. mfspr r13,SPRN_SPRG_DBG_SCRATCH
  703. rfdi
  704. /* Normal debug exception */
  705. /* XXX We only handle coming from userspace for now since we can't
  706. * quite save properly an interrupted kernel state yet
  707. */
  708. 1: andi. r14,r11,MSR_PR; /* check for userspace again */
  709. beq kernel_dbg_exc; /* if from kernel mode */
  710. /* Now we mash up things to make it look like we are coming on a
  711. * normal exception
  712. */
  713. mfspr r14,SPRN_DBSR
  714. std r14,_DSISR(r1)
  715. ld r14,PACA_EXDBG+EX_R14(r13)
  716. ld r15,PACA_EXDBG+EX_R15(r13)
  717. EXCEPTION_COMMON_DBG(0xd08)
  718. addi r3,r1,STACK_INT_FRAME_REGS
  719. bl DebugException
  720. REST_NVGPRS(r1)
  721. b interrupt_return
  722. START_EXCEPTION(perfmon);
  723. NORMAL_EXCEPTION_PROLOG(0x260, BOOKE_INTERRUPT_PERFORMANCE_MONITOR,
  724. PROLOG_ADDITION_NONE)
  725. EXCEPTION_COMMON(0x260)
  726. CHECK_NAPPING()
  727. addi r3,r1,STACK_INT_FRAME_REGS
  728. /*
  729. * XXX: Returning from performance_monitor_exception taken as a
  730. * soft-NMI (Linux irqs disabled) may be risky to use interrupt_return
  731. * and could cause bugs in return or elsewhere. That case should just
  732. * restore registers and return. There is a workaround for one known
  733. * problem in interrupt_exit_kernel_prepare().
  734. */
  735. bl performance_monitor_exception
  736. b interrupt_return
  737. /* Doorbell interrupt */
  738. MASKABLE_EXCEPTION(0x280, BOOKE_INTERRUPT_DOORBELL,
  739. doorbell, doorbell_exception, ACK_NONE)
  740. /* Doorbell critical Interrupt */
  741. START_EXCEPTION(doorbell_crit);
  742. CRIT_EXCEPTION_PROLOG(0x2a0, BOOKE_INTERRUPT_DOORBELL_CRITICAL,
  743. PROLOG_ADDITION_NONE)
  744. EXCEPTION_COMMON_CRIT(0x2a0)
  745. bl special_reg_save
  746. CHECK_NAPPING();
  747. addi r3,r1,STACK_INT_FRAME_REGS
  748. bl unknown_nmi_exception
  749. b ret_from_crit_except
  750. /*
  751. * Guest doorbell interrupt
  752. * This general exception use GSRRx save/restore registers
  753. */
  754. START_EXCEPTION(guest_doorbell);
  755. GDBELL_EXCEPTION_PROLOG(0x2c0, BOOKE_INTERRUPT_GUEST_DBELL,
  756. PROLOG_ADDITION_NONE)
  757. EXCEPTION_COMMON(0x2c0)
  758. addi r3,r1,STACK_INT_FRAME_REGS
  759. bl unknown_exception
  760. b interrupt_return
  761. /* Guest Doorbell critical Interrupt */
  762. START_EXCEPTION(guest_doorbell_crit);
  763. CRIT_EXCEPTION_PROLOG(0x2e0, BOOKE_INTERRUPT_GUEST_DBELL_CRIT,
  764. PROLOG_ADDITION_NONE)
  765. EXCEPTION_COMMON_CRIT(0x2e0)
  766. bl special_reg_save
  767. CHECK_NAPPING();
  768. addi r3,r1,STACK_INT_FRAME_REGS
  769. bl unknown_nmi_exception
  770. b ret_from_crit_except
  771. /* Hypervisor call */
  772. START_EXCEPTION(hypercall);
  773. NORMAL_EXCEPTION_PROLOG(0x310, BOOKE_INTERRUPT_HV_SYSCALL,
  774. PROLOG_ADDITION_NONE)
  775. EXCEPTION_COMMON(0x310)
  776. addi r3,r1,STACK_INT_FRAME_REGS
  777. bl unknown_exception
  778. b interrupt_return
  779. /* Embedded Hypervisor priviledged */
  780. START_EXCEPTION(ehpriv);
  781. NORMAL_EXCEPTION_PROLOG(0x320, BOOKE_INTERRUPT_HV_PRIV,
  782. PROLOG_ADDITION_NONE)
  783. EXCEPTION_COMMON(0x320)
  784. addi r3,r1,STACK_INT_FRAME_REGS
  785. bl unknown_exception
  786. b interrupt_return
  787. /* LRAT Error interrupt */
  788. START_EXCEPTION(lrat_error);
  789. NORMAL_EXCEPTION_PROLOG(0x340, BOOKE_INTERRUPT_LRAT_ERROR,
  790. PROLOG_ADDITION_NONE)
  791. EXCEPTION_COMMON(0x340)
  792. addi r3,r1,STACK_INT_FRAME_REGS
  793. bl unknown_exception
  794. b interrupt_return
  795. .macro SEARCH_RESTART_TABLE
  796. #ifdef CONFIG_RELOCATABLE
  797. __LOAD_PACA_TOC(r11)
  798. LOAD_REG_ADDR_ALTTOC(r14, r11, __start___restart_table)
  799. LOAD_REG_ADDR_ALTTOC(r15, r11, __stop___restart_table)
  800. #else
  801. LOAD_REG_IMMEDIATE_SYM(r14, r11, __start___restart_table)
  802. LOAD_REG_IMMEDIATE_SYM(r15, r11, __stop___restart_table)
  803. #endif
  804. 300:
  805. cmpd r14,r15
  806. beq 302f
  807. ld r11,0(r14)
  808. cmpld r10,r11
  809. blt 301f
  810. ld r11,8(r14)
  811. cmpld r10,r11
  812. bge 301f
  813. ld r11,16(r14)
  814. b 303f
  815. 301:
  816. addi r14,r14,24
  817. b 300b
  818. 302:
  819. li r11,0
  820. 303:
  821. .endm
  822. /*
  823. * An interrupt came in while soft-disabled; We mark paca->irq_happened
  824. * accordingly and if the interrupt is level sensitive, we hard disable
  825. * hard disable (full_mask) corresponds to PACA_IRQ_MUST_HARD_MASK, so
  826. * keep these in synch.
  827. */
  828. .macro masked_interrupt_book3e paca_irq full_mask
  829. std r14,PACA_EXGEN+EX_R14(r13)
  830. std r15,PACA_EXGEN+EX_R15(r13)
  831. lbz r10,PACAIRQHAPPENED(r13)
  832. .if \full_mask == 1
  833. ori r10,r10,\paca_irq | PACA_IRQ_HARD_DIS
  834. .else
  835. ori r10,r10,\paca_irq
  836. .endif
  837. stb r10,PACAIRQHAPPENED(r13)
  838. .if \full_mask == 1
  839. xori r11,r11,MSR_EE /* clear MSR_EE */
  840. mtspr SPRN_SRR1,r11
  841. .endif
  842. mfspr r10,SPRN_SRR0
  843. SEARCH_RESTART_TABLE
  844. cmpdi r11,0
  845. beq 1f
  846. mtspr SPRN_SRR0,r11 /* return to restart address */
  847. 1:
  848. lwz r11,PACA_EXGEN+EX_CR(r13)
  849. mtcr r11
  850. ld r10,PACA_EXGEN+EX_R10(r13)
  851. ld r11,PACA_EXGEN+EX_R11(r13)
  852. ld r14,PACA_EXGEN+EX_R14(r13)
  853. ld r15,PACA_EXGEN+EX_R15(r13)
  854. mfspr r13,SPRN_SPRG_GEN_SCRATCH
  855. rfi
  856. b .
  857. .endm
  858. masked_interrupt_book3e_0x500:
  859. masked_interrupt_book3e PACA_IRQ_EE 1
  860. masked_interrupt_book3e_0x900:
  861. ACK_DEC(r10);
  862. masked_interrupt_book3e PACA_IRQ_DEC 0
  863. masked_interrupt_book3e_0x980:
  864. ACK_FIT(r10);
  865. masked_interrupt_book3e PACA_IRQ_DEC 0
  866. masked_interrupt_book3e_0x280:
  867. masked_interrupt_book3e_0x2c0:
  868. masked_interrupt_book3e PACA_IRQ_DBELL 0
  869. /*
  870. * This is called from 0x300 and 0x400 handlers after the prologs with
  871. * r14 and r15 containing the fault address and error code, with the
  872. * original values stashed away in the PACA
  873. */
  874. SYM_CODE_START_LOCAL(storage_fault_common)
  875. addi r3,r1,STACK_INT_FRAME_REGS
  876. bl do_page_fault
  877. b interrupt_return
  878. SYM_CODE_END(storage_fault_common)
  879. /*
  880. * Alignment exception doesn't fit entirely in the 0x100 bytes so it
  881. * continues here.
  882. */
  883. SYM_CODE_START_LOCAL(alignment_more)
  884. addi r3,r1,STACK_INT_FRAME_REGS
  885. bl alignment_exception
  886. REST_NVGPRS(r1)
  887. b interrupt_return
  888. SYM_CODE_END(alignment_more)
  889. /*
  890. * Trampolines used when spotting a bad kernel stack pointer in
  891. * the exception entry code.
  892. *
  893. * TODO: move some bits like SRR0 read to trampoline, pass PACA
  894. * index around, etc... to handle crit & mcheck
  895. */
  896. BAD_STACK_TRAMPOLINE(0x000)
  897. BAD_STACK_TRAMPOLINE(0x100)
  898. BAD_STACK_TRAMPOLINE(0x200)
  899. BAD_STACK_TRAMPOLINE(0x220)
  900. BAD_STACK_TRAMPOLINE(0x260)
  901. BAD_STACK_TRAMPOLINE(0x280)
  902. BAD_STACK_TRAMPOLINE(0x2a0)
  903. BAD_STACK_TRAMPOLINE(0x2c0)
  904. BAD_STACK_TRAMPOLINE(0x2e0)
  905. BAD_STACK_TRAMPOLINE(0x300)
  906. BAD_STACK_TRAMPOLINE(0x310)
  907. BAD_STACK_TRAMPOLINE(0x320)
  908. BAD_STACK_TRAMPOLINE(0x340)
  909. BAD_STACK_TRAMPOLINE(0x400)
  910. BAD_STACK_TRAMPOLINE(0x500)
  911. BAD_STACK_TRAMPOLINE(0x600)
  912. BAD_STACK_TRAMPOLINE(0x700)
  913. BAD_STACK_TRAMPOLINE(0x800)
  914. BAD_STACK_TRAMPOLINE(0x900)
  915. BAD_STACK_TRAMPOLINE(0x980)
  916. BAD_STACK_TRAMPOLINE(0x9f0)
  917. BAD_STACK_TRAMPOLINE(0xa00)
  918. BAD_STACK_TRAMPOLINE(0xb00)
  919. BAD_STACK_TRAMPOLINE(0xc00)
  920. BAD_STACK_TRAMPOLINE(0xd00)
  921. BAD_STACK_TRAMPOLINE(0xd08)
  922. BAD_STACK_TRAMPOLINE(0xe00)
  923. BAD_STACK_TRAMPOLINE(0xf00)
  924. BAD_STACK_TRAMPOLINE(0xf20)
  925. _GLOBAL(bad_stack_book3e)
  926. /* XXX: Needs to make SPRN_SPRG_GEN depend on exception type */
  927. mfspr r10,SPRN_SRR0; /* read SRR0 before touching stack */
  928. ld r1,PACAEMERGSP(r13)
  929. subi r1,r1,64+INT_FRAME_SIZE
  930. std r10,_NIP(r1)
  931. std r11,_MSR(r1)
  932. ld r10,PACA_EXGEN+EX_R1(r13) /* FIXME for crit & mcheck */
  933. lwz r11,PACA_EXGEN+EX_CR(r13) /* FIXME for crit & mcheck */
  934. std r10,GPR1(r1)
  935. std r11,_CCR(r1)
  936. mfspr r10,SPRN_DEAR
  937. mfspr r11,SPRN_ESR
  938. std r10,_DEAR(r1)
  939. std r11,_ESR(r1)
  940. SAVE_GPR(0, r1); /* save r0 in stackframe */ \
  941. SAVE_GPRS(2, 9, r1); /* save r2 - r9 in stackframe */ \
  942. ld r3,PACA_EXGEN+EX_R10(r13);/* get back r10 */ \
  943. ld r4,PACA_EXGEN+EX_R11(r13);/* get back r11 */ \
  944. mfspr r5,SPRN_SPRG_GEN_SCRATCH;/* get back r13 XXX can be wrong */ \
  945. std r3,GPR10(r1); /* save r10 to stackframe */ \
  946. std r4,GPR11(r1); /* save r11 to stackframe */ \
  947. SAVE_GPR(12, r1); /* save r12 in stackframe */ \
  948. std r5,GPR13(r1); /* save it to stackframe */ \
  949. mflr r10
  950. mfctr r11
  951. mfxer r12
  952. std r10,_LINK(r1)
  953. std r11,_CTR(r1)
  954. std r12,_XER(r1)
  955. SAVE_NVGPRS(r1)
  956. lhz r12,PACA_TRAP_SAVE(r13)
  957. std r12,_TRAP(r1)
  958. addi r11,r1,INT_FRAME_SIZE
  959. std r11,0(r1)
  960. ZEROIZE_GPR(12)
  961. std r12,0(r11)
  962. LOAD_PACA_TOC()
  963. 1: addi r3,r1,STACK_INT_FRAME_REGS
  964. bl kernel_bad_stack
  965. b 1b
  966. /*
  967. * Setup the initial TLB for a core. This current implementation
  968. * assume that whatever we are running off will not conflict with
  969. * the new mapping at PAGE_OFFSET.
  970. */
  971. _GLOBAL(initial_tlb_book3e)
  972. /* Look for the first TLB with IPROT set */
  973. mfspr r4,SPRN_TLB0CFG
  974. andi. r3,r4,TLBnCFG_IPROT
  975. lis r3,MAS0_TLBSEL(0)@h
  976. bne found_iprot
  977. mfspr r4,SPRN_TLB1CFG
  978. andi. r3,r4,TLBnCFG_IPROT
  979. lis r3,MAS0_TLBSEL(1)@h
  980. bne found_iprot
  981. mfspr r4,SPRN_TLB2CFG
  982. andi. r3,r4,TLBnCFG_IPROT
  983. lis r3,MAS0_TLBSEL(2)@h
  984. bne found_iprot
  985. lis r3,MAS0_TLBSEL(3)@h
  986. mfspr r4,SPRN_TLB3CFG
  987. /* fall through */
  988. found_iprot:
  989. andi. r5,r4,TLBnCFG_HES
  990. bne have_hes
  991. mflr r8 /* save LR */
  992. /* 1. Find the index of the entry we're executing in
  993. *
  994. * r3 = MAS0_TLBSEL (for the iprot array)
  995. * r4 = SPRN_TLBnCFG
  996. */
  997. bcl 20,31,$+4 /* Find our address */
  998. invstr: mflr r6 /* Make it accessible */
  999. mfmsr r7
  1000. rlwinm r5,r7,27,31,31 /* extract MSR[IS] */
  1001. mfspr r7,SPRN_PID
  1002. slwi r7,r7,16
  1003. or r7,r7,r5
  1004. mtspr SPRN_MAS6,r7
  1005. tlbsx 0,r6 /* search MSR[IS], SPID=PID */
  1006. mfspr r3,SPRN_MAS0
  1007. rlwinm r5,r3,16,20,31 /* Extract MAS0(Entry) */
  1008. mfspr r7,SPRN_MAS1 /* Insure IPROT set */
  1009. oris r7,r7,MAS1_IPROT@h
  1010. mtspr SPRN_MAS1,r7
  1011. tlbwe
  1012. /* 2. Invalidate all entries except the entry we're executing in
  1013. *
  1014. * r3 = MAS0 w/TLBSEL & ESEL for the entry we are running in
  1015. * r4 = SPRN_TLBnCFG
  1016. * r5 = ESEL of entry we are running in
  1017. */
  1018. andi. r4,r4,TLBnCFG_N_ENTRY /* Extract # entries */
  1019. li r6,0 /* Set Entry counter to 0 */
  1020. 1: mr r7,r3 /* Set MAS0(TLBSEL) */
  1021. rlwimi r7,r6,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r6) */
  1022. mtspr SPRN_MAS0,r7
  1023. tlbre
  1024. mfspr r7,SPRN_MAS1
  1025. rlwinm r7,r7,0,2,31 /* Clear MAS1 Valid and IPROT */
  1026. cmpw r5,r6
  1027. beq skpinv /* Dont update the current execution TLB */
  1028. mtspr SPRN_MAS1,r7
  1029. tlbwe
  1030. isync
  1031. skpinv: addi r6,r6,1 /* Increment */
  1032. cmpw r6,r4 /* Are we done? */
  1033. bne 1b /* If not, repeat */
  1034. /* Invalidate all TLBs */
  1035. PPC_TLBILX_ALL(0,R0)
  1036. sync
  1037. isync
  1038. /* 3. Setup a temp mapping and jump to it
  1039. *
  1040. * r3 = MAS0 w/TLBSEL & ESEL for the entry we are running in
  1041. * r5 = ESEL of entry we are running in
  1042. */
  1043. andi. r7,r5,0x1 /* Find an entry not used and is non-zero */
  1044. addi r7,r7,0x1
  1045. mr r4,r3 /* Set MAS0(TLBSEL) = 1 */
  1046. mtspr SPRN_MAS0,r4
  1047. tlbre
  1048. rlwimi r4,r7,16,4,15 /* Setup MAS0 = TLBSEL | ESEL(r7) */
  1049. mtspr SPRN_MAS0,r4
  1050. mfspr r7,SPRN_MAS1
  1051. xori r6,r7,MAS1_TS /* Setup TMP mapping in the other Address space */
  1052. mtspr SPRN_MAS1,r6
  1053. tlbwe
  1054. mfmsr r6
  1055. xori r6,r6,MSR_IS
  1056. mtspr SPRN_SRR1,r6
  1057. bcl 20,31,$+4 /* Find our address */
  1058. 1: mflr r6
  1059. addi r6,r6,(2f - 1b)
  1060. mtspr SPRN_SRR0,r6
  1061. rfi
  1062. 2:
  1063. /* 4. Clear out PIDs & Search info
  1064. *
  1065. * r3 = MAS0 w/TLBSEL & ESEL for the entry we started in
  1066. * r4 = MAS0 w/TLBSEL & ESEL for the temp mapping
  1067. * r5 = MAS3
  1068. */
  1069. li r6,0
  1070. mtspr SPRN_MAS6,r6
  1071. mtspr SPRN_PID,r6
  1072. /* 5. Invalidate mapping we started in
  1073. *
  1074. * r3 = MAS0 w/TLBSEL & ESEL for the entry we started in
  1075. * r4 = MAS0 w/TLBSEL & ESEL for the temp mapping
  1076. * r5 = MAS3
  1077. */
  1078. mtspr SPRN_MAS0,r3
  1079. tlbre
  1080. mfspr r6,SPRN_MAS1
  1081. rlwinm r6,r6,0,2,31 /* clear IPROT and VALID */
  1082. mtspr SPRN_MAS1,r6
  1083. tlbwe
  1084. sync
  1085. isync
  1086. /* 6. Setup KERNELBASE mapping in TLB[0]
  1087. *
  1088. * r3 = MAS0 w/TLBSEL & ESEL for the entry we started in
  1089. * r4 = MAS0 w/TLBSEL & ESEL for the temp mapping
  1090. * r5 = MAS3
  1091. */
  1092. rlwinm r3,r3,0,16,3 /* clear ESEL */
  1093. mtspr SPRN_MAS0,r3
  1094. lis r6,(MAS1_VALID|MAS1_IPROT)@h
  1095. ori r6,r6,(MAS1_TSIZE(BOOK3E_PAGESZ_1GB))@l
  1096. mtspr SPRN_MAS1,r6
  1097. LOAD_REG_IMMEDIATE(r6, PAGE_OFFSET | MAS2_M_IF_NEEDED)
  1098. mtspr SPRN_MAS2,r6
  1099. rlwinm r5,r5,0,0,25
  1100. ori r5,r5,MAS3_SR | MAS3_SW | MAS3_SX
  1101. mtspr SPRN_MAS3,r5
  1102. li r5,-1
  1103. rlwinm r5,r5,0,0,25
  1104. tlbwe
  1105. /* 7. Jump to KERNELBASE mapping
  1106. *
  1107. * r4 = MAS0 w/TLBSEL & ESEL for the temp mapping
  1108. */
  1109. /* Now we branch the new virtual address mapped by this entry */
  1110. bcl 20,31,$+4 /* Find our address */
  1111. 1: mflr r6
  1112. addi r6,r6,(2f - 1b)
  1113. tovirt(r6,r6)
  1114. lis r7,MSR_KERNEL@h
  1115. ori r7,r7,MSR_KERNEL@l
  1116. mtspr SPRN_SRR0,r6
  1117. mtspr SPRN_SRR1,r7
  1118. rfi /* start execution out of TLB1[0] entry */
  1119. 2:
  1120. /* 8. Clear out the temp mapping
  1121. *
  1122. * r4 = MAS0 w/TLBSEL & ESEL for the entry we are running in
  1123. */
  1124. mtspr SPRN_MAS0,r4
  1125. tlbre
  1126. mfspr r5,SPRN_MAS1
  1127. rlwinm r5,r5,0,2,31 /* clear IPROT and VALID */
  1128. mtspr SPRN_MAS1,r5
  1129. tlbwe
  1130. sync
  1131. isync
  1132. /* We translate LR and return */
  1133. tovirt(r8,r8)
  1134. mtlr r8
  1135. blr
  1136. have_hes:
  1137. /* Setup MAS 0,1,2,3 and 7 for tlbwe of a 1G entry that maps the
  1138. * kernel linear mapping. We also set MAS8 once for all here though
  1139. * that will have to be made dependent on whether we are running under
  1140. * a hypervisor I suppose.
  1141. */
  1142. /* BEWARE, MAGIC
  1143. * This code is called as an ordinary function on the boot CPU. But to
  1144. * avoid duplication, this code is also used in SCOM bringup of
  1145. * secondary CPUs. We read the code between the initial_tlb_code_start
  1146. * and initial_tlb_code_end labels one instruction at a time and RAM it
  1147. * into the new core via SCOM. That doesn't process branches, so there
  1148. * must be none between those two labels. It also means if this code
  1149. * ever takes any parameters, the SCOM code must also be updated to
  1150. * provide them.
  1151. */
  1152. _GLOBAL(a2_tlbinit_code_start)
  1153. ori r11,r3,MAS0_WQ_ALLWAYS
  1154. oris r11,r11,MAS0_ESEL(3)@h /* Use way 3: workaround A2 erratum 376 */
  1155. mtspr SPRN_MAS0,r11
  1156. lis r3,(MAS1_VALID | MAS1_IPROT)@h
  1157. ori r3,r3,BOOK3E_PAGESZ_1GB << MAS1_TSIZE_SHIFT
  1158. mtspr SPRN_MAS1,r3
  1159. LOAD_REG_IMMEDIATE(r3, PAGE_OFFSET | MAS2_M)
  1160. mtspr SPRN_MAS2,r3
  1161. li r3,MAS3_SR | MAS3_SW | MAS3_SX
  1162. mtspr SPRN_MAS7_MAS3,r3
  1163. li r3,0
  1164. mtspr SPRN_MAS8,r3
  1165. /* Write the TLB entry */
  1166. tlbwe
  1167. .globl a2_tlbinit_after_linear_map
  1168. a2_tlbinit_after_linear_map:
  1169. /* Now we branch the new virtual address mapped by this entry */
  1170. #ifdef CONFIG_RELOCATABLE
  1171. __LOAD_PACA_TOC(r5)
  1172. LOAD_REG_ADDR_ALTTOC(r3, r5, 1f)
  1173. #else
  1174. LOAD_REG_IMMEDIATE_SYM(r3, r5, 1f)
  1175. #endif
  1176. mtctr r3
  1177. bctr
  1178. 1: /* We are now running at PAGE_OFFSET, clean the TLB of everything
  1179. * else (including IPROTed things left by firmware)
  1180. * r4 = TLBnCFG
  1181. * r3 = current address (more or less)
  1182. */
  1183. li r5,0
  1184. mtspr SPRN_MAS6,r5
  1185. tlbsx 0,r3
  1186. rlwinm r9,r4,0,TLBnCFG_N_ENTRY
  1187. rlwinm r10,r4,8,0xff
  1188. addi r10,r10,-1 /* Get inner loop mask */
  1189. li r3,1
  1190. mfspr r5,SPRN_MAS1
  1191. rlwinm r5,r5,0,(~(MAS1_VALID|MAS1_IPROT))
  1192. mfspr r6,SPRN_MAS2
  1193. rldicr r6,r6,0,51 /* Extract EPN */
  1194. mfspr r7,SPRN_MAS0
  1195. rlwinm r7,r7,0,0xffff0fff /* Clear HES and WQ */
  1196. rlwinm r8,r7,16,0xfff /* Extract ESEL */
  1197. 2: add r4,r3,r8
  1198. and r4,r4,r10
  1199. rlwimi r7,r4,16,MAS0_ESEL_MASK
  1200. mtspr SPRN_MAS0,r7
  1201. mtspr SPRN_MAS1,r5
  1202. mtspr SPRN_MAS2,r6
  1203. tlbwe
  1204. addi r3,r3,1
  1205. and. r4,r3,r10
  1206. bne 3f
  1207. addis r6,r6,(1<<30)@h
  1208. 3:
  1209. cmpw r3,r9
  1210. blt 2b
  1211. .globl a2_tlbinit_after_iprot_flush
  1212. a2_tlbinit_after_iprot_flush:
  1213. PPC_TLBILX(0,0,R0)
  1214. sync
  1215. isync
  1216. .globl a2_tlbinit_code_end
  1217. a2_tlbinit_code_end:
  1218. /* We translate LR and return */
  1219. mflr r3
  1220. tovirt(r3,r3)
  1221. mtlr r3
  1222. blr
  1223. /*
  1224. * Main entry (boot CPU, thread 0)
  1225. *
  1226. * We enter here from head_64.S, possibly after the prom_init trampoline
  1227. * with r3 and r4 already saved to r31 and 30 respectively and in 64 bits
  1228. * mode. Anything else is as it was left by the bootloader
  1229. *
  1230. * Initial requirements of this port:
  1231. *
  1232. * - Kernel loaded at 0 physical
  1233. * - A good lump of memory mapped 0:0 by UTLB entry 0
  1234. * - MSR:IS & MSR:DS set to 0
  1235. *
  1236. * Note that some of the above requirements will be relaxed in the future
  1237. * as the kernel becomes smarter at dealing with different initial conditions
  1238. * but for now you have to be careful
  1239. */
  1240. _GLOBAL(start_initialization_book3e)
  1241. mflr r28
  1242. /* First, we need to setup some initial TLBs to map the kernel
  1243. * text, data and bss at PAGE_OFFSET. We don't have a real mode
  1244. * and always use AS 0, so we just set it up to match our link
  1245. * address and never use 0 based addresses.
  1246. */
  1247. bl initial_tlb_book3e
  1248. /* Init global core bits */
  1249. bl init_core_book3e
  1250. /* Init per-thread bits */
  1251. bl init_thread_book3e
  1252. /* Return to common init code */
  1253. tovirt(r28,r28)
  1254. mtlr r28
  1255. blr
  1256. /*
  1257. * Secondary core/processor entry
  1258. *
  1259. * This is entered for thread 0 of a secondary core, all other threads
  1260. * are expected to be stopped. It's similar to start_initialization_book3e
  1261. * except that it's generally entered from the holding loop in head_64.S
  1262. * after CPUs have been gathered by Open Firmware.
  1263. *
  1264. * We assume we are in 32 bits mode running with whatever TLB entry was
  1265. * set for us by the firmware or POR engine.
  1266. */
  1267. _GLOBAL(book3e_secondary_core_init_tlb_set)
  1268. li r4,1
  1269. b generic_secondary_smp_init
  1270. _GLOBAL(book3e_secondary_core_init)
  1271. mflr r28
  1272. /* Do we need to setup initial TLB entry ? */
  1273. cmplwi r4,0
  1274. bne 2f
  1275. /* Setup TLB for this core */
  1276. bl initial_tlb_book3e
  1277. /* We can return from the above running at a different
  1278. * address, so recalculate r2 (TOC)
  1279. */
  1280. bl relative_toc
  1281. /* Init global core bits */
  1282. 2: bl init_core_book3e
  1283. /* Init per-thread bits */
  1284. 3: bl init_thread_book3e
  1285. /* Return to common init code at proper virtual address.
  1286. *
  1287. * Due to various previous assumptions, we know we entered this
  1288. * function at either the final PAGE_OFFSET mapping or using a
  1289. * 1:1 mapping at 0, so we don't bother doing a complicated check
  1290. * here, we just ensure the return address has the right top bits.
  1291. *
  1292. * Note that if we ever want to be smarter about where we can be
  1293. * started from, we have to be careful that by the time we reach
  1294. * the code below we may already be running at a different location
  1295. * than the one we were called from since initial_tlb_book3e can
  1296. * have moved us already.
  1297. */
  1298. cmpdi cr0,r28,0
  1299. blt 1f
  1300. lis r3,PAGE_OFFSET@highest
  1301. sldi r3,r3,32
  1302. or r28,r28,r3
  1303. 1: mtlr r28
  1304. blr
  1305. _GLOBAL(book3e_secondary_thread_init)
  1306. mflr r28
  1307. b 3b
  1308. _GLOBAL(init_core_book3e)
  1309. /* Establish the interrupt vector base */
  1310. tovirt(r2,r2)
  1311. LOAD_REG_ADDR(r3, interrupt_base_book3e)
  1312. mtspr SPRN_IVPR,r3
  1313. sync
  1314. blr
  1315. SYM_CODE_START_LOCAL(init_thread_book3e)
  1316. lis r3,(SPRN_EPCR_ICM | SPRN_EPCR_GICM)@h
  1317. mtspr SPRN_EPCR,r3
  1318. /* Make sure interrupts are off */
  1319. wrteei 0
  1320. /* disable all timers and clear out status */
  1321. li r3,0
  1322. mtspr SPRN_TCR,r3
  1323. mfspr r3,SPRN_TSR
  1324. mtspr SPRN_TSR,r3
  1325. blr
  1326. SYM_CODE_END(init_thread_book3e)
  1327. _GLOBAL(__setup_base_ivors)
  1328. SET_IVOR(0, 0x020) /* Critical Input */
  1329. SET_IVOR(1, 0x000) /* Machine Check */
  1330. SET_IVOR(2, 0x060) /* Data Storage */
  1331. SET_IVOR(3, 0x080) /* Instruction Storage */
  1332. SET_IVOR(4, 0x0a0) /* External Input */
  1333. SET_IVOR(5, 0x0c0) /* Alignment */
  1334. SET_IVOR(6, 0x0e0) /* Program */
  1335. SET_IVOR(7, 0x100) /* FP Unavailable */
  1336. SET_IVOR(8, 0x120) /* System Call */
  1337. SET_IVOR(9, 0x140) /* Auxiliary Processor Unavailable */
  1338. SET_IVOR(10, 0x160) /* Decrementer */
  1339. SET_IVOR(11, 0x180) /* Fixed Interval Timer */
  1340. SET_IVOR(12, 0x1a0) /* Watchdog Timer */
  1341. SET_IVOR(13, 0x1c0) /* Data TLB Error */
  1342. SET_IVOR(14, 0x1e0) /* Instruction TLB Error */
  1343. SET_IVOR(15, 0x040) /* Debug */
  1344. sync
  1345. blr
  1346. _GLOBAL(setup_altivec_ivors)
  1347. SET_IVOR(32, 0x200) /* AltiVec Unavailable */
  1348. SET_IVOR(33, 0x220) /* AltiVec Assist */
  1349. blr
  1350. _GLOBAL(setup_perfmon_ivor)
  1351. SET_IVOR(35, 0x260) /* Performance Monitor */
  1352. blr
  1353. _GLOBAL(setup_doorbell_ivors)
  1354. SET_IVOR(36, 0x280) /* Processor Doorbell */
  1355. SET_IVOR(37, 0x2a0) /* Processor Doorbell Crit */
  1356. blr
  1357. _GLOBAL(setup_ehv_ivors)
  1358. SET_IVOR(40, 0x300) /* Embedded Hypervisor System Call */
  1359. SET_IVOR(41, 0x320) /* Embedded Hypervisor Privilege */
  1360. SET_IVOR(38, 0x2c0) /* Guest Processor Doorbell */
  1361. SET_IVOR(39, 0x2e0) /* Guest Processor Doorbell Crit/MC */
  1362. blr
  1363. _GLOBAL(setup_lrat_ivor)
  1364. SET_IVOR(42, 0x340) /* LRAT Error */
  1365. blr