mce_power.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. /*
  2. * Machine check exception handling CPU-side for power7 and power8
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. *
  18. * Copyright 2013 IBM Corporation
  19. * Author: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
  20. */
  21. #undef DEBUG
  22. #define pr_fmt(fmt) "mce_power: " fmt
  23. #include <linux/types.h>
  24. #include <linux/ptrace.h>
  25. #include <asm/mmu.h>
  26. #include <asm/mce.h>
  27. #include <asm/machdep.h>
  28. static void flush_tlb_206(unsigned int num_sets, unsigned int action)
  29. {
  30. unsigned long rb;
  31. unsigned int i;
  32. switch (action) {
  33. case TLB_INVAL_SCOPE_GLOBAL:
  34. rb = TLBIEL_INVAL_SET;
  35. break;
  36. case TLB_INVAL_SCOPE_LPID:
  37. rb = TLBIEL_INVAL_SET_LPID;
  38. break;
  39. default:
  40. BUG();
  41. break;
  42. }
  43. asm volatile("ptesync" : : : "memory");
  44. for (i = 0; i < num_sets; i++) {
  45. asm volatile("tlbiel %0" : : "r" (rb));
  46. rb += 1 << TLBIEL_INVAL_SET_SHIFT;
  47. }
  48. asm volatile("ptesync" : : : "memory");
  49. }
  50. /*
  51. * Generic routines to flush TLB on POWER processors. These routines
  52. * are used as flush_tlb hook in the cpu_spec.
  53. *
  54. * action => TLB_INVAL_SCOPE_GLOBAL: Invalidate all TLBs.
  55. * TLB_INVAL_SCOPE_LPID: Invalidate TLB for current LPID.
  56. */
  57. void __flush_tlb_power7(unsigned int action)
  58. {
  59. flush_tlb_206(POWER7_TLB_SETS, action);
  60. }
  61. void __flush_tlb_power8(unsigned int action)
  62. {
  63. flush_tlb_206(POWER8_TLB_SETS, action);
  64. }
  65. void __flush_tlb_power9(unsigned int action)
  66. {
  67. if (radix_enabled())
  68. flush_tlb_206(POWER9_TLB_SETS_RADIX, action);
  69. flush_tlb_206(POWER9_TLB_SETS_HASH, action);
  70. }
  71. /* flush SLBs and reload */
  72. #ifdef CONFIG_PPC_STD_MMU_64
  73. static void flush_and_reload_slb(void)
  74. {
  75. struct slb_shadow *slb;
  76. unsigned long i, n;
  77. /* Invalidate all SLBs */
  78. asm volatile("slbmte %0,%0; slbia" : : "r" (0));
  79. #ifdef CONFIG_KVM_BOOK3S_HANDLER
  80. /*
  81. * If machine check is hit when in guest or in transition, we will
  82. * only flush the SLBs and continue.
  83. */
  84. if (get_paca()->kvm_hstate.in_guest)
  85. return;
  86. #endif
  87. /* For host kernel, reload the SLBs from shadow SLB buffer. */
  88. slb = get_slb_shadow();
  89. if (!slb)
  90. return;
  91. n = min_t(u32, be32_to_cpu(slb->persistent), SLB_MIN_SIZE);
  92. /* Load up the SLB entries from shadow SLB */
  93. for (i = 0; i < n; i++) {
  94. unsigned long rb = be64_to_cpu(slb->save_area[i].esid);
  95. unsigned long rs = be64_to_cpu(slb->save_area[i].vsid);
  96. rb = (rb & ~0xFFFul) | i;
  97. asm volatile("slbmte %0,%1" : : "r" (rs), "r" (rb));
  98. }
  99. }
  100. #endif
  101. static void flush_erat(void)
  102. {
  103. asm volatile(PPC_INVALIDATE_ERAT : : :"memory");
  104. }
  105. #define MCE_FLUSH_SLB 1
  106. #define MCE_FLUSH_TLB 2
  107. #define MCE_FLUSH_ERAT 3
  108. static int mce_flush(int what)
  109. {
  110. #ifdef CONFIG_PPC_STD_MMU_64
  111. if (what == MCE_FLUSH_SLB) {
  112. flush_and_reload_slb();
  113. return 1;
  114. }
  115. #endif
  116. if (what == MCE_FLUSH_ERAT) {
  117. flush_erat();
  118. return 1;
  119. }
  120. if (what == MCE_FLUSH_TLB) {
  121. if (cur_cpu_spec && cur_cpu_spec->flush_tlb) {
  122. cur_cpu_spec->flush_tlb(TLB_INVAL_SCOPE_GLOBAL);
  123. return 1;
  124. }
  125. }
  126. return 0;
  127. }
  128. static int mce_handle_flush_derrors(uint64_t dsisr, uint64_t slb, uint64_t tlb, uint64_t erat)
  129. {
  130. if ((dsisr & slb) && mce_flush(MCE_FLUSH_SLB))
  131. dsisr &= ~slb;
  132. if ((dsisr & erat) && mce_flush(MCE_FLUSH_ERAT))
  133. dsisr &= ~erat;
  134. if ((dsisr & tlb) && mce_flush(MCE_FLUSH_TLB))
  135. dsisr &= ~tlb;
  136. /* Any other errors we don't understand? */
  137. if (dsisr)
  138. return 0;
  139. return 1;
  140. }
  141. static long mce_handle_derror(uint64_t dsisr, uint64_t slb_error_bits)
  142. {
  143. long handled = 1;
  144. /*
  145. * flush and reload SLBs for SLB errors and flush TLBs for TLB errors.
  146. * reset the error bits whenever we handle them so that at the end
  147. * we can check whether we handled all of them or not.
  148. * */
  149. #ifdef CONFIG_PPC_STD_MMU_64
  150. if (dsisr & slb_error_bits) {
  151. flush_and_reload_slb();
  152. /* reset error bits */
  153. dsisr &= ~(slb_error_bits);
  154. }
  155. if (dsisr & P7_DSISR_MC_TLB_MULTIHIT_MFTLB) {
  156. if (cur_cpu_spec && cur_cpu_spec->flush_tlb)
  157. cur_cpu_spec->flush_tlb(TLB_INVAL_SCOPE_GLOBAL);
  158. /* reset error bits */
  159. dsisr &= ~P7_DSISR_MC_TLB_MULTIHIT_MFTLB;
  160. }
  161. #endif
  162. /* Any other errors we don't understand? */
  163. if (dsisr & 0xffffffffUL)
  164. handled = 0;
  165. return handled;
  166. }
  167. static long mce_handle_derror_p7(uint64_t dsisr)
  168. {
  169. return mce_handle_derror(dsisr, P7_DSISR_MC_SLB_ERRORS);
  170. }
  171. static long mce_handle_common_ierror(uint64_t srr1)
  172. {
  173. long handled = 0;
  174. switch (P7_SRR1_MC_IFETCH(srr1)) {
  175. case 0:
  176. break;
  177. #ifdef CONFIG_PPC_STD_MMU_64
  178. case P7_SRR1_MC_IFETCH_SLB_PARITY:
  179. case P7_SRR1_MC_IFETCH_SLB_MULTIHIT:
  180. /* flush and reload SLBs for SLB errors. */
  181. flush_and_reload_slb();
  182. handled = 1;
  183. break;
  184. case P7_SRR1_MC_IFETCH_TLB_MULTIHIT:
  185. if (cur_cpu_spec && cur_cpu_spec->flush_tlb) {
  186. cur_cpu_spec->flush_tlb(TLB_INVAL_SCOPE_GLOBAL);
  187. handled = 1;
  188. }
  189. break;
  190. #endif
  191. default:
  192. break;
  193. }
  194. return handled;
  195. }
  196. static long mce_handle_ierror_p7(uint64_t srr1)
  197. {
  198. long handled = 0;
  199. handled = mce_handle_common_ierror(srr1);
  200. #ifdef CONFIG_PPC_STD_MMU_64
  201. if (P7_SRR1_MC_IFETCH(srr1) == P7_SRR1_MC_IFETCH_SLB_BOTH) {
  202. flush_and_reload_slb();
  203. handled = 1;
  204. }
  205. #endif
  206. return handled;
  207. }
  208. static void mce_get_common_ierror(struct mce_error_info *mce_err, uint64_t srr1)
  209. {
  210. switch (P7_SRR1_MC_IFETCH(srr1)) {
  211. case P7_SRR1_MC_IFETCH_SLB_PARITY:
  212. mce_err->error_type = MCE_ERROR_TYPE_SLB;
  213. mce_err->u.slb_error_type = MCE_SLB_ERROR_PARITY;
  214. break;
  215. case P7_SRR1_MC_IFETCH_SLB_MULTIHIT:
  216. mce_err->error_type = MCE_ERROR_TYPE_SLB;
  217. mce_err->u.slb_error_type = MCE_SLB_ERROR_MULTIHIT;
  218. break;
  219. case P7_SRR1_MC_IFETCH_TLB_MULTIHIT:
  220. mce_err->error_type = MCE_ERROR_TYPE_TLB;
  221. mce_err->u.tlb_error_type = MCE_TLB_ERROR_MULTIHIT;
  222. break;
  223. case P7_SRR1_MC_IFETCH_UE:
  224. case P7_SRR1_MC_IFETCH_UE_IFU_INTERNAL:
  225. mce_err->error_type = MCE_ERROR_TYPE_UE;
  226. mce_err->u.ue_error_type = MCE_UE_ERROR_IFETCH;
  227. break;
  228. case P7_SRR1_MC_IFETCH_UE_TLB_RELOAD:
  229. mce_err->error_type = MCE_ERROR_TYPE_UE;
  230. mce_err->u.ue_error_type =
  231. MCE_UE_ERROR_PAGE_TABLE_WALK_IFETCH;
  232. break;
  233. }
  234. }
  235. static void mce_get_ierror_p7(struct mce_error_info *mce_err, uint64_t srr1)
  236. {
  237. mce_get_common_ierror(mce_err, srr1);
  238. if (P7_SRR1_MC_IFETCH(srr1) == P7_SRR1_MC_IFETCH_SLB_BOTH) {
  239. mce_err->error_type = MCE_ERROR_TYPE_SLB;
  240. mce_err->u.slb_error_type = MCE_SLB_ERROR_INDETERMINATE;
  241. }
  242. }
  243. static void mce_get_derror_p7(struct mce_error_info *mce_err, uint64_t dsisr)
  244. {
  245. if (dsisr & P7_DSISR_MC_UE) {
  246. mce_err->error_type = MCE_ERROR_TYPE_UE;
  247. mce_err->u.ue_error_type = MCE_UE_ERROR_LOAD_STORE;
  248. } else if (dsisr & P7_DSISR_MC_UE_TABLEWALK) {
  249. mce_err->error_type = MCE_ERROR_TYPE_UE;
  250. mce_err->u.ue_error_type =
  251. MCE_UE_ERROR_PAGE_TABLE_WALK_LOAD_STORE;
  252. } else if (dsisr & P7_DSISR_MC_ERAT_MULTIHIT) {
  253. mce_err->error_type = MCE_ERROR_TYPE_ERAT;
  254. mce_err->u.erat_error_type = MCE_ERAT_ERROR_MULTIHIT;
  255. } else if (dsisr & P7_DSISR_MC_SLB_MULTIHIT) {
  256. mce_err->error_type = MCE_ERROR_TYPE_SLB;
  257. mce_err->u.slb_error_type = MCE_SLB_ERROR_MULTIHIT;
  258. } else if (dsisr & P7_DSISR_MC_SLB_PARITY_MFSLB) {
  259. mce_err->error_type = MCE_ERROR_TYPE_SLB;
  260. mce_err->u.slb_error_type = MCE_SLB_ERROR_PARITY;
  261. } else if (dsisr & P7_DSISR_MC_TLB_MULTIHIT_MFTLB) {
  262. mce_err->error_type = MCE_ERROR_TYPE_TLB;
  263. mce_err->u.tlb_error_type = MCE_TLB_ERROR_MULTIHIT;
  264. } else if (dsisr & P7_DSISR_MC_SLB_MULTIHIT_PARITY) {
  265. mce_err->error_type = MCE_ERROR_TYPE_SLB;
  266. mce_err->u.slb_error_type = MCE_SLB_ERROR_INDETERMINATE;
  267. }
  268. }
  269. static long mce_handle_ue_error(struct pt_regs *regs)
  270. {
  271. long handled = 0;
  272. /*
  273. * On specific SCOM read via MMIO we may get a machine check
  274. * exception with SRR0 pointing inside opal. If that is the
  275. * case OPAL may have recovery address to re-read SCOM data in
  276. * different way and hence we can recover from this MC.
  277. */
  278. if (ppc_md.mce_check_early_recovery) {
  279. if (ppc_md.mce_check_early_recovery(regs))
  280. handled = 1;
  281. }
  282. return handled;
  283. }
  284. long __machine_check_early_realmode_p7(struct pt_regs *regs)
  285. {
  286. uint64_t srr1, nip, addr;
  287. long handled = 1;
  288. struct mce_error_info mce_error_info = { 0 };
  289. mce_error_info.severity = MCE_SEV_ERROR_SYNC;
  290. mce_error_info.initiator = MCE_INITIATOR_CPU;
  291. srr1 = regs->msr;
  292. nip = regs->nip;
  293. /*
  294. * Handle memory errors depending whether this was a load/store or
  295. * ifetch exception. Also, populate the mce error_type and
  296. * type-specific error_type from either SRR1 or DSISR, depending
  297. * whether this was a load/store or ifetch exception
  298. */
  299. if (P7_SRR1_MC_LOADSTORE(srr1)) {
  300. handled = mce_handle_derror_p7(regs->dsisr);
  301. mce_get_derror_p7(&mce_error_info, regs->dsisr);
  302. addr = regs->dar;
  303. } else {
  304. handled = mce_handle_ierror_p7(srr1);
  305. mce_get_ierror_p7(&mce_error_info, srr1);
  306. addr = regs->nip;
  307. }
  308. /* Handle UE error. */
  309. if (mce_error_info.error_type == MCE_ERROR_TYPE_UE)
  310. handled = mce_handle_ue_error(regs);
  311. save_mce_event(regs, handled, &mce_error_info, nip, addr);
  312. return handled;
  313. }
  314. static void mce_get_ierror_p8(struct mce_error_info *mce_err, uint64_t srr1)
  315. {
  316. mce_get_common_ierror(mce_err, srr1);
  317. if (P7_SRR1_MC_IFETCH(srr1) == P8_SRR1_MC_IFETCH_ERAT_MULTIHIT) {
  318. mce_err->error_type = MCE_ERROR_TYPE_ERAT;
  319. mce_err->u.erat_error_type = MCE_ERAT_ERROR_MULTIHIT;
  320. }
  321. }
  322. static void mce_get_derror_p8(struct mce_error_info *mce_err, uint64_t dsisr)
  323. {
  324. mce_get_derror_p7(mce_err, dsisr);
  325. if (dsisr & P8_DSISR_MC_ERAT_MULTIHIT_SEC) {
  326. mce_err->error_type = MCE_ERROR_TYPE_ERAT;
  327. mce_err->u.erat_error_type = MCE_ERAT_ERROR_MULTIHIT;
  328. }
  329. }
  330. static long mce_handle_ierror_p8(uint64_t srr1)
  331. {
  332. long handled = 0;
  333. handled = mce_handle_common_ierror(srr1);
  334. #ifdef CONFIG_PPC_STD_MMU_64
  335. if (P7_SRR1_MC_IFETCH(srr1) == P8_SRR1_MC_IFETCH_ERAT_MULTIHIT) {
  336. flush_and_reload_slb();
  337. handled = 1;
  338. }
  339. #endif
  340. return handled;
  341. }
  342. static long mce_handle_derror_p8(uint64_t dsisr)
  343. {
  344. return mce_handle_derror(dsisr, P8_DSISR_MC_SLB_ERRORS);
  345. }
  346. long __machine_check_early_realmode_p8(struct pt_regs *regs)
  347. {
  348. uint64_t srr1, nip, addr;
  349. long handled = 1;
  350. struct mce_error_info mce_error_info = { 0 };
  351. mce_error_info.severity = MCE_SEV_ERROR_SYNC;
  352. mce_error_info.initiator = MCE_INITIATOR_CPU;
  353. srr1 = regs->msr;
  354. nip = regs->nip;
  355. if (P7_SRR1_MC_LOADSTORE(srr1)) {
  356. handled = mce_handle_derror_p8(regs->dsisr);
  357. mce_get_derror_p8(&mce_error_info, regs->dsisr);
  358. addr = regs->dar;
  359. } else {
  360. handled = mce_handle_ierror_p8(srr1);
  361. mce_get_ierror_p8(&mce_error_info, srr1);
  362. addr = regs->nip;
  363. }
  364. /* Handle UE error. */
  365. if (mce_error_info.error_type == MCE_ERROR_TYPE_UE)
  366. handled = mce_handle_ue_error(regs);
  367. save_mce_event(regs, handled, &mce_error_info, nip, addr);
  368. return handled;
  369. }
  370. static int mce_handle_derror_p9(struct pt_regs *regs)
  371. {
  372. uint64_t dsisr = regs->dsisr;
  373. return mce_handle_flush_derrors(dsisr,
  374. P9_DSISR_MC_SLB_PARITY_MFSLB |
  375. P9_DSISR_MC_SLB_MULTIHIT_MFSLB,
  376. P9_DSISR_MC_TLB_MULTIHIT_MFTLB,
  377. P9_DSISR_MC_ERAT_MULTIHIT);
  378. }
  379. static int mce_handle_ierror_p9(struct pt_regs *regs)
  380. {
  381. uint64_t srr1 = regs->msr;
  382. switch (P9_SRR1_MC_IFETCH(srr1)) {
  383. case P9_SRR1_MC_IFETCH_SLB_PARITY:
  384. case P9_SRR1_MC_IFETCH_SLB_MULTIHIT:
  385. return mce_flush(MCE_FLUSH_SLB);
  386. case P9_SRR1_MC_IFETCH_TLB_MULTIHIT:
  387. return mce_flush(MCE_FLUSH_TLB);
  388. case P9_SRR1_MC_IFETCH_ERAT_MULTIHIT:
  389. return mce_flush(MCE_FLUSH_ERAT);
  390. default:
  391. return 0;
  392. }
  393. }
  394. static void mce_get_derror_p9(struct pt_regs *regs,
  395. struct mce_error_info *mce_err, uint64_t *addr)
  396. {
  397. uint64_t dsisr = regs->dsisr;
  398. mce_err->severity = MCE_SEV_ERROR_SYNC;
  399. mce_err->initiator = MCE_INITIATOR_CPU;
  400. if (dsisr & P9_DSISR_MC_USER_TLBIE)
  401. *addr = regs->nip;
  402. else
  403. *addr = regs->dar;
  404. if (dsisr & P9_DSISR_MC_UE) {
  405. mce_err->error_type = MCE_ERROR_TYPE_UE;
  406. mce_err->u.ue_error_type = MCE_UE_ERROR_LOAD_STORE;
  407. } else if (dsisr & P9_DSISR_MC_UE_TABLEWALK) {
  408. mce_err->error_type = MCE_ERROR_TYPE_UE;
  409. mce_err->u.ue_error_type = MCE_UE_ERROR_PAGE_TABLE_WALK_LOAD_STORE;
  410. } else if (dsisr & P9_DSISR_MC_LINK_LOAD_TIMEOUT) {
  411. mce_err->error_type = MCE_ERROR_TYPE_LINK;
  412. mce_err->u.link_error_type = MCE_LINK_ERROR_LOAD_TIMEOUT;
  413. } else if (dsisr & P9_DSISR_MC_LINK_TABLEWALK_TIMEOUT) {
  414. mce_err->error_type = MCE_ERROR_TYPE_LINK;
  415. mce_err->u.link_error_type = MCE_LINK_ERROR_PAGE_TABLE_WALK_LOAD_STORE_TIMEOUT;
  416. } else if (dsisr & P9_DSISR_MC_ERAT_MULTIHIT) {
  417. mce_err->error_type = MCE_ERROR_TYPE_ERAT;
  418. mce_err->u.erat_error_type = MCE_ERAT_ERROR_MULTIHIT;
  419. } else if (dsisr & P9_DSISR_MC_TLB_MULTIHIT_MFTLB) {
  420. mce_err->error_type = MCE_ERROR_TYPE_TLB;
  421. mce_err->u.tlb_error_type = MCE_TLB_ERROR_MULTIHIT;
  422. } else if (dsisr & P9_DSISR_MC_USER_TLBIE) {
  423. mce_err->error_type = MCE_ERROR_TYPE_USER;
  424. mce_err->u.user_error_type = MCE_USER_ERROR_TLBIE;
  425. } else if (dsisr & P9_DSISR_MC_SLB_PARITY_MFSLB) {
  426. mce_err->error_type = MCE_ERROR_TYPE_SLB;
  427. mce_err->u.slb_error_type = MCE_SLB_ERROR_PARITY;
  428. } else if (dsisr & P9_DSISR_MC_SLB_MULTIHIT_MFSLB) {
  429. mce_err->error_type = MCE_ERROR_TYPE_SLB;
  430. mce_err->u.slb_error_type = MCE_SLB_ERROR_MULTIHIT;
  431. } else if (dsisr & P9_DSISR_MC_RA_LOAD) {
  432. mce_err->error_type = MCE_ERROR_TYPE_RA;
  433. mce_err->u.ra_error_type = MCE_RA_ERROR_LOAD;
  434. } else if (dsisr & P9_DSISR_MC_RA_TABLEWALK) {
  435. mce_err->error_type = MCE_ERROR_TYPE_RA;
  436. mce_err->u.ra_error_type = MCE_RA_ERROR_PAGE_TABLE_WALK_LOAD_STORE;
  437. } else if (dsisr & P9_DSISR_MC_RA_TABLEWALK_FOREIGN) {
  438. mce_err->error_type = MCE_ERROR_TYPE_RA;
  439. mce_err->u.ra_error_type = MCE_RA_ERROR_PAGE_TABLE_WALK_LOAD_STORE_FOREIGN;
  440. } else if (dsisr & P9_DSISR_MC_RA_FOREIGN) {
  441. mce_err->error_type = MCE_ERROR_TYPE_RA;
  442. mce_err->u.ra_error_type = MCE_RA_ERROR_LOAD_STORE_FOREIGN;
  443. }
  444. }
  445. static void mce_get_ierror_p9(struct pt_regs *regs,
  446. struct mce_error_info *mce_err, uint64_t *addr)
  447. {
  448. uint64_t srr1 = regs->msr;
  449. switch (P9_SRR1_MC_IFETCH(srr1)) {
  450. case P9_SRR1_MC_IFETCH_RA_ASYNC_STORE:
  451. case P9_SRR1_MC_IFETCH_LINK_ASYNC_STORE_TIMEOUT:
  452. mce_err->severity = MCE_SEV_FATAL;
  453. break;
  454. default:
  455. mce_err->severity = MCE_SEV_ERROR_SYNC;
  456. break;
  457. }
  458. mce_err->initiator = MCE_INITIATOR_CPU;
  459. *addr = regs->nip;
  460. switch (P9_SRR1_MC_IFETCH(srr1)) {
  461. case P9_SRR1_MC_IFETCH_UE:
  462. mce_err->error_type = MCE_ERROR_TYPE_UE;
  463. mce_err->u.ue_error_type = MCE_UE_ERROR_IFETCH;
  464. break;
  465. case P9_SRR1_MC_IFETCH_SLB_PARITY:
  466. mce_err->error_type = MCE_ERROR_TYPE_SLB;
  467. mce_err->u.slb_error_type = MCE_SLB_ERROR_PARITY;
  468. break;
  469. case P9_SRR1_MC_IFETCH_SLB_MULTIHIT:
  470. mce_err->error_type = MCE_ERROR_TYPE_SLB;
  471. mce_err->u.slb_error_type = MCE_SLB_ERROR_MULTIHIT;
  472. break;
  473. case P9_SRR1_MC_IFETCH_ERAT_MULTIHIT:
  474. mce_err->error_type = MCE_ERROR_TYPE_ERAT;
  475. mce_err->u.erat_error_type = MCE_ERAT_ERROR_MULTIHIT;
  476. break;
  477. case P9_SRR1_MC_IFETCH_TLB_MULTIHIT:
  478. mce_err->error_type = MCE_ERROR_TYPE_TLB;
  479. mce_err->u.tlb_error_type = MCE_TLB_ERROR_MULTIHIT;
  480. break;
  481. case P9_SRR1_MC_IFETCH_UE_TLB_RELOAD:
  482. mce_err->error_type = MCE_ERROR_TYPE_UE;
  483. mce_err->u.ue_error_type = MCE_UE_ERROR_PAGE_TABLE_WALK_IFETCH;
  484. break;
  485. case P9_SRR1_MC_IFETCH_LINK_TIMEOUT:
  486. mce_err->error_type = MCE_ERROR_TYPE_LINK;
  487. mce_err->u.link_error_type = MCE_LINK_ERROR_IFETCH_TIMEOUT;
  488. break;
  489. case P9_SRR1_MC_IFETCH_LINK_TABLEWALK_TIMEOUT:
  490. mce_err->error_type = MCE_ERROR_TYPE_LINK;
  491. mce_err->u.link_error_type = MCE_LINK_ERROR_PAGE_TABLE_WALK_IFETCH_TIMEOUT;
  492. break;
  493. case P9_SRR1_MC_IFETCH_RA:
  494. mce_err->error_type = MCE_ERROR_TYPE_RA;
  495. mce_err->u.ra_error_type = MCE_RA_ERROR_IFETCH;
  496. break;
  497. case P9_SRR1_MC_IFETCH_RA_TABLEWALK:
  498. mce_err->error_type = MCE_ERROR_TYPE_RA;
  499. mce_err->u.ra_error_type = MCE_RA_ERROR_PAGE_TABLE_WALK_IFETCH;
  500. break;
  501. case P9_SRR1_MC_IFETCH_RA_ASYNC_STORE:
  502. mce_err->error_type = MCE_ERROR_TYPE_RA;
  503. mce_err->u.ra_error_type = MCE_RA_ERROR_STORE;
  504. break;
  505. case P9_SRR1_MC_IFETCH_LINK_ASYNC_STORE_TIMEOUT:
  506. mce_err->error_type = MCE_ERROR_TYPE_LINK;
  507. mce_err->u.link_error_type = MCE_LINK_ERROR_STORE_TIMEOUT;
  508. break;
  509. case P9_SRR1_MC_IFETCH_RA_TABLEWALK_FOREIGN:
  510. mce_err->error_type = MCE_ERROR_TYPE_RA;
  511. mce_err->u.ra_error_type = MCE_RA_ERROR_PAGE_TABLE_WALK_IFETCH_FOREIGN;
  512. break;
  513. default:
  514. break;
  515. }
  516. }
  517. long __machine_check_early_realmode_p9(struct pt_regs *regs)
  518. {
  519. uint64_t nip, addr;
  520. long handled;
  521. struct mce_error_info mce_error_info = { 0 };
  522. nip = regs->nip;
  523. if (P9_SRR1_MC_LOADSTORE(regs->msr)) {
  524. handled = mce_handle_derror_p9(regs);
  525. mce_get_derror_p9(regs, &mce_error_info, &addr);
  526. } else {
  527. handled = mce_handle_ierror_p9(regs);
  528. mce_get_ierror_p9(regs, &mce_error_info, &addr);
  529. }
  530. /* Handle UE error. */
  531. if (mce_error_info.error_type == MCE_ERROR_TYPE_UE)
  532. handled = mce_handle_ue_error(regs);
  533. save_mce_event(regs, handled, &mce_error_info, nip, addr);
  534. return handled;
  535. }