exceptions-64s.S 30 KB

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