diff options
author | Borislav Petkov <borislav.petkov@amd.com> | 2011-12-08 12:28:33 +0100 |
---|---|---|
committer | Borislav Petkov <bp@amd64.org> | 2011-12-14 12:50:13 +0100 |
commit | 0937195715713b37ec843f28d99930dd7b1e8fbe (patch) | |
tree | 11a96986c1768fd117f95267371db27895d487d2 /arch/x86 | |
parent | 3653ada5d3e173489b3a466305687cb5c44b2ab1 (diff) | |
download | op-kernel-dev-0937195715713b37ec843f28d99930dd7b1e8fbe.zip op-kernel-dev-0937195715713b37ec843f28d99930dd7b1e8fbe.tar.gz |
x86, MCE: Drain mcelog buffer
Add a function which drains whatever MCEs were logged in already during
boot and before the decoder chains were registered.
Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kernel/cpu/mcheck/mce.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c index c3c66ac..5be2464 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c @@ -189,9 +189,48 @@ void mce_log(struct mce *mce) set_bit(0, &mce_need_notify); } +static void drain_mcelog_buffer(void) +{ + unsigned int next, i, prev = 0; + + next = rcu_dereference_check_mce(mcelog.next); + + do { + struct mce *m; + + /* drain what was logged during boot */ + for (i = prev; i < next; i++) { + unsigned long start = jiffies; + unsigned retries = 1; + + m = &mcelog.entry[i]; + + while (!m->finished) { + if (time_after_eq(jiffies, start + 2*retries)) + retries++; + + cpu_relax(); + + if (!m->finished && retries >= 4) { + pr_err("MCE: skipping error being logged currently!\n"); + break; + } + } + smp_rmb(); + atomic_notifier_call_chain(&x86_mce_decoder_chain, 0, m); + } + + memset(mcelog.entry + prev, 0, (next - prev) * sizeof(*m)); + prev = next; + next = cmpxchg(&mcelog.next, prev, 0); + } while (next != prev); +} + + void mce_register_decode_chain(struct notifier_block *nb) { atomic_notifier_chain_register(&x86_mce_decoder_chain, nb); + drain_mcelog_buffer(); } EXPORT_SYMBOL_GPL(mce_register_decode_chain); |