mce-apei.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Bridge between MCE and APEI
  3. *
  4. * On some machine, corrected memory errors are reported via APEI
  5. * generic hardware error source (GHES) instead of corrected Machine
  6. * Check. These corrected memory errors can be reported to user space
  7. * through /dev/mcelog via faking a corrected Machine Check, so that
  8. * the error memory page can be offlined by /sbin/mcelog if the error
  9. * count for one page is beyond the threshold.
  10. *
  11. * Copyright 2010 Intel Corp.
  12. * Author: Huang Ying <ying.huang@intel.com>
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License version
  16. * 2 as published by the Free Software Foundation.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  26. */
  27. #include <linux/kernel.h>
  28. #include <linux/acpi.h>
  29. #include <linux/cper.h>
  30. #include <acpi/apei.h>
  31. #include <asm/mce.h>
  32. #include "mce-internal.h"
  33. void apei_mce_report_mem_error(int corrected, struct cper_sec_mem_err *mem_err)
  34. {
  35. struct mce m;
  36. /* Only corrected MC is reported */
  37. if (!corrected)
  38. return;
  39. mce_setup(&m);
  40. m.bank = 1;
  41. /* Fake a memory read corrected error with unknown channel */
  42. m.status = MCI_STATUS_VAL | MCI_STATUS_EN | MCI_STATUS_ADDRV | 0x9f;
  43. m.addr = mem_err->physical_addr;
  44. mce_log(&m);
  45. mce_notify_irq();
  46. }
  47. EXPORT_SYMBOL_GPL(apei_mce_report_mem_error);