exceptions-64s.S 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204
  1. /*
  2. * This file contains the 64-bit "server" PowerPC variant
  3. * of the low level exception handling including exception
  4. * vectors, exception return, part of the slb and stab
  5. * handling and other fixed offset specific things.
  6. *
  7. * This file is meant to be #included from head_64.S due to
  8. * position dependent assembly.
  9. *
  10. * Most of this originates from head_64.S and thus has the same
  11. * copyright history.
  12. *
  13. */
  14. #include <asm/exception-64s.h>
  15. #include <asm/ptrace.h>
  16. /*
  17. * We layout physical memory as follows:
  18. * 0x0000 - 0x00ff : Secondary processor spin code
  19. * 0x0100 - 0x2fff : pSeries Interrupt prologs
  20. * 0x3000 - 0x5fff : interrupt support, iSeries and common interrupt prologs
  21. * 0x6000 - 0x6fff : Initial (CPU0) segment table
  22. * 0x7000 - 0x7fff : FWNMI data area
  23. * 0x8000 - : Early init and support code
  24. */
  25. /*
  26. * This is the start of the interrupt handlers for pSeries
  27. * This code runs with relocation off.
  28. * Code from here to __end_interrupts gets copied down to real
  29. * address 0x100 when we are running a relocatable kernel.
  30. * Therefore any relative branches in this section must only
  31. * branch to labels in this section.
  32. */
  33. . = 0x100
  34. .globl __start_interrupts
  35. __start_interrupts:
  36. .globl system_reset_pSeries;
  37. system_reset_pSeries:
  38. HMT_MEDIUM;
  39. SET_SCRATCH0(r13)
  40. #ifdef CONFIG_PPC_P7_NAP
  41. BEGIN_FTR_SECTION
  42. /* Running native on arch 2.06 or later, check if we are
  43. * waking up from nap. We only handle no state loss and
  44. * supervisor state loss. We do -not- handle hypervisor
  45. * state loss at this time.
  46. */
  47. mfspr r13,SPRN_SRR1
  48. rlwinm. r13,r13,47-31,30,31
  49. beq 9f
  50. /* waking up from powersave (nap) state */
  51. cmpwi cr1,r13,2
  52. /* Total loss of HV state is fatal, we could try to use the
  53. * PIR to locate a PACA, then use an emergency stack etc...
  54. * but for now, let's just stay stuck here
  55. */
  56. bgt cr1,.
  57. GET_PACA(r13)
  58. #ifdef CONFIG_KVM_BOOK3S_64_HV
  59. lbz r0,PACAPROCSTART(r13)
  60. cmpwi r0,0x80
  61. bne 1f
  62. li r0,0
  63. stb r0,PACAPROCSTART(r13)
  64. b kvm_start_guest
  65. 1:
  66. #endif
  67. beq cr1,2f
  68. b .power7_wakeup_noloss
  69. 2: b .power7_wakeup_loss
  70. 9:
  71. END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
  72. #endif /* CONFIG_PPC_P7_NAP */
  73. EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD,
  74. NOTEST, 0x100)
  75. . = 0x200
  76. machine_check_pSeries_1:
  77. /* This is moved out of line as it can be patched by FW, but
  78. * some code path might still want to branch into the original
  79. * vector
  80. */
  81. b machine_check_pSeries
  82. . = 0x300
  83. .globl data_access_pSeries
  84. data_access_pSeries:
  85. HMT_MEDIUM
  86. SET_SCRATCH0(r13)
  87. #ifndef CONFIG_POWER4_ONLY
  88. BEGIN_FTR_SECTION
  89. b data_access_check_stab
  90. data_access_not_stab:
  91. END_MMU_FTR_SECTION_IFCLR(MMU_FTR_SLB)
  92. #endif
  93. EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, data_access_common, EXC_STD,
  94. KVMTEST_PR, 0x300)
  95. . = 0x380
  96. .globl data_access_slb_pSeries
  97. data_access_slb_pSeries:
  98. HMT_MEDIUM
  99. SET_SCRATCH0(r13)
  100. EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST_PR, 0x380)
  101. std r3,PACA_EXSLB+EX_R3(r13)
  102. mfspr r3,SPRN_DAR
  103. #ifdef __DISABLED__
  104. /* Keep that around for when we re-implement dynamic VSIDs */
  105. cmpdi r3,0
  106. bge slb_miss_user_pseries
  107. #endif /* __DISABLED__ */
  108. mfspr r12,SPRN_SRR1
  109. #ifndef CONFIG_RELOCATABLE
  110. b .slb_miss_realmode
  111. #else
  112. /*
  113. * We can't just use a direct branch to .slb_miss_realmode
  114. * because the distance from here to there depends on where
  115. * the kernel ends up being put.
  116. */
  117. mfctr r11
  118. ld r10,PACAKBASE(r13)
  119. LOAD_HANDLER(r10, .slb_miss_realmode)
  120. mtctr r10
  121. bctr
  122. #endif
  123. STD_EXCEPTION_PSERIES(0x400, 0x400, instruction_access)
  124. . = 0x480
  125. .globl instruction_access_slb_pSeries
  126. instruction_access_slb_pSeries:
  127. HMT_MEDIUM
  128. SET_SCRATCH0(r13)
  129. EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST_PR, 0x480)
  130. std r3,PACA_EXSLB+EX_R3(r13)
  131. mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */
  132. #ifdef __DISABLED__
  133. /* Keep that around for when we re-implement dynamic VSIDs */
  134. cmpdi r3,0
  135. bge slb_miss_user_pseries
  136. #endif /* __DISABLED__ */
  137. mfspr r12,SPRN_SRR1
  138. #ifndef CONFIG_RELOCATABLE
  139. b .slb_miss_realmode
  140. #else
  141. mfctr r11
  142. ld r10,PACAKBASE(r13)
  143. LOAD_HANDLER(r10, .slb_miss_realmode)
  144. mtctr r10
  145. bctr
  146. #endif
  147. /* We open code these as we can't have a ". = x" (even with
  148. * x = "." within a feature section
  149. */
  150. . = 0x500;
  151. .globl hardware_interrupt_pSeries;
  152. .globl hardware_interrupt_hv;
  153. hardware_interrupt_pSeries:
  154. hardware_interrupt_hv:
  155. BEGIN_FTR_SECTION
  156. _MASKABLE_EXCEPTION_PSERIES(0x502, hardware_interrupt,
  157. EXC_HV, SOFTEN_TEST_HV)
  158. KVM_HANDLER(PACA_EXGEN, EXC_HV, 0x502)
  159. FTR_SECTION_ELSE
  160. _MASKABLE_EXCEPTION_PSERIES(0x500, hardware_interrupt,
  161. EXC_STD, SOFTEN_TEST_HV_201)
  162. KVM_HANDLER(PACA_EXGEN, EXC_STD, 0x500)
  163. ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
  164. STD_EXCEPTION_PSERIES(0x600, 0x600, alignment)
  165. KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x600)
  166. STD_EXCEPTION_PSERIES(0x700, 0x700, program_check)
  167. KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x700)
  168. STD_EXCEPTION_PSERIES(0x800, 0x800, fp_unavailable)
  169. KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x800)
  170. MASKABLE_EXCEPTION_PSERIES(0x900, 0x900, decrementer)
  171. MASKABLE_EXCEPTION_HV(0x980, 0x982, decrementer)
  172. STD_EXCEPTION_PSERIES(0xa00, 0xa00, trap_0a)
  173. KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xa00)
  174. STD_EXCEPTION_PSERIES(0xb00, 0xb00, trap_0b)
  175. KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xb00)
  176. . = 0xc00
  177. .globl system_call_pSeries
  178. system_call_pSeries:
  179. HMT_MEDIUM
  180. #ifdef CONFIG_KVM_BOOK3S_64_HANDLER
  181. SET_SCRATCH0(r13)
  182. GET_PACA(r13)
  183. std r9,PACA_EXGEN+EX_R9(r13)
  184. std r10,PACA_EXGEN+EX_R10(r13)
  185. mfcr r9
  186. KVMTEST(0xc00)
  187. GET_SCRATCH0(r13)
  188. #endif
  189. BEGIN_FTR_SECTION
  190. cmpdi r0,0x1ebe
  191. beq- 1f
  192. END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE)
  193. mr r9,r13
  194. GET_PACA(r13)
  195. mfspr r11,SPRN_SRR0
  196. mfspr r12,SPRN_SRR1
  197. ld r10,PACAKBASE(r13)
  198. LOAD_HANDLER(r10, system_call_entry)
  199. mtspr SPRN_SRR0,r10
  200. ld r10,PACAKMSR(r13)
  201. mtspr SPRN_SRR1,r10
  202. rfid
  203. b . /* prevent speculative execution */
  204. KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xc00)
  205. /* Fast LE/BE switch system call */
  206. 1: mfspr r12,SPRN_SRR1
  207. xori r12,r12,MSR_LE
  208. mtspr SPRN_SRR1,r12
  209. rfid /* return to userspace */
  210. b .
  211. STD_EXCEPTION_PSERIES(0xd00, 0xd00, single_step)
  212. KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xd00)
  213. /* At 0xe??? we have a bunch of hypervisor exceptions, we branch
  214. * out of line to handle them
  215. */
  216. . = 0xe00
  217. b h_data_storage_hv
  218. . = 0xe20
  219. b h_instr_storage_hv
  220. . = 0xe40
  221. b emulation_assist_hv
  222. . = 0xe50
  223. b hmi_exception_hv
  224. . = 0xe60
  225. b hmi_exception_hv
  226. /* We need to deal with the Altivec unavailable exception
  227. * here which is at 0xf20, thus in the middle of the
  228. * prolog code of the PerformanceMonitor one. A little
  229. * trickery is thus necessary
  230. */
  231. performance_monitor_pSeries_1:
  232. . = 0xf00
  233. b performance_monitor_pSeries
  234. altivec_unavailable_pSeries_1:
  235. . = 0xf20
  236. b altivec_unavailable_pSeries
  237. vsx_unavailable_pSeries_1:
  238. . = 0xf40
  239. b vsx_unavailable_pSeries
  240. #ifdef CONFIG_CBE_RAS
  241. STD_EXCEPTION_HV(0x1200, 0x1202, cbe_system_error)
  242. KVM_HANDLER_PR_SKIP(PACA_EXGEN, EXC_HV, 0x1202)
  243. #endif /* CONFIG_CBE_RAS */
  244. STD_EXCEPTION_PSERIES(0x1300, 0x1300, instruction_breakpoint)
  245. KVM_HANDLER_PR_SKIP(PACA_EXGEN, EXC_STD, 0x1300)
  246. #ifdef CONFIG_CBE_RAS
  247. STD_EXCEPTION_HV(0x1600, 0x1602, cbe_maintenance)
  248. KVM_HANDLER_PR_SKIP(PACA_EXGEN, EXC_HV, 0x1602)
  249. #endif /* CONFIG_CBE_RAS */
  250. STD_EXCEPTION_PSERIES(0x1700, 0x1700, altivec_assist)
  251. KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x1700)
  252. #ifdef CONFIG_CBE_RAS
  253. STD_EXCEPTION_HV(0x1800, 0x1802, cbe_thermal)
  254. KVM_HANDLER_PR_SKIP(PACA_EXGEN, EXC_HV, 0x1802)
  255. #endif /* CONFIG_CBE_RAS */
  256. . = 0x3000
  257. /*** Out of line interrupts support ***/
  258. /* moved from 0x200 */
  259. machine_check_pSeries:
  260. .globl machine_check_fwnmi
  261. machine_check_fwnmi:
  262. HMT_MEDIUM
  263. SET_SCRATCH0(r13) /* save r13 */
  264. EXCEPTION_PROLOG_PSERIES(PACA_EXMC, machine_check_common,
  265. EXC_STD, KVMTEST, 0x200)
  266. KVM_HANDLER_SKIP(PACA_EXMC, EXC_STD, 0x200)
  267. #ifndef CONFIG_POWER4_ONLY
  268. /* moved from 0x300 */
  269. data_access_check_stab:
  270. GET_PACA(r13)
  271. std r9,PACA_EXSLB+EX_R9(r13)
  272. std r10,PACA_EXSLB+EX_R10(r13)
  273. mfspr r10,SPRN_DAR
  274. mfspr r9,SPRN_DSISR
  275. srdi r10,r10,60
  276. rlwimi r10,r9,16,0x20
  277. #ifdef CONFIG_KVM_BOOK3S_PR
  278. lbz r9,HSTATE_IN_GUEST(r13)
  279. rlwimi r10,r9,8,0x300
  280. #endif
  281. mfcr r9
  282. cmpwi r10,0x2c
  283. beq do_stab_bolted_pSeries
  284. mtcrf 0x80,r9
  285. ld r9,PACA_EXSLB+EX_R9(r13)
  286. ld r10,PACA_EXSLB+EX_R10(r13)
  287. b data_access_not_stab
  288. do_stab_bolted_pSeries:
  289. std r11,PACA_EXSLB+EX_R11(r13)
  290. std r12,PACA_EXSLB+EX_R12(r13)
  291. GET_SCRATCH0(r10)
  292. std r10,PACA_EXSLB+EX_R13(r13)
  293. EXCEPTION_PROLOG_PSERIES_1(.do_stab_bolted, EXC_STD)
  294. #endif /* CONFIG_POWER4_ONLY */
  295. KVM_HANDLER_PR_SKIP(PACA_EXGEN, EXC_STD, 0x300)
  296. KVM_HANDLER_PR_SKIP(PACA_EXSLB, EXC_STD, 0x380)
  297. KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x400)
  298. KVM_HANDLER_PR(PACA_EXSLB, EXC_STD, 0x480)
  299. KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x900)
  300. KVM_HANDLER(PACA_EXGEN, EXC_HV, 0x982)
  301. .align 7
  302. /* moved from 0xe00 */
  303. STD_EXCEPTION_HV(., 0xe02, h_data_storage)
  304. KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0xe02)
  305. STD_EXCEPTION_HV(., 0xe22, h_instr_storage)
  306. KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe22)
  307. STD_EXCEPTION_HV(., 0xe42, emulation_assist)
  308. KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe42)
  309. STD_EXCEPTION_HV(., 0xe62, hmi_exception) /* need to flush cache ? */
  310. KVM_HANDLER(PACA_EXGEN, EXC_HV, 0xe62)
  311. /* moved from 0xf00 */
  312. STD_EXCEPTION_PSERIES(., 0xf00, performance_monitor)
  313. KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf00)
  314. STD_EXCEPTION_PSERIES(., 0xf20, altivec_unavailable)
  315. KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf20)
  316. STD_EXCEPTION_PSERIES(., 0xf40, vsx_unavailable)
  317. KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0xf40)
  318. /*
  319. * An interrupt came in while soft-disabled; clear EE in SRR1,
  320. * clear paca->hard_enabled and return.
  321. */
  322. masked_interrupt:
  323. stb r10,PACAHARDIRQEN(r13)
  324. mtcrf 0x80,r9
  325. ld r9,PACA_EXGEN+EX_R9(r13)
  326. mfspr r10,SPRN_SRR1
  327. rldicl r10,r10,48,1 /* clear MSR_EE */
  328. rotldi r10,r10,16
  329. mtspr SPRN_SRR1,r10
  330. ld r10,PACA_EXGEN+EX_R10(r13)
  331. GET_SCRATCH0(r13)
  332. rfid
  333. b .
  334. masked_Hinterrupt:
  335. stb r10,PACAHARDIRQEN(r13)
  336. mtcrf 0x80,r9
  337. ld r9,PACA_EXGEN+EX_R9(r13)
  338. mfspr r10,SPRN_HSRR1
  339. rldicl r10,r10,48,1 /* clear MSR_EE */
  340. rotldi r10,r10,16
  341. mtspr SPRN_HSRR1,r10
  342. ld r10,PACA_EXGEN+EX_R10(r13)
  343. GET_SCRATCH0(r13)
  344. hrfid
  345. b .
  346. #ifdef CONFIG_PPC_PSERIES
  347. /*
  348. * Vectors for the FWNMI option. Share common code.
  349. */
  350. .globl system_reset_fwnmi
  351. .align 7
  352. system_reset_fwnmi:
  353. HMT_MEDIUM
  354. SET_SCRATCH0(r13) /* save r13 */
  355. EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common, EXC_STD,
  356. NOTEST, 0x100)
  357. #endif /* CONFIG_PPC_PSERIES */
  358. #ifdef __DISABLED__
  359. /*
  360. * This is used for when the SLB miss handler has to go virtual,
  361. * which doesn't happen for now anymore but will once we re-implement
  362. * dynamic VSIDs for shared page tables
  363. */
  364. slb_miss_user_pseries:
  365. std r10,PACA_EXGEN+EX_R10(r13)
  366. std r11,PACA_EXGEN+EX_R11(r13)
  367. std r12,PACA_EXGEN+EX_R12(r13)
  368. GET_SCRATCH0(r10)
  369. ld r11,PACA_EXSLB+EX_R9(r13)
  370. ld r12,PACA_EXSLB+EX_R3(r13)
  371. std r10,PACA_EXGEN+EX_R13(r13)
  372. std r11,PACA_EXGEN+EX_R9(r13)
  373. std r12,PACA_EXGEN+EX_R3(r13)
  374. clrrdi r12,r13,32
  375. mfmsr r10
  376. mfspr r11,SRR0 /* save SRR0 */
  377. ori r12,r12,slb_miss_user_common@l /* virt addr of handler */
  378. ori r10,r10,MSR_IR|MSR_DR|MSR_RI
  379. mtspr SRR0,r12
  380. mfspr r12,SRR1 /* and SRR1 */
  381. mtspr SRR1,r10
  382. rfid
  383. b . /* prevent spec. execution */
  384. #endif /* __DISABLED__ */
  385. .align 7
  386. .globl __end_interrupts
  387. __end_interrupts:
  388. /*
  389. * Code from here down to __end_handlers is invoked from the
  390. * exception prologs above. Because the prologs assemble the
  391. * addresses of these handlers using the LOAD_HANDLER macro,
  392. * which uses an addi instruction, these handlers must be in
  393. * the first 32k of the kernel image.
  394. */
  395. /*** Common interrupt handlers ***/
  396. STD_EXCEPTION_COMMON(0x100, system_reset, .system_reset_exception)
  397. /*
  398. * Machine check is different because we use a different
  399. * save area: PACA_EXMC instead of PACA_EXGEN.
  400. */
  401. .align 7
  402. .globl machine_check_common
  403. machine_check_common:
  404. EXCEPTION_PROLOG_COMMON(0x200, PACA_EXMC)
  405. FINISH_NAP
  406. DISABLE_INTS
  407. bl .save_nvgprs
  408. addi r3,r1,STACK_FRAME_OVERHEAD
  409. bl .machine_check_exception
  410. b .ret_from_except
  411. STD_EXCEPTION_COMMON_LITE(0x900, decrementer, .timer_interrupt)
  412. STD_EXCEPTION_COMMON(0xa00, trap_0a, .unknown_exception)
  413. STD_EXCEPTION_COMMON(0xb00, trap_0b, .unknown_exception)
  414. STD_EXCEPTION_COMMON(0xd00, single_step, .single_step_exception)
  415. STD_EXCEPTION_COMMON(0xe00, trap_0e, .unknown_exception)
  416. STD_EXCEPTION_COMMON(0xe40, emulation_assist, .program_check_exception)
  417. STD_EXCEPTION_COMMON(0xe60, hmi_exception, .unknown_exception)
  418. STD_EXCEPTION_COMMON_IDLE(0xf00, performance_monitor, .performance_monitor_exception)
  419. STD_EXCEPTION_COMMON(0x1300, instruction_breakpoint, .instruction_breakpoint_exception)
  420. #ifdef CONFIG_ALTIVEC
  421. STD_EXCEPTION_COMMON(0x1700, altivec_assist, .altivec_assist_exception)
  422. #else
  423. STD_EXCEPTION_COMMON(0x1700, altivec_assist, .unknown_exception)
  424. #endif
  425. #ifdef CONFIG_CBE_RAS
  426. STD_EXCEPTION_COMMON(0x1200, cbe_system_error, .cbe_system_error_exception)
  427. STD_EXCEPTION_COMMON(0x1600, cbe_maintenance, .cbe_maintenance_exception)
  428. STD_EXCEPTION_COMMON(0x1800, cbe_thermal, .cbe_thermal_exception)
  429. #endif /* CONFIG_CBE_RAS */
  430. .align 7
  431. system_call_entry:
  432. b system_call_common
  433. /*
  434. * Here we have detected that the kernel stack pointer is bad.
  435. * R9 contains the saved CR, r13 points to the paca,
  436. * r10 contains the (bad) kernel stack pointer,
  437. * r11 and r12 contain the saved SRR0 and SRR1.
  438. * We switch to using an emergency stack, save the registers there,
  439. * and call kernel_bad_stack(), which panics.
  440. */
  441. bad_stack:
  442. ld r1,PACAEMERGSP(r13)
  443. subi r1,r1,64+INT_FRAME_SIZE
  444. std r9,_CCR(r1)
  445. std r10,GPR1(r1)
  446. std r11,_NIP(r1)
  447. std r12,_MSR(r1)
  448. mfspr r11,SPRN_DAR
  449. mfspr r12,SPRN_DSISR
  450. std r11,_DAR(r1)
  451. std r12,_DSISR(r1)
  452. mflr r10
  453. mfctr r11
  454. mfxer r12
  455. std r10,_LINK(r1)
  456. std r11,_CTR(r1)
  457. std r12,_XER(r1)
  458. SAVE_GPR(0,r1)
  459. SAVE_GPR(2,r1)
  460. ld r10,EX_R3(r3)
  461. std r10,GPR3(r1)
  462. SAVE_GPR(4,r1)
  463. SAVE_4GPRS(5,r1)
  464. ld r9,EX_R9(r3)
  465. ld r10,EX_R10(r3)
  466. SAVE_2GPRS(9,r1)
  467. ld r9,EX_R11(r3)
  468. ld r10,EX_R12(r3)
  469. ld r11,EX_R13(r3)
  470. std r9,GPR11(r1)
  471. std r10,GPR12(r1)
  472. std r11,GPR13(r1)
  473. BEGIN_FTR_SECTION
  474. ld r10,EX_CFAR(r3)
  475. std r10,ORIG_GPR3(r1)
  476. END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
  477. SAVE_8GPRS(14,r1)
  478. SAVE_10GPRS(22,r1)
  479. lhz r12,PACA_TRAP_SAVE(r13)
  480. std r12,_TRAP(r1)
  481. addi r11,r1,INT_FRAME_SIZE
  482. std r11,0(r1)
  483. li r12,0
  484. std r12,0(r11)
  485. ld r2,PACATOC(r13)
  486. ld r11,exception_marker@toc(r2)
  487. std r12,RESULT(r1)
  488. std r11,STACK_FRAME_OVERHEAD-16(r1)
  489. 1: addi r3,r1,STACK_FRAME_OVERHEAD
  490. bl .kernel_bad_stack
  491. b 1b
  492. /*
  493. * Here r13 points to the paca, r9 contains the saved CR,
  494. * SRR0 and SRR1 are saved in r11 and r12,
  495. * r9 - r13 are saved in paca->exgen.
  496. */
  497. .align 7
  498. .globl data_access_common
  499. data_access_common:
  500. mfspr r10,SPRN_DAR
  501. std r10,PACA_EXGEN+EX_DAR(r13)
  502. mfspr r10,SPRN_DSISR
  503. stw r10,PACA_EXGEN+EX_DSISR(r13)
  504. EXCEPTION_PROLOG_COMMON(0x300, PACA_EXGEN)
  505. ld r3,PACA_EXGEN+EX_DAR(r13)
  506. lwz r4,PACA_EXGEN+EX_DSISR(r13)
  507. li r5,0x300
  508. b .do_hash_page /* Try to handle as hpte fault */
  509. .align 7
  510. .globl h_data_storage_common
  511. h_data_storage_common:
  512. mfspr r10,SPRN_HDAR
  513. std r10,PACA_EXGEN+EX_DAR(r13)
  514. mfspr r10,SPRN_HDSISR
  515. stw r10,PACA_EXGEN+EX_DSISR(r13)
  516. EXCEPTION_PROLOG_COMMON(0xe00, PACA_EXGEN)
  517. bl .save_nvgprs
  518. addi r3,r1,STACK_FRAME_OVERHEAD
  519. bl .unknown_exception
  520. b .ret_from_except
  521. .align 7
  522. .globl instruction_access_common
  523. instruction_access_common:
  524. EXCEPTION_PROLOG_COMMON(0x400, PACA_EXGEN)
  525. ld r3,_NIP(r1)
  526. andis. r4,r12,0x5820
  527. li r5,0x400
  528. b .do_hash_page /* Try to handle as hpte fault */
  529. STD_EXCEPTION_COMMON(0xe20, h_instr_storage, .unknown_exception)
  530. /*
  531. * Here is the common SLB miss user that is used when going to virtual
  532. * mode for SLB misses, that is currently not used
  533. */
  534. #ifdef __DISABLED__
  535. .align 7
  536. .globl slb_miss_user_common
  537. slb_miss_user_common:
  538. mflr r10
  539. std r3,PACA_EXGEN+EX_DAR(r13)
  540. stw r9,PACA_EXGEN+EX_CCR(r13)
  541. std r10,PACA_EXGEN+EX_LR(r13)
  542. std r11,PACA_EXGEN+EX_SRR0(r13)
  543. bl .slb_allocate_user
  544. ld r10,PACA_EXGEN+EX_LR(r13)
  545. ld r3,PACA_EXGEN+EX_R3(r13)
  546. lwz r9,PACA_EXGEN+EX_CCR(r13)
  547. ld r11,PACA_EXGEN+EX_SRR0(r13)
  548. mtlr r10
  549. beq- slb_miss_fault
  550. andi. r10,r12,MSR_RI /* check for unrecoverable exception */
  551. beq- unrecov_user_slb
  552. mfmsr r10
  553. .machine push
  554. .machine "power4"
  555. mtcrf 0x80,r9
  556. .machine pop
  557. clrrdi r10,r10,2 /* clear RI before setting SRR0/1 */
  558. mtmsrd r10,1
  559. mtspr SRR0,r11
  560. mtspr SRR1,r12
  561. ld r9,PACA_EXGEN+EX_R9(r13)
  562. ld r10,PACA_EXGEN+EX_R10(r13)
  563. ld r11,PACA_EXGEN+EX_R11(r13)
  564. ld r12,PACA_EXGEN+EX_R12(r13)
  565. ld r13,PACA_EXGEN+EX_R13(r13)
  566. rfid
  567. b .
  568. slb_miss_fault:
  569. EXCEPTION_PROLOG_COMMON(0x380, PACA_EXGEN)
  570. ld r4,PACA_EXGEN+EX_DAR(r13)
  571. li r5,0
  572. std r4,_DAR(r1)
  573. std r5,_DSISR(r1)
  574. b handle_page_fault
  575. unrecov_user_slb:
  576. EXCEPTION_PROLOG_COMMON(0x4200, PACA_EXGEN)
  577. DISABLE_INTS
  578. bl .save_nvgprs
  579. 1: addi r3,r1,STACK_FRAME_OVERHEAD
  580. bl .unrecoverable_exception
  581. b 1b
  582. #endif /* __DISABLED__ */
  583. /*
  584. * r13 points to the PACA, r9 contains the saved CR,
  585. * r12 contain the saved SRR1, SRR0 is still ready for return
  586. * r3 has the faulting address
  587. * r9 - r13 are saved in paca->exslb.
  588. * r3 is saved in paca->slb_r3
  589. * We assume we aren't going to take any exceptions during this procedure.
  590. */
  591. _GLOBAL(slb_miss_realmode)
  592. mflr r10
  593. #ifdef CONFIG_RELOCATABLE
  594. mtctr r11
  595. #endif
  596. stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */
  597. std r10,PACA_EXSLB+EX_LR(r13) /* save LR */
  598. bl .slb_allocate_realmode
  599. /* All done -- return from exception. */
  600. ld r10,PACA_EXSLB+EX_LR(r13)
  601. ld r3,PACA_EXSLB+EX_R3(r13)
  602. lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */
  603. #ifdef CONFIG_PPC_ISERIES
  604. BEGIN_FW_FTR_SECTION
  605. ld r11,PACALPPACAPTR(r13)
  606. ld r11,LPPACASRR0(r11) /* get SRR0 value */
  607. END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
  608. #endif /* CONFIG_PPC_ISERIES */
  609. mtlr r10
  610. andi. r10,r12,MSR_RI /* check for unrecoverable exception */
  611. beq- 2f
  612. .machine push
  613. .machine "power4"
  614. mtcrf 0x80,r9
  615. mtcrf 0x01,r9 /* slb_allocate uses cr0 and cr7 */
  616. .machine pop
  617. #ifdef CONFIG_PPC_ISERIES
  618. BEGIN_FW_FTR_SECTION
  619. mtspr SPRN_SRR0,r11
  620. mtspr SPRN_SRR1,r12
  621. END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
  622. #endif /* CONFIG_PPC_ISERIES */
  623. ld r9,PACA_EXSLB+EX_R9(r13)
  624. ld r10,PACA_EXSLB+EX_R10(r13)
  625. ld r11,PACA_EXSLB+EX_R11(r13)
  626. ld r12,PACA_EXSLB+EX_R12(r13)
  627. ld r13,PACA_EXSLB+EX_R13(r13)
  628. rfid
  629. b . /* prevent speculative execution */
  630. 2:
  631. #ifdef CONFIG_PPC_ISERIES
  632. BEGIN_FW_FTR_SECTION
  633. b unrecov_slb
  634. END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
  635. #endif /* CONFIG_PPC_ISERIES */
  636. mfspr r11,SPRN_SRR0
  637. ld r10,PACAKBASE(r13)
  638. LOAD_HANDLER(r10,unrecov_slb)
  639. mtspr SPRN_SRR0,r10
  640. ld r10,PACAKMSR(r13)
  641. mtspr SPRN_SRR1,r10
  642. rfid
  643. b .
  644. unrecov_slb:
  645. EXCEPTION_PROLOG_COMMON(0x4100, PACA_EXSLB)
  646. DISABLE_INTS
  647. bl .save_nvgprs
  648. 1: addi r3,r1,STACK_FRAME_OVERHEAD
  649. bl .unrecoverable_exception
  650. b 1b
  651. .align 7
  652. .globl hardware_interrupt_common
  653. .globl hardware_interrupt_entry
  654. hardware_interrupt_common:
  655. EXCEPTION_PROLOG_COMMON(0x500, PACA_EXGEN)
  656. FINISH_NAP
  657. hardware_interrupt_entry:
  658. DISABLE_INTS
  659. BEGIN_FTR_SECTION
  660. bl .ppc64_runlatch_on
  661. END_FTR_SECTION_IFSET(CPU_FTR_CTRL)
  662. addi r3,r1,STACK_FRAME_OVERHEAD
  663. bl .do_IRQ
  664. b .ret_from_except_lite
  665. #ifdef CONFIG_PPC_970_NAP
  666. power4_fixup_nap:
  667. andc r9,r9,r10
  668. std r9,TI_LOCAL_FLAGS(r11)
  669. ld r10,_LINK(r1) /* make idle task do the */
  670. std r10,_NIP(r1) /* equivalent of a blr */
  671. blr
  672. #endif
  673. .align 7
  674. .globl alignment_common
  675. alignment_common:
  676. mfspr r10,SPRN_DAR
  677. std r10,PACA_EXGEN+EX_DAR(r13)
  678. mfspr r10,SPRN_DSISR
  679. stw r10,PACA_EXGEN+EX_DSISR(r13)
  680. EXCEPTION_PROLOG_COMMON(0x600, PACA_EXGEN)
  681. ld r3,PACA_EXGEN+EX_DAR(r13)
  682. lwz r4,PACA_EXGEN+EX_DSISR(r13)
  683. std r3,_DAR(r1)
  684. std r4,_DSISR(r1)
  685. bl .save_nvgprs
  686. addi r3,r1,STACK_FRAME_OVERHEAD
  687. ENABLE_INTS
  688. bl .alignment_exception
  689. b .ret_from_except
  690. .align 7
  691. .globl program_check_common
  692. program_check_common:
  693. EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN)
  694. bl .save_nvgprs
  695. addi r3,r1,STACK_FRAME_OVERHEAD
  696. ENABLE_INTS
  697. bl .program_check_exception
  698. b .ret_from_except
  699. .align 7
  700. .globl fp_unavailable_common
  701. fp_unavailable_common:
  702. EXCEPTION_PROLOG_COMMON(0x800, PACA_EXGEN)
  703. bne 1f /* if from user, just load it up */
  704. bl .save_nvgprs
  705. addi r3,r1,STACK_FRAME_OVERHEAD
  706. ENABLE_INTS
  707. bl .kernel_fp_unavailable_exception
  708. BUG_OPCODE
  709. 1: bl .load_up_fpu
  710. b fast_exception_return
  711. .align 7
  712. .globl altivec_unavailable_common
  713. altivec_unavailable_common:
  714. EXCEPTION_PROLOG_COMMON(0xf20, PACA_EXGEN)
  715. #ifdef CONFIG_ALTIVEC
  716. BEGIN_FTR_SECTION
  717. beq 1f
  718. bl .load_up_altivec
  719. b fast_exception_return
  720. 1:
  721. END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
  722. #endif
  723. bl .save_nvgprs
  724. addi r3,r1,STACK_FRAME_OVERHEAD
  725. ENABLE_INTS
  726. bl .altivec_unavailable_exception
  727. b .ret_from_except
  728. .align 7
  729. .globl vsx_unavailable_common
  730. vsx_unavailable_common:
  731. EXCEPTION_PROLOG_COMMON(0xf40, PACA_EXGEN)
  732. #ifdef CONFIG_VSX
  733. BEGIN_FTR_SECTION
  734. bne .load_up_vsx
  735. 1:
  736. END_FTR_SECTION_IFSET(CPU_FTR_VSX)
  737. #endif
  738. bl .save_nvgprs
  739. addi r3,r1,STACK_FRAME_OVERHEAD
  740. ENABLE_INTS
  741. bl .vsx_unavailable_exception
  742. b .ret_from_except
  743. .align 7
  744. .globl __end_handlers
  745. __end_handlers:
  746. /*
  747. * Return from an exception with minimal checks.
  748. * The caller is assumed to have done EXCEPTION_PROLOG_COMMON.
  749. * If interrupts have been enabled, or anything has been
  750. * done that might have changed the scheduling status of
  751. * any task or sent any task a signal, you should use
  752. * ret_from_except or ret_from_except_lite instead of this.
  753. */
  754. fast_exc_return_irq: /* restores irq state too */
  755. ld r3,SOFTE(r1)
  756. TRACE_AND_RESTORE_IRQ(r3);
  757. ld r12,_MSR(r1)
  758. rldicl r4,r12,49,63 /* get MSR_EE to LSB */
  759. stb r4,PACAHARDIRQEN(r13) /* restore paca->hard_enabled */
  760. b 1f
  761. .globl fast_exception_return
  762. fast_exception_return:
  763. ld r12,_MSR(r1)
  764. 1: ld r11,_NIP(r1)
  765. andi. r3,r12,MSR_RI /* check if RI is set */
  766. beq- unrecov_fer
  767. #ifdef CONFIG_VIRT_CPU_ACCOUNTING
  768. andi. r3,r12,MSR_PR
  769. beq 2f
  770. ACCOUNT_CPU_USER_EXIT(r3, r4)
  771. 2:
  772. #endif
  773. ld r3,_CCR(r1)
  774. ld r4,_LINK(r1)
  775. ld r5,_CTR(r1)
  776. ld r6,_XER(r1)
  777. mtcr r3
  778. mtlr r4
  779. mtctr r5
  780. mtxer r6
  781. REST_GPR(0, r1)
  782. REST_8GPRS(2, r1)
  783. mfmsr r10
  784. rldicl r10,r10,48,1 /* clear EE */
  785. rldicr r10,r10,16,61 /* clear RI (LE is 0 already) */
  786. mtmsrd r10,1
  787. mtspr SPRN_SRR1,r12
  788. mtspr SPRN_SRR0,r11
  789. REST_4GPRS(10, r1)
  790. ld r1,GPR1(r1)
  791. rfid
  792. b . /* prevent speculative execution */
  793. unrecov_fer:
  794. bl .save_nvgprs
  795. 1: addi r3,r1,STACK_FRAME_OVERHEAD
  796. bl .unrecoverable_exception
  797. b 1b
  798. /*
  799. * Hash table stuff
  800. */
  801. .align 7
  802. _STATIC(do_hash_page)
  803. std r3,_DAR(r1)
  804. std r4,_DSISR(r1)
  805. andis. r0,r4,0xa410 /* weird error? */
  806. bne- handle_page_fault /* if not, try to insert a HPTE */
  807. andis. r0,r4,DSISR_DABRMATCH@h
  808. bne- handle_dabr_fault
  809. BEGIN_FTR_SECTION
  810. andis. r0,r4,0x0020 /* Is it a segment table fault? */
  811. bne- do_ste_alloc /* If so handle it */
  812. END_MMU_FTR_SECTION_IFCLR(MMU_FTR_SLB)
  813. clrrdi r11,r1,THREAD_SHIFT
  814. lwz r0,TI_PREEMPT(r11) /* If we're in an "NMI" */
  815. andis. r0,r0,NMI_MASK@h /* (i.e. an irq when soft-disabled) */
  816. bne 77f /* then don't call hash_page now */
  817. /*
  818. * On iSeries, we soft-disable interrupts here, then
  819. * hard-enable interrupts so that the hash_page code can spin on
  820. * the hash_table_lock without problems on a shared processor.
  821. */
  822. DISABLE_INTS
  823. /*
  824. * Currently, trace_hardirqs_off() will be called by DISABLE_INTS
  825. * and will clobber volatile registers when irq tracing is enabled
  826. * so we need to reload them. It may be possible to be smarter here
  827. * and move the irq tracing elsewhere but let's keep it simple for
  828. * now
  829. */
  830. #ifdef CONFIG_TRACE_IRQFLAGS
  831. ld r3,_DAR(r1)
  832. ld r4,_DSISR(r1)
  833. ld r5,_TRAP(r1)
  834. ld r12,_MSR(r1)
  835. clrrdi r5,r5,4
  836. #endif /* CONFIG_TRACE_IRQFLAGS */
  837. /*
  838. * We need to set the _PAGE_USER bit if MSR_PR is set or if we are
  839. * accessing a userspace segment (even from the kernel). We assume
  840. * kernel addresses always have the high bit set.
  841. */
  842. rlwinm r4,r4,32-25+9,31-9,31-9 /* DSISR_STORE -> _PAGE_RW */
  843. rotldi r0,r3,15 /* Move high bit into MSR_PR posn */
  844. orc r0,r12,r0 /* MSR_PR | ~high_bit */
  845. rlwimi r4,r0,32-13,30,30 /* becomes _PAGE_USER access bit */
  846. ori r4,r4,1 /* add _PAGE_PRESENT */
  847. rlwimi r4,r5,22+2,31-2,31-2 /* Set _PAGE_EXEC if trap is 0x400 */
  848. /*
  849. * r3 contains the faulting address
  850. * r4 contains the required access permissions
  851. * r5 contains the trap number
  852. *
  853. * at return r3 = 0 for success
  854. */
  855. bl .hash_page /* build HPTE if possible */
  856. cmpdi r3,0 /* see if hash_page succeeded */
  857. BEGIN_FW_FTR_SECTION
  858. /*
  859. * If we had interrupts soft-enabled at the point where the
  860. * DSI/ISI occurred, and an interrupt came in during hash_page,
  861. * handle it now.
  862. * We jump to ret_from_except_lite rather than fast_exception_return
  863. * because ret_from_except_lite will check for and handle pending
  864. * interrupts if necessary.
  865. */
  866. beq 13f
  867. END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
  868. BEGIN_FW_FTR_SECTION
  869. /*
  870. * Here we have interrupts hard-disabled, so it is sufficient
  871. * to restore paca->{soft,hard}_enable and get out.
  872. */
  873. beq fast_exc_return_irq /* Return from exception on success */
  874. END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES)
  875. /* For a hash failure, we don't bother re-enabling interrupts */
  876. ble- 12f
  877. /*
  878. * hash_page couldn't handle it, set soft interrupt enable back
  879. * to what it was before the trap. Note that .arch_local_irq_restore
  880. * handles any interrupts pending at this point.
  881. */
  882. ld r3,SOFTE(r1)
  883. TRACE_AND_RESTORE_IRQ_PARTIAL(r3, 11f)
  884. bl .arch_local_irq_restore
  885. b 11f
  886. /* We have a data breakpoint exception - handle it */
  887. handle_dabr_fault:
  888. bl .save_nvgprs
  889. ld r4,_DAR(r1)
  890. ld r5,_DSISR(r1)
  891. addi r3,r1,STACK_FRAME_OVERHEAD
  892. bl .do_dabr
  893. b .ret_from_except_lite
  894. /* Here we have a page fault that hash_page can't handle. */
  895. handle_page_fault:
  896. ENABLE_INTS
  897. 11: ld r4,_DAR(r1)
  898. ld r5,_DSISR(r1)
  899. addi r3,r1,STACK_FRAME_OVERHEAD
  900. bl .do_page_fault
  901. cmpdi r3,0
  902. beq+ 13f
  903. bl .save_nvgprs
  904. mr r5,r3
  905. addi r3,r1,STACK_FRAME_OVERHEAD
  906. lwz r4,_DAR(r1)
  907. bl .bad_page_fault
  908. b .ret_from_except
  909. 13: b .ret_from_except_lite
  910. /* We have a page fault that hash_page could handle but HV refused
  911. * the PTE insertion
  912. */
  913. 12: bl .save_nvgprs
  914. mr r5,r3
  915. addi r3,r1,STACK_FRAME_OVERHEAD
  916. ld r4,_DAR(r1)
  917. bl .low_hash_fault
  918. b .ret_from_except
  919. /*
  920. * We come here as a result of a DSI at a point where we don't want
  921. * to call hash_page, such as when we are accessing memory (possibly
  922. * user memory) inside a PMU interrupt that occurred while interrupts
  923. * were soft-disabled. We want to invoke the exception handler for
  924. * the access, or panic if there isn't a handler.
  925. */
  926. 77: bl .save_nvgprs
  927. mr r4,r3
  928. addi r3,r1,STACK_FRAME_OVERHEAD
  929. li r5,SIGSEGV
  930. bl .bad_page_fault
  931. b .ret_from_except
  932. /* here we have a segment miss */
  933. do_ste_alloc:
  934. bl .ste_allocate /* try to insert stab entry */
  935. cmpdi r3,0
  936. bne- handle_page_fault
  937. b fast_exception_return
  938. /*
  939. * r13 points to the PACA, r9 contains the saved CR,
  940. * r11 and r12 contain the saved SRR0 and SRR1.
  941. * r9 - r13 are saved in paca->exslb.
  942. * We assume we aren't going to take any exceptions during this procedure.
  943. * We assume (DAR >> 60) == 0xc.
  944. */
  945. .align 7
  946. _GLOBAL(do_stab_bolted)
  947. stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */
  948. std r11,PACA_EXSLB+EX_SRR0(r13) /* save SRR0 in exc. frame */
  949. /* Hash to the primary group */
  950. ld r10,PACASTABVIRT(r13)
  951. mfspr r11,SPRN_DAR
  952. srdi r11,r11,28
  953. rldimi r10,r11,7,52 /* r10 = first ste of the group */
  954. /* Calculate VSID */
  955. /* This is a kernel address, so protovsid = ESID */
  956. ASM_VSID_SCRAMBLE(r11, r9, 256M)
  957. rldic r9,r11,12,16 /* r9 = vsid << 12 */
  958. /* Search the primary group for a free entry */
  959. 1: ld r11,0(r10) /* Test valid bit of the current ste */
  960. andi. r11,r11,0x80
  961. beq 2f
  962. addi r10,r10,16
  963. andi. r11,r10,0x70
  964. bne 1b
  965. /* Stick for only searching the primary group for now. */
  966. /* At least for now, we use a very simple random castout scheme */
  967. /* Use the TB as a random number ; OR in 1 to avoid entry 0 */
  968. mftb r11
  969. rldic r11,r11,4,57 /* r11 = (r11 << 4) & 0x70 */
  970. ori r11,r11,0x10
  971. /* r10 currently points to an ste one past the group of interest */
  972. /* make it point to the randomly selected entry */
  973. subi r10,r10,128
  974. or r10,r10,r11 /* r10 is the entry to invalidate */
  975. isync /* mark the entry invalid */
  976. ld r11,0(r10)
  977. rldicl r11,r11,56,1 /* clear the valid bit */
  978. rotldi r11,r11,8
  979. std r11,0(r10)
  980. sync
  981. clrrdi r11,r11,28 /* Get the esid part of the ste */
  982. slbie r11
  983. 2: std r9,8(r10) /* Store the vsid part of the ste */
  984. eieio
  985. mfspr r11,SPRN_DAR /* Get the new esid */
  986. clrrdi r11,r11,28 /* Permits a full 32b of ESID */
  987. ori r11,r11,0x90 /* Turn on valid and kp */
  988. std r11,0(r10) /* Put new entry back into the stab */
  989. sync
  990. /* All done -- return from exception. */
  991. lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */
  992. ld r11,PACA_EXSLB+EX_SRR0(r13) /* get saved SRR0 */
  993. andi. r10,r12,MSR_RI
  994. beq- unrecov_slb
  995. mtcrf 0x80,r9 /* restore CR */
  996. mfmsr r10
  997. clrrdi r10,r10,2
  998. mtmsrd r10,1
  999. mtspr SPRN_SRR0,r11
  1000. mtspr SPRN_SRR1,r12
  1001. ld r9,PACA_EXSLB+EX_R9(r13)
  1002. ld r10,PACA_EXSLB+EX_R10(r13)
  1003. ld r11,PACA_EXSLB+EX_R11(r13)
  1004. ld r12,PACA_EXSLB+EX_R12(r13)
  1005. ld r13,PACA_EXSLB+EX_R13(r13)
  1006. rfid
  1007. b . /* prevent speculative execution */
  1008. #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV)
  1009. /*
  1010. * Data area reserved for FWNMI option.
  1011. * This address (0x7000) is fixed by the RPA.
  1012. */
  1013. .= 0x7000
  1014. .globl fwnmi_data_area
  1015. fwnmi_data_area:
  1016. #endif /* defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) */
  1017. /* iSeries does not use the FWNMI stuff, so it is safe to put
  1018. * this here, even if we later allow kernels that will boot on
  1019. * both pSeries and iSeries */
  1020. #ifdef CONFIG_PPC_ISERIES
  1021. . = LPARMAP_PHYS
  1022. .globl xLparMap
  1023. xLparMap:
  1024. .quad HvEsidsToMap /* xNumberEsids */
  1025. .quad HvRangesToMap /* xNumberRanges */
  1026. .quad STAB0_PAGE /* xSegmentTableOffs */
  1027. .zero 40 /* xRsvd */
  1028. /* xEsids (HvEsidsToMap entries of 2 quads) */
  1029. .quad PAGE_OFFSET_ESID /* xKernelEsid */
  1030. .quad PAGE_OFFSET_VSID /* xKernelVsid */
  1031. .quad VMALLOC_START_ESID /* xKernelEsid */
  1032. .quad VMALLOC_START_VSID /* xKernelVsid */
  1033. /* xRanges (HvRangesToMap entries of 3 quads) */
  1034. .quad HvPagesToMap /* xPages */
  1035. .quad 0 /* xOffset */
  1036. .quad PAGE_OFFSET_VSID << (SID_SHIFT - HW_PAGE_SHIFT) /* xVPN */
  1037. #endif /* CONFIG_PPC_ISERIES */
  1038. #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV)
  1039. /* pseries and powernv need to keep the whole page from
  1040. * 0x7000 to 0x8000 free for use by the firmware
  1041. */
  1042. . = 0x8000
  1043. #endif /* defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) */
  1044. /*
  1045. * Space for CPU0's segment table.
  1046. *
  1047. * On iSeries, the hypervisor must fill in at least one entry before
  1048. * we get control (with relocate on). The address is given to the hv
  1049. * as a page number (see xLparMap above), so this must be at a
  1050. * fixed address (the linker can't compute (u64)&initial_stab >>
  1051. * PAGE_SHIFT).
  1052. */
  1053. . = STAB0_OFFSET /* 0x8000 */
  1054. .globl initial_stab
  1055. initial_stab:
  1056. .space 4096
  1057. #ifdef CONFIG_PPC_POWERNV
  1058. _GLOBAL(opal_mc_secondary_handler)
  1059. HMT_MEDIUM
  1060. SET_SCRATCH0(r13)
  1061. GET_PACA(r13)
  1062. clrldi r3,r3,2
  1063. tovirt(r3,r3)
  1064. std r3,PACA_OPAL_MC_EVT(r13)
  1065. ld r13,OPAL_MC_SRR0(r3)
  1066. mtspr SPRN_SRR0,r13
  1067. ld r13,OPAL_MC_SRR1(r3)
  1068. mtspr SPRN_SRR1,r13
  1069. ld r3,OPAL_MC_GPR3(r3)
  1070. GET_SCRATCH0(r13)
  1071. b machine_check_pSeries
  1072. #endif /* CONFIG_PPC_POWERNV */