mca_drv.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. /*
  2. * File: mca_drv.c
  3. * Purpose: Generic MCA handling layer
  4. *
  5. * Copyright (C) 2004 FUJITSU LIMITED
  6. * Copyright (C) Hidetoshi Seto (seto.hidetoshi@jp.fujitsu.com)
  7. * Copyright (C) 2005 Silicon Graphics, Inc
  8. * Copyright (C) 2005 Keith Owens <kaos@sgi.com>
  9. */
  10. #include <linux/config.h>
  11. #include <linux/types.h>
  12. #include <linux/init.h>
  13. #include <linux/sched.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/irq.h>
  16. #include <linux/kallsyms.h>
  17. #include <linux/smp_lock.h>
  18. #include <linux/bootmem.h>
  19. #include <linux/acpi.h>
  20. #include <linux/timer.h>
  21. #include <linux/module.h>
  22. #include <linux/kernel.h>
  23. #include <linux/smp.h>
  24. #include <linux/workqueue.h>
  25. #include <linux/mm.h>
  26. #include <asm/delay.h>
  27. #include <asm/machvec.h>
  28. #include <asm/page.h>
  29. #include <asm/ptrace.h>
  30. #include <asm/system.h>
  31. #include <asm/sal.h>
  32. #include <asm/mca.h>
  33. #include <asm/irq.h>
  34. #include <asm/hw_irq.h>
  35. #include "mca_drv.h"
  36. /* max size of SAL error record (default) */
  37. static int sal_rec_max = 10000;
  38. /* from mca_drv_asm.S */
  39. extern void *mca_handler_bhhook(void);
  40. static DEFINE_SPINLOCK(mca_bh_lock);
  41. typedef enum {
  42. MCA_IS_LOCAL = 0,
  43. MCA_IS_GLOBAL = 1
  44. } mca_type_t;
  45. #define MAX_PAGE_ISOLATE 1024
  46. static struct page *page_isolate[MAX_PAGE_ISOLATE];
  47. static int num_page_isolate = 0;
  48. typedef enum {
  49. ISOLATE_NG,
  50. ISOLATE_OK,
  51. ISOLATE_NONE
  52. } isolate_status_t;
  53. /*
  54. * This pool keeps pointers to the section part of SAL error record
  55. */
  56. static struct {
  57. slidx_list_t *buffer; /* section pointer list pool */
  58. int cur_idx; /* Current index of section pointer list pool */
  59. int max_idx; /* Maximum index of section pointer list pool */
  60. } slidx_pool;
  61. /**
  62. * mca_page_isolate - isolate a poisoned page in order not to use it later
  63. * @paddr: poisoned memory location
  64. *
  65. * Return value:
  66. * one of isolate_status_t, ISOLATE_OK/NG/NONE.
  67. */
  68. static isolate_status_t
  69. mca_page_isolate(unsigned long paddr)
  70. {
  71. int i;
  72. struct page *p;
  73. /* whether physical address is valid or not */
  74. if (!ia64_phys_addr_valid(paddr))
  75. return ISOLATE_NONE;
  76. if (!pfn_valid(paddr >> PAGE_SHIFT))
  77. return ISOLATE_NONE;
  78. /* convert physical address to physical page number */
  79. p = pfn_to_page(paddr>>PAGE_SHIFT);
  80. /* check whether a page number have been already registered or not */
  81. for (i = 0; i < num_page_isolate; i++)
  82. if (page_isolate[i] == p)
  83. return ISOLATE_OK; /* already listed */
  84. /* limitation check */
  85. if (num_page_isolate == MAX_PAGE_ISOLATE)
  86. return ISOLATE_NG;
  87. /* kick pages having attribute 'SLAB' or 'Reserved' */
  88. if (PageSlab(p) || PageReserved(p))
  89. return ISOLATE_NG;
  90. /* add attribute 'Reserved' and register the page */
  91. get_page(p);
  92. SetPageReserved(p);
  93. page_isolate[num_page_isolate++] = p;
  94. return ISOLATE_OK;
  95. }
  96. /**
  97. * mca_hanlder_bh - Kill the process which occurred memory read error
  98. * @paddr: poisoned address received from MCA Handler
  99. */
  100. void
  101. mca_handler_bh(unsigned long paddr)
  102. {
  103. printk(KERN_DEBUG "OS_MCA: process [pid: %d](%s) encounters MCA.\n",
  104. current->pid, current->comm);
  105. spin_lock(&mca_bh_lock);
  106. switch (mca_page_isolate(paddr)) {
  107. case ISOLATE_OK:
  108. printk(KERN_DEBUG "Page isolation: ( %lx ) success.\n", paddr);
  109. break;
  110. case ISOLATE_NG:
  111. printk(KERN_DEBUG "Page isolation: ( %lx ) failure.\n", paddr);
  112. break;
  113. default:
  114. break;
  115. }
  116. spin_unlock(&mca_bh_lock);
  117. /* This process is about to be killed itself */
  118. do_exit(SIGKILL);
  119. }
  120. /**
  121. * mca_make_peidx - Make index of processor error section
  122. * @slpi: pointer to record of processor error section
  123. * @peidx: pointer to index of processor error section
  124. */
  125. static void
  126. mca_make_peidx(sal_log_processor_info_t *slpi, peidx_table_t *peidx)
  127. {
  128. /*
  129. * calculate the start address of
  130. * "struct cpuid_info" and "sal_processor_static_info_t".
  131. */
  132. u64 total_check_num = slpi->valid.num_cache_check
  133. + slpi->valid.num_tlb_check
  134. + slpi->valid.num_bus_check
  135. + slpi->valid.num_reg_file_check
  136. + slpi->valid.num_ms_check;
  137. u64 head_size = sizeof(sal_log_mod_error_info_t) * total_check_num
  138. + sizeof(sal_log_processor_info_t);
  139. u64 mid_size = slpi->valid.cpuid_info * sizeof(struct sal_cpuid_info);
  140. peidx_head(peidx) = slpi;
  141. peidx_mid(peidx) = (struct sal_cpuid_info *)
  142. (slpi->valid.cpuid_info ? ((char*)slpi + head_size) : NULL);
  143. peidx_bottom(peidx) = (sal_processor_static_info_t *)
  144. (slpi->valid.psi_static_struct ?
  145. ((char*)slpi + head_size + mid_size) : NULL);
  146. }
  147. /**
  148. * mca_make_slidx - Make index of SAL error record
  149. * @buffer: pointer to SAL error record
  150. * @slidx: pointer to index of SAL error record
  151. *
  152. * Return value:
  153. * 1 if record has platform error / 0 if not
  154. */
  155. #define LOG_INDEX_ADD_SECT_PTR(sect, ptr) \
  156. {slidx_list_t *hl = &slidx_pool.buffer[slidx_pool.cur_idx]; \
  157. hl->hdr = ptr; \
  158. list_add(&hl->list, &(sect)); \
  159. slidx_pool.cur_idx = (slidx_pool.cur_idx + 1)%slidx_pool.max_idx; }
  160. static int
  161. mca_make_slidx(void *buffer, slidx_table_t *slidx)
  162. {
  163. int platform_err = 0;
  164. int record_len = ((sal_log_record_header_t*)buffer)->len;
  165. u32 ercd_pos;
  166. int sects;
  167. sal_log_section_hdr_t *sp;
  168. /*
  169. * Initialize index referring current record
  170. */
  171. INIT_LIST_HEAD(&(slidx->proc_err));
  172. INIT_LIST_HEAD(&(slidx->mem_dev_err));
  173. INIT_LIST_HEAD(&(slidx->sel_dev_err));
  174. INIT_LIST_HEAD(&(slidx->pci_bus_err));
  175. INIT_LIST_HEAD(&(slidx->smbios_dev_err));
  176. INIT_LIST_HEAD(&(slidx->pci_comp_err));
  177. INIT_LIST_HEAD(&(slidx->plat_specific_err));
  178. INIT_LIST_HEAD(&(slidx->host_ctlr_err));
  179. INIT_LIST_HEAD(&(slidx->plat_bus_err));
  180. INIT_LIST_HEAD(&(slidx->unsupported));
  181. /*
  182. * Extract a Record Header
  183. */
  184. slidx->header = buffer;
  185. /*
  186. * Extract each section records
  187. * (arranged from "int ia64_log_platform_info_print()")
  188. */
  189. for (ercd_pos = sizeof(sal_log_record_header_t), sects = 0;
  190. ercd_pos < record_len; ercd_pos += sp->len, sects++) {
  191. sp = (sal_log_section_hdr_t *)((char*)buffer + ercd_pos);
  192. if (!efi_guidcmp(sp->guid, SAL_PROC_DEV_ERR_SECT_GUID)) {
  193. LOG_INDEX_ADD_SECT_PTR(slidx->proc_err, sp);
  194. } else if (!efi_guidcmp(sp->guid,
  195. SAL_PLAT_MEM_DEV_ERR_SECT_GUID)) {
  196. platform_err = 1;
  197. LOG_INDEX_ADD_SECT_PTR(slidx->mem_dev_err, sp);
  198. } else if (!efi_guidcmp(sp->guid,
  199. SAL_PLAT_SEL_DEV_ERR_SECT_GUID)) {
  200. platform_err = 1;
  201. LOG_INDEX_ADD_SECT_PTR(slidx->sel_dev_err, sp);
  202. } else if (!efi_guidcmp(sp->guid,
  203. SAL_PLAT_PCI_BUS_ERR_SECT_GUID)) {
  204. platform_err = 1;
  205. LOG_INDEX_ADD_SECT_PTR(slidx->pci_bus_err, sp);
  206. } else if (!efi_guidcmp(sp->guid,
  207. SAL_PLAT_SMBIOS_DEV_ERR_SECT_GUID)) {
  208. platform_err = 1;
  209. LOG_INDEX_ADD_SECT_PTR(slidx->smbios_dev_err, sp);
  210. } else if (!efi_guidcmp(sp->guid,
  211. SAL_PLAT_PCI_COMP_ERR_SECT_GUID)) {
  212. platform_err = 1;
  213. LOG_INDEX_ADD_SECT_PTR(slidx->pci_comp_err, sp);
  214. } else if (!efi_guidcmp(sp->guid,
  215. SAL_PLAT_SPECIFIC_ERR_SECT_GUID)) {
  216. platform_err = 1;
  217. LOG_INDEX_ADD_SECT_PTR(slidx->plat_specific_err, sp);
  218. } else if (!efi_guidcmp(sp->guid,
  219. SAL_PLAT_HOST_CTLR_ERR_SECT_GUID)) {
  220. platform_err = 1;
  221. LOG_INDEX_ADD_SECT_PTR(slidx->host_ctlr_err, sp);
  222. } else if (!efi_guidcmp(sp->guid,
  223. SAL_PLAT_BUS_ERR_SECT_GUID)) {
  224. platform_err = 1;
  225. LOG_INDEX_ADD_SECT_PTR(slidx->plat_bus_err, sp);
  226. } else {
  227. LOG_INDEX_ADD_SECT_PTR(slidx->unsupported, sp);
  228. }
  229. }
  230. slidx->n_sections = sects;
  231. return platform_err;
  232. }
  233. /**
  234. * init_record_index_pools - Initialize pool of lists for SAL record index
  235. *
  236. * Return value:
  237. * 0 on Success / -ENOMEM on Failure
  238. */
  239. static int
  240. init_record_index_pools(void)
  241. {
  242. int i;
  243. int rec_max_size; /* Maximum size of SAL error records */
  244. int sect_min_size; /* Minimum size of SAL error sections */
  245. /* minimum size table of each section */
  246. static int sal_log_sect_min_sizes[] = {
  247. sizeof(sal_log_processor_info_t)
  248. + sizeof(sal_processor_static_info_t),
  249. sizeof(sal_log_mem_dev_err_info_t),
  250. sizeof(sal_log_sel_dev_err_info_t),
  251. sizeof(sal_log_pci_bus_err_info_t),
  252. sizeof(sal_log_smbios_dev_err_info_t),
  253. sizeof(sal_log_pci_comp_err_info_t),
  254. sizeof(sal_log_plat_specific_err_info_t),
  255. sizeof(sal_log_host_ctlr_err_info_t),
  256. sizeof(sal_log_plat_bus_err_info_t),
  257. };
  258. /*
  259. * MCA handler cannot allocate new memory on flight,
  260. * so we preallocate enough memory to handle a SAL record.
  261. *
  262. * Initialize a handling set of slidx_pool:
  263. * 1. Pick up the max size of SAL error records
  264. * 2. Pick up the min size of SAL error sections
  265. * 3. Allocate the pool as enough to 2 SAL records
  266. * (now we can estimate the maxinum of section in a record.)
  267. */
  268. /* - 1 - */
  269. rec_max_size = sal_rec_max;
  270. /* - 2 - */
  271. sect_min_size = sal_log_sect_min_sizes[0];
  272. for (i = 1; i < sizeof sal_log_sect_min_sizes/sizeof(size_t); i++)
  273. if (sect_min_size > sal_log_sect_min_sizes[i])
  274. sect_min_size = sal_log_sect_min_sizes[i];
  275. /* - 3 - */
  276. slidx_pool.max_idx = (rec_max_size/sect_min_size) * 2 + 1;
  277. slidx_pool.buffer = (slidx_list_t *)
  278. kmalloc(slidx_pool.max_idx * sizeof(slidx_list_t), GFP_KERNEL);
  279. return slidx_pool.buffer ? 0 : -ENOMEM;
  280. }
  281. /*****************************************************************************
  282. * Recovery functions *
  283. *****************************************************************************/
  284. /**
  285. * is_mca_global - Check whether this MCA is global or not
  286. * @peidx: pointer of index of processor error section
  287. * @pbci: pointer to pal_bus_check_info_t
  288. * @sos: pointer to hand off struct between SAL and OS
  289. *
  290. * Return value:
  291. * MCA_IS_LOCAL / MCA_IS_GLOBAL
  292. */
  293. static mca_type_t
  294. is_mca_global(peidx_table_t *peidx, pal_bus_check_info_t *pbci,
  295. struct ia64_sal_os_state *sos)
  296. {
  297. pal_processor_state_info_t *psp =
  298. (pal_processor_state_info_t*)peidx_psp(peidx);
  299. /*
  300. * PAL can request a rendezvous, if the MCA has a global scope.
  301. * If "rz_always" flag is set, SAL requests MCA rendezvous
  302. * in spite of global MCA.
  303. * Therefore it is local MCA when rendezvous has not been requested.
  304. * Failed to rendezvous, the system must be down.
  305. */
  306. switch (sos->rv_rc) {
  307. case -1: /* SAL rendezvous unsuccessful */
  308. return MCA_IS_GLOBAL;
  309. case 0: /* SAL rendezvous not required */
  310. return MCA_IS_LOCAL;
  311. case 1: /* SAL rendezvous successful int */
  312. case 2: /* SAL rendezvous successful int with init */
  313. default:
  314. break;
  315. }
  316. /*
  317. * If One or more Cache/TLB/Reg_File/Uarch_Check is here,
  318. * it would be a local MCA. (i.e. processor internal error)
  319. */
  320. if (psp->tc || psp->cc || psp->rc || psp->uc)
  321. return MCA_IS_LOCAL;
  322. /*
  323. * Bus_Check structure with Bus_Check.ib (internal bus error) flag set
  324. * would be a global MCA. (e.g. a system bus address parity error)
  325. */
  326. if (!pbci || pbci->ib)
  327. return MCA_IS_GLOBAL;
  328. /*
  329. * Bus_Check structure with Bus_Check.eb (external bus error) flag set
  330. * could be either a local MCA or a global MCA.
  331. *
  332. * Referring Bus_Check.bsi:
  333. * 0: Unknown/unclassified
  334. * 1: BERR#
  335. * 2: BINIT#
  336. * 3: Hard Fail
  337. * (FIXME: Are these SGI specific or generic bsi values?)
  338. */
  339. if (pbci->eb)
  340. switch (pbci->bsi) {
  341. case 0:
  342. /* e.g. a load from poisoned memory */
  343. return MCA_IS_LOCAL;
  344. case 1:
  345. case 2:
  346. case 3:
  347. return MCA_IS_GLOBAL;
  348. }
  349. return MCA_IS_GLOBAL;
  350. }
  351. /**
  352. * recover_from_read_error - Try to recover the errors which type are "read"s.
  353. * @slidx: pointer of index of SAL error record
  354. * @peidx: pointer of index of processor error section
  355. * @pbci: pointer of pal_bus_check_info
  356. * @sos: pointer to hand off struct between SAL and OS
  357. *
  358. * Return value:
  359. * 1 on Success / 0 on Failure
  360. */
  361. static int
  362. recover_from_read_error(slidx_table_t *slidx,
  363. peidx_table_t *peidx, pal_bus_check_info_t *pbci,
  364. struct ia64_sal_os_state *sos)
  365. {
  366. sal_log_mod_error_info_t *smei;
  367. pal_min_state_area_t *pmsa;
  368. struct ia64_psr *psr1, *psr2;
  369. ia64_fptr_t *mca_hdlr_bh = (ia64_fptr_t*)mca_handler_bhhook;
  370. /* Is target address valid? */
  371. if (!pbci->tv)
  372. return 0;
  373. /*
  374. * cpu read or memory-mapped io read
  375. *
  376. * offending process affected process OS MCA do
  377. * kernel mode kernel mode down system
  378. * kernel mode user mode kill the process
  379. * user mode kernel mode down system (*)
  380. * user mode user mode kill the process
  381. *
  382. * (*) You could terminate offending user-mode process
  383. * if (pbci->pv && pbci->pl != 0) *and* if you sure
  384. * the process not have any locks of kernel.
  385. */
  386. psr1 =(struct ia64_psr *)&(peidx_minstate_area(peidx)->pmsa_ipsr);
  387. /*
  388. * Check the privilege level of interrupted context.
  389. * If it is user-mode, then terminate affected process.
  390. */
  391. if (psr1->cpl != 0) {
  392. smei = peidx_bus_check(peidx, 0);
  393. if (smei->valid.target_identifier) {
  394. /*
  395. * setup for resume to bottom half of MCA,
  396. * "mca_handler_bhhook"
  397. */
  398. pmsa = sos->pal_min_state;
  399. /* pass to bhhook as 1st argument (gr8) */
  400. pmsa->pmsa_gr[8-1] = smei->target_identifier;
  401. /* set interrupted return address (but no use) */
  402. pmsa->pmsa_br0 = pmsa->pmsa_iip;
  403. /* change resume address to bottom half */
  404. pmsa->pmsa_iip = mca_hdlr_bh->fp;
  405. pmsa->pmsa_gr[1-1] = mca_hdlr_bh->gp;
  406. /* set cpl with kernel mode */
  407. psr2 = (struct ia64_psr *)&pmsa->pmsa_ipsr;
  408. psr2->cpl = 0;
  409. psr2->ri = 0;
  410. psr2->i = 0;
  411. return 1;
  412. }
  413. }
  414. return 0;
  415. }
  416. /**
  417. * recover_from_platform_error - Recover from platform error.
  418. * @slidx: pointer of index of SAL error record
  419. * @peidx: pointer of index of processor error section
  420. * @pbci: pointer of pal_bus_check_info
  421. * @sos: pointer to hand off struct between SAL and OS
  422. *
  423. * Return value:
  424. * 1 on Success / 0 on Failure
  425. */
  426. static int
  427. recover_from_platform_error(slidx_table_t *slidx, peidx_table_t *peidx,
  428. pal_bus_check_info_t *pbci,
  429. struct ia64_sal_os_state *sos)
  430. {
  431. int status = 0;
  432. pal_processor_state_info_t *psp =
  433. (pal_processor_state_info_t*)peidx_psp(peidx);
  434. if (psp->bc && pbci->eb && pbci->bsi == 0) {
  435. switch(pbci->type) {
  436. case 1: /* partial read */
  437. case 3: /* full line(cpu) read */
  438. case 9: /* I/O space read */
  439. status = recover_from_read_error(slidx, peidx, pbci,
  440. sos);
  441. break;
  442. case 0: /* unknown */
  443. case 2: /* partial write */
  444. case 4: /* full line write */
  445. case 5: /* implicit or explicit write-back operation */
  446. case 6: /* snoop probe */
  447. case 7: /* incoming or outgoing ptc.g */
  448. case 8: /* write coalescing transactions */
  449. case 10: /* I/O space write */
  450. case 11: /* inter-processor interrupt message(IPI) */
  451. case 12: /* interrupt acknowledge or
  452. external task priority cycle */
  453. default:
  454. break;
  455. }
  456. }
  457. return status;
  458. }
  459. /**
  460. * recover_from_processor_error
  461. * @platform: whether there are some platform error section or not
  462. * @slidx: pointer of index of SAL error record
  463. * @peidx: pointer of index of processor error section
  464. * @pbci: pointer of pal_bus_check_info
  465. * @sos: pointer to hand off struct between SAL and OS
  466. *
  467. * Return value:
  468. * 1 on Success / 0 on Failure
  469. */
  470. /*
  471. * Later we try to recover when below all conditions are satisfied.
  472. * 1. Only one processor error section is exist.
  473. * 2. BUS_CHECK is exist and the others are not exist.(Except TLB_CHECK)
  474. * 3. The entry of BUS_CHECK_INFO is 1.
  475. * 4. "External bus error" flag is set and the others are not set.
  476. */
  477. static int
  478. recover_from_processor_error(int platform, slidx_table_t *slidx,
  479. peidx_table_t *peidx, pal_bus_check_info_t *pbci,
  480. struct ia64_sal_os_state *sos)
  481. {
  482. pal_processor_state_info_t *psp =
  483. (pal_processor_state_info_t*)peidx_psp(peidx);
  484. /*
  485. * Processor recovery status must key off of the PAL recovery
  486. * status in the Processor State Parameter.
  487. */
  488. /*
  489. * The machine check is corrected.
  490. */
  491. if (psp->cm == 1)
  492. return 1;
  493. /*
  494. * The error was not contained. Software must be reset.
  495. */
  496. if (psp->us || psp->ci == 0)
  497. return 0;
  498. /*
  499. * If there is no bus error, record is weird but we need not to recover.
  500. */
  501. if (psp->bc == 0 || pbci == NULL)
  502. return 1;
  503. /*
  504. * Sorry, we cannot handle so many.
  505. */
  506. if (peidx_bus_check_num(peidx) > 1)
  507. return 0;
  508. /*
  509. * Well, here is only one bus error.
  510. */
  511. if (pbci->ib || pbci->cc)
  512. return 0;
  513. if (pbci->eb && pbci->bsi > 0)
  514. return 0;
  515. /*
  516. * This is a local MCA and estimated as recoverble external bus error.
  517. * (e.g. a load from poisoned memory)
  518. * This means "there are some platform errors".
  519. */
  520. if (platform)
  521. return recover_from_platform_error(slidx, peidx, pbci, sos);
  522. /*
  523. * On account of strange SAL error record, we cannot recover.
  524. */
  525. return 0;
  526. }
  527. /**
  528. * mca_try_to_recover - Try to recover from MCA
  529. * @rec: pointer to a SAL error record
  530. * @sos: pointer to hand off struct between SAL and OS
  531. *
  532. * Return value:
  533. * 1 on Success / 0 on Failure
  534. */
  535. static int
  536. mca_try_to_recover(void *rec, struct ia64_sal_os_state *sos)
  537. {
  538. int platform_err;
  539. int n_proc_err;
  540. slidx_table_t slidx;
  541. peidx_table_t peidx;
  542. pal_bus_check_info_t pbci;
  543. /* Make index of SAL error record */
  544. platform_err = mca_make_slidx(rec, &slidx);
  545. /* Count processor error sections */
  546. n_proc_err = slidx_count(&slidx, proc_err);
  547. /* Now, OS can recover when there is one processor error section */
  548. if (n_proc_err > 1)
  549. return 0;
  550. else if (n_proc_err == 0) {
  551. /* Weird SAL record ... We need not to recover */
  552. return 1;
  553. }
  554. /* Make index of processor error section */
  555. mca_make_peidx((sal_log_processor_info_t*)
  556. slidx_first_entry(&slidx.proc_err)->hdr, &peidx);
  557. /* Extract Processor BUS_CHECK[0] */
  558. *((u64*)&pbci) = peidx_check_info(&peidx, bus_check, 0);
  559. /* Check whether MCA is global or not */
  560. if (is_mca_global(&peidx, &pbci, sos))
  561. return 0;
  562. /* Try to recover a processor error */
  563. return recover_from_processor_error(platform_err, &slidx, &peidx,
  564. &pbci, sos);
  565. }
  566. /*
  567. * =============================================================================
  568. */
  569. int __init mca_external_handler_init(void)
  570. {
  571. if (init_record_index_pools())
  572. return -ENOMEM;
  573. /* register external mca handlers */
  574. if (ia64_reg_MCA_extension(mca_try_to_recover)) {
  575. printk(KERN_ERR "ia64_reg_MCA_extension failed.\n");
  576. kfree(slidx_pool.buffer);
  577. return -EFAULT;
  578. }
  579. return 0;
  580. }
  581. void __exit mca_external_handler_exit(void)
  582. {
  583. /* unregister external mca handlers */
  584. ia64_unreg_MCA_extension();
  585. kfree(slidx_pool.buffer);
  586. }
  587. module_init(mca_external_handler_init);
  588. module_exit(mca_external_handler_exit);
  589. module_param(sal_rec_max, int, 0644);
  590. MODULE_PARM_DESC(sal_rec_max, "Max size of SAL error record");
  591. MODULE_DESCRIPTION("ia64 platform dependent mca handler driver");
  592. MODULE_LICENSE("GPL");