exceptions-64s.S 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588
  1. /*
  2. * This file contains the 64-bit "server" PowerPC variant
  3. * of the low level exception handling including exception
  4. * vectors, exception return, part of the slb and stab
  5. * handling and other fixed offset specific things.
  6. *
  7. * This file is meant to be #included from head_64.S due to
  8. * position dependent assembly.
  9. *
  10. * Most of this originates from head_64.S and thus has the same
  11. * copyright history.
  12. *
  13. */
  14. #include <asm/hw_irq.h>
  15. #include <asm/exception-64s.h>
  16. #include <asm/ptrace.h>
  17. #include <asm/cpuidle.h>
  18. #include <asm/head-64.h>
  19. /*
  20. * There are a few constraints to be concerned with.
  21. * - Real mode exceptions code/data must be located at their physical location.
  22. * - Virtual mode exceptions must be mapped at their 0xc000... location.
  23. * - Fixed location code must not call directly beyond the __end_interrupts
  24. * area when built with CONFIG_RELOCATABLE. LOAD_HANDLER / bctr sequence
  25. * must be used.
  26. * - LOAD_HANDLER targets must be within first 64K of physical 0 /
  27. * virtual 0xc00...
  28. * - Conditional branch targets must be within +/-32K of caller.
  29. *
  30. * "Virtual exceptions" run with relocation on (MSR_IR=1, MSR_DR=1), and
  31. * therefore don't have to run in physically located code or rfid to
  32. * virtual mode kernel code. However on relocatable kernels they do have
  33. * to branch to KERNELBASE offset because the rest of the kernel (outside
  34. * the exception vectors) may be located elsewhere.
  35. *
  36. * Virtual exceptions correspond with physical, except their entry points
  37. * are offset by 0xc000000000000000 and also tend to get an added 0x4000
  38. * offset applied. Virtual exceptions are enabled with the Alternate
  39. * Interrupt Location (AIL) bit set in the LPCR. However this does not
  40. * guarantee they will be delivered virtually. Some conditions (see the ISA)
  41. * cause exceptions to be delivered in real mode.
  42. *
  43. * It's impossible to receive interrupts below 0x300 via AIL.
  44. *
  45. * KVM: None of the virtual exceptions are from the guest. Anything that
  46. * escalated to HV=1 from HV=0 is delivered via real mode handlers.
  47. *
  48. *
  49. * We layout physical memory as follows:
  50. * 0x0000 - 0x00ff : Secondary processor spin code
  51. * 0x0100 - 0x18ff : Real mode pSeries interrupt vectors
  52. * 0x1900 - 0x3fff : Real mode trampolines
  53. * 0x4000 - 0x58ff : Relon (IR=1,DR=1) mode pSeries interrupt vectors
  54. * 0x5900 - 0x6fff : Relon mode trampolines
  55. * 0x7000 - 0x7fff : FWNMI data area
  56. * 0x8000 - .... : Common interrupt handlers, remaining early
  57. * setup code, rest of kernel.
  58. *
  59. * We could reclaim 0x4000-0x42ff for real mode trampolines if the space
  60. * is necessary. Until then it's more consistent to explicitly put VIRT_NONE
  61. * vectors there.
  62. */
  63. OPEN_FIXED_SECTION(real_vectors, 0x0100, 0x1900)
  64. OPEN_FIXED_SECTION(real_trampolines, 0x1900, 0x4000)
  65. OPEN_FIXED_SECTION(virt_vectors, 0x4000, 0x5900)
  66. OPEN_FIXED_SECTION(virt_trampolines, 0x5900, 0x7000)
  67. #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV)
  68. /*
  69. * Data area reserved for FWNMI option.
  70. * This address (0x7000) is fixed by the RPA.
  71. * pseries and powernv need to keep the whole page from
  72. * 0x7000 to 0x8000 free for use by the firmware
  73. */
  74. ZERO_FIXED_SECTION(fwnmi_page, 0x7000, 0x8000)
  75. OPEN_TEXT_SECTION(0x8000)
  76. #else
  77. OPEN_TEXT_SECTION(0x7000)
  78. #endif
  79. USE_FIXED_SECTION(real_vectors)
  80. /*
  81. * This is the start of the interrupt handlers for pSeries
  82. * This code runs with relocation off.
  83. * Code from here to __end_interrupts gets copied down to real
  84. * address 0x100 when we are running a relocatable kernel.
  85. * Therefore any relative branches in this section must only
  86. * branch to labels in this section.
  87. */
  88. .globl __start_interrupts
  89. __start_interrupts:
  90. /* No virt vectors corresponding with 0x0..0x100 */
  91. EXC_VIRT_NONE(0x4000, 0x100)
  92. #ifdef CONFIG_PPC_P7_NAP
  93. /*
  94. * If running native on arch 2.06 or later, check if we are waking up
  95. * from nap/sleep/winkle, and branch to idle handler.
  96. */
  97. #define IDLETEST(n) \
  98. BEGIN_FTR_SECTION ; \
  99. mfspr r10,SPRN_SRR1 ; \
  100. rlwinm. r10,r10,47-31,30,31 ; \
  101. beq- 1f ; \
  102. cmpwi cr3,r10,2 ; \
  103. BRANCH_TO_COMMON(r10, system_reset_idle_common) ; \
  104. 1: \
  105. END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
  106. #else
  107. #define IDLETEST NOTEST
  108. #endif
  109. EXC_REAL_BEGIN(system_reset, 0x100, 0x100)
  110. SET_SCRATCH0(r13)
  111. /*
  112. * MSR_RI is not enabled, because PACA_EXNMI and nmi stack is
  113. * being used, so a nested NMI exception would corrupt it.
  114. */
  115. EXCEPTION_PROLOG_PSERIES_NORI(PACA_EXNMI, system_reset_common, EXC_STD,
  116. IDLETEST, 0x100)
  117. EXC_REAL_END(system_reset, 0x100, 0x100)
  118. EXC_VIRT_NONE(0x4100, 0x100)
  119. #ifdef CONFIG_PPC_P7_NAP
  120. EXC_COMMON_BEGIN(system_reset_idle_common)
  121. b pnv_powersave_wakeup
  122. #endif
  123. EXC_COMMON_BEGIN(system_reset_common)
  124. /*
  125. * Increment paca->in_nmi then enable MSR_RI. SLB or MCE will be able
  126. * to recover, but nested NMI will notice in_nmi and not recover
  127. * because of the use of the NMI stack. in_nmi reentrancy is tested in
  128. * system_reset_exception.
  129. */
  130. lhz r10,PACA_IN_NMI(r13)
  131. addi r10,r10,1
  132. sth r10,PACA_IN_NMI(r13)
  133. li r10,MSR_RI
  134. mtmsrd r10,1
  135. mr r10,r1
  136. ld r1,PACA_NMI_EMERG_SP(r13)
  137. subi r1,r1,INT_FRAME_SIZE
  138. EXCEPTION_COMMON_NORET_STACK(PACA_EXNMI, 0x100,
  139. system_reset, system_reset_exception,
  140. ADD_NVGPRS;ADD_RECONCILE)
  141. /*
  142. * The stack is no longer in use, decrement in_nmi.
  143. */
  144. lhz r10,PACA_IN_NMI(r13)
  145. subi r10,r10,1
  146. sth r10,PACA_IN_NMI(r13)
  147. b ret_from_except
  148. #ifdef CONFIG_PPC_PSERIES
  149. /*
  150. * Vectors for the FWNMI option. Share common code.
  151. */
  152. TRAMP_REAL_BEGIN(system_reset_fwnmi)
  153. SET_SCRATCH0(r13) /* save r13 */
  154. /* See comment at system_reset exception */
  155. EXCEPTION_PROLOG_PSERIES_NORI(PACA_EXNMI, system_reset_common,
  156. EXC_STD, NOTEST, 0x100)
  157. #endif /* CONFIG_PPC_PSERIES */
  158. EXC_REAL_BEGIN(machine_check, 0x200, 0x100)
  159. /* This is moved out of line as it can be patched by FW, but
  160. * some code path might still want to branch into the original
  161. * vector
  162. */
  163. SET_SCRATCH0(r13) /* save r13 */
  164. EXCEPTION_PROLOG_0(PACA_EXMC)
  165. BEGIN_FTR_SECTION
  166. b machine_check_powernv_early
  167. FTR_SECTION_ELSE
  168. b machine_check_pSeries_0
  169. ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
  170. EXC_REAL_END(machine_check, 0x200, 0x100)
  171. EXC_VIRT_NONE(0x4200, 0x100)
  172. TRAMP_REAL_BEGIN(machine_check_powernv_early)
  173. BEGIN_FTR_SECTION
  174. EXCEPTION_PROLOG_1(PACA_EXMC, NOTEST, 0x200)
  175. /*
  176. * Register contents:
  177. * R13 = PACA
  178. * R9 = CR
  179. * Original R9 to R13 is saved on PACA_EXMC
  180. *
  181. * Switch to mc_emergency stack and handle re-entrancy (we limit
  182. * the nested MCE upto level 4 to avoid stack overflow).
  183. * Save MCE registers srr1, srr0, dar and dsisr and then set ME=1
  184. *
  185. * We use paca->in_mce to check whether this is the first entry or
  186. * nested machine check. We increment paca->in_mce to track nested
  187. * machine checks.
  188. *
  189. * If this is the first entry then set stack pointer to
  190. * paca->mc_emergency_sp, otherwise r1 is already pointing to
  191. * stack frame on mc_emergency stack.
  192. *
  193. * NOTE: We are here with MSR_ME=0 (off), which means we risk a
  194. * checkstop if we get another machine check exception before we do
  195. * rfid with MSR_ME=1.
  196. *
  197. * This interrupt can wake directly from idle. If that is the case,
  198. * the machine check is handled then the idle wakeup code is called
  199. * to restore state. In that case, the POWER9 DD1 idle PACA workaround
  200. * is not applied in the early machine check code, which will cause
  201. * bugs.
  202. */
  203. mr r11,r1 /* Save r1 */
  204. lhz r10,PACA_IN_MCE(r13)
  205. cmpwi r10,0 /* Are we in nested machine check */
  206. bne 0f /* Yes, we are. */
  207. /* First machine check entry */
  208. ld r1,PACAMCEMERGSP(r13) /* Use MC emergency stack */
  209. 0: subi r1,r1,INT_FRAME_SIZE /* alloc stack frame */
  210. addi r10,r10,1 /* increment paca->in_mce */
  211. sth r10,PACA_IN_MCE(r13)
  212. /* Limit nested MCE to level 4 to avoid stack overflow */
  213. cmpwi r10,4
  214. bgt 2f /* Check if we hit limit of 4 */
  215. std r11,GPR1(r1) /* Save r1 on the stack. */
  216. std r11,0(r1) /* make stack chain pointer */
  217. mfspr r11,SPRN_SRR0 /* Save SRR0 */
  218. std r11,_NIP(r1)
  219. mfspr r11,SPRN_SRR1 /* Save SRR1 */
  220. std r11,_MSR(r1)
  221. mfspr r11,SPRN_DAR /* Save DAR */
  222. std r11,_DAR(r1)
  223. mfspr r11,SPRN_DSISR /* Save DSISR */
  224. std r11,_DSISR(r1)
  225. std r9,_CCR(r1) /* Save CR in stackframe */
  226. /* Save r9 through r13 from EXMC save area to stack frame. */
  227. EXCEPTION_PROLOG_COMMON_2(PACA_EXMC)
  228. mfmsr r11 /* get MSR value */
  229. ori r11,r11,MSR_ME /* turn on ME bit */
  230. ori r11,r11,MSR_RI /* turn on RI bit */
  231. LOAD_HANDLER(r12, machine_check_handle_early)
  232. 1: mtspr SPRN_SRR0,r12
  233. mtspr SPRN_SRR1,r11
  234. rfid
  235. b . /* prevent speculative execution */
  236. 2:
  237. /* Stack overflow. Stay on emergency stack and panic.
  238. * Keep the ME bit off while panic-ing, so that if we hit
  239. * another machine check we checkstop.
  240. */
  241. addi r1,r1,INT_FRAME_SIZE /* go back to previous stack frame */
  242. ld r11,PACAKMSR(r13)
  243. LOAD_HANDLER(r12, unrecover_mce)
  244. li r10,MSR_ME
  245. andc r11,r11,r10 /* Turn off MSR_ME */
  246. b 1b
  247. b . /* prevent speculative execution */
  248. END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
  249. TRAMP_REAL_BEGIN(machine_check_pSeries)
  250. .globl machine_check_fwnmi
  251. machine_check_fwnmi:
  252. SET_SCRATCH0(r13) /* save r13 */
  253. EXCEPTION_PROLOG_0(PACA_EXMC)
  254. machine_check_pSeries_0:
  255. EXCEPTION_PROLOG_1(PACA_EXMC, KVMTEST_PR, 0x200)
  256. /*
  257. * MSR_RI is not enabled, because PACA_EXMC is being used, so a
  258. * nested machine check corrupts it. machine_check_common enables
  259. * MSR_RI.
  260. */
  261. EXCEPTION_PROLOG_PSERIES_1_NORI(machine_check_common, EXC_STD)
  262. TRAMP_KVM_SKIP(PACA_EXMC, 0x200)
  263. EXC_COMMON_BEGIN(machine_check_common)
  264. /*
  265. * Machine check is different because we use a different
  266. * save area: PACA_EXMC instead of PACA_EXGEN.
  267. */
  268. mfspr r10,SPRN_DAR
  269. std r10,PACA_EXMC+EX_DAR(r13)
  270. mfspr r10,SPRN_DSISR
  271. stw r10,PACA_EXMC+EX_DSISR(r13)
  272. EXCEPTION_PROLOG_COMMON(0x200, PACA_EXMC)
  273. FINISH_NAP
  274. RECONCILE_IRQ_STATE(r10, r11)
  275. ld r3,PACA_EXMC+EX_DAR(r13)
  276. lwz r4,PACA_EXMC+EX_DSISR(r13)
  277. /* Enable MSR_RI when finished with PACA_EXMC */
  278. li r10,MSR_RI
  279. mtmsrd r10,1
  280. std r3,_DAR(r1)
  281. std r4,_DSISR(r1)
  282. bl save_nvgprs
  283. addi r3,r1,STACK_FRAME_OVERHEAD
  284. bl machine_check_exception
  285. b ret_from_except
  286. #define MACHINE_CHECK_HANDLER_WINDUP \
  287. /* Clear MSR_RI before setting SRR0 and SRR1. */\
  288. li r0,MSR_RI; \
  289. mfmsr r9; /* get MSR value */ \
  290. andc r9,r9,r0; \
  291. mtmsrd r9,1; /* Clear MSR_RI */ \
  292. /* Move original SRR0 and SRR1 into the respective regs */ \
  293. ld r9,_MSR(r1); \
  294. mtspr SPRN_SRR1,r9; \
  295. ld r3,_NIP(r1); \
  296. mtspr SPRN_SRR0,r3; \
  297. ld r9,_CTR(r1); \
  298. mtctr r9; \
  299. ld r9,_XER(r1); \
  300. mtxer r9; \
  301. ld r9,_LINK(r1); \
  302. mtlr r9; \
  303. REST_GPR(0, r1); \
  304. REST_8GPRS(2, r1); \
  305. REST_GPR(10, r1); \
  306. ld r11,_CCR(r1); \
  307. mtcr r11; \
  308. /* Decrement paca->in_mce. */ \
  309. lhz r12,PACA_IN_MCE(r13); \
  310. subi r12,r12,1; \
  311. sth r12,PACA_IN_MCE(r13); \
  312. REST_GPR(11, r1); \
  313. REST_2GPRS(12, r1); \
  314. /* restore original r1. */ \
  315. ld r1,GPR1(r1)
  316. #ifdef CONFIG_PPC_P7_NAP
  317. /*
  318. * This is an idle wakeup. Low level machine check has already been
  319. * done. Queue the event then call the idle code to do the wake up.
  320. */
  321. EXC_COMMON_BEGIN(machine_check_idle_common)
  322. bl machine_check_queue_event
  323. /*
  324. * We have not used any non-volatile GPRs here, and as a rule
  325. * most exception code including machine check does not.
  326. * Therefore PACA_NAPSTATELOST does not need to be set. Idle
  327. * wakeup will restore volatile registers.
  328. *
  329. * Load the original SRR1 into r3 for pnv_powersave_wakeup_mce.
  330. *
  331. * Then decrement MCE nesting after finishing with the stack.
  332. */
  333. ld r3,_MSR(r1)
  334. lhz r11,PACA_IN_MCE(r13)
  335. subi r11,r11,1
  336. sth r11,PACA_IN_MCE(r13)
  337. /* Turn off the RI bit because SRR1 is used by idle wakeup code. */
  338. /* Recoverability could be improved by reducing the use of SRR1. */
  339. li r11,0
  340. mtmsrd r11,1
  341. b pnv_powersave_wakeup_mce
  342. #endif
  343. /*
  344. * Handle machine check early in real mode. We come here with
  345. * ME=1, MMU (IR=0 and DR=0) off and using MC emergency stack.
  346. */
  347. EXC_COMMON_BEGIN(machine_check_handle_early)
  348. std r0,GPR0(r1) /* Save r0 */
  349. EXCEPTION_PROLOG_COMMON_3(0x200)
  350. bl save_nvgprs
  351. addi r3,r1,STACK_FRAME_OVERHEAD
  352. bl machine_check_early
  353. std r3,RESULT(r1) /* Save result */
  354. ld r12,_MSR(r1)
  355. #ifdef CONFIG_PPC_P7_NAP
  356. /*
  357. * Check if thread was in power saving mode. We come here when any
  358. * of the following is true:
  359. * a. thread wasn't in power saving mode
  360. * b. thread was in power saving mode with no state loss,
  361. * supervisor state loss or hypervisor state loss.
  362. *
  363. * Go back to nap/sleep/winkle mode again if (b) is true.
  364. */
  365. BEGIN_FTR_SECTION
  366. rlwinm. r11,r12,47-31,30,31
  367. bne machine_check_idle_common
  368. END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
  369. #endif
  370. /*
  371. * Check if we are coming from hypervisor userspace. If yes then we
  372. * continue in host kernel in V mode to deliver the MC event.
  373. */
  374. rldicl. r11,r12,4,63 /* See if MC hit while in HV mode. */
  375. beq 5f
  376. andi. r11,r12,MSR_PR /* See if coming from user. */
  377. bne 9f /* continue in V mode if we are. */
  378. 5:
  379. #ifdef CONFIG_KVM_BOOK3S_64_HANDLER
  380. /*
  381. * We are coming from kernel context. Check if we are coming from
  382. * guest. if yes, then we can continue. We will fall through
  383. * do_kvm_200->kvmppc_interrupt to deliver the MC event to guest.
  384. */
  385. lbz r11,HSTATE_IN_GUEST(r13)
  386. cmpwi r11,0 /* Check if coming from guest */
  387. bne 9f /* continue if we are. */
  388. #endif
  389. /*
  390. * At this point we are not sure about what context we come from.
  391. * Queue up the MCE event and return from the interrupt.
  392. * But before that, check if this is an un-recoverable exception.
  393. * If yes, then stay on emergency stack and panic.
  394. */
  395. andi. r11,r12,MSR_RI
  396. bne 2f
  397. 1: mfspr r11,SPRN_SRR0
  398. LOAD_HANDLER(r10,unrecover_mce)
  399. mtspr SPRN_SRR0,r10
  400. ld r10,PACAKMSR(r13)
  401. /*
  402. * We are going down. But there are chances that we might get hit by
  403. * another MCE during panic path and we may run into unstable state
  404. * with no way out. Hence, turn ME bit off while going down, so that
  405. * when another MCE is hit during panic path, system will checkstop
  406. * and hypervisor will get restarted cleanly by SP.
  407. */
  408. li r3,MSR_ME
  409. andc r10,r10,r3 /* Turn off MSR_ME */
  410. mtspr SPRN_SRR1,r10
  411. rfid
  412. b .
  413. 2:
  414. /*
  415. * Check if we have successfully handled/recovered from error, if not
  416. * then stay on emergency stack and panic.
  417. */
  418. ld r3,RESULT(r1) /* Load result */
  419. cmpdi r3,0 /* see if we handled MCE successfully */
  420. beq 1b /* if !handled then panic */
  421. /*
  422. * Return from MC interrupt.
  423. * Queue up the MCE event so that we can log it later, while
  424. * returning from kernel or opal call.
  425. */
  426. bl machine_check_queue_event
  427. MACHINE_CHECK_HANDLER_WINDUP
  428. rfid
  429. 9:
  430. /* Deliver the machine check to host kernel in V mode. */
  431. MACHINE_CHECK_HANDLER_WINDUP
  432. b machine_check_pSeries
  433. EXC_COMMON_BEGIN(unrecover_mce)
  434. /* Invoke machine_check_exception to print MCE event and panic. */
  435. addi r3,r1,STACK_FRAME_OVERHEAD
  436. bl machine_check_exception
  437. /*
  438. * We will not reach here. Even if we did, there is no way out. Call
  439. * unrecoverable_exception and die.
  440. */
  441. 1: addi r3,r1,STACK_FRAME_OVERHEAD
  442. bl unrecoverable_exception
  443. b 1b
  444. EXC_REAL(data_access, 0x300, 0x80)
  445. EXC_VIRT(data_access, 0x4300, 0x80, 0x300)
  446. TRAMP_KVM_SKIP(PACA_EXGEN, 0x300)
  447. EXC_COMMON_BEGIN(data_access_common)
  448. /*
  449. * Here r13 points to the paca, r9 contains the saved CR,
  450. * SRR0 and SRR1 are saved in r11 and r12,
  451. * r9 - r13 are saved in paca->exgen.
  452. */
  453. mfspr r10,SPRN_DAR
  454. std r10,PACA_EXGEN+EX_DAR(r13)
  455. mfspr r10,SPRN_DSISR
  456. stw r10,PACA_EXGEN+EX_DSISR(r13)
  457. EXCEPTION_PROLOG_COMMON(0x300, PACA_EXGEN)
  458. RECONCILE_IRQ_STATE(r10, r11)
  459. ld r12,_MSR(r1)
  460. ld r3,PACA_EXGEN+EX_DAR(r13)
  461. lwz r4,PACA_EXGEN+EX_DSISR(r13)
  462. li r5,0x300
  463. std r3,_DAR(r1)
  464. std r4,_DSISR(r1)
  465. BEGIN_MMU_FTR_SECTION
  466. b do_hash_page /* Try to handle as hpte fault */
  467. MMU_FTR_SECTION_ELSE
  468. b handle_page_fault
  469. ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX)
  470. EXC_REAL_BEGIN(data_access_slb, 0x380, 0x80)
  471. SET_SCRATCH0(r13)
  472. EXCEPTION_PROLOG_0(PACA_EXSLB)
  473. EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST_PR, 0x380)
  474. std r3,PACA_EXSLB+EX_R3(r13)
  475. mfspr r3,SPRN_DAR
  476. mfspr r12,SPRN_SRR1
  477. crset 4*cr6+eq
  478. #ifndef CONFIG_RELOCATABLE
  479. b slb_miss_realmode
  480. #else
  481. /*
  482. * We can't just use a direct branch to slb_miss_realmode
  483. * because the distance from here to there depends on where
  484. * the kernel ends up being put.
  485. */
  486. mfctr r11
  487. LOAD_HANDLER(r10, slb_miss_realmode)
  488. mtctr r10
  489. bctr
  490. #endif
  491. EXC_REAL_END(data_access_slb, 0x380, 0x80)
  492. EXC_VIRT_BEGIN(data_access_slb, 0x4380, 0x80)
  493. SET_SCRATCH0(r13)
  494. EXCEPTION_PROLOG_0(PACA_EXSLB)
  495. EXCEPTION_PROLOG_1(PACA_EXSLB, NOTEST, 0x380)
  496. std r3,PACA_EXSLB+EX_R3(r13)
  497. mfspr r3,SPRN_DAR
  498. mfspr r12,SPRN_SRR1
  499. crset 4*cr6+eq
  500. #ifndef CONFIG_RELOCATABLE
  501. b slb_miss_realmode
  502. #else
  503. /*
  504. * We can't just use a direct branch to slb_miss_realmode
  505. * because the distance from here to there depends on where
  506. * the kernel ends up being put.
  507. */
  508. mfctr r11
  509. LOAD_HANDLER(r10, slb_miss_realmode)
  510. mtctr r10
  511. bctr
  512. #endif
  513. EXC_VIRT_END(data_access_slb, 0x4380, 0x80)
  514. TRAMP_KVM_SKIP(PACA_EXSLB, 0x380)
  515. EXC_REAL(instruction_access, 0x400, 0x80)
  516. EXC_VIRT(instruction_access, 0x4400, 0x80, 0x400)
  517. TRAMP_KVM(PACA_EXGEN, 0x400)
  518. EXC_COMMON_BEGIN(instruction_access_common)
  519. EXCEPTION_PROLOG_COMMON(0x400, PACA_EXGEN)
  520. RECONCILE_IRQ_STATE(r10, r11)
  521. ld r12,_MSR(r1)
  522. ld r3,_NIP(r1)
  523. andis. r4,r12,0x5820
  524. li r5,0x400
  525. std r3,_DAR(r1)
  526. std r4,_DSISR(r1)
  527. BEGIN_MMU_FTR_SECTION
  528. b do_hash_page /* Try to handle as hpte fault */
  529. MMU_FTR_SECTION_ELSE
  530. b handle_page_fault
  531. ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX)
  532. EXC_REAL_BEGIN(instruction_access_slb, 0x480, 0x80)
  533. SET_SCRATCH0(r13)
  534. EXCEPTION_PROLOG_0(PACA_EXSLB)
  535. EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST_PR, 0x480)
  536. std r3,PACA_EXSLB+EX_R3(r13)
  537. mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */
  538. mfspr r12,SPRN_SRR1
  539. crclr 4*cr6+eq
  540. #ifndef CONFIG_RELOCATABLE
  541. b slb_miss_realmode
  542. #else
  543. mfctr r11
  544. LOAD_HANDLER(r10, slb_miss_realmode)
  545. mtctr r10
  546. bctr
  547. #endif
  548. EXC_REAL_END(instruction_access_slb, 0x480, 0x80)
  549. EXC_VIRT_BEGIN(instruction_access_slb, 0x4480, 0x80)
  550. SET_SCRATCH0(r13)
  551. EXCEPTION_PROLOG_0(PACA_EXSLB)
  552. EXCEPTION_PROLOG_1(PACA_EXSLB, NOTEST, 0x480)
  553. std r3,PACA_EXSLB+EX_R3(r13)
  554. mfspr r3,SPRN_SRR0 /* SRR0 is faulting address */
  555. mfspr r12,SPRN_SRR1
  556. crclr 4*cr6+eq
  557. #ifndef CONFIG_RELOCATABLE
  558. b slb_miss_realmode
  559. #else
  560. mfctr r11
  561. LOAD_HANDLER(r10, slb_miss_realmode)
  562. mtctr r10
  563. bctr
  564. #endif
  565. EXC_VIRT_END(instruction_access_slb, 0x4480, 0x80)
  566. TRAMP_KVM(PACA_EXSLB, 0x480)
  567. /* This handler is used by both 0x380 and 0x480 slb miss interrupts */
  568. EXC_COMMON_BEGIN(slb_miss_realmode)
  569. /*
  570. * r13 points to the PACA, r9 contains the saved CR,
  571. * r12 contain the saved SRR1, SRR0 is still ready for return
  572. * r3 has the faulting address
  573. * r9 - r13 are saved in paca->exslb.
  574. * r3 is saved in paca->slb_r3
  575. * cr6.eq is set for a D-SLB miss, clear for a I-SLB miss
  576. * We assume we aren't going to take any exceptions during this
  577. * procedure.
  578. */
  579. mflr r10
  580. #ifdef CONFIG_RELOCATABLE
  581. mtctr r11
  582. #endif
  583. stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */
  584. std r10,PACA_EXSLB+EX_LR(r13) /* save LR */
  585. std r3,PACA_EXSLB+EX_DAR(r13)
  586. crset 4*cr0+eq
  587. #ifdef CONFIG_PPC_STD_MMU_64
  588. BEGIN_MMU_FTR_SECTION
  589. bl slb_allocate_realmode
  590. END_MMU_FTR_SECTION_IFCLR(MMU_FTR_TYPE_RADIX)
  591. #endif
  592. ld r10,PACA_EXSLB+EX_LR(r13)
  593. ld r3,PACA_EXSLB+EX_R3(r13)
  594. lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */
  595. mtlr r10
  596. beq 8f /* if bad address, make full stack frame */
  597. andi. r10,r12,MSR_RI /* check for unrecoverable exception */
  598. beq- 2f
  599. /* All done -- return from exception. */
  600. .machine push
  601. .machine "power4"
  602. mtcrf 0x80,r9
  603. mtcrf 0x02,r9 /* I/D indication is in cr6 */
  604. mtcrf 0x01,r9 /* slb_allocate uses cr0 and cr7 */
  605. .machine pop
  606. RESTORE_PPR_PACA(PACA_EXSLB, r9)
  607. ld r9,PACA_EXSLB+EX_R9(r13)
  608. ld r10,PACA_EXSLB+EX_R10(r13)
  609. ld r11,PACA_EXSLB+EX_R11(r13)
  610. ld r12,PACA_EXSLB+EX_R12(r13)
  611. ld r13,PACA_EXSLB+EX_R13(r13)
  612. rfid
  613. b . /* prevent speculative execution */
  614. 2: mfspr r11,SPRN_SRR0
  615. LOAD_HANDLER(r10,unrecov_slb)
  616. mtspr SPRN_SRR0,r10
  617. ld r10,PACAKMSR(r13)
  618. mtspr SPRN_SRR1,r10
  619. rfid
  620. b .
  621. 8: mfspr r11,SPRN_SRR0
  622. LOAD_HANDLER(r10,bad_addr_slb)
  623. mtspr SPRN_SRR0,r10
  624. ld r10,PACAKMSR(r13)
  625. mtspr SPRN_SRR1,r10
  626. rfid
  627. b .
  628. EXC_COMMON_BEGIN(unrecov_slb)
  629. EXCEPTION_PROLOG_COMMON(0x4100, PACA_EXSLB)
  630. RECONCILE_IRQ_STATE(r10, r11)
  631. bl save_nvgprs
  632. 1: addi r3,r1,STACK_FRAME_OVERHEAD
  633. bl unrecoverable_exception
  634. b 1b
  635. EXC_COMMON_BEGIN(bad_addr_slb)
  636. EXCEPTION_PROLOG_COMMON(0x380, PACA_EXSLB)
  637. RECONCILE_IRQ_STATE(r10, r11)
  638. ld r3, PACA_EXSLB+EX_DAR(r13)
  639. std r3, _DAR(r1)
  640. beq cr6, 2f
  641. li r10, 0x480 /* fix trap number for I-SLB miss */
  642. std r10, _TRAP(r1)
  643. 2: bl save_nvgprs
  644. addi r3, r1, STACK_FRAME_OVERHEAD
  645. bl slb_miss_bad_addr
  646. b ret_from_except
  647. EXC_REAL_BEGIN(hardware_interrupt, 0x500, 0x100)
  648. .globl hardware_interrupt_hv;
  649. hardware_interrupt_hv:
  650. BEGIN_FTR_SECTION
  651. _MASKABLE_EXCEPTION_PSERIES(0x500, hardware_interrupt_common,
  652. EXC_HV, SOFTEN_TEST_HV)
  653. FTR_SECTION_ELSE
  654. _MASKABLE_EXCEPTION_PSERIES(0x500, hardware_interrupt_common,
  655. EXC_STD, SOFTEN_TEST_PR)
  656. ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
  657. EXC_REAL_END(hardware_interrupt, 0x500, 0x100)
  658. EXC_VIRT_BEGIN(hardware_interrupt, 0x4500, 0x100)
  659. .globl hardware_interrupt_relon_hv;
  660. hardware_interrupt_relon_hv:
  661. BEGIN_FTR_SECTION
  662. _MASKABLE_RELON_EXCEPTION_PSERIES(0x500, hardware_interrupt_common, EXC_HV, SOFTEN_TEST_HV)
  663. FTR_SECTION_ELSE
  664. _MASKABLE_RELON_EXCEPTION_PSERIES(0x500, hardware_interrupt_common, EXC_STD, SOFTEN_TEST_PR)
  665. ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
  666. EXC_VIRT_END(hardware_interrupt, 0x4500, 0x100)
  667. TRAMP_KVM(PACA_EXGEN, 0x500)
  668. TRAMP_KVM_HV(PACA_EXGEN, 0x500)
  669. EXC_COMMON_ASYNC(hardware_interrupt_common, 0x500, do_IRQ)
  670. EXC_REAL(alignment, 0x600, 0x100)
  671. EXC_VIRT(alignment, 0x4600, 0x100, 0x600)
  672. TRAMP_KVM(PACA_EXGEN, 0x600)
  673. EXC_COMMON_BEGIN(alignment_common)
  674. mfspr r10,SPRN_DAR
  675. std r10,PACA_EXGEN+EX_DAR(r13)
  676. mfspr r10,SPRN_DSISR
  677. stw r10,PACA_EXGEN+EX_DSISR(r13)
  678. EXCEPTION_PROLOG_COMMON(0x600, PACA_EXGEN)
  679. ld r3,PACA_EXGEN+EX_DAR(r13)
  680. lwz r4,PACA_EXGEN+EX_DSISR(r13)
  681. std r3,_DAR(r1)
  682. std r4,_DSISR(r1)
  683. bl save_nvgprs
  684. RECONCILE_IRQ_STATE(r10, r11)
  685. addi r3,r1,STACK_FRAME_OVERHEAD
  686. bl alignment_exception
  687. b ret_from_except
  688. EXC_REAL(program_check, 0x700, 0x100)
  689. EXC_VIRT(program_check, 0x4700, 0x100, 0x700)
  690. TRAMP_KVM(PACA_EXGEN, 0x700)
  691. EXC_COMMON_BEGIN(program_check_common)
  692. EXCEPTION_PROLOG_COMMON(0x700, PACA_EXGEN)
  693. bl save_nvgprs
  694. RECONCILE_IRQ_STATE(r10, r11)
  695. addi r3,r1,STACK_FRAME_OVERHEAD
  696. bl program_check_exception
  697. b ret_from_except
  698. EXC_REAL(fp_unavailable, 0x800, 0x100)
  699. EXC_VIRT(fp_unavailable, 0x4800, 0x100, 0x800)
  700. TRAMP_KVM(PACA_EXGEN, 0x800)
  701. EXC_COMMON_BEGIN(fp_unavailable_common)
  702. EXCEPTION_PROLOG_COMMON(0x800, PACA_EXGEN)
  703. bne 1f /* if from user, just load it up */
  704. bl save_nvgprs
  705. RECONCILE_IRQ_STATE(r10, r11)
  706. addi r3,r1,STACK_FRAME_OVERHEAD
  707. bl kernel_fp_unavailable_exception
  708. BUG_OPCODE
  709. 1:
  710. #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
  711. BEGIN_FTR_SECTION
  712. /* Test if 2 TM state bits are zero. If non-zero (ie. userspace was in
  713. * transaction), go do TM stuff
  714. */
  715. rldicl. r0, r12, (64-MSR_TS_LG), (64-2)
  716. bne- 2f
  717. END_FTR_SECTION_IFSET(CPU_FTR_TM)
  718. #endif
  719. bl load_up_fpu
  720. b fast_exception_return
  721. #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
  722. 2: /* User process was in a transaction */
  723. bl save_nvgprs
  724. RECONCILE_IRQ_STATE(r10, r11)
  725. addi r3,r1,STACK_FRAME_OVERHEAD
  726. bl fp_unavailable_tm
  727. b ret_from_except
  728. #endif
  729. EXC_REAL_MASKABLE(decrementer, 0x900, 0x80)
  730. EXC_VIRT_MASKABLE(decrementer, 0x4900, 0x80, 0x900)
  731. TRAMP_KVM(PACA_EXGEN, 0x900)
  732. EXC_COMMON_ASYNC(decrementer_common, 0x900, timer_interrupt)
  733. EXC_REAL_HV(hdecrementer, 0x980, 0x80)
  734. EXC_VIRT_HV(hdecrementer, 0x4980, 0x80, 0x980)
  735. TRAMP_KVM_HV(PACA_EXGEN, 0x980)
  736. EXC_COMMON(hdecrementer_common, 0x980, hdec_interrupt)
  737. EXC_REAL_MASKABLE(doorbell_super, 0xa00, 0x100)
  738. EXC_VIRT_MASKABLE(doorbell_super, 0x4a00, 0x100, 0xa00)
  739. TRAMP_KVM(PACA_EXGEN, 0xa00)
  740. #ifdef CONFIG_PPC_DOORBELL
  741. EXC_COMMON_ASYNC(doorbell_super_common, 0xa00, doorbell_exception)
  742. #else
  743. EXC_COMMON_ASYNC(doorbell_super_common, 0xa00, unknown_exception)
  744. #endif
  745. EXC_REAL(trap_0b, 0xb00, 0x100)
  746. EXC_VIRT(trap_0b, 0x4b00, 0x100, 0xb00)
  747. TRAMP_KVM(PACA_EXGEN, 0xb00)
  748. EXC_COMMON(trap_0b_common, 0xb00, unknown_exception)
  749. #ifdef CONFIG_KVM_BOOK3S_64_HANDLER
  750. /*
  751. * If CONFIG_KVM_BOOK3S_64_HANDLER is set, save the PPR (on systems
  752. * that support it) before changing to HMT_MEDIUM. That allows the KVM
  753. * code to save that value into the guest state (it is the guest's PPR
  754. * value). Otherwise just change to HMT_MEDIUM as userspace has
  755. * already saved the PPR.
  756. */
  757. #define SYSCALL_KVMTEST \
  758. SET_SCRATCH0(r13); \
  759. GET_PACA(r13); \
  760. std r9,PACA_EXGEN+EX_R9(r13); \
  761. OPT_GET_SPR(r9, SPRN_PPR, CPU_FTR_HAS_PPR); \
  762. HMT_MEDIUM; \
  763. std r10,PACA_EXGEN+EX_R10(r13); \
  764. OPT_SAVE_REG_TO_PACA(PACA_EXGEN+EX_PPR, r9, CPU_FTR_HAS_PPR); \
  765. mfcr r9; \
  766. KVMTEST_PR(0xc00); \
  767. GET_SCRATCH0(r13)
  768. #else
  769. #define SYSCALL_KVMTEST \
  770. HMT_MEDIUM
  771. #endif
  772. #define LOAD_SYSCALL_HANDLER(reg) \
  773. __LOAD_HANDLER(reg, system_call_common)
  774. /* Syscall routine is used twice, in reloc-off and reloc-on paths */
  775. #define SYSCALL_PSERIES_1 \
  776. BEGIN_FTR_SECTION \
  777. cmpdi r0,0x1ebe ; \
  778. beq- 1f ; \
  779. END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE) \
  780. mr r9,r13 ; \
  781. GET_PACA(r13) ; \
  782. mfspr r11,SPRN_SRR0 ; \
  783. 0:
  784. #define SYSCALL_PSERIES_2_RFID \
  785. mfspr r12,SPRN_SRR1 ; \
  786. LOAD_SYSCALL_HANDLER(r10) ; \
  787. mtspr SPRN_SRR0,r10 ; \
  788. ld r10,PACAKMSR(r13) ; \
  789. mtspr SPRN_SRR1,r10 ; \
  790. rfid ; \
  791. b . ; /* prevent speculative execution */
  792. #define SYSCALL_PSERIES_3 \
  793. /* Fast LE/BE switch system call */ \
  794. 1: mfspr r12,SPRN_SRR1 ; \
  795. xori r12,r12,MSR_LE ; \
  796. mtspr SPRN_SRR1,r12 ; \
  797. rfid ; /* return to userspace */ \
  798. b . ; /* prevent speculative execution */
  799. #if defined(CONFIG_RELOCATABLE)
  800. /*
  801. * We can't branch directly so we do it via the CTR which
  802. * is volatile across system calls.
  803. */
  804. #define SYSCALL_PSERIES_2_DIRECT \
  805. LOAD_SYSCALL_HANDLER(r12) ; \
  806. mtctr r12 ; \
  807. mfspr r12,SPRN_SRR1 ; \
  808. li r10,MSR_RI ; \
  809. mtmsrd r10,1 ; \
  810. bctr ;
  811. #else
  812. /* We can branch directly */
  813. #define SYSCALL_PSERIES_2_DIRECT \
  814. mfspr r12,SPRN_SRR1 ; \
  815. li r10,MSR_RI ; \
  816. mtmsrd r10,1 ; /* Set RI (EE=0) */ \
  817. b system_call_common ;
  818. #endif
  819. EXC_REAL_BEGIN(system_call, 0xc00, 0x100)
  820. SYSCALL_KVMTEST
  821. SYSCALL_PSERIES_1
  822. SYSCALL_PSERIES_2_RFID
  823. SYSCALL_PSERIES_3
  824. EXC_REAL_END(system_call, 0xc00, 0x100)
  825. EXC_VIRT_BEGIN(system_call, 0x4c00, 0x100)
  826. SYSCALL_KVMTEST
  827. SYSCALL_PSERIES_1
  828. SYSCALL_PSERIES_2_DIRECT
  829. SYSCALL_PSERIES_3
  830. EXC_VIRT_END(system_call, 0x4c00, 0x100)
  831. TRAMP_KVM(PACA_EXGEN, 0xc00)
  832. EXC_REAL(single_step, 0xd00, 0x100)
  833. EXC_VIRT(single_step, 0x4d00, 0x100, 0xd00)
  834. TRAMP_KVM(PACA_EXGEN, 0xd00)
  835. EXC_COMMON(single_step_common, 0xd00, single_step_exception)
  836. EXC_REAL_OOL_HV(h_data_storage, 0xe00, 0x20)
  837. EXC_VIRT_OOL_HV(h_data_storage, 0x4e00, 0x20, 0xe00)
  838. TRAMP_KVM_HV_SKIP(PACA_EXGEN, 0xe00)
  839. EXC_COMMON_BEGIN(h_data_storage_common)
  840. mfspr r10,SPRN_HDAR
  841. std r10,PACA_EXGEN+EX_DAR(r13)
  842. mfspr r10,SPRN_HDSISR
  843. stw r10,PACA_EXGEN+EX_DSISR(r13)
  844. EXCEPTION_PROLOG_COMMON(0xe00, PACA_EXGEN)
  845. bl save_nvgprs
  846. RECONCILE_IRQ_STATE(r10, r11)
  847. addi r3,r1,STACK_FRAME_OVERHEAD
  848. bl unknown_exception
  849. b ret_from_except
  850. EXC_REAL_OOL_HV(h_instr_storage, 0xe20, 0x20)
  851. EXC_VIRT_OOL_HV(h_instr_storage, 0x4e20, 0x20, 0xe20)
  852. TRAMP_KVM_HV(PACA_EXGEN, 0xe20)
  853. EXC_COMMON(h_instr_storage_common, 0xe20, unknown_exception)
  854. EXC_REAL_OOL_HV(emulation_assist, 0xe40, 0x20)
  855. EXC_VIRT_OOL_HV(emulation_assist, 0x4e40, 0x20, 0xe40)
  856. TRAMP_KVM_HV(PACA_EXGEN, 0xe40)
  857. EXC_COMMON(emulation_assist_common, 0xe40, emulation_assist_interrupt)
  858. /*
  859. * hmi_exception trampoline is a special case. It jumps to hmi_exception_early
  860. * first, and then eventaully from there to the trampoline to get into virtual
  861. * mode.
  862. */
  863. __EXC_REAL_OOL_HV_DIRECT(hmi_exception, 0xe60, 0x20, hmi_exception_early)
  864. __TRAMP_REAL_OOL_MASKABLE_HV(hmi_exception, 0xe60)
  865. EXC_VIRT_NONE(0x4e60, 0x20)
  866. TRAMP_KVM_HV(PACA_EXGEN, 0xe60)
  867. TRAMP_REAL_BEGIN(hmi_exception_early)
  868. EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_HV, 0xe60)
  869. mr r10,r1 /* Save r1 */
  870. ld r1,PACAEMERGSP(r13) /* Use emergency stack for realmode */
  871. subi r1,r1,INT_FRAME_SIZE /* alloc stack frame */
  872. mfspr r11,SPRN_HSRR0 /* Save HSRR0 */
  873. mfspr r12,SPRN_HSRR1 /* Save HSRR1 */
  874. EXCEPTION_PROLOG_COMMON_1()
  875. EXCEPTION_PROLOG_COMMON_2(PACA_EXGEN)
  876. EXCEPTION_PROLOG_COMMON_3(0xe60)
  877. addi r3,r1,STACK_FRAME_OVERHEAD
  878. BRANCH_LINK_TO_FAR(hmi_exception_realmode) /* Function call ABI */
  879. /* Windup the stack. */
  880. /* Move original HSRR0 and HSRR1 into the respective regs */
  881. ld r9,_MSR(r1)
  882. mtspr SPRN_HSRR1,r9
  883. ld r3,_NIP(r1)
  884. mtspr SPRN_HSRR0,r3
  885. ld r9,_CTR(r1)
  886. mtctr r9
  887. ld r9,_XER(r1)
  888. mtxer r9
  889. ld r9,_LINK(r1)
  890. mtlr r9
  891. REST_GPR(0, r1)
  892. REST_8GPRS(2, r1)
  893. REST_GPR(10, r1)
  894. ld r11,_CCR(r1)
  895. mtcr r11
  896. REST_GPR(11, r1)
  897. REST_2GPRS(12, r1)
  898. /* restore original r1. */
  899. ld r1,GPR1(r1)
  900. /*
  901. * Go to virtual mode and pull the HMI event information from
  902. * firmware.
  903. */
  904. .globl hmi_exception_after_realmode
  905. hmi_exception_after_realmode:
  906. SET_SCRATCH0(r13)
  907. EXCEPTION_PROLOG_0(PACA_EXGEN)
  908. b tramp_real_hmi_exception
  909. EXC_COMMON_ASYNC(hmi_exception_common, 0xe60, handle_hmi_exception)
  910. EXC_REAL_OOL_MASKABLE_HV(h_doorbell, 0xe80, 0x20)
  911. EXC_VIRT_OOL_MASKABLE_HV(h_doorbell, 0x4e80, 0x20, 0xe80)
  912. TRAMP_KVM_HV(PACA_EXGEN, 0xe80)
  913. #ifdef CONFIG_PPC_DOORBELL
  914. EXC_COMMON_ASYNC(h_doorbell_common, 0xe80, doorbell_exception)
  915. #else
  916. EXC_COMMON_ASYNC(h_doorbell_common, 0xe80, unknown_exception)
  917. #endif
  918. EXC_REAL_OOL_MASKABLE_HV(h_virt_irq, 0xea0, 0x20)
  919. EXC_VIRT_OOL_MASKABLE_HV(h_virt_irq, 0x4ea0, 0x20, 0xea0)
  920. TRAMP_KVM_HV(PACA_EXGEN, 0xea0)
  921. EXC_COMMON_ASYNC(h_virt_irq_common, 0xea0, do_IRQ)
  922. EXC_REAL_NONE(0xec0, 0x20)
  923. EXC_VIRT_NONE(0x4ec0, 0x20)
  924. EXC_REAL_NONE(0xee0, 0x20)
  925. EXC_VIRT_NONE(0x4ee0, 0x20)
  926. EXC_REAL_OOL(performance_monitor, 0xf00, 0x20)
  927. EXC_VIRT_OOL(performance_monitor, 0x4f00, 0x20, 0xf00)
  928. TRAMP_KVM(PACA_EXGEN, 0xf00)
  929. EXC_COMMON_ASYNC(performance_monitor_common, 0xf00, performance_monitor_exception)
  930. EXC_REAL_OOL(altivec_unavailable, 0xf20, 0x20)
  931. EXC_VIRT_OOL(altivec_unavailable, 0x4f20, 0x20, 0xf20)
  932. TRAMP_KVM(PACA_EXGEN, 0xf20)
  933. EXC_COMMON_BEGIN(altivec_unavailable_common)
  934. EXCEPTION_PROLOG_COMMON(0xf20, PACA_EXGEN)
  935. #ifdef CONFIG_ALTIVEC
  936. BEGIN_FTR_SECTION
  937. beq 1f
  938. #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
  939. BEGIN_FTR_SECTION_NESTED(69)
  940. /* Test if 2 TM state bits are zero. If non-zero (ie. userspace was in
  941. * transaction), go do TM stuff
  942. */
  943. rldicl. r0, r12, (64-MSR_TS_LG), (64-2)
  944. bne- 2f
  945. END_FTR_SECTION_NESTED(CPU_FTR_TM, CPU_FTR_TM, 69)
  946. #endif
  947. bl load_up_altivec
  948. b fast_exception_return
  949. #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
  950. 2: /* User process was in a transaction */
  951. bl save_nvgprs
  952. RECONCILE_IRQ_STATE(r10, r11)
  953. addi r3,r1,STACK_FRAME_OVERHEAD
  954. bl altivec_unavailable_tm
  955. b ret_from_except
  956. #endif
  957. 1:
  958. END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
  959. #endif
  960. bl save_nvgprs
  961. RECONCILE_IRQ_STATE(r10, r11)
  962. addi r3,r1,STACK_FRAME_OVERHEAD
  963. bl altivec_unavailable_exception
  964. b ret_from_except
  965. EXC_REAL_OOL(vsx_unavailable, 0xf40, 0x20)
  966. EXC_VIRT_OOL(vsx_unavailable, 0x4f40, 0x20, 0xf40)
  967. TRAMP_KVM(PACA_EXGEN, 0xf40)
  968. EXC_COMMON_BEGIN(vsx_unavailable_common)
  969. EXCEPTION_PROLOG_COMMON(0xf40, PACA_EXGEN)
  970. #ifdef CONFIG_VSX
  971. BEGIN_FTR_SECTION
  972. beq 1f
  973. #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
  974. BEGIN_FTR_SECTION_NESTED(69)
  975. /* Test if 2 TM state bits are zero. If non-zero (ie. userspace was in
  976. * transaction), go do TM stuff
  977. */
  978. rldicl. r0, r12, (64-MSR_TS_LG), (64-2)
  979. bne- 2f
  980. END_FTR_SECTION_NESTED(CPU_FTR_TM, CPU_FTR_TM, 69)
  981. #endif
  982. b load_up_vsx
  983. #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
  984. 2: /* User process was in a transaction */
  985. bl save_nvgprs
  986. RECONCILE_IRQ_STATE(r10, r11)
  987. addi r3,r1,STACK_FRAME_OVERHEAD
  988. bl vsx_unavailable_tm
  989. b ret_from_except
  990. #endif
  991. 1:
  992. END_FTR_SECTION_IFSET(CPU_FTR_VSX)
  993. #endif
  994. bl save_nvgprs
  995. RECONCILE_IRQ_STATE(r10, r11)
  996. addi r3,r1,STACK_FRAME_OVERHEAD
  997. bl vsx_unavailable_exception
  998. b ret_from_except
  999. EXC_REAL_OOL(facility_unavailable, 0xf60, 0x20)
  1000. EXC_VIRT_OOL(facility_unavailable, 0x4f60, 0x20, 0xf60)
  1001. TRAMP_KVM(PACA_EXGEN, 0xf60)
  1002. EXC_COMMON(facility_unavailable_common, 0xf60, facility_unavailable_exception)
  1003. EXC_REAL_OOL_HV(h_facility_unavailable, 0xf80, 0x20)
  1004. EXC_VIRT_OOL_HV(h_facility_unavailable, 0x4f80, 0x20, 0xf80)
  1005. TRAMP_KVM_HV(PACA_EXGEN, 0xf80)
  1006. EXC_COMMON(h_facility_unavailable_common, 0xf80, facility_unavailable_exception)
  1007. EXC_REAL_NONE(0xfa0, 0x20)
  1008. EXC_VIRT_NONE(0x4fa0, 0x20)
  1009. EXC_REAL_NONE(0xfc0, 0x20)
  1010. EXC_VIRT_NONE(0x4fc0, 0x20)
  1011. EXC_REAL_NONE(0xfe0, 0x20)
  1012. EXC_VIRT_NONE(0x4fe0, 0x20)
  1013. EXC_REAL_NONE(0x1000, 0x100)
  1014. EXC_VIRT_NONE(0x5000, 0x100)
  1015. EXC_REAL_NONE(0x1100, 0x100)
  1016. EXC_VIRT_NONE(0x5100, 0x100)
  1017. #ifdef CONFIG_CBE_RAS
  1018. EXC_REAL_HV(cbe_system_error, 0x1200, 0x100)
  1019. EXC_VIRT_NONE(0x5200, 0x100)
  1020. TRAMP_KVM_HV_SKIP(PACA_EXGEN, 0x1200)
  1021. EXC_COMMON(cbe_system_error_common, 0x1200, cbe_system_error_exception)
  1022. #else /* CONFIG_CBE_RAS */
  1023. EXC_REAL_NONE(0x1200, 0x100)
  1024. EXC_VIRT_NONE(0x5200, 0x100)
  1025. #endif
  1026. EXC_REAL(instruction_breakpoint, 0x1300, 0x100)
  1027. EXC_VIRT(instruction_breakpoint, 0x5300, 0x100, 0x1300)
  1028. TRAMP_KVM_SKIP(PACA_EXGEN, 0x1300)
  1029. EXC_COMMON(instruction_breakpoint_common, 0x1300, instruction_breakpoint_exception)
  1030. EXC_REAL_NONE(0x1400, 0x100)
  1031. EXC_VIRT_NONE(0x5400, 0x100)
  1032. EXC_REAL_BEGIN(denorm_exception_hv, 0x1500, 0x100)
  1033. mtspr SPRN_SPRG_HSCRATCH0,r13
  1034. EXCEPTION_PROLOG_0(PACA_EXGEN)
  1035. EXCEPTION_PROLOG_1(PACA_EXGEN, NOTEST, 0x1500)
  1036. #ifdef CONFIG_PPC_DENORMALISATION
  1037. mfspr r10,SPRN_HSRR1
  1038. mfspr r11,SPRN_HSRR0 /* save HSRR0 */
  1039. andis. r10,r10,(HSRR1_DENORM)@h /* denorm? */
  1040. addi r11,r11,-4 /* HSRR0 is next instruction */
  1041. bne+ denorm_assist
  1042. #endif
  1043. KVMTEST_PR(0x1500)
  1044. EXCEPTION_PROLOG_PSERIES_1(denorm_common, EXC_HV)
  1045. EXC_REAL_END(denorm_exception_hv, 0x1500, 0x100)
  1046. #ifdef CONFIG_PPC_DENORMALISATION
  1047. EXC_VIRT_BEGIN(denorm_exception, 0x5500, 0x100)
  1048. b exc_real_0x1500_denorm_exception_hv
  1049. EXC_VIRT_END(denorm_exception, 0x5500, 0x100)
  1050. #else
  1051. EXC_VIRT_NONE(0x5500, 0x100)
  1052. #endif
  1053. TRAMP_KVM_SKIP(PACA_EXGEN, 0x1500)
  1054. #ifdef CONFIG_PPC_DENORMALISATION
  1055. TRAMP_REAL_BEGIN(denorm_assist)
  1056. BEGIN_FTR_SECTION
  1057. /*
  1058. * To denormalise we need to move a copy of the register to itself.
  1059. * For POWER6 do that here for all FP regs.
  1060. */
  1061. mfmsr r10
  1062. ori r10,r10,(MSR_FP|MSR_FE0|MSR_FE1)
  1063. xori r10,r10,(MSR_FE0|MSR_FE1)
  1064. mtmsrd r10
  1065. sync
  1066. #define FMR2(n) fmr (n), (n) ; fmr n+1, n+1
  1067. #define FMR4(n) FMR2(n) ; FMR2(n+2)
  1068. #define FMR8(n) FMR4(n) ; FMR4(n+4)
  1069. #define FMR16(n) FMR8(n) ; FMR8(n+8)
  1070. #define FMR32(n) FMR16(n) ; FMR16(n+16)
  1071. FMR32(0)
  1072. FTR_SECTION_ELSE
  1073. /*
  1074. * To denormalise we need to move a copy of the register to itself.
  1075. * For POWER7 do that here for the first 32 VSX registers only.
  1076. */
  1077. mfmsr r10
  1078. oris r10,r10,MSR_VSX@h
  1079. mtmsrd r10
  1080. sync
  1081. #define XVCPSGNDP2(n) XVCPSGNDP(n,n,n) ; XVCPSGNDP(n+1,n+1,n+1)
  1082. #define XVCPSGNDP4(n) XVCPSGNDP2(n) ; XVCPSGNDP2(n+2)
  1083. #define XVCPSGNDP8(n) XVCPSGNDP4(n) ; XVCPSGNDP4(n+4)
  1084. #define XVCPSGNDP16(n) XVCPSGNDP8(n) ; XVCPSGNDP8(n+8)
  1085. #define XVCPSGNDP32(n) XVCPSGNDP16(n) ; XVCPSGNDP16(n+16)
  1086. XVCPSGNDP32(0)
  1087. ALT_FTR_SECTION_END_IFCLR(CPU_FTR_ARCH_206)
  1088. BEGIN_FTR_SECTION
  1089. b denorm_done
  1090. END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
  1091. /*
  1092. * To denormalise we need to move a copy of the register to itself.
  1093. * For POWER8 we need to do that for all 64 VSX registers
  1094. */
  1095. XVCPSGNDP32(32)
  1096. denorm_done:
  1097. mtspr SPRN_HSRR0,r11
  1098. mtcrf 0x80,r9
  1099. ld r9,PACA_EXGEN+EX_R9(r13)
  1100. RESTORE_PPR_PACA(PACA_EXGEN, r10)
  1101. BEGIN_FTR_SECTION
  1102. ld r10,PACA_EXGEN+EX_CFAR(r13)
  1103. mtspr SPRN_CFAR,r10
  1104. END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
  1105. ld r10,PACA_EXGEN+EX_R10(r13)
  1106. ld r11,PACA_EXGEN+EX_R11(r13)
  1107. ld r12,PACA_EXGEN+EX_R12(r13)
  1108. ld r13,PACA_EXGEN+EX_R13(r13)
  1109. HRFID
  1110. b .
  1111. #endif
  1112. EXC_COMMON_HV(denorm_common, 0x1500, unknown_exception)
  1113. #ifdef CONFIG_CBE_RAS
  1114. EXC_REAL_HV(cbe_maintenance, 0x1600, 0x100)
  1115. EXC_VIRT_NONE(0x5600, 0x100)
  1116. TRAMP_KVM_HV_SKIP(PACA_EXGEN, 0x1600)
  1117. EXC_COMMON(cbe_maintenance_common, 0x1600, cbe_maintenance_exception)
  1118. #else /* CONFIG_CBE_RAS */
  1119. EXC_REAL_NONE(0x1600, 0x100)
  1120. EXC_VIRT_NONE(0x5600, 0x100)
  1121. #endif
  1122. EXC_REAL(altivec_assist, 0x1700, 0x100)
  1123. EXC_VIRT(altivec_assist, 0x5700, 0x100, 0x1700)
  1124. TRAMP_KVM(PACA_EXGEN, 0x1700)
  1125. #ifdef CONFIG_ALTIVEC
  1126. EXC_COMMON(altivec_assist_common, 0x1700, altivec_assist_exception)
  1127. #else
  1128. EXC_COMMON(altivec_assist_common, 0x1700, unknown_exception)
  1129. #endif
  1130. #ifdef CONFIG_CBE_RAS
  1131. EXC_REAL_HV(cbe_thermal, 0x1800, 0x100)
  1132. EXC_VIRT_NONE(0x5800, 0x100)
  1133. TRAMP_KVM_HV_SKIP(PACA_EXGEN, 0x1800)
  1134. EXC_COMMON(cbe_thermal_common, 0x1800, cbe_thermal_exception)
  1135. #else /* CONFIG_CBE_RAS */
  1136. EXC_REAL_NONE(0x1800, 0x100)
  1137. EXC_VIRT_NONE(0x5800, 0x100)
  1138. #endif
  1139. /*
  1140. * An interrupt came in while soft-disabled. We set paca->irq_happened, then:
  1141. * - If it was a decrementer interrupt, we bump the dec to max and and return.
  1142. * - If it was a doorbell we return immediately since doorbells are edge
  1143. * triggered and won't automatically refire.
  1144. * - If it was a HMI we return immediately since we handled it in realmode
  1145. * and it won't refire.
  1146. * - else we hard disable and return.
  1147. * This is called with r10 containing the value to OR to the paca field.
  1148. */
  1149. #define MASKED_INTERRUPT(_H) \
  1150. masked_##_H##interrupt: \
  1151. std r11,PACA_EXGEN+EX_R11(r13); \
  1152. lbz r11,PACAIRQHAPPENED(r13); \
  1153. or r11,r11,r10; \
  1154. stb r11,PACAIRQHAPPENED(r13); \
  1155. cmpwi r10,PACA_IRQ_DEC; \
  1156. bne 1f; \
  1157. lis r10,0x7fff; \
  1158. ori r10,r10,0xffff; \
  1159. mtspr SPRN_DEC,r10; \
  1160. b 2f; \
  1161. 1: cmpwi r10,PACA_IRQ_DBELL; \
  1162. beq 2f; \
  1163. cmpwi r10,PACA_IRQ_HMI; \
  1164. beq 2f; \
  1165. mfspr r10,SPRN_##_H##SRR1; \
  1166. rldicl r10,r10,48,1; /* clear MSR_EE */ \
  1167. rotldi r10,r10,16; \
  1168. mtspr SPRN_##_H##SRR1,r10; \
  1169. 2: mtcrf 0x80,r9; \
  1170. ld r9,PACA_EXGEN+EX_R9(r13); \
  1171. ld r10,PACA_EXGEN+EX_R10(r13); \
  1172. ld r11,PACA_EXGEN+EX_R11(r13); \
  1173. GET_SCRATCH0(r13); \
  1174. ##_H##rfid; \
  1175. b .
  1176. /*
  1177. * Real mode exceptions actually use this too, but alternate
  1178. * instruction code patches (which end up in the common .text area)
  1179. * cannot reach these if they are put there.
  1180. */
  1181. USE_FIXED_SECTION(virt_trampolines)
  1182. MASKED_INTERRUPT()
  1183. MASKED_INTERRUPT(H)
  1184. #ifdef CONFIG_KVM_BOOK3S_64_HANDLER
  1185. TRAMP_REAL_BEGIN(kvmppc_skip_interrupt)
  1186. /*
  1187. * Here all GPRs are unchanged from when the interrupt happened
  1188. * except for r13, which is saved in SPRG_SCRATCH0.
  1189. */
  1190. mfspr r13, SPRN_SRR0
  1191. addi r13, r13, 4
  1192. mtspr SPRN_SRR0, r13
  1193. GET_SCRATCH0(r13)
  1194. rfid
  1195. b .
  1196. TRAMP_REAL_BEGIN(kvmppc_skip_Hinterrupt)
  1197. /*
  1198. * Here all GPRs are unchanged from when the interrupt happened
  1199. * except for r13, which is saved in SPRG_SCRATCH0.
  1200. */
  1201. mfspr r13, SPRN_HSRR0
  1202. addi r13, r13, 4
  1203. mtspr SPRN_HSRR0, r13
  1204. GET_SCRATCH0(r13)
  1205. hrfid
  1206. b .
  1207. #endif
  1208. /*
  1209. * Ensure that any handlers that get invoked from the exception prologs
  1210. * above are below the first 64KB (0x10000) of the kernel image because
  1211. * the prologs assemble the addresses of these handlers using the
  1212. * LOAD_HANDLER macro, which uses an ori instruction.
  1213. */
  1214. /*** Common interrupt handlers ***/
  1215. /*
  1216. * Relocation-on interrupts: A subset of the interrupts can be delivered
  1217. * with IR=1/DR=1, if AIL==2 and MSR.HV won't be changed by delivering
  1218. * it. Addresses are the same as the original interrupt addresses, but
  1219. * offset by 0xc000000000004000.
  1220. * It's impossible to receive interrupts below 0x300 via this mechanism.
  1221. * KVM: None of these traps are from the guest ; anything that escalated
  1222. * to HV=1 from HV=0 is delivered via real mode handlers.
  1223. */
  1224. /*
  1225. * This uses the standard macro, since the original 0x300 vector
  1226. * only has extra guff for STAB-based processors -- which never
  1227. * come here.
  1228. */
  1229. EXC_COMMON_BEGIN(ppc64_runlatch_on_trampoline)
  1230. b __ppc64_runlatch_on
  1231. USE_FIXED_SECTION(virt_trampolines)
  1232. /*
  1233. * The __end_interrupts marker must be past the out-of-line (OOL)
  1234. * handlers, so that they are copied to real address 0x100 when running
  1235. * a relocatable kernel. This ensures they can be reached from the short
  1236. * trampoline handlers (like 0x4f00, 0x4f20, etc.) which branch
  1237. * directly, without using LOAD_HANDLER().
  1238. */
  1239. .align 7
  1240. .globl __end_interrupts
  1241. __end_interrupts:
  1242. DEFINE_FIXED_SYMBOL(__end_interrupts)
  1243. #ifdef CONFIG_PPC_970_NAP
  1244. EXC_COMMON_BEGIN(power4_fixup_nap)
  1245. andc r9,r9,r10
  1246. std r9,TI_LOCAL_FLAGS(r11)
  1247. ld r10,_LINK(r1) /* make idle task do the */
  1248. std r10,_NIP(r1) /* equivalent of a blr */
  1249. blr
  1250. #endif
  1251. CLOSE_FIXED_SECTION(real_vectors);
  1252. CLOSE_FIXED_SECTION(real_trampolines);
  1253. CLOSE_FIXED_SECTION(virt_vectors);
  1254. CLOSE_FIXED_SECTION(virt_trampolines);
  1255. USE_TEXT_SECTION()
  1256. /*
  1257. * Hash table stuff
  1258. */
  1259. .balign IFETCH_ALIGN_BYTES
  1260. do_hash_page:
  1261. #ifdef CONFIG_PPC_STD_MMU_64
  1262. andis. r0,r4,0xa410 /* weird error? */
  1263. bne- handle_page_fault /* if not, try to insert a HPTE */
  1264. andis. r0,r4,DSISR_DABRMATCH@h
  1265. bne- handle_dabr_fault
  1266. CURRENT_THREAD_INFO(r11, r1)
  1267. lwz r0,TI_PREEMPT(r11) /* If we're in an "NMI" */
  1268. andis. r0,r0,NMI_MASK@h /* (i.e. an irq when soft-disabled) */
  1269. bne 77f /* then don't call hash_page now */
  1270. /*
  1271. * r3 contains the faulting address
  1272. * r4 msr
  1273. * r5 contains the trap number
  1274. * r6 contains dsisr
  1275. *
  1276. * at return r3 = 0 for success, 1 for page fault, negative for error
  1277. */
  1278. mr r4,r12
  1279. ld r6,_DSISR(r1)
  1280. bl __hash_page /* build HPTE if possible */
  1281. cmpdi r3,0 /* see if __hash_page succeeded */
  1282. /* Success */
  1283. beq fast_exc_return_irq /* Return from exception on success */
  1284. /* Error */
  1285. blt- 13f
  1286. #endif /* CONFIG_PPC_STD_MMU_64 */
  1287. /* Here we have a page fault that hash_page can't handle. */
  1288. handle_page_fault:
  1289. 11: ld r4,_DAR(r1)
  1290. ld r5,_DSISR(r1)
  1291. addi r3,r1,STACK_FRAME_OVERHEAD
  1292. bl do_page_fault
  1293. cmpdi r3,0
  1294. beq+ 12f
  1295. bl save_nvgprs
  1296. mr r5,r3
  1297. addi r3,r1,STACK_FRAME_OVERHEAD
  1298. lwz r4,_DAR(r1)
  1299. bl bad_page_fault
  1300. b ret_from_except
  1301. /* We have a data breakpoint exception - handle it */
  1302. handle_dabr_fault:
  1303. bl save_nvgprs
  1304. ld r4,_DAR(r1)
  1305. ld r5,_DSISR(r1)
  1306. addi r3,r1,STACK_FRAME_OVERHEAD
  1307. bl do_break
  1308. 12: b ret_from_except_lite
  1309. #ifdef CONFIG_PPC_STD_MMU_64
  1310. /* We have a page fault that hash_page could handle but HV refused
  1311. * the PTE insertion
  1312. */
  1313. 13: bl save_nvgprs
  1314. mr r5,r3
  1315. addi r3,r1,STACK_FRAME_OVERHEAD
  1316. ld r4,_DAR(r1)
  1317. bl low_hash_fault
  1318. b ret_from_except
  1319. #endif
  1320. /*
  1321. * We come here as a result of a DSI at a point where we don't want
  1322. * to call hash_page, such as when we are accessing memory (possibly
  1323. * user memory) inside a PMU interrupt that occurred while interrupts
  1324. * were soft-disabled. We want to invoke the exception handler for
  1325. * the access, or panic if there isn't a handler.
  1326. */
  1327. 77: bl save_nvgprs
  1328. mr r4,r3
  1329. addi r3,r1,STACK_FRAME_OVERHEAD
  1330. li r5,SIGSEGV
  1331. bl bad_page_fault
  1332. b ret_from_except
  1333. /*
  1334. * Here we have detected that the kernel stack pointer is bad.
  1335. * R9 contains the saved CR, r13 points to the paca,
  1336. * r10 contains the (bad) kernel stack pointer,
  1337. * r11 and r12 contain the saved SRR0 and SRR1.
  1338. * We switch to using an emergency stack, save the registers there,
  1339. * and call kernel_bad_stack(), which panics.
  1340. */
  1341. bad_stack:
  1342. ld r1,PACAEMERGSP(r13)
  1343. subi r1,r1,64+INT_FRAME_SIZE
  1344. std r9,_CCR(r1)
  1345. std r10,GPR1(r1)
  1346. std r11,_NIP(r1)
  1347. std r12,_MSR(r1)
  1348. mfspr r11,SPRN_DAR
  1349. mfspr r12,SPRN_DSISR
  1350. std r11,_DAR(r1)
  1351. std r12,_DSISR(r1)
  1352. mflr r10
  1353. mfctr r11
  1354. mfxer r12
  1355. std r10,_LINK(r1)
  1356. std r11,_CTR(r1)
  1357. std r12,_XER(r1)
  1358. SAVE_GPR(0,r1)
  1359. SAVE_GPR(2,r1)
  1360. ld r10,EX_R3(r3)
  1361. std r10,GPR3(r1)
  1362. SAVE_GPR(4,r1)
  1363. SAVE_4GPRS(5,r1)
  1364. ld r9,EX_R9(r3)
  1365. ld r10,EX_R10(r3)
  1366. SAVE_2GPRS(9,r1)
  1367. ld r9,EX_R11(r3)
  1368. ld r10,EX_R12(r3)
  1369. ld r11,EX_R13(r3)
  1370. std r9,GPR11(r1)
  1371. std r10,GPR12(r1)
  1372. std r11,GPR13(r1)
  1373. BEGIN_FTR_SECTION
  1374. ld r10,EX_CFAR(r3)
  1375. std r10,ORIG_GPR3(r1)
  1376. END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
  1377. SAVE_8GPRS(14,r1)
  1378. SAVE_10GPRS(22,r1)
  1379. lhz r12,PACA_TRAP_SAVE(r13)
  1380. std r12,_TRAP(r1)
  1381. addi r11,r1,INT_FRAME_SIZE
  1382. std r11,0(r1)
  1383. li r12,0
  1384. std r12,0(r11)
  1385. ld r2,PACATOC(r13)
  1386. ld r11,exception_marker@toc(r2)
  1387. std r12,RESULT(r1)
  1388. std r11,STACK_FRAME_OVERHEAD-16(r1)
  1389. 1: addi r3,r1,STACK_FRAME_OVERHEAD
  1390. bl kernel_bad_stack
  1391. b 1b
  1392. /*
  1393. * Called from arch_local_irq_enable when an interrupt needs
  1394. * to be resent. r3 contains 0x500, 0x900, 0xa00 or 0xe80 to indicate
  1395. * which kind of interrupt. MSR:EE is already off. We generate a
  1396. * stackframe like if a real interrupt had happened.
  1397. *
  1398. * Note: While MSR:EE is off, we need to make sure that _MSR
  1399. * in the generated frame has EE set to 1 or the exception
  1400. * handler will not properly re-enable them.
  1401. */
  1402. _GLOBAL(__replay_interrupt)
  1403. /* We are going to jump to the exception common code which
  1404. * will retrieve various register values from the PACA which
  1405. * we don't give a damn about, so we don't bother storing them.
  1406. */
  1407. mfmsr r12
  1408. mflr r11
  1409. mfcr r9
  1410. ori r12,r12,MSR_EE
  1411. cmpwi r3,0x900
  1412. beq decrementer_common
  1413. cmpwi r3,0x500
  1414. beq hardware_interrupt_common
  1415. BEGIN_FTR_SECTION
  1416. cmpwi r3,0xe80
  1417. beq h_doorbell_common
  1418. cmpwi r3,0xea0
  1419. beq h_virt_irq_common
  1420. cmpwi r3,0xe60
  1421. beq hmi_exception_common
  1422. FTR_SECTION_ELSE
  1423. cmpwi r3,0xa00
  1424. beq doorbell_super_common
  1425. ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
  1426. blr