diff options
author | Borislav Petkov <bp@suse.de> | 2017-05-19 05:39:09 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2017-05-21 15:39:58 -0400 |
commit | 2d1f406139ec20320bf38bcd2461aa8e358084b5 (patch) | |
tree | cacc883680bc0eaaaf78f8957b0c11c3a3f13c91 | |
parent | 56f410cf45a1c1f68f77741990e0435b06a07676 (diff) |
x86/MCE: Export memory_error()
Export the function which checks whether an MCE is a memory error to
other users so that we can reuse the logic. Drop the boot_cpu_data use,
while at it, as mce.cpuvendor already has the CPU vendor in there.
Integrate a piece from a patch from Vishal Verma
<vishal.l.verma@intel.com> to export it for modules (nfit).
The main reason we're exporting it is that the nfit handler
nfit_handle_mce() needs to detect a memory error properly before doing
its recovery actions.
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: <stable@vger.kernel.org>
Link: http://lkml.kernel.org/r/20170519093915.15413-2-bp@alien8.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | arch/x86/include/asm/mce.h | 1 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/mcheck/mce.c | 13 |
2 files changed, 7 insertions, 7 deletions
diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h index 4fd5195deed0..3f9a3d2a5209 100644 --- a/arch/x86/include/asm/mce.h +++ b/arch/x86/include/asm/mce.h | |||
@@ -266,6 +266,7 @@ static inline int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *s | |||
266 | #endif | 266 | #endif |
267 | 267 | ||
268 | int mce_available(struct cpuinfo_x86 *c); | 268 | int mce_available(struct cpuinfo_x86 *c); |
269 | bool mce_is_memory_error(struct mce *m); | ||
269 | 270 | ||
270 | DECLARE_PER_CPU(unsigned, mce_exception_count); | 271 | DECLARE_PER_CPU(unsigned, mce_exception_count); |
271 | DECLARE_PER_CPU(unsigned, mce_poll_count); | 272 | DECLARE_PER_CPU(unsigned, mce_poll_count); |
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c index 5abd4bf73d6e..5cfbaeb6529a 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c | |||
@@ -499,16 +499,14 @@ static int mce_usable_address(struct mce *m) | |||
499 | return 1; | 499 | return 1; |
500 | } | 500 | } |
501 | 501 | ||
502 | static bool memory_error(struct mce *m) | 502 | bool mce_is_memory_error(struct mce *m) |
503 | { | 503 | { |
504 | struct cpuinfo_x86 *c = &boot_cpu_data; | 504 | if (m->cpuvendor == X86_VENDOR_AMD) { |
505 | |||
506 | if (c->x86_vendor == X86_VENDOR_AMD) { | ||
507 | /* ErrCodeExt[20:16] */ | 505 | /* ErrCodeExt[20:16] */ |
508 | u8 xec = (m->status >> 16) & 0x1f; | 506 | u8 xec = (m->status >> 16) & 0x1f; |
509 | 507 | ||
510 | return (xec == 0x0 || xec == 0x8); | 508 | return (xec == 0x0 || xec == 0x8); |
511 | } else if (c->x86_vendor == X86_VENDOR_INTEL) { | 509 | } else if (m->cpuvendor == X86_VENDOR_INTEL) { |
512 | /* | 510 | /* |
513 | * Intel SDM Volume 3B - 15.9.2 Compound Error Codes | 511 | * Intel SDM Volume 3B - 15.9.2 Compound Error Codes |
514 | * | 512 | * |
@@ -529,6 +527,7 @@ static bool memory_error(struct mce *m) | |||
529 | 527 | ||
530 | return false; | 528 | return false; |
531 | } | 529 | } |
530 | EXPORT_SYMBOL_GPL(mce_is_memory_error); | ||
532 | 531 | ||
533 | static bool cec_add_mce(struct mce *m) | 532 | static bool cec_add_mce(struct mce *m) |
534 | { | 533 | { |
@@ -536,7 +535,7 @@ static bool cec_add_mce(struct mce *m) | |||
536 | return false; | 535 | return false; |
537 | 536 | ||
538 | /* We eat only correctable DRAM errors with usable addresses. */ | 537 | /* We eat only correctable DRAM errors with usable addresses. */ |
539 | if (memory_error(m) && | 538 | if (mce_is_memory_error(m) && |
540 | !(m->status & MCI_STATUS_UC) && | 539 | !(m->status & MCI_STATUS_UC) && |
541 | mce_usable_address(m)) | 540 | mce_usable_address(m)) |
542 | if (!cec_add_elem(m->addr >> PAGE_SHIFT)) | 541 | if (!cec_add_elem(m->addr >> PAGE_SHIFT)) |
@@ -713,7 +712,7 @@ bool machine_check_poll(enum mcp_flags flags, mce_banks_t *b) | |||
713 | 712 | ||
714 | severity = mce_severity(&m, mca_cfg.tolerant, NULL, false); | 713 | severity = mce_severity(&m, mca_cfg.tolerant, NULL, false); |
715 | 714 | ||
716 | if (severity == MCE_DEFERRED_SEVERITY && memory_error(&m)) | 715 | if (severity == MCE_DEFERRED_SEVERITY && mce_is_memory_error(&m)) |
717 | if (m.status & MCI_STATUS_ADDRV) | 716 | if (m.status & MCI_STATUS_ADDRV) |
718 | m.severity = severity; | 717 | m.severity = severity; |
719 | 718 | ||