head_64.S 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745
  1. /*
  2. * PowerPC version
  3. * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
  4. *
  5. * Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP
  6. * Copyright (C) 1996 Cort Dougan <cort@cs.nmt.edu>
  7. * Adapted for Power Macintosh by Paul Mackerras.
  8. * Low-level exception handlers and MMU support
  9. * rewritten by Paul Mackerras.
  10. * Copyright (C) 1996 Paul Mackerras.
  11. *
  12. * Adapted for 64bit PowerPC by Dave Engebretsen, Peter Bergner, and
  13. * Mike Corrigan {engebret|bergner|mikejc}@us.ibm.com
  14. *
  15. * This file contains the low-level support and setup for the
  16. * PowerPC-64 platform, including trap and interrupt dispatch.
  17. *
  18. * This program is free software; you can redistribute it and/or
  19. * modify it under the terms of the GNU General Public License
  20. * as published by the Free Software Foundation; either version
  21. * 2 of the License, or (at your option) any later version.
  22. */
  23. #include <linux/threads.h>
  24. #include <asm/reg.h>
  25. #include <asm/page.h>
  26. #include <asm/mmu.h>
  27. #include <asm/ppc_asm.h>
  28. #include <asm/asm-offsets.h>
  29. #include <asm/bug.h>
  30. #include <asm/cputable.h>
  31. #include <asm/setup.h>
  32. #include <asm/hvcall.h>
  33. #include <asm/iseries/lpar_map.h>
  34. #include <asm/thread_info.h>
  35. #include <asm/firmware.h>
  36. #include <asm/page_64.h>
  37. #include <asm/exception.h>
  38. #include <asm/irqflags.h>
  39. /*
  40. * We layout physical memory as follows:
  41. * 0x0000 - 0x00ff : Secondary processor spin code
  42. * 0x0100 - 0x2fff : pSeries Interrupt prologs
  43. * 0x3000 - 0x5fff : interrupt support, iSeries and common interrupt prologs
  44. * 0x6000 - 0x6fff : Initial (CPU0) segment table
  45. * 0x7000 - 0x7fff : FWNMI data area
  46. * 0x8000 - : Early init and support code
  47. */
  48. /*
  49. * SPRG Usage
  50. *
  51. * Register Definition
  52. *
  53. * SPRG0 reserved for hypervisor
  54. * SPRG1 temp - used to save gpr
  55. * SPRG2 temp - used to save gpr
  56. * SPRG3 virt addr of paca
  57. */
  58. /*
  59. * Entering into this code we make the following assumptions:
  60. * For pSeries:
  61. * 1. The MMU is off & open firmware is running in real mode.
  62. * 2. The kernel is entered at __start
  63. *
  64. * For iSeries:
  65. * 1. The MMU is on (as it always is for iSeries)
  66. * 2. The kernel is entered at system_reset_iSeries
  67. */
  68. .text
  69. .globl _stext
  70. _stext:
  71. _GLOBAL(__start)
  72. /* NOP this out unconditionally */
  73. BEGIN_FTR_SECTION
  74. b .__start_initialization_multiplatform
  75. END_FTR_SECTION(0, 1)
  76. /* Catch branch to 0 in real mode */
  77. trap
  78. /* Secondary processors spin on this value until it becomes nonzero.
  79. * When it does it contains the real address of the descriptor
  80. * of the function that the cpu should jump to to continue
  81. * initialization.
  82. */
  83. .globl __secondary_hold_spinloop
  84. __secondary_hold_spinloop:
  85. .llong 0x0
  86. /* Secondary processors write this value with their cpu # */
  87. /* after they enter the spin loop immediately below. */
  88. .globl __secondary_hold_acknowledge
  89. __secondary_hold_acknowledge:
  90. .llong 0x0
  91. #ifdef CONFIG_PPC_ISERIES
  92. /*
  93. * At offset 0x20, there is a pointer to iSeries LPAR data.
  94. * This is required by the hypervisor
  95. */
  96. . = 0x20
  97. .llong hvReleaseData-KERNELBASE
  98. #endif /* CONFIG_PPC_ISERIES */
  99. #ifdef CONFIG_CRASH_DUMP
  100. /* This flag is set to 1 by a loader if the kernel should run
  101. * at the loaded address instead of the linked address. This
  102. * is used by kexec-tools to keep the the kdump kernel in the
  103. * crash_kernel region. The loader is responsible for
  104. * observing the alignment requirement.
  105. */
  106. /* Do not move this variable as kexec-tools knows about it. */
  107. . = 0x5c
  108. .globl __run_at_load
  109. __run_at_load:
  110. .long 0x72756e30 /* "run0" -- relocate to 0 by default */
  111. #endif
  112. . = 0x60
  113. /*
  114. * The following code is used to hold secondary processors
  115. * in a spin loop after they have entered the kernel, but
  116. * before the bulk of the kernel has been relocated. This code
  117. * is relocated to physical address 0x60 before prom_init is run.
  118. * All of it must fit below the first exception vector at 0x100.
  119. * Use .globl here not _GLOBAL because we want __secondary_hold
  120. * to be the actual text address, not a descriptor.
  121. */
  122. .globl __secondary_hold
  123. __secondary_hold:
  124. mfmsr r24
  125. ori r24,r24,MSR_RI
  126. mtmsrd r24 /* RI on */
  127. /* Grab our physical cpu number */
  128. mr r24,r3
  129. /* Tell the master cpu we're here */
  130. /* Relocation is off & we are located at an address less */
  131. /* than 0x100, so only need to grab low order offset. */
  132. std r24,__secondary_hold_acknowledge-_stext(0)
  133. sync
  134. /* All secondary cpus wait here until told to start. */
  135. 100: ld r4,__secondary_hold_spinloop-_stext(0)
  136. cmpdi 0,r4,0
  137. beq 100b
  138. #if defined(CONFIG_SMP) || defined(CONFIG_KEXEC)
  139. ld r4,0(r4) /* deref function descriptor */
  140. mtctr r4
  141. mr r3,r24
  142. bctr
  143. #else
  144. BUG_OPCODE
  145. #endif
  146. /* This value is used to mark exception frames on the stack. */
  147. .section ".toc","aw"
  148. exception_marker:
  149. .tc ID_72656773_68657265[TC],0x7265677368657265
  150. .text
  151. /*
  152. * This is the start of the interrupt handlers for pSeries
  153. * This code runs with relocation off.
  154. * Code from here to __end_interrupts gets copied down to real
  155. * address 0x100 when we are running a relocatable kernel.
  156. * Therefore any relative branches in this section must only
  157. * branch to labels in this section.
  158. */
  159. . = 0x100
  160. .globl __start_interrupts
  161. __start_interrupts:
  162. STD_EXCEPTION_PSERIES(0x100, system_reset)
  163. . = 0x200
  164. _machine_check_pSeries:
  165. HMT_MEDIUM
  166. mtspr SPRN_SPRG1,r13 /* save r13 */
  167. EXCEPTION_PROLOG_PSERIES(PACA_EXMC, machine_check_common)
  168. . = 0x300
  169. .globl data_access_pSeries
  170. data_access_pSeries:
  171. HMT_MEDIUM
  172. mtspr SPRN_SPRG1,r13
  173. BEGIN_FTR_SECTION
  174. mtspr SPRN_SPRG2,r12
  175. mfspr r13,SPRN_DAR
  176. mfspr r12,SPRN_DSISR
  177. srdi r13,r13,60
  178. rlwimi r13,r12,16,0x20
  179. mfcr r12
  180. cmpwi r13,0x2c
  181. beq do_stab_bolted_pSeries
  182. mtcrf 0x80,r12
  183. mfspr r12,SPRN_SPRG2
  184. END_FTR_SECTION_IFCLR(CPU_FTR_SLB)
  185. EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, data_access_common)
  186. . = 0x380
  187. .globl data_access_slb_pSeries
  188. data_access_slb_pSeries:
  189. HMT_MEDIUM
  190. mtspr SPRN_SPRG1,r13
  191. mfspr r13,SPRN_SPRG3 /* get paca address into r13 */
  192. std r3,PACA_EXSLB+EX_R3(r13)
  193. mfspr r3,SPRN_DAR
  194. std r9,PACA_EXSLB+EX_R9(r13) /* save r9 - r12 */
  195. mfcr r9
  196. #ifdef __DISABLED__
  197. /* Keep that around for when we re-implement dynamic VSIDs */
  198. cmpdi r3,0
  199. bge slb_miss_user_pseries
  200. #endif /* __DISABLED__ */
  201. std r10,PACA_EXSLB+EX_R10(r13)
  202. std r11,PACA_EXSLB+EX_R11(r13)
  203. std r12,PACA_EXSLB+EX_R12(r13)
  204. mfspr r10,SPRN_SPRG1
  205. std r10,PACA_EXSLB+EX_R13(r13)
  206. mfspr r12,SPRN_SRR1 /* and SRR1 */
  207. #ifndef CONFIG_RELOCATABLE
  208. b .slb_miss_realmode
  209. #else
  210. /*
  211. * We can't just use a direct branch to .slb_miss_realmode
  212. * because the distance from here to there depends on where
  213. * the kernel ends up being put.
  214. */
  215. mfctr r11
  216. ld r10,PACAKBASE(r13)
  217. LOAD_HANDLER(r10, .slb_miss_realmode)
  218. mtctr r10
  219. bctr
  220. #endif
  221. STD_EXCEPTION_PSERIES(0x400, instruction_access)
  222. . = 0x480
  223. .globl instruction_access_slb_pSeries
  224. instruction_access_slb_pSeries:
  225. HMT_MEDIUM
  226. mtspr SPRN_SPRG1,r13
  227. mfspr r13,SPRN_SPRG3 /* get paca address into r13 */
  228. std r3,PACA_EXSLB+EX_R3(r13)
  229. mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */
  230. std r9,PACA_EXSLB+EX_R9(r13) /* save r9 - r12 */
  231. mfcr r9
  232. #ifdef __DISABLED__
  233. /* Keep that around for when we re-implement dynamic VSIDs */
  234. cmpdi r3,0
  235. bge slb_miss_user_pseries
  236. #endif /* __DISABLED__ */
  237. std r10,PACA_EXSLB+EX_R10(r13)
  238. std r11,PACA_EXSLB+EX_R11(r13)
  239. std r12,PACA_EXSLB+EX_R12(r13)
  240. mfspr r10,SPRN_SPRG1
  241. std r10,PACA_EXSLB+EX_R13(r13)
  242. mfspr r12,SPRN_SRR1 /* and SRR1 */
  243. #ifndef CONFIG_RELOCATABLE
  244. b .slb_miss_realmode
  245. #else
  246. mfctr r11
  247. ld r10,PACAKBASE(r13)
  248. LOAD_HANDLER(r10, .slb_miss_realmode)
  249. mtctr r10
  250. bctr
  251. #endif
  252. MASKABLE_EXCEPTION_PSERIES(0x500, hardware_interrupt)
  253. STD_EXCEPTION_PSERIES(0x600, alignment)
  254. STD_EXCEPTION_PSERIES(0x700, program_check)
  255. STD_EXCEPTION_PSERIES(0x800, fp_unavailable)
  256. MASKABLE_EXCEPTION_PSERIES(0x900, decrementer)
  257. STD_EXCEPTION_PSERIES(0xa00, trap_0a)
  258. STD_EXCEPTION_PSERIES(0xb00, trap_0b)
  259. . = 0xc00
  260. .globl system_call_pSeries
  261. system_call_pSeries:
  262. HMT_MEDIUM
  263. BEGIN_FTR_SECTION
  264. cmpdi r0,0x1ebe
  265. beq- 1f
  266. END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE)
  267. mr r9,r13
  268. mfspr r13,SPRN_SPRG3
  269. mfspr r11,SPRN_SRR0
  270. ld r12,PACAKBASE(r13)
  271. ld r10,PACAKMSR(r13)
  272. LOAD_HANDLER(r12, system_call_entry)
  273. mtspr SPRN_SRR0,r12
  274. mfspr r12,SPRN_SRR1
  275. mtspr SPRN_SRR1,r10
  276. rfid
  277. b . /* prevent speculative execution */
  278. /* Fast LE/BE switch system call */
  279. 1: mfspr r12,SPRN_SRR1
  280. xori r12,r12,MSR_LE
  281. mtspr SPRN_SRR1,r12
  282. rfid /* return to userspace */
  283. b .
  284. STD_EXCEPTION_PSERIES(0xd00, single_step)
  285. STD_EXCEPTION_PSERIES(0xe00, trap_0e)
  286. /* We need to deal with the Altivec unavailable exception
  287. * here which is at 0xf20, thus in the middle of the
  288. * prolog code of the PerformanceMonitor one. A little
  289. * trickery is thus necessary
  290. */
  291. . = 0xf00
  292. b performance_monitor_pSeries
  293. . = 0xf20
  294. b altivec_unavailable_pSeries
  295. . = 0xf40
  296. b vsx_unavailable_pSeries
  297. #ifdef CONFIG_CBE_RAS
  298. HSTD_EXCEPTION_PSERIES(0x1200, cbe_system_error)
  299. #endif /* CONFIG_CBE_RAS */
  300. STD_EXCEPTION_PSERIES(0x1300, instruction_breakpoint)
  301. #ifdef CONFIG_CBE_RAS
  302. HSTD_EXCEPTION_PSERIES(0x1600, cbe_maintenance)
  303. #endif /* CONFIG_CBE_RAS */
  304. STD_EXCEPTION_PSERIES(0x1700, altivec_assist)
  305. #ifdef CONFIG_CBE_RAS
  306. HSTD_EXCEPTION_PSERIES(0x1800, cbe_thermal)
  307. #endif /* CONFIG_CBE_RAS */
  308. . = 0x3000
  309. /*** pSeries interrupt support ***/
  310. /* moved from 0xf00 */
  311. STD_EXCEPTION_PSERIES(., performance_monitor)
  312. STD_EXCEPTION_PSERIES(., altivec_unavailable)
  313. STD_EXCEPTION_PSERIES(., vsx_unavailable)
  314. /*
  315. * An interrupt came in while soft-disabled; clear EE in SRR1,
  316. * clear paca->hard_enabled and return.
  317. */
  318. masked_interrupt:
  319. stb r10,PACAHARDIRQEN(r13)
  320. mtcrf 0x80,r9
  321. ld r9,PACA_EXGEN+EX_R9(r13)
  322. mfspr r10,SPRN_SRR1
  323. rldicl r10,r10,48,1 /* clear MSR_EE */
  324. rotldi r10,r10,16
  325. mtspr SPRN_SRR1,r10
  326. ld r10,PACA_EXGEN+EX_R10(r13)
  327. mfspr r13,SPRN_SPRG1
  328. rfid
  329. b .
  330. .align 7
  331. do_stab_bolted_pSeries:
  332. mtcrf 0x80,r12
  333. mfspr r12,SPRN_SPRG2
  334. EXCEPTION_PROLOG_PSERIES(PACA_EXSLB, .do_stab_bolted)
  335. #ifdef CONFIG_PPC_PSERIES
  336. /*
  337. * Vectors for the FWNMI option. Share common code.
  338. */
  339. .globl system_reset_fwnmi
  340. .align 7
  341. system_reset_fwnmi:
  342. HMT_MEDIUM
  343. mtspr SPRN_SPRG1,r13 /* save r13 */
  344. EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, system_reset_common)
  345. .globl machine_check_fwnmi
  346. .align 7
  347. machine_check_fwnmi:
  348. HMT_MEDIUM
  349. mtspr SPRN_SPRG1,r13 /* save r13 */
  350. EXCEPTION_PROLOG_PSERIES(PACA_EXMC, machine_check_common)
  351. #endif /* CONFIG_PPC_PSERIES */
  352. #ifdef __DISABLED__
  353. /*
  354. * This is used for when the SLB miss handler has to go virtual,
  355. * which doesn't happen for now anymore but will once we re-implement
  356. * dynamic VSIDs for shared page tables
  357. */
  358. slb_miss_user_pseries:
  359. std r10,PACA_EXGEN+EX_R10(r13)
  360. std r11,PACA_EXGEN+EX_R11(r13)
  361. std r12,PACA_EXGEN+EX_R12(r13)
  362. mfspr r10,SPRG1
  363. ld r11,PACA_EXSLB+EX_R9(r13)
  364. ld r12,PACA_EXSLB+EX_R3(r13)
  365. std r10,PACA_EXGEN+EX_R13(r13)
  366. std r11,PACA_EXGEN+EX_R9(r13)
  367. std r12,PACA_EXGEN+EX_R3(r13)
  368. clrrdi r12,r13,32
  369. mfmsr r10
  370. mfspr r11,SRR0 /* save SRR0 */
  371. ori r12,r12,slb_miss_user_common@l /* virt addr of handler */
  372. ori r10,r10,MSR_IR|MSR_DR|MSR_RI
  373. mtspr SRR0,r12
  374. mfspr r12,SRR1 /* and SRR1 */
  375. mtspr SRR1,r10
  376. rfid
  377. b . /* prevent spec. execution */
  378. #endif /* __DISABLED__ */
  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_IDLE(0xf00, performance_monitor, .performance_monitor_exception)
  411. STD_EXCEPTION_COMMON(0x1300, instruction_breakpoint, .instruction_breakpoint_exception)
  412. #ifdef CONFIG_ALTIVEC
  413. STD_EXCEPTION_COMMON(0x1700, altivec_assist, .altivec_assist_exception)
  414. #else
  415. STD_EXCEPTION_COMMON(0x1700, altivec_assist, .unknown_exception)
  416. #endif
  417. #ifdef CONFIG_CBE_RAS
  418. STD_EXCEPTION_COMMON(0x1200, cbe_system_error, .cbe_system_error_exception)
  419. STD_EXCEPTION_COMMON(0x1600, cbe_maintenance, .cbe_maintenance_exception)
  420. STD_EXCEPTION_COMMON(0x1800, cbe_thermal, .cbe_thermal_exception)
  421. #endif /* CONFIG_CBE_RAS */
  422. .align 7
  423. system_call_entry:
  424. b system_call_common
  425. /*
  426. * Here we have detected that the kernel stack pointer is bad.
  427. * R9 contains the saved CR, r13 points to the paca,
  428. * r10 contains the (bad) kernel stack pointer,
  429. * r11 and r12 contain the saved SRR0 and SRR1.
  430. * We switch to using an emergency stack, save the registers there,
  431. * and call kernel_bad_stack(), which panics.
  432. */
  433. bad_stack:
  434. ld r1,PACAEMERGSP(r13)
  435. subi r1,r1,64+INT_FRAME_SIZE
  436. std r9,_CCR(r1)
  437. std r10,GPR1(r1)
  438. std r11,_NIP(r1)
  439. std r12,_MSR(r1)
  440. mfspr r11,SPRN_DAR
  441. mfspr r12,SPRN_DSISR
  442. std r11,_DAR(r1)
  443. std r12,_DSISR(r1)
  444. mflr r10
  445. mfctr r11
  446. mfxer r12
  447. std r10,_LINK(r1)
  448. std r11,_CTR(r1)
  449. std r12,_XER(r1)
  450. SAVE_GPR(0,r1)
  451. SAVE_GPR(2,r1)
  452. SAVE_4GPRS(3,r1)
  453. SAVE_2GPRS(7,r1)
  454. SAVE_10GPRS(12,r1)
  455. SAVE_10GPRS(22,r1)
  456. lhz r12,PACA_TRAP_SAVE(r13)
  457. std r12,_TRAP(r1)
  458. addi r11,r1,INT_FRAME_SIZE
  459. std r11,0(r1)
  460. li r12,0
  461. std r12,0(r11)
  462. ld r2,PACATOC(r13)
  463. 1: addi r3,r1,STACK_FRAME_OVERHEAD
  464. bl .kernel_bad_stack
  465. b 1b
  466. /*
  467. * Here r13 points to the paca, r9 contains the saved CR,
  468. * SRR0 and SRR1 are saved in r11 and r12,
  469. * r9 - r13 are saved in paca->exgen.
  470. */
  471. .align 7
  472. .globl data_access_common
  473. data_access_common:
  474. mfspr r10,SPRN_DAR
  475. std r10,PACA_EXGEN+EX_DAR(r13)
  476. mfspr r10,SPRN_DSISR
  477. stw r10,PACA_EXGEN+EX_DSISR(r13)
  478. EXCEPTION_PROLOG_COMMON(0x300, PACA_EXGEN)
  479. ld r3,PACA_EXGEN+EX_DAR(r13)
  480. lwz r4,PACA_EXGEN+EX_DSISR(r13)
  481. li r5,0x300
  482. b .do_hash_page /* Try to handle as hpte fault */
  483. .align 7
  484. .globl instruction_access_common
  485. instruction_access_common:
  486. EXCEPTION_PROLOG_COMMON(0x400, PACA_EXGEN)
  487. ld r3,_NIP(r1)
  488. andis. r4,r12,0x5820
  489. li r5,0x400
  490. b .do_hash_page /* Try to handle as hpte fault */
  491. /*
  492. * Here is the common SLB miss user that is used when going to virtual
  493. * mode for SLB misses, that is currently not used
  494. */
  495. #ifdef __DISABLED__
  496. .align 7
  497. .globl slb_miss_user_common
  498. slb_miss_user_common:
  499. mflr r10
  500. std r3,PACA_EXGEN+EX_DAR(r13)
  501. stw r9,PACA_EXGEN+EX_CCR(r13)
  502. std r10,PACA_EXGEN+EX_LR(r13)
  503. std r11,PACA_EXGEN+EX_SRR0(r13)
  504. bl .slb_allocate_user
  505. ld r10,PACA_EXGEN+EX_LR(r13)
  506. ld r3,PACA_EXGEN+EX_R3(r13)
  507. lwz r9,PACA_EXGEN+EX_CCR(r13)
  508. ld r11,PACA_EXGEN+EX_SRR0(r13)
  509. mtlr r10
  510. beq- slb_miss_fault
  511. andi. r10,r12,MSR_RI /* check for unrecoverable exception */
  512. beq- unrecov_user_slb
  513. mfmsr r10
  514. .machine push
  515. .machine "power4"
  516. mtcrf 0x80,r9
  517. .machine pop
  518. clrrdi r10,r10,2 /* clear RI before setting SRR0/1 */
  519. mtmsrd r10,1
  520. mtspr SRR0,r11
  521. mtspr SRR1,r12
  522. ld r9,PACA_EXGEN+EX_R9(r13)
  523. ld r10,PACA_EXGEN+EX_R10(r13)
  524. ld r11,PACA_EXGEN+EX_R11(r13)
  525. ld r12,PACA_EXGEN+EX_R12(r13)
  526. ld r13,PACA_EXGEN+EX_R13(r13)
  527. rfid
  528. b .
  529. slb_miss_fault:
  530. EXCEPTION_PROLOG_COMMON(0x380, PACA_EXGEN)
  531. ld r4,PACA_EXGEN+EX_DAR(r13)
  532. li r5,0
  533. std r4,_DAR(r1)
  534. std r5,_DSISR(r1)
  535. b handle_page_fault
  536. unrecov_user_slb:
  537. EXCEPTION_PROLOG_COMMON(0x4200, PACA_EXGEN)
  538. DISABLE_INTS
  539. bl .save_nvgprs
  540. 1: addi r3,r1,STACK_FRAME_OVERHEAD
  541. bl .unrecoverable_exception
  542. b 1b
  543. #endif /* __DISABLED__ */
  544. /*
  545. * r13 points to the PACA, r9 contains the saved CR,
  546. * r12 contain the saved SRR1, SRR0 is still ready for return
  547. * r3 has the faulting address
  548. * r9 - r13 are saved in paca->exslb.
  549. * r3 is saved in paca->slb_r3
  550. * We assume we aren't going to take any exceptions during this procedure.
  551. */
  552. _GLOBAL(slb_miss_realmode)
  553. mflr r10
  554. #ifdef CONFIG_RELOCATABLE
  555. mtctr r11
  556. #endif
  557. stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */
  558. std r10,PACA_EXSLB+EX_LR(r13) /* save LR */
  559. bl .slb_allocate_realmode
  560. /* All done -- return from exception. */
  561. ld r10,PACA_EXSLB+EX_LR(r13)
  562. ld r3,PACA_EXSLB+EX_R3(r13)
  563. lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */
  564. #ifdef CONFIG_PPC_ISERIES
  565. BEGIN_FW_FTR_SECTION
  566. ld r11,PACALPPACAPTR(r13)
  567. ld r11,LPPACASRR0(r11) /* get SRR0 value */
  568. END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
  569. #endif /* CONFIG_PPC_ISERIES */
  570. mtlr r10
  571. andi. r10,r12,MSR_RI /* check for unrecoverable exception */
  572. beq- 2f
  573. .machine push
  574. .machine "power4"
  575. mtcrf 0x80,r9
  576. mtcrf 0x01,r9 /* slb_allocate uses cr0 and cr7 */
  577. .machine pop
  578. #ifdef CONFIG_PPC_ISERIES
  579. BEGIN_FW_FTR_SECTION
  580. mtspr SPRN_SRR0,r11
  581. mtspr SPRN_SRR1,r12
  582. END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
  583. #endif /* CONFIG_PPC_ISERIES */
  584. ld r9,PACA_EXSLB+EX_R9(r13)
  585. ld r10,PACA_EXSLB+EX_R10(r13)
  586. ld r11,PACA_EXSLB+EX_R11(r13)
  587. ld r12,PACA_EXSLB+EX_R12(r13)
  588. ld r13,PACA_EXSLB+EX_R13(r13)
  589. rfid
  590. b . /* prevent speculative execution */
  591. 2:
  592. #ifdef CONFIG_PPC_ISERIES
  593. BEGIN_FW_FTR_SECTION
  594. b unrecov_slb
  595. END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
  596. #endif /* CONFIG_PPC_ISERIES */
  597. mfspr r11,SPRN_SRR0
  598. ld r10,PACAKBASE(r13)
  599. LOAD_HANDLER(r10,unrecov_slb)
  600. mtspr SPRN_SRR0,r10
  601. ld r10,PACAKMSR(r13)
  602. mtspr SPRN_SRR1,r10
  603. rfid
  604. b .
  605. unrecov_slb:
  606. EXCEPTION_PROLOG_COMMON(0x4100, PACA_EXSLB)
  607. DISABLE_INTS
  608. bl .save_nvgprs
  609. 1: addi r3,r1,STACK_FRAME_OVERHEAD
  610. bl .unrecoverable_exception
  611. b 1b
  612. .align 7
  613. .globl hardware_interrupt_common
  614. .globl hardware_interrupt_entry
  615. hardware_interrupt_common:
  616. EXCEPTION_PROLOG_COMMON(0x500, PACA_EXGEN)
  617. FINISH_NAP
  618. hardware_interrupt_entry:
  619. DISABLE_INTS
  620. BEGIN_FTR_SECTION
  621. bl .ppc64_runlatch_on
  622. END_FTR_SECTION_IFSET(CPU_FTR_CTRL)
  623. addi r3,r1,STACK_FRAME_OVERHEAD
  624. bl .do_IRQ
  625. b .ret_from_except_lite
  626. #ifdef CONFIG_PPC_970_NAP
  627. power4_fixup_nap:
  628. andc r9,r9,r10
  629. std r9,TI_LOCAL_FLAGS(r11)
  630. ld r10,_LINK(r1) /* make idle task do the */
  631. std r10,_NIP(r1) /* equivalent of a blr */
  632. blr
  633. #endif
  634. .align 7
  635. .globl alignment_common
  636. alignment_common:
  637. mfspr r10,SPRN_DAR
  638. std r10,PACA_EXGEN+EX_DAR(r13)
  639. mfspr r10,SPRN_DSISR
  640. stw r10,PACA_EXGEN+EX_DSISR(r13)
  641. EXCEPTION_PROLOG_COMMON(0x600, PACA_EXGEN)
  642. ld r3,PACA_EXGEN+EX_DAR(r13)
  643. lwz r4,PACA_EXGEN+EX_DSISR(r13)
  644. std r3,_DAR(r1)
  645. std r4,_DSISR(r1)
  646. bl .save_nvgprs
  647. addi r3,r1,STACK_FRAME_OVERHEAD
  648. ENABLE_INTS
  649. bl .alignment_exception
  650. b .ret_from_except
  651. .align 7
  652. .globl program_check_common
  653. program_check_common:
  654. EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN)
  655. bl .save_nvgprs
  656. addi r3,r1,STACK_FRAME_OVERHEAD
  657. ENABLE_INTS
  658. bl .program_check_exception
  659. b .ret_from_except
  660. .align 7
  661. .globl fp_unavailable_common
  662. fp_unavailable_common:
  663. EXCEPTION_PROLOG_COMMON(0x800, PACA_EXGEN)
  664. bne 1f /* if from user, just load it up */
  665. bl .save_nvgprs
  666. addi r3,r1,STACK_FRAME_OVERHEAD
  667. ENABLE_INTS
  668. bl .kernel_fp_unavailable_exception
  669. BUG_OPCODE
  670. 1: bl .load_up_fpu
  671. b fast_exception_return
  672. .align 7
  673. .globl altivec_unavailable_common
  674. altivec_unavailable_common:
  675. EXCEPTION_PROLOG_COMMON(0xf20, PACA_EXGEN)
  676. #ifdef CONFIG_ALTIVEC
  677. BEGIN_FTR_SECTION
  678. beq 1f
  679. bl .load_up_altivec
  680. b fast_exception_return
  681. 1:
  682. END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
  683. #endif
  684. bl .save_nvgprs
  685. addi r3,r1,STACK_FRAME_OVERHEAD
  686. ENABLE_INTS
  687. bl .altivec_unavailable_exception
  688. b .ret_from_except
  689. .align 7
  690. .globl vsx_unavailable_common
  691. vsx_unavailable_common:
  692. EXCEPTION_PROLOG_COMMON(0xf40, PACA_EXGEN)
  693. #ifdef CONFIG_VSX
  694. BEGIN_FTR_SECTION
  695. bne .load_up_vsx
  696. 1:
  697. END_FTR_SECTION_IFSET(CPU_FTR_VSX)
  698. #endif
  699. bl .save_nvgprs
  700. addi r3,r1,STACK_FRAME_OVERHEAD
  701. ENABLE_INTS
  702. bl .vsx_unavailable_exception
  703. b .ret_from_except
  704. .align 7
  705. .globl __end_handlers
  706. __end_handlers:
  707. /*
  708. * Return from an exception with minimal checks.
  709. * The caller is assumed to have done EXCEPTION_PROLOG_COMMON.
  710. * If interrupts have been enabled, or anything has been
  711. * done that might have changed the scheduling status of
  712. * any task or sent any task a signal, you should use
  713. * ret_from_except or ret_from_except_lite instead of this.
  714. */
  715. fast_exc_return_irq: /* restores irq state too */
  716. ld r3,SOFTE(r1)
  717. TRACE_AND_RESTORE_IRQ(r3);
  718. ld r12,_MSR(r1)
  719. rldicl r4,r12,49,63 /* get MSR_EE to LSB */
  720. stb r4,PACAHARDIRQEN(r13) /* restore paca->hard_enabled */
  721. b 1f
  722. .globl fast_exception_return
  723. fast_exception_return:
  724. ld r12,_MSR(r1)
  725. 1: ld r11,_NIP(r1)
  726. andi. r3,r12,MSR_RI /* check if RI is set */
  727. beq- unrecov_fer
  728. #ifdef CONFIG_VIRT_CPU_ACCOUNTING
  729. andi. r3,r12,MSR_PR
  730. beq 2f
  731. ACCOUNT_CPU_USER_EXIT(r3, r4)
  732. 2:
  733. #endif
  734. ld r3,_CCR(r1)
  735. ld r4,_LINK(r1)
  736. ld r5,_CTR(r1)
  737. ld r6,_XER(r1)
  738. mtcr r3
  739. mtlr r4
  740. mtctr r5
  741. mtxer r6
  742. REST_GPR(0, r1)
  743. REST_8GPRS(2, r1)
  744. mfmsr r10
  745. rldicl r10,r10,48,1 /* clear EE */
  746. rldicr r10,r10,16,61 /* clear RI (LE is 0 already) */
  747. mtmsrd r10,1
  748. mtspr SPRN_SRR1,r12
  749. mtspr SPRN_SRR0,r11
  750. REST_4GPRS(10, r1)
  751. ld r1,GPR1(r1)
  752. rfid
  753. b . /* prevent speculative execution */
  754. unrecov_fer:
  755. bl .save_nvgprs
  756. 1: addi r3,r1,STACK_FRAME_OVERHEAD
  757. bl .unrecoverable_exception
  758. b 1b
  759. #ifdef CONFIG_ALTIVEC
  760. /*
  761. * load_up_altivec(unused, unused, tsk)
  762. * Disable VMX for the task which had it previously,
  763. * and save its vector registers in its thread_struct.
  764. * Enables the VMX for use in the kernel on return.
  765. * On SMP we know the VMX is free, since we give it up every
  766. * switch (ie, no lazy save of the vector registers).
  767. * On entry: r13 == 'current' && last_task_used_altivec != 'current'
  768. */
  769. _STATIC(load_up_altivec)
  770. mfmsr r5 /* grab the current MSR */
  771. oris r5,r5,MSR_VEC@h
  772. mtmsrd r5 /* enable use of VMX now */
  773. isync
  774. /*
  775. * For SMP, we don't do lazy VMX switching because it just gets too
  776. * horrendously complex, especially when a task switches from one CPU
  777. * to another. Instead we call giveup_altvec in switch_to.
  778. * VRSAVE isn't dealt with here, that is done in the normal context
  779. * switch code. Note that we could rely on vrsave value to eventually
  780. * avoid saving all of the VREGs here...
  781. */
  782. #ifndef CONFIG_SMP
  783. ld r3,last_task_used_altivec@got(r2)
  784. ld r4,0(r3)
  785. cmpdi 0,r4,0
  786. beq 1f
  787. /* Save VMX state to last_task_used_altivec's THREAD struct */
  788. addi r4,r4,THREAD
  789. SAVE_32VRS(0,r5,r4)
  790. mfvscr vr0
  791. li r10,THREAD_VSCR
  792. stvx vr0,r10,r4
  793. /* Disable VMX for last_task_used_altivec */
  794. ld r5,PT_REGS(r4)
  795. ld r4,_MSR-STACK_FRAME_OVERHEAD(r5)
  796. lis r6,MSR_VEC@h
  797. andc r4,r4,r6
  798. std r4,_MSR-STACK_FRAME_OVERHEAD(r5)
  799. 1:
  800. #endif /* CONFIG_SMP */
  801. /* Hack: if we get an altivec unavailable trap with VRSAVE
  802. * set to all zeros, we assume this is a broken application
  803. * that fails to set it properly, and thus we switch it to
  804. * all 1's
  805. */
  806. mfspr r4,SPRN_VRSAVE
  807. cmpdi 0,r4,0
  808. bne+ 1f
  809. li r4,-1
  810. mtspr SPRN_VRSAVE,r4
  811. 1:
  812. /* enable use of VMX after return */
  813. ld r4,PACACURRENT(r13)
  814. addi r5,r4,THREAD /* Get THREAD */
  815. oris r12,r12,MSR_VEC@h
  816. std r12,_MSR(r1)
  817. li r4,1
  818. li r10,THREAD_VSCR
  819. stw r4,THREAD_USED_VR(r5)
  820. lvx vr0,r10,r5
  821. mtvscr vr0
  822. REST_32VRS(0,r4,r5)
  823. #ifndef CONFIG_SMP
  824. /* Update last_task_used_math to 'current' */
  825. subi r4,r5,THREAD /* Back to 'current' */
  826. std r4,0(r3)
  827. #endif /* CONFIG_SMP */
  828. /* restore registers and return */
  829. blr
  830. #endif /* CONFIG_ALTIVEC */
  831. #ifdef CONFIG_VSX
  832. /*
  833. * load_up_vsx(unused, unused, tsk)
  834. * Disable VSX for the task which had it previously,
  835. * and save its vector registers in its thread_struct.
  836. * Reuse the fp and vsx saves, but first check to see if they have
  837. * been saved already.
  838. * On entry: r13 == 'current' && last_task_used_vsx != 'current'
  839. */
  840. _STATIC(load_up_vsx)
  841. /* Load FP and VSX registers if they haven't been done yet */
  842. andi. r5,r12,MSR_FP
  843. beql+ load_up_fpu /* skip if already loaded */
  844. andis. r5,r12,MSR_VEC@h
  845. beql+ load_up_altivec /* skip if already loaded */
  846. #ifndef CONFIG_SMP
  847. ld r3,last_task_used_vsx@got(r2)
  848. ld r4,0(r3)
  849. cmpdi 0,r4,0
  850. beq 1f
  851. /* Disable VSX for last_task_used_vsx */
  852. addi r4,r4,THREAD
  853. ld r5,PT_REGS(r4)
  854. ld r4,_MSR-STACK_FRAME_OVERHEAD(r5)
  855. lis r6,MSR_VSX@h
  856. andc r6,r4,r6
  857. std r6,_MSR-STACK_FRAME_OVERHEAD(r5)
  858. 1:
  859. #endif /* CONFIG_SMP */
  860. ld r4,PACACURRENT(r13)
  861. addi r4,r4,THREAD /* Get THREAD */
  862. li r6,1
  863. stw r6,THREAD_USED_VSR(r4) /* ... also set thread used vsr */
  864. /* enable use of VSX after return */
  865. oris r12,r12,MSR_VSX@h
  866. std r12,_MSR(r1)
  867. #ifndef CONFIG_SMP
  868. /* Update last_task_used_math to 'current' */
  869. ld r4,PACACURRENT(r13)
  870. std r4,0(r3)
  871. #endif /* CONFIG_SMP */
  872. b fast_exception_return
  873. #endif /* CONFIG_VSX */
  874. /*
  875. * Hash table stuff
  876. */
  877. .align 7
  878. _STATIC(do_hash_page)
  879. std r3,_DAR(r1)
  880. std r4,_DSISR(r1)
  881. andis. r0,r4,0xa450 /* weird error? */
  882. bne- handle_page_fault /* if not, try to insert a HPTE */
  883. BEGIN_FTR_SECTION
  884. andis. r0,r4,0x0020 /* Is it a segment table fault? */
  885. bne- do_ste_alloc /* If so handle it */
  886. END_FTR_SECTION_IFCLR(CPU_FTR_SLB)
  887. /*
  888. * On iSeries, we soft-disable interrupts here, then
  889. * hard-enable interrupts so that the hash_page code can spin on
  890. * the hash_table_lock without problems on a shared processor.
  891. */
  892. DISABLE_INTS
  893. /*
  894. * Currently, trace_hardirqs_off() will be called by DISABLE_INTS
  895. * and will clobber volatile registers when irq tracing is enabled
  896. * so we need to reload them. It may be possible to be smarter here
  897. * and move the irq tracing elsewhere but let's keep it simple for
  898. * now
  899. */
  900. #ifdef CONFIG_TRACE_IRQFLAGS
  901. ld r3,_DAR(r1)
  902. ld r4,_DSISR(r1)
  903. ld r5,_TRAP(r1)
  904. ld r12,_MSR(r1)
  905. clrrdi r5,r5,4
  906. #endif /* CONFIG_TRACE_IRQFLAGS */
  907. /*
  908. * We need to set the _PAGE_USER bit if MSR_PR is set or if we are
  909. * accessing a userspace segment (even from the kernel). We assume
  910. * kernel addresses always have the high bit set.
  911. */
  912. rlwinm r4,r4,32-25+9,31-9,31-9 /* DSISR_STORE -> _PAGE_RW */
  913. rotldi r0,r3,15 /* Move high bit into MSR_PR posn */
  914. orc r0,r12,r0 /* MSR_PR | ~high_bit */
  915. rlwimi r4,r0,32-13,30,30 /* becomes _PAGE_USER access bit */
  916. ori r4,r4,1 /* add _PAGE_PRESENT */
  917. rlwimi r4,r5,22+2,31-2,31-2 /* Set _PAGE_EXEC if trap is 0x400 */
  918. /*
  919. * r3 contains the faulting address
  920. * r4 contains the required access permissions
  921. * r5 contains the trap number
  922. *
  923. * at return r3 = 0 for success
  924. */
  925. bl .hash_page /* build HPTE if possible */
  926. cmpdi r3,0 /* see if hash_page succeeded */
  927. BEGIN_FW_FTR_SECTION
  928. /*
  929. * If we had interrupts soft-enabled at the point where the
  930. * DSI/ISI occurred, and an interrupt came in during hash_page,
  931. * handle it now.
  932. * We jump to ret_from_except_lite rather than fast_exception_return
  933. * because ret_from_except_lite will check for and handle pending
  934. * interrupts if necessary.
  935. */
  936. beq 13f
  937. END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
  938. BEGIN_FW_FTR_SECTION
  939. /*
  940. * Here we have interrupts hard-disabled, so it is sufficient
  941. * to restore paca->{soft,hard}_enable and get out.
  942. */
  943. beq fast_exc_return_irq /* Return from exception on success */
  944. END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES)
  945. /* For a hash failure, we don't bother re-enabling interrupts */
  946. ble- 12f
  947. /*
  948. * hash_page couldn't handle it, set soft interrupt enable back
  949. * to what it was before the trap. Note that .raw_local_irq_restore
  950. * handles any interrupts pending at this point.
  951. */
  952. ld r3,SOFTE(r1)
  953. TRACE_AND_RESTORE_IRQ_PARTIAL(r3, 11f)
  954. bl .raw_local_irq_restore
  955. b 11f
  956. /* Here we have a page fault that hash_page can't handle. */
  957. handle_page_fault:
  958. ENABLE_INTS
  959. 11: ld r4,_DAR(r1)
  960. ld r5,_DSISR(r1)
  961. addi r3,r1,STACK_FRAME_OVERHEAD
  962. bl .do_page_fault
  963. cmpdi r3,0
  964. beq+ 13f
  965. bl .save_nvgprs
  966. mr r5,r3
  967. addi r3,r1,STACK_FRAME_OVERHEAD
  968. lwz r4,_DAR(r1)
  969. bl .bad_page_fault
  970. b .ret_from_except
  971. 13: b .ret_from_except_lite
  972. /* We have a page fault that hash_page could handle but HV refused
  973. * the PTE insertion
  974. */
  975. 12: bl .save_nvgprs
  976. mr r5,r3
  977. addi r3,r1,STACK_FRAME_OVERHEAD
  978. ld r4,_DAR(r1)
  979. bl .low_hash_fault
  980. b .ret_from_except
  981. /* here we have a segment miss */
  982. do_ste_alloc:
  983. bl .ste_allocate /* try to insert stab entry */
  984. cmpdi r3,0
  985. bne- handle_page_fault
  986. b fast_exception_return
  987. /*
  988. * r13 points to the PACA, r9 contains the saved CR,
  989. * r11 and r12 contain the saved SRR0 and SRR1.
  990. * r9 - r13 are saved in paca->exslb.
  991. * We assume we aren't going to take any exceptions during this procedure.
  992. * We assume (DAR >> 60) == 0xc.
  993. */
  994. .align 7
  995. _GLOBAL(do_stab_bolted)
  996. stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */
  997. std r11,PACA_EXSLB+EX_SRR0(r13) /* save SRR0 in exc. frame */
  998. /* Hash to the primary group */
  999. ld r10,PACASTABVIRT(r13)
  1000. mfspr r11,SPRN_DAR
  1001. srdi r11,r11,28
  1002. rldimi r10,r11,7,52 /* r10 = first ste of the group */
  1003. /* Calculate VSID */
  1004. /* This is a kernel address, so protovsid = ESID */
  1005. ASM_VSID_SCRAMBLE(r11, r9, 256M)
  1006. rldic r9,r11,12,16 /* r9 = vsid << 12 */
  1007. /* Search the primary group for a free entry */
  1008. 1: ld r11,0(r10) /* Test valid bit of the current ste */
  1009. andi. r11,r11,0x80
  1010. beq 2f
  1011. addi r10,r10,16
  1012. andi. r11,r10,0x70
  1013. bne 1b
  1014. /* Stick for only searching the primary group for now. */
  1015. /* At least for now, we use a very simple random castout scheme */
  1016. /* Use the TB as a random number ; OR in 1 to avoid entry 0 */
  1017. mftb r11
  1018. rldic r11,r11,4,57 /* r11 = (r11 << 4) & 0x70 */
  1019. ori r11,r11,0x10
  1020. /* r10 currently points to an ste one past the group of interest */
  1021. /* make it point to the randomly selected entry */
  1022. subi r10,r10,128
  1023. or r10,r10,r11 /* r10 is the entry to invalidate */
  1024. isync /* mark the entry invalid */
  1025. ld r11,0(r10)
  1026. rldicl r11,r11,56,1 /* clear the valid bit */
  1027. rotldi r11,r11,8
  1028. std r11,0(r10)
  1029. sync
  1030. clrrdi r11,r11,28 /* Get the esid part of the ste */
  1031. slbie r11
  1032. 2: std r9,8(r10) /* Store the vsid part of the ste */
  1033. eieio
  1034. mfspr r11,SPRN_DAR /* Get the new esid */
  1035. clrrdi r11,r11,28 /* Permits a full 32b of ESID */
  1036. ori r11,r11,0x90 /* Turn on valid and kp */
  1037. std r11,0(r10) /* Put new entry back into the stab */
  1038. sync
  1039. /* All done -- return from exception. */
  1040. lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */
  1041. ld r11,PACA_EXSLB+EX_SRR0(r13) /* get saved SRR0 */
  1042. andi. r10,r12,MSR_RI
  1043. beq- unrecov_slb
  1044. mtcrf 0x80,r9 /* restore CR */
  1045. mfmsr r10
  1046. clrrdi r10,r10,2
  1047. mtmsrd r10,1
  1048. mtspr SPRN_SRR0,r11
  1049. mtspr SPRN_SRR1,r12
  1050. ld r9,PACA_EXSLB+EX_R9(r13)
  1051. ld r10,PACA_EXSLB+EX_R10(r13)
  1052. ld r11,PACA_EXSLB+EX_R11(r13)
  1053. ld r12,PACA_EXSLB+EX_R12(r13)
  1054. ld r13,PACA_EXSLB+EX_R13(r13)
  1055. rfid
  1056. b . /* prevent speculative execution */
  1057. /*
  1058. * Space for CPU0's segment table.
  1059. *
  1060. * On iSeries, the hypervisor must fill in at least one entry before
  1061. * we get control (with relocate on). The address is given to the hv
  1062. * as a page number (see xLparMap below), so this must be at a
  1063. * fixed address (the linker can't compute (u64)&initial_stab >>
  1064. * PAGE_SHIFT).
  1065. */
  1066. . = STAB0_OFFSET /* 0x6000 */
  1067. .globl initial_stab
  1068. initial_stab:
  1069. .space 4096
  1070. #ifdef CONFIG_PPC_PSERIES
  1071. /*
  1072. * Data area reserved for FWNMI option.
  1073. * This address (0x7000) is fixed by the RPA.
  1074. */
  1075. .= 0x7000
  1076. .globl fwnmi_data_area
  1077. fwnmi_data_area:
  1078. #endif /* CONFIG_PPC_PSERIES */
  1079. /* iSeries does not use the FWNMI stuff, so it is safe to put
  1080. * this here, even if we later allow kernels that will boot on
  1081. * both pSeries and iSeries */
  1082. #ifdef CONFIG_PPC_ISERIES
  1083. . = LPARMAP_PHYS
  1084. .globl xLparMap
  1085. xLparMap:
  1086. .quad HvEsidsToMap /* xNumberEsids */
  1087. .quad HvRangesToMap /* xNumberRanges */
  1088. .quad STAB0_PAGE /* xSegmentTableOffs */
  1089. .zero 40 /* xRsvd */
  1090. /* xEsids (HvEsidsToMap entries of 2 quads) */
  1091. .quad PAGE_OFFSET_ESID /* xKernelEsid */
  1092. .quad PAGE_OFFSET_VSID /* xKernelVsid */
  1093. .quad VMALLOC_START_ESID /* xKernelEsid */
  1094. .quad VMALLOC_START_VSID /* xKernelVsid */
  1095. /* xRanges (HvRangesToMap entries of 3 quads) */
  1096. .quad HvPagesToMap /* xPages */
  1097. .quad 0 /* xOffset */
  1098. .quad PAGE_OFFSET_VSID << (SID_SHIFT - HW_PAGE_SHIFT) /* xVPN */
  1099. #endif /* CONFIG_PPC_ISERIES */
  1100. #ifdef CONFIG_PPC_PSERIES
  1101. . = 0x8000
  1102. #endif /* CONFIG_PPC_PSERIES */
  1103. /*
  1104. * On pSeries and most other platforms, secondary processors spin
  1105. * in the following code.
  1106. * At entry, r3 = this processor's number (physical cpu id)
  1107. */
  1108. _GLOBAL(generic_secondary_smp_init)
  1109. mr r24,r3
  1110. /* turn on 64-bit mode */
  1111. bl .enable_64b_mode
  1112. /* get the TOC pointer (real address) */
  1113. bl .relative_toc
  1114. /* Set up a paca value for this processor. Since we have the
  1115. * physical cpu id in r24, we need to search the pacas to find
  1116. * which logical id maps to our physical one.
  1117. */
  1118. LOAD_REG_ADDR(r13, paca) /* Get base vaddr of paca array */
  1119. li r5,0 /* logical cpu id */
  1120. 1: lhz r6,PACAHWCPUID(r13) /* Load HW procid from paca */
  1121. cmpw r6,r24 /* Compare to our id */
  1122. beq 2f
  1123. addi r13,r13,PACA_SIZE /* Loop to next PACA on miss */
  1124. addi r5,r5,1
  1125. cmpwi r5,NR_CPUS
  1126. blt 1b
  1127. mr r3,r24 /* not found, copy phys to r3 */
  1128. b .kexec_wait /* next kernel might do better */
  1129. 2: mtspr SPRN_SPRG3,r13 /* Save vaddr of paca in SPRG3 */
  1130. /* From now on, r24 is expected to be logical cpuid */
  1131. mr r24,r5
  1132. 3: HMT_LOW
  1133. lbz r23,PACAPROCSTART(r13) /* Test if this processor should */
  1134. /* start. */
  1135. #ifndef CONFIG_SMP
  1136. b 3b /* Never go on non-SMP */
  1137. #else
  1138. cmpwi 0,r23,0
  1139. beq 3b /* Loop until told to go */
  1140. sync /* order paca.run and cur_cpu_spec */
  1141. /* See if we need to call a cpu state restore handler */
  1142. LOAD_REG_ADDR(r23, cur_cpu_spec)
  1143. ld r23,0(r23)
  1144. ld r23,CPU_SPEC_RESTORE(r23)
  1145. cmpdi 0,r23,0
  1146. beq 4f
  1147. ld r23,0(r23)
  1148. mtctr r23
  1149. bctrl
  1150. 4: /* Create a temp kernel stack for use before relocation is on. */
  1151. ld r1,PACAEMERGSP(r13)
  1152. subi r1,r1,STACK_FRAME_OVERHEAD
  1153. b __secondary_start
  1154. #endif
  1155. /*
  1156. * Turn the MMU off.
  1157. * Assumes we're mapped EA == RA if the MMU is on.
  1158. */
  1159. _STATIC(__mmu_off)
  1160. mfmsr r3
  1161. andi. r0,r3,MSR_IR|MSR_DR
  1162. beqlr
  1163. mflr r4
  1164. andc r3,r3,r0
  1165. mtspr SPRN_SRR0,r4
  1166. mtspr SPRN_SRR1,r3
  1167. sync
  1168. rfid
  1169. b . /* prevent speculative execution */
  1170. /*
  1171. * Here is our main kernel entry point. We support currently 2 kind of entries
  1172. * depending on the value of r5.
  1173. *
  1174. * r5 != NULL -> OF entry, we go to prom_init, "legacy" parameter content
  1175. * in r3...r7
  1176. *
  1177. * r5 == NULL -> kexec style entry. r3 is a physical pointer to the
  1178. * DT block, r4 is a physical pointer to the kernel itself
  1179. *
  1180. */
  1181. _GLOBAL(__start_initialization_multiplatform)
  1182. /* Make sure we are running in 64 bits mode */
  1183. bl .enable_64b_mode
  1184. /* Get TOC pointer (current runtime address) */
  1185. bl .relative_toc
  1186. /* find out where we are now */
  1187. bcl 20,31,$+4
  1188. 0: mflr r26 /* r26 = runtime addr here */
  1189. addis r26,r26,(_stext - 0b)@ha
  1190. addi r26,r26,(_stext - 0b)@l /* current runtime base addr */
  1191. /*
  1192. * Are we booted from a PROM Of-type client-interface ?
  1193. */
  1194. cmpldi cr0,r5,0
  1195. beq 1f
  1196. b .__boot_from_prom /* yes -> prom */
  1197. 1:
  1198. /* Save parameters */
  1199. mr r31,r3
  1200. mr r30,r4
  1201. /* Setup some critical 970 SPRs before switching MMU off */
  1202. mfspr r0,SPRN_PVR
  1203. srwi r0,r0,16
  1204. cmpwi r0,0x39 /* 970 */
  1205. beq 1f
  1206. cmpwi r0,0x3c /* 970FX */
  1207. beq 1f
  1208. cmpwi r0,0x44 /* 970MP */
  1209. beq 1f
  1210. cmpwi r0,0x45 /* 970GX */
  1211. bne 2f
  1212. 1: bl .__cpu_preinit_ppc970
  1213. 2:
  1214. /* Switch off MMU if not already off */
  1215. bl .__mmu_off
  1216. b .__after_prom_start
  1217. _INIT_STATIC(__boot_from_prom)
  1218. /* Save parameters */
  1219. mr r31,r3
  1220. mr r30,r4
  1221. mr r29,r5
  1222. mr r28,r6
  1223. mr r27,r7
  1224. /*
  1225. * Align the stack to 16-byte boundary
  1226. * Depending on the size and layout of the ELF sections in the initial
  1227. * boot binary, the stack pointer may be unaligned on PowerMac
  1228. */
  1229. rldicr r1,r1,0,59
  1230. #ifdef CONFIG_RELOCATABLE
  1231. /* Relocate code for where we are now */
  1232. mr r3,r26
  1233. bl .relocate
  1234. #endif
  1235. /* Restore parameters */
  1236. mr r3,r31
  1237. mr r4,r30
  1238. mr r5,r29
  1239. mr r6,r28
  1240. mr r7,r27
  1241. /* Do all of the interaction with OF client interface */
  1242. mr r8,r26
  1243. bl .prom_init
  1244. /* We never return */
  1245. trap
  1246. _STATIC(__after_prom_start)
  1247. #ifdef CONFIG_RELOCATABLE
  1248. /* process relocations for the final address of the kernel */
  1249. lis r25,PAGE_OFFSET@highest /* compute virtual base of kernel */
  1250. sldi r25,r25,32
  1251. #ifdef CONFIG_CRASH_DUMP
  1252. lwz r7,__run_at_load-_stext(r26)
  1253. cmplwi cr0,r7,1 /* kdump kernel ? - stay where we are */
  1254. bne 1f
  1255. add r25,r25,r26
  1256. #endif
  1257. 1: mr r3,r25
  1258. bl .relocate
  1259. #endif
  1260. /*
  1261. * We need to run with _stext at physical address PHYSICAL_START.
  1262. * This will leave some code in the first 256B of
  1263. * real memory, which are reserved for software use.
  1264. *
  1265. * Note: This process overwrites the OF exception vectors.
  1266. */
  1267. li r3,0 /* target addr */
  1268. mr. r4,r26 /* In some cases the loader may */
  1269. beq 9f /* have already put us at zero */
  1270. li r6,0x100 /* Start offset, the first 0x100 */
  1271. /* bytes were copied earlier. */
  1272. #ifdef CONFIG_CRASH_DUMP
  1273. /*
  1274. * Check if the kernel has to be running as relocatable kernel based on the
  1275. * variable __run_at_load, if it is set the kernel is treated as relocatable
  1276. * kernel, otherwise it will be moved to PHYSICAL_START
  1277. */
  1278. lwz r7,__run_at_load-_stext(r26)
  1279. cmplwi cr0,r7,1
  1280. bne 3f
  1281. li r5,__end_interrupts - _stext /* just copy interrupts */
  1282. b 5f
  1283. 3:
  1284. #endif
  1285. lis r5,(copy_to_here - _stext)@ha
  1286. addi r5,r5,(copy_to_here - _stext)@l /* # bytes of memory to copy */
  1287. bl .copy_and_flush /* copy the first n bytes */
  1288. /* this includes the code being */
  1289. /* executed here. */
  1290. addis r8,r3,(4f - _stext)@ha /* Jump to the copy of this code */
  1291. addi r8,r8,(4f - _stext)@l /* that we just made */
  1292. mtctr r8
  1293. bctr
  1294. p_end: .llong _end - _stext
  1295. 4: /* Now copy the rest of the kernel up to _end */
  1296. addis r5,r26,(p_end - _stext)@ha
  1297. ld r5,(p_end - _stext)@l(r5) /* get _end */
  1298. 5: bl .copy_and_flush /* copy the rest */
  1299. 9: b .start_here_multiplatform
  1300. /*
  1301. * Copy routine used to copy the kernel to start at physical address 0
  1302. * and flush and invalidate the caches as needed.
  1303. * r3 = dest addr, r4 = source addr, r5 = copy limit, r6 = start offset
  1304. * on exit, r3, r4, r5 are unchanged, r6 is updated to be >= r5.
  1305. *
  1306. * Note: this routine *only* clobbers r0, r6 and lr
  1307. */
  1308. _GLOBAL(copy_and_flush)
  1309. addi r5,r5,-8
  1310. addi r6,r6,-8
  1311. 4: li r0,8 /* Use the smallest common */
  1312. /* denominator cache line */
  1313. /* size. This results in */
  1314. /* extra cache line flushes */
  1315. /* but operation is correct. */
  1316. /* Can't get cache line size */
  1317. /* from NACA as it is being */
  1318. /* moved too. */
  1319. mtctr r0 /* put # words/line in ctr */
  1320. 3: addi r6,r6,8 /* copy a cache line */
  1321. ldx r0,r6,r4
  1322. stdx r0,r6,r3
  1323. bdnz 3b
  1324. dcbst r6,r3 /* write it to memory */
  1325. sync
  1326. icbi r6,r3 /* flush the icache line */
  1327. cmpld 0,r6,r5
  1328. blt 4b
  1329. sync
  1330. addi r5,r5,8
  1331. addi r6,r6,8
  1332. blr
  1333. .align 8
  1334. copy_to_here:
  1335. #ifdef CONFIG_SMP
  1336. #ifdef CONFIG_PPC_PMAC
  1337. /*
  1338. * On PowerMac, secondary processors starts from the reset vector, which
  1339. * is temporarily turned into a call to one of the functions below.
  1340. */
  1341. .section ".text";
  1342. .align 2 ;
  1343. .globl __secondary_start_pmac_0
  1344. __secondary_start_pmac_0:
  1345. /* NB the entries for cpus 0, 1, 2 must each occupy 8 bytes. */
  1346. li r24,0
  1347. b 1f
  1348. li r24,1
  1349. b 1f
  1350. li r24,2
  1351. b 1f
  1352. li r24,3
  1353. 1:
  1354. _GLOBAL(pmac_secondary_start)
  1355. /* turn on 64-bit mode */
  1356. bl .enable_64b_mode
  1357. /* get TOC pointer (real address) */
  1358. bl .relative_toc
  1359. /* Copy some CPU settings from CPU 0 */
  1360. bl .__restore_cpu_ppc970
  1361. /* pSeries do that early though I don't think we really need it */
  1362. mfmsr r3
  1363. ori r3,r3,MSR_RI
  1364. mtmsrd r3 /* RI on */
  1365. /* Set up a paca value for this processor. */
  1366. LOAD_REG_ADDR(r4,paca) /* Get base vaddr of paca array */
  1367. mulli r13,r24,PACA_SIZE /* Calculate vaddr of right paca */
  1368. add r13,r13,r4 /* for this processor. */
  1369. mtspr SPRN_SPRG3,r13 /* Save vaddr of paca in SPRG3 */
  1370. /* Create a temp kernel stack for use before relocation is on. */
  1371. ld r1,PACAEMERGSP(r13)
  1372. subi r1,r1,STACK_FRAME_OVERHEAD
  1373. b __secondary_start
  1374. #endif /* CONFIG_PPC_PMAC */
  1375. /*
  1376. * This function is called after the master CPU has released the
  1377. * secondary processors. The execution environment is relocation off.
  1378. * The paca for this processor has the following fields initialized at
  1379. * this point:
  1380. * 1. Processor number
  1381. * 2. Segment table pointer (virtual address)
  1382. * On entry the following are set:
  1383. * r1 = stack pointer. vaddr for iSeries, raddr (temp stack) for pSeries
  1384. * r24 = cpu# (in Linux terms)
  1385. * r13 = paca virtual address
  1386. * SPRG3 = paca virtual address
  1387. */
  1388. .globl __secondary_start
  1389. __secondary_start:
  1390. /* Set thread priority to MEDIUM */
  1391. HMT_MEDIUM
  1392. /* Do early setup for that CPU (stab, slb, hash table pointer) */
  1393. bl .early_setup_secondary
  1394. /* Initialize the kernel stack. Just a repeat for iSeries. */
  1395. LOAD_REG_ADDR(r3, current_set)
  1396. sldi r28,r24,3 /* get current_set[cpu#] */
  1397. ldx r1,r3,r28
  1398. addi r1,r1,THREAD_SIZE-STACK_FRAME_OVERHEAD
  1399. std r1,PACAKSAVE(r13)
  1400. /* Clear backchain so we get nice backtraces */
  1401. li r7,0
  1402. mtlr r7
  1403. /* enable MMU and jump to start_secondary */
  1404. LOAD_REG_ADDR(r3, .start_secondary_prolog)
  1405. LOAD_REG_IMMEDIATE(r4, MSR_KERNEL)
  1406. #ifdef CONFIG_PPC_ISERIES
  1407. BEGIN_FW_FTR_SECTION
  1408. ori r4,r4,MSR_EE
  1409. li r8,1
  1410. stb r8,PACAHARDIRQEN(r13)
  1411. END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
  1412. #endif
  1413. BEGIN_FW_FTR_SECTION
  1414. stb r7,PACAHARDIRQEN(r13)
  1415. END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES)
  1416. stb r7,PACASOFTIRQEN(r13)
  1417. mtspr SPRN_SRR0,r3
  1418. mtspr SPRN_SRR1,r4
  1419. rfid
  1420. b . /* prevent speculative execution */
  1421. /*
  1422. * Running with relocation on at this point. All we want to do is
  1423. * zero the stack back-chain pointer and get the TOC virtual address
  1424. * before going into C code.
  1425. */
  1426. _GLOBAL(start_secondary_prolog)
  1427. ld r2,PACATOC(r13)
  1428. li r3,0
  1429. std r3,0(r1) /* Zero the stack frame pointer */
  1430. bl .start_secondary
  1431. b .
  1432. #endif
  1433. /*
  1434. * This subroutine clobbers r11 and r12
  1435. */
  1436. _GLOBAL(enable_64b_mode)
  1437. mfmsr r11 /* grab the current MSR */
  1438. li r12,(MSR_SF | MSR_ISF)@highest
  1439. sldi r12,r12,48
  1440. or r11,r11,r12
  1441. mtmsrd r11
  1442. isync
  1443. blr
  1444. /*
  1445. * This puts the TOC pointer into r2, offset by 0x8000 (as expected
  1446. * by the toolchain). It computes the correct value for wherever we
  1447. * are running at the moment, using position-independent code.
  1448. */
  1449. _GLOBAL(relative_toc)
  1450. mflr r0
  1451. bcl 20,31,$+4
  1452. 0: mflr r9
  1453. ld r2,(p_toc - 0b)(r9)
  1454. add r2,r2,r9
  1455. mtlr r0
  1456. blr
  1457. p_toc: .llong __toc_start + 0x8000 - 0b
  1458. /*
  1459. * This is where the main kernel code starts.
  1460. */
  1461. _INIT_STATIC(start_here_multiplatform)
  1462. /* set up the TOC (real address) */
  1463. bl .relative_toc
  1464. /* Clear out the BSS. It may have been done in prom_init,
  1465. * already but that's irrelevant since prom_init will soon
  1466. * be detached from the kernel completely. Besides, we need
  1467. * to clear it now for kexec-style entry.
  1468. */
  1469. LOAD_REG_ADDR(r11,__bss_stop)
  1470. LOAD_REG_ADDR(r8,__bss_start)
  1471. sub r11,r11,r8 /* bss size */
  1472. addi r11,r11,7 /* round up to an even double word */
  1473. srdi. r11,r11,3 /* shift right by 3 */
  1474. beq 4f
  1475. addi r8,r8,-8
  1476. li r0,0
  1477. mtctr r11 /* zero this many doublewords */
  1478. 3: stdu r0,8(r8)
  1479. bdnz 3b
  1480. 4:
  1481. mfmsr r6
  1482. ori r6,r6,MSR_RI
  1483. mtmsrd r6 /* RI on */
  1484. #ifdef CONFIG_RELOCATABLE
  1485. /* Save the physical address we're running at in kernstart_addr */
  1486. LOAD_REG_ADDR(r4, kernstart_addr)
  1487. clrldi r0,r25,2
  1488. std r0,0(r4)
  1489. #endif
  1490. /* The following gets the stack set up with the regs */
  1491. /* pointing to the real addr of the kernel stack. This is */
  1492. /* all done to support the C function call below which sets */
  1493. /* up the htab. This is done because we have relocated the */
  1494. /* kernel but are still running in real mode. */
  1495. LOAD_REG_ADDR(r3,init_thread_union)
  1496. /* set up a stack pointer */
  1497. addi r1,r3,THREAD_SIZE
  1498. li r0,0
  1499. stdu r0,-STACK_FRAME_OVERHEAD(r1)
  1500. /* Do very early kernel initializations, including initial hash table,
  1501. * stab and slb setup before we turn on relocation. */
  1502. /* Restore parameters passed from prom_init/kexec */
  1503. mr r3,r31
  1504. bl .early_setup /* also sets r13 and SPRG3 */
  1505. LOAD_REG_ADDR(r3, .start_here_common)
  1506. ld r4,PACAKMSR(r13)
  1507. mtspr SPRN_SRR0,r3
  1508. mtspr SPRN_SRR1,r4
  1509. rfid
  1510. b . /* prevent speculative execution */
  1511. /* This is where all platforms converge execution */
  1512. _INIT_GLOBAL(start_here_common)
  1513. /* relocation is on at this point */
  1514. std r1,PACAKSAVE(r13)
  1515. /* Load the TOC (virtual address) */
  1516. ld r2,PACATOC(r13)
  1517. bl .setup_system
  1518. /* Load up the kernel context */
  1519. 5:
  1520. li r5,0
  1521. stb r5,PACASOFTIRQEN(r13) /* Soft Disabled */
  1522. #ifdef CONFIG_PPC_ISERIES
  1523. BEGIN_FW_FTR_SECTION
  1524. mfmsr r5
  1525. ori r5,r5,MSR_EE /* Hard Enabled on iSeries*/
  1526. mtmsrd r5
  1527. li r5,1
  1528. END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
  1529. #endif
  1530. stb r5,PACAHARDIRQEN(r13) /* Hard Disabled on others */
  1531. bl .start_kernel
  1532. /* Not reached */
  1533. BUG_OPCODE
  1534. /*
  1535. * We put a few things here that have to be page-aligned.
  1536. * This stuff goes at the beginning of the bss, which is page-aligned.
  1537. */
  1538. .section ".bss"
  1539. .align PAGE_SHIFT
  1540. .globl empty_zero_page
  1541. empty_zero_page:
  1542. .space PAGE_SIZE
  1543. .globl swapper_pg_dir
  1544. swapper_pg_dir:
  1545. .space PGD_TABLE_SIZE