exceptions-64s.S 31 KB

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