head_64.S 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758
  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. #ifdef CONFIG_PPC_OF_BOOT_TRAMPOLINE
  1219. /* Save parameters */
  1220. mr r31,r3
  1221. mr r30,r4
  1222. mr r29,r5
  1223. mr r28,r6
  1224. mr r27,r7
  1225. /*
  1226. * Align the stack to 16-byte boundary
  1227. * Depending on the size and layout of the ELF sections in the initial
  1228. * boot binary, the stack pointer may be unaligned on PowerMac
  1229. */
  1230. rldicr r1,r1,0,59
  1231. #ifdef CONFIG_RELOCATABLE
  1232. /* Relocate code for where we are now */
  1233. mr r3,r26
  1234. bl .relocate
  1235. #endif
  1236. /* Restore parameters */
  1237. mr r3,r31
  1238. mr r4,r30
  1239. mr r5,r29
  1240. mr r6,r28
  1241. mr r7,r27
  1242. /* Do all of the interaction with OF client interface */
  1243. mr r8,r26
  1244. bl .prom_init
  1245. #endif /* #CONFIG_PPC_OF_BOOT_TRAMPOLINE */
  1246. /* We never return. We also hit that trap if trying to boot
  1247. * from OF while CONFIG_PPC_OF_BOOT_TRAMPOLINE isn't selected */
  1248. trap
  1249. _STATIC(__after_prom_start)
  1250. #ifdef CONFIG_RELOCATABLE
  1251. /* process relocations for the final address of the kernel */
  1252. lis r25,PAGE_OFFSET@highest /* compute virtual base of kernel */
  1253. sldi r25,r25,32
  1254. #ifdef CONFIG_CRASH_DUMP
  1255. lwz r7,__run_at_load-_stext(r26)
  1256. cmplwi cr0,r7,1 /* kdump kernel ? - stay where we are */
  1257. bne 1f
  1258. add r25,r25,r26
  1259. #endif
  1260. 1: mr r3,r25
  1261. bl .relocate
  1262. #endif
  1263. /*
  1264. * We need to run with _stext at physical address PHYSICAL_START.
  1265. * This will leave some code in the first 256B of
  1266. * real memory, which are reserved for software use.
  1267. *
  1268. * Note: This process overwrites the OF exception vectors.
  1269. */
  1270. li r3,0 /* target addr */
  1271. mr. r4,r26 /* In some cases the loader may */
  1272. beq 9f /* have already put us at zero */
  1273. li r6,0x100 /* Start offset, the first 0x100 */
  1274. /* bytes were copied earlier. */
  1275. #ifdef CONFIG_CRASH_DUMP
  1276. /*
  1277. * Check if the kernel has to be running as relocatable kernel based on the
  1278. * variable __run_at_load, if it is set the kernel is treated as relocatable
  1279. * kernel, otherwise it will be moved to PHYSICAL_START
  1280. */
  1281. lwz r7,__run_at_load-_stext(r26)
  1282. cmplwi cr0,r7,1
  1283. bne 3f
  1284. li r5,__end_interrupts - _stext /* just copy interrupts */
  1285. b 5f
  1286. 3:
  1287. #endif
  1288. lis r5,(copy_to_here - _stext)@ha
  1289. addi r5,r5,(copy_to_here - _stext)@l /* # bytes of memory to copy */
  1290. bl .copy_and_flush /* copy the first n bytes */
  1291. /* this includes the code being */
  1292. /* executed here. */
  1293. addis r8,r3,(4f - _stext)@ha /* Jump to the copy of this code */
  1294. addi r8,r8,(4f - _stext)@l /* that we just made */
  1295. mtctr r8
  1296. bctr
  1297. p_end: .llong _end - _stext
  1298. 4: /* Now copy the rest of the kernel up to _end */
  1299. addis r5,r26,(p_end - _stext)@ha
  1300. ld r5,(p_end - _stext)@l(r5) /* get _end */
  1301. 5: bl .copy_and_flush /* copy the rest */
  1302. 9: b .start_here_multiplatform
  1303. /*
  1304. * Copy routine used to copy the kernel to start at physical address 0
  1305. * and flush and invalidate the caches as needed.
  1306. * r3 = dest addr, r4 = source addr, r5 = copy limit, r6 = start offset
  1307. * on exit, r3, r4, r5 are unchanged, r6 is updated to be >= r5.
  1308. *
  1309. * Note: this routine *only* clobbers r0, r6 and lr
  1310. */
  1311. _GLOBAL(copy_and_flush)
  1312. addi r5,r5,-8
  1313. addi r6,r6,-8
  1314. 4: li r0,8 /* Use the smallest common */
  1315. /* denominator cache line */
  1316. /* size. This results in */
  1317. /* extra cache line flushes */
  1318. /* but operation is correct. */
  1319. /* Can't get cache line size */
  1320. /* from NACA as it is being */
  1321. /* moved too. */
  1322. mtctr r0 /* put # words/line in ctr */
  1323. 3: addi r6,r6,8 /* copy a cache line */
  1324. ldx r0,r6,r4
  1325. stdx r0,r6,r3
  1326. bdnz 3b
  1327. dcbst r6,r3 /* write it to memory */
  1328. sync
  1329. icbi r6,r3 /* flush the icache line */
  1330. cmpld 0,r6,r5
  1331. blt 4b
  1332. sync
  1333. addi r5,r5,8
  1334. addi r6,r6,8
  1335. blr
  1336. .align 8
  1337. copy_to_here:
  1338. #ifdef CONFIG_SMP
  1339. #ifdef CONFIG_PPC_PMAC
  1340. /*
  1341. * On PowerMac, secondary processors starts from the reset vector, which
  1342. * is temporarily turned into a call to one of the functions below.
  1343. */
  1344. .section ".text";
  1345. .align 2 ;
  1346. .globl __secondary_start_pmac_0
  1347. __secondary_start_pmac_0:
  1348. /* NB the entries for cpus 0, 1, 2 must each occupy 8 bytes. */
  1349. li r24,0
  1350. b 1f
  1351. li r24,1
  1352. b 1f
  1353. li r24,2
  1354. b 1f
  1355. li r24,3
  1356. 1:
  1357. _GLOBAL(pmac_secondary_start)
  1358. /* turn on 64-bit mode */
  1359. bl .enable_64b_mode
  1360. li r0,0
  1361. mfspr r3,SPRN_HID4
  1362. rldimi r3,r0,40,23 /* clear bit 23 (rm_ci) */
  1363. sync
  1364. mtspr SPRN_HID4,r3
  1365. isync
  1366. sync
  1367. slbia
  1368. /* get TOC pointer (real address) */
  1369. bl .relative_toc
  1370. /* Copy some CPU settings from CPU 0 */
  1371. bl .__restore_cpu_ppc970
  1372. /* pSeries do that early though I don't think we really need it */
  1373. mfmsr r3
  1374. ori r3,r3,MSR_RI
  1375. mtmsrd r3 /* RI on */
  1376. /* Set up a paca value for this processor. */
  1377. LOAD_REG_ADDR(r4,paca) /* Get base vaddr of paca array */
  1378. mulli r13,r24,PACA_SIZE /* Calculate vaddr of right paca */
  1379. add r13,r13,r4 /* for this processor. */
  1380. mtspr SPRN_SPRG3,r13 /* Save vaddr of paca in SPRG3 */
  1381. /* Create a temp kernel stack for use before relocation is on. */
  1382. ld r1,PACAEMERGSP(r13)
  1383. subi r1,r1,STACK_FRAME_OVERHEAD
  1384. b __secondary_start
  1385. #endif /* CONFIG_PPC_PMAC */
  1386. /*
  1387. * This function is called after the master CPU has released the
  1388. * secondary processors. The execution environment is relocation off.
  1389. * The paca for this processor has the following fields initialized at
  1390. * this point:
  1391. * 1. Processor number
  1392. * 2. Segment table pointer (virtual address)
  1393. * On entry the following are set:
  1394. * r1 = stack pointer. vaddr for iSeries, raddr (temp stack) for pSeries
  1395. * r24 = cpu# (in Linux terms)
  1396. * r13 = paca virtual address
  1397. * SPRG3 = paca virtual address
  1398. */
  1399. .globl __secondary_start
  1400. __secondary_start:
  1401. /* Set thread priority to MEDIUM */
  1402. HMT_MEDIUM
  1403. /* Do early setup for that CPU (stab, slb, hash table pointer) */
  1404. bl .early_setup_secondary
  1405. /* Initialize the kernel stack. Just a repeat for iSeries. */
  1406. LOAD_REG_ADDR(r3, current_set)
  1407. sldi r28,r24,3 /* get current_set[cpu#] */
  1408. ldx r1,r3,r28
  1409. addi r1,r1,THREAD_SIZE-STACK_FRAME_OVERHEAD
  1410. std r1,PACAKSAVE(r13)
  1411. /* Clear backchain so we get nice backtraces */
  1412. li r7,0
  1413. mtlr r7
  1414. /* enable MMU and jump to start_secondary */
  1415. LOAD_REG_ADDR(r3, .start_secondary_prolog)
  1416. LOAD_REG_IMMEDIATE(r4, MSR_KERNEL)
  1417. #ifdef CONFIG_PPC_ISERIES
  1418. BEGIN_FW_FTR_SECTION
  1419. ori r4,r4,MSR_EE
  1420. li r8,1
  1421. stb r8,PACAHARDIRQEN(r13)
  1422. END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
  1423. #endif
  1424. BEGIN_FW_FTR_SECTION
  1425. stb r7,PACAHARDIRQEN(r13)
  1426. END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES)
  1427. stb r7,PACASOFTIRQEN(r13)
  1428. mtspr SPRN_SRR0,r3
  1429. mtspr SPRN_SRR1,r4
  1430. rfid
  1431. b . /* prevent speculative execution */
  1432. /*
  1433. * Running with relocation on at this point. All we want to do is
  1434. * zero the stack back-chain pointer and get the TOC virtual address
  1435. * before going into C code.
  1436. */
  1437. _GLOBAL(start_secondary_prolog)
  1438. ld r2,PACATOC(r13)
  1439. li r3,0
  1440. std r3,0(r1) /* Zero the stack frame pointer */
  1441. bl .start_secondary
  1442. b .
  1443. #endif
  1444. /*
  1445. * This subroutine clobbers r11 and r12
  1446. */
  1447. _GLOBAL(enable_64b_mode)
  1448. mfmsr r11 /* grab the current MSR */
  1449. li r12,(MSR_SF | MSR_ISF)@highest
  1450. sldi r12,r12,48
  1451. or r11,r11,r12
  1452. mtmsrd r11
  1453. isync
  1454. blr
  1455. /*
  1456. * This puts the TOC pointer into r2, offset by 0x8000 (as expected
  1457. * by the toolchain). It computes the correct value for wherever we
  1458. * are running at the moment, using position-independent code.
  1459. */
  1460. _GLOBAL(relative_toc)
  1461. mflr r0
  1462. bcl 20,31,$+4
  1463. 0: mflr r9
  1464. ld r2,(p_toc - 0b)(r9)
  1465. add r2,r2,r9
  1466. mtlr r0
  1467. blr
  1468. p_toc: .llong __toc_start + 0x8000 - 0b
  1469. /*
  1470. * This is where the main kernel code starts.
  1471. */
  1472. _INIT_STATIC(start_here_multiplatform)
  1473. /* set up the TOC (real address) */
  1474. bl .relative_toc
  1475. /* Clear out the BSS. It may have been done in prom_init,
  1476. * already but that's irrelevant since prom_init will soon
  1477. * be detached from the kernel completely. Besides, we need
  1478. * to clear it now for kexec-style entry.
  1479. */
  1480. LOAD_REG_ADDR(r11,__bss_stop)
  1481. LOAD_REG_ADDR(r8,__bss_start)
  1482. sub r11,r11,r8 /* bss size */
  1483. addi r11,r11,7 /* round up to an even double word */
  1484. srdi. r11,r11,3 /* shift right by 3 */
  1485. beq 4f
  1486. addi r8,r8,-8
  1487. li r0,0
  1488. mtctr r11 /* zero this many doublewords */
  1489. 3: stdu r0,8(r8)
  1490. bdnz 3b
  1491. 4:
  1492. mfmsr r6
  1493. ori r6,r6,MSR_RI
  1494. mtmsrd r6 /* RI on */
  1495. #ifdef CONFIG_RELOCATABLE
  1496. /* Save the physical address we're running at in kernstart_addr */
  1497. LOAD_REG_ADDR(r4, kernstart_addr)
  1498. clrldi r0,r25,2
  1499. std r0,0(r4)
  1500. #endif
  1501. /* The following gets the stack set up with the regs */
  1502. /* pointing to the real addr of the kernel stack. This is */
  1503. /* all done to support the C function call below which sets */
  1504. /* up the htab. This is done because we have relocated the */
  1505. /* kernel but are still running in real mode. */
  1506. LOAD_REG_ADDR(r3,init_thread_union)
  1507. /* set up a stack pointer */
  1508. addi r1,r3,THREAD_SIZE
  1509. li r0,0
  1510. stdu r0,-STACK_FRAME_OVERHEAD(r1)
  1511. /* Do very early kernel initializations, including initial hash table,
  1512. * stab and slb setup before we turn on relocation. */
  1513. /* Restore parameters passed from prom_init/kexec */
  1514. mr r3,r31
  1515. bl .early_setup /* also sets r13 and SPRG3 */
  1516. LOAD_REG_ADDR(r3, .start_here_common)
  1517. ld r4,PACAKMSR(r13)
  1518. mtspr SPRN_SRR0,r3
  1519. mtspr SPRN_SRR1,r4
  1520. rfid
  1521. b . /* prevent speculative execution */
  1522. /* This is where all platforms converge execution */
  1523. _INIT_GLOBAL(start_here_common)
  1524. /* relocation is on at this point */
  1525. std r1,PACAKSAVE(r13)
  1526. /* Load the TOC (virtual address) */
  1527. ld r2,PACATOC(r13)
  1528. bl .setup_system
  1529. /* Load up the kernel context */
  1530. 5:
  1531. li r5,0
  1532. stb r5,PACASOFTIRQEN(r13) /* Soft Disabled */
  1533. #ifdef CONFIG_PPC_ISERIES
  1534. BEGIN_FW_FTR_SECTION
  1535. mfmsr r5
  1536. ori r5,r5,MSR_EE /* Hard Enabled on iSeries*/
  1537. mtmsrd r5
  1538. li r5,1
  1539. END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
  1540. #endif
  1541. stb r5,PACAHARDIRQEN(r13) /* Hard Disabled on others */
  1542. bl .start_kernel
  1543. /* Not reached */
  1544. BUG_OPCODE
  1545. /*
  1546. * We put a few things here that have to be page-aligned.
  1547. * This stuff goes at the beginning of the bss, which is page-aligned.
  1548. */
  1549. .section ".bss"
  1550. .align PAGE_SHIFT
  1551. .globl empty_zero_page
  1552. empty_zero_page:
  1553. .space PAGE_SIZE
  1554. .globl swapper_pg_dir
  1555. swapper_pg_dir:
  1556. .space PGD_TABLE_SIZE