New way to track mce notifier chain actions
Subsystems (11)
Tony Luck
maintainercover New way to track mce notifier chain actions
This is just a skeleton of how it might look. Several issues arose while looking at this ... not all directly related to the problem at hand.
Parts 1 & 2 are just cleanup. CEC should follow the same rules as everyone else who wants to be on the mce notifier chain. No real reason for it to have direct hooks into mce/core.c
Part 3 adds a field to struct mce, and defines the BIT fields for each class of notifier. All EDAC drivers share the same BIT since only one of them should be active.
Part 4 is where things are interesting and need a great deal more thought. A bunch of things on the chain return NOTIFY_STOP which prevents anything else on the chain from being run. For the moment I ignored that semantic and added code everywhere to set the BIT even though nobody else will see it. This is because I think at least some of them should NOT be NOTIFY_STOP.
Part 5 is currently written to always call __print_mce() for debugging. The "if (1 || ...)" obviously doesn't want the "1" (though I'd like to add some /sys knob to flip a switch to force printing for systems where something weird is happening and logs are being lost).
Tony Luck (5):
x86/mce: Rename "first" function as "early"
x86/mce: Convert corrected error collector to use mce notifier x86/mce: Add new "handled" field to "struct mce" x86/mce: Fix all mce notifiers to update the mce->handled bitmask x86/mce: Change default mce logger to check mce->handled
arch/x86/include/asm/mce.h | 15 ++++---- arch/x86/include/uapi/asm/mce.h | 9 +++++ arch/x86/kernel/cpu/mce/core.c | 53 +++++++--------------------- arch/x86/kernel/cpu/mce/dev-mcelog.c | 1 + drivers/acpi/acpi_extlog.c | 1 + drivers/acpi/nfit/mce.c | 1 + drivers/edac/i7core_edac.c | 1 + drivers/edac/mce_amd.c | 5 ++- drivers/edac/pnd2_edac.c | 1 + drivers/edac/sb_edac.c | 1 + drivers/edac/skx_common.c | 1 + drivers/ras/cec.c | 29 +++++++++++++++ 12 files changed, 69 insertions(+), 49 deletions(-)
Signature · 1 line
2.21.1
Tony Luck
maintainerPATCH 1/5 x86/mce: Rename "first" function as "early"
It isn't going to be first on the notifier chain when we move the CEC code to be a normal user of the notifier chain.
Fix the enum for the MCE_PRIO symbols to list them in reverse order so that the compiler can give them numbers from low to high priority. Add an entry for MCE_PRIO_CEC as the highest priority.
--- arch/x86/include/asm/mce.h | 15 ++++++++------- arch/x86/kernel/cpu/mce/core.c | 10 +++++----- 2 files changed, 13 insertions(+), 12 deletions(-)
arch/x86/include/asm/mce.h +8 -7
@@ -143,13 +143,14 @@ struct mce_log_buffer { };enum mce_notifier_prios { -MCE_PRIO_FIRST =INT_MAX , -MCE_PRIO_UC =INT_MAX -1 , -MCE_PRIO_EXTLOG =INT_MAX -2 , -MCE_PRIO_NFIT =INT_MAX -3 , -MCE_PRIO_EDAC =INT_MAX -4 , -MCE_PRIO_MCELOG =1 , -MCE_PRIO_LOWEST =0 , +MCE_PRIO_LOWEST , +MCE_PRIO_MCELOG , +MCE_PRIO_EDAC , +MCE_PRIO_NFIT , +MCE_PRIO_EXTLOG , +MCE_PRIO_UC , +MCE_PRIO_EARLY , +MCE_PRIO_CEC };struct notifier_block ;
arch/x86/kernel/cpu/mce/core.c +5 -5
@@ -557,7 +557,7 @@ static bool cec_add_mce(struct mce *m)return false; } -static int mce_first_notifier (struct notifier_block *nb,unsigned long val, +static int mce_early_notifier (struct notifier_block *nb,unsigned long val,void *data) {struct mce *m = (struct mce *)data;
@@ -578,9 +578,9 @@ static int mce_first_notifier(struct notifier_block *nb, unsigned long val,return NOTIFY_DONE ; } -static struct notifier_block first_nb = { - .notifier_call = mce_first_notifier, - .priority =MCE_PRIO_FIRST , +static struct notifier_block early_nb = { + .notifier_call = mce_early_notifier, + .priority =MCE_PRIO_EARLY , }; static int uc_decode_notifier(struct notifier_block *nb, unsigned long val,
@@ -2028,7 +2028,7 @@ __setup("mce", mcheck_enable);int __init mcheck_init (void ) {mcheck_intel_therm_init (); -mce_register_decode_chain (&first_nb); +mce_register_decode_chain (&early_nb);mce_register_decode_chain (&mce_uc_nb);mce_register_decode_chain (&mce_default_nb);mcheck_vendor_init_severity ();
Signature · 1 line
2.21.1
Tony Luck
maintainerPATCH 5/5 x86/mce: Change default mce logger to check mce->handled
In reply to Tony LuckInstead of keeping count of how many handlers are registered on the mce chain and printing if we are below some magic value. Look at the mce->handled to see if anyone claims to have handled/logged this error.
[debug to always print in this version]
--- arch/x86/kernel/cpu/mce/core.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)
arch/x86/kernel/cpu/mce/core.c +4 -16
@@ -156,29 +156,17 @@ void mce_log(struct mce *m) }EXPORT_SYMBOL_GPL (mce_log); -/* -* We run the default notifier if we have only the UC, the first and the -* default notifier registered. I.e., the mandatory NUM_DEFAULT_NOTIFIERS -* notifiers registered on the chain. -*/ -#define NUM_DEFAULT_NOTIFIERS 3 -static atomic_t num_notifiers; -void mce_register_decode_chain (struct notifier_block *nb) {if (WARN_ON (nb->priority >MCE_PRIO_MCELOG && nb->priority <MCE_PRIO_EDAC ))return ; -atomic_inc (&num_notifiers); -blocking_notifier_chain_register (&x86_mce_decoder_chain, nb); }EXPORT_SYMBOL_GPL (mce_register_decode_chain);void mce_unregister_decode_chain (struct notifier_block *nb) { -atomic_dec (&num_notifiers); -blocking_notifier_chain_unregister (&x86_mce_decoder_chain, nb); }EXPORT_SYMBOL_GPL (mce_unregister_decode_chain);
@@ -261,6 +249,8 @@ static void __print_mce(struct mce *m) }pr_cont ("\n" ); +if (m->handled) +pr_emerg (HW_ERR "handled = %x\n" , m->handled);/* * Note this output is parsed by external tools and old fields * should not be changed.
@@ -600,10 +590,8 @@ static int mce_default_notifier(struct notifier_block *nb, unsigned long val,if (!m)return NOTIFY_DONE ; -if (atomic_read (&num_notifiers) >NUM_DEFAULT_NOTIFIERS ) -return NOTIFY_DONE ; - -__print_mce (m); +if (1 || !m->handled) +__print_mce (m);return NOTIFY_DONE ; }
Signature · 1 line
2.21.1
Tony Luck
maintainerPATCH 2/5 x86/mce: Convert corrected error collector to use mce notifier
In reply to Tony LuckThe CEC code has its claws in a couple of routines in mce/core.c
Convert it to just register itself on the normal mce notifier chain.
--- arch/x86/kernel/cpu/mce/core.c | 19 ------------------- drivers/ras/cec.c | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 19 deletions(-)
arch/x86/kernel/cpu/mce/core.c +0 -19
@@ -542,21 +542,6 @@ bool mce_is_correctable(struct mce *m) }EXPORT_SYMBOL_GPL (mce_is_correctable); -static bool cec_add_mce (struct mce *m) -{ -if (!m) -return false; - -/* We eat only correctable DRAM errors with usable addresses. */ -if (mce_is_memory_error (m) && -mce_is_correctable (m) && -mce_usable_address (m)) -if (!cec_add_elem (m->addr >>PAGE_SHIFT )) -return true; - -return false; -} -static int mce_early_notifier (struct notifier_block *nb,unsigned long val,void *data) {
@@ -565,9 +550,6 @@ static int mce_early_notifier(struct notifier_block *nb, unsigned long val,if (!m)return NOTIFY_DONE ; -if (cec_add_mce (m)) -return NOTIFY_STOP ; -/* Emit the trace record: */ trace_mce_record (m);
@@ -2588,7 +2570,6 @@ static int __init mcheck_late_init(void)static_branch_inc (&mcsafe_key);mcheck_debugfs_init (); -cec_init ();/* * Flush out everything that has been logged during early boot, now that
drivers/ras/cec.c +26 -0
@@ -527,6 +527,29 @@ static int __init create_debugfs_nodes(void)return 1 ; } +static int cec_notifier (struct notifier_block *nb,unsigned long val, +void *data) +{ +struct mce *m = (struct mce *)data; + +if (!m) +return NOTIFY_DONE ; + +/* We eat only correctable DRAM errors with usable addresses. */ +if (mce_is_memory_error (m) && +mce_is_correctable (m) && +mce_usable_address (m)) +if (!cec_add_elem (m->addr >>PAGE_SHIFT )) +return NOTIFY_STOP ; + +return NOTIFY_DONE ; +} + +static struct notifier_block cec_nb = { + .notifier_call = cec_notifier, + .priority =MCE_PRIO_CEC , +}; +void __init cec_init (void ) {if (ce_arr.disabled)
@@ -546,8 +569,11 @@ void __init cec_init(void)INIT_DELAYED_WORK (&cec_work, cec_work_fn);schedule_delayed_work (&cec_work,CEC_DECAY_DEFAULT_INTERVAL ); +mce_register_decode_chain (&cec_nb); +pr_info ("Correctable Errors collector initialized.\n" ); } +late_initcall (cec_init);int __init parse_cec_param (char *str) {
Signature · 1 line
2.21.1
Tony Luck
maintainerPATCH 4/5 x86/mce: Fix all mce notifiers to update the mce->handled bitmask
In reply to Tony LuckIf the handler took any action to log or deal with the error, set a bit int mce->handled so that the default handler on the end of the machine check chain can see what has been done.
[!!! What to do about NOTIFY_STOP ... any handler that returns this value short-circuits calling subsequent entries on the chain. In some cases this may be the right thing to do ... but it others we really want to keep calling other functions on the chain]
--- arch/x86/kernel/cpu/mce/core.c | 4 +++- arch/x86/kernel/cpu/mce/dev-mcelog.c | 1 + drivers/acpi/acpi_extlog.c | 1 + drivers/acpi/nfit/mce.c | 1 + drivers/edac/i7core_edac.c | 1 + drivers/edac/mce_amd.c | 5 ++++- drivers/edac/pnd2_edac.c | 1 + drivers/edac/sb_edac.c | 1 + drivers/edac/skx_common.c | 1 + drivers/ras/cec.c | 7 +++++-- 10 files changed, 19 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/mce/core.c +3 -1
@@ -579,8 +579,10 @@ static int uc_decode_notifier(struct notifier_block *nb, unsigned long val,return NOTIFY_DONE ; pfn = mce->addr >>PAGE_SHIFT ; -if (!memory_failure (pfn,0 )) +if (!memory_failure (pfn,0 )) {set_mce_nospec (pfn); + mce->handled |=MCE_HANDLED_UC ; + }return NOTIFY_OK ; }
arch/x86/kernel/cpu/mce/dev-mcelog.c +1 -0
@@ -67,6 +67,7 @@ static int dev_mce_log(struct notifier_block *nb, unsigned long val, unlock:mutex_unlock (&mce_chrdev_read_mutex); + mce->handled |=MCE_HANDLED_MCELOG ;return NOTIFY_OK ; }
drivers/acpi/acpi_extlog.c +1 -0
@@ -176,6 +176,7 @@ static int extlog_print(struct notifier_block *nb, unsigned long val, } out: + mce->handled |=MCE_HANDLED_EXTLOG ;return NOTIFY_STOP ; }
drivers/acpi/nfit/mce.c +1 -0
@@ -76,6 +76,7 @@ static int nfit_handle_mce(struct notifier_block *nb, unsigned long val,*/ acpi_nfit_ars_rescan (acpi_desc,0 ); } + mce->handled |=MCE_HANDLED_NFIT ;break ; }
drivers/edac/i7core_edac.c +1 -0
@@ -1834,6 +1834,7 @@ static int i7core_mce_check_error(struct notifier_block *nb, unsigned long val,i7core_check_error (mci, mce);/* Advise mcelog that the errors were handled */ + mce->handled |=MCE_HANDLED_EDAC ;return NOTIFY_STOP ; }
drivers/edac/mce_amd.c +4 -1
@@ -1067,8 +1067,10 @@ amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data)unsigned int fam =x86_family (m->cpuid);int ecc; -if (ignore_mce (m)) +if (ignore_mce (m)) { + m->handled |=MCE_HANDLED_EDAC ;return NOTIFY_STOP ; + }pr_emerg (HW_ERR "%s\n" ,decode_error_status (m));
@@ -1170,6 +1172,7 @@ amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data) err_code:amd_decode_err_code (m->status &0xffff ); + m->handled |=MCE_HANDLED_EDAC ;return NOTIFY_STOP ; }
drivers/edac/pnd2_edac.c +1 -0
@@ -1429,6 +1429,7 @@ static int pnd2_mce_check_error(struct notifier_block *nb, unsigned long val, vopnd2_mce_output_error (mci, mce, &daddr);/* Advice mcelog that the error were handled */ + mce->handled |=MCE_HANDLED_EDAC ;return NOTIFY_STOP ; }
drivers/edac/sb_edac.c +1 -0
@@ -3183,6 +3183,7 @@ static int sbridge_mce_check_error(struct notifier_block *nb, unsigned long val,sbridge_mce_output_error (mci, mce);/* Advice mcelog that the error were handled */ + mce->handled |=MCE_HANDLED_EDAC ;return NOTIFY_STOP ; }
drivers/edac/skx_common.c +1 -0
@@ -616,6 +616,7 @@ int skx_mce_check_error(struct notifier_block *nb, unsigned long val,skx_mce_output_error (mci, mce, &res); + mce->handled |=MCE_HANDLED_EDAC ;return NOTIFY_DONE ; }
drivers/ras/cec.c +5 -2
@@ -538,9 +538,12 @@ static int cec_notifier(struct notifier_block *nb, unsigned long val,/* We eat only correctable DRAM errors with usable addresses. */ if (mce_is_memory_error (m) &&mce_is_correctable (m) && -mce_usable_address (m)) -if (!cec_add_elem (m->addr >>PAGE_SHIFT )) +mce_usable_address (m)) { +if (!cec_add_elem (m->addr >>PAGE_SHIFT )) { + m->handled |=MCE_HANDLED_CEC ;return NOTIFY_STOP ; + } + }return NOTIFY_DONE ; }
Signature · 1 line
2.21.1
Tony Luck
maintainerPATCH 3/5 x86/mce: Add new "handled" field to "struct mce"
In reply to Tony LuckThere can be many different subsystems register on the mce handler chain. Add a new bitmask field and define values so that handlers can indicate whether they took any action to log or otherwise handle an error.
The default handler at the end of the chain can use this information to decide whether to print to the console log.
--- arch/x86/include/uapi/asm/mce.h | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/x86/include/uapi/asm/mce.h +9 -0
@@ -35,8 +35,17 @@ struct mce {__u64 ipid;/* MCA_IPID MSR: only valid on SMCA systems */ __u64 ppin;/* Protected Processor Inventory Number */ __u32 microcode;/* Microcode revision */ +__u32 handled;/* Bitmap of logging/handling actions */ }; +/* handled flag bits */ +#define MCE_HANDLED_CEC BIT(0) +#define MCE_HANDLED_UC BIT(1) +#define MCE_HANDLED_EXTLOG BIT(2) +#define MCE_HANDLED_NFIT BIT(3) +#define MCE_HANDLED_EDAC BIT(4) +#define MCE_HANDLED_MCELOG BIT(5) +#define MCE_GET_RECORD_LEN _IOR('M', 1, int)#define MCE_GET_LOG_LEN _IOR('M', 2, int)#define MCE_GETCLEAR_FLAGS _IOR('M', 3, int)
Signature · 1 line
2.21.1
Luck, Tony
maintainerQuoted 6 lines · Tony Luck
Part 4 is where things are interesting and need a great deal more thought. A bunch of things on the chain return
NOTIFY_STOPwhich prevents anything else on the chain from being run. For the moment I ignored that semantic and added code everywhere to set the BIT even though nobody else will see it. This is because I think at least some of them should NOT beNOTIFY_STOP.
NOTIFY_STOP is just one mechanism for preventing every function on the mce chain from reporting an error.
The other bit I'd like to reconsider is edac_get_report_status(). Back in the day we seemed to be paranoid about reporting the same error more than once via all the different reporting mechanisms.
Since then I've had to track down numerous "Why didn't this error get reported?" questions that frequently resolved to "It was reported, but not in the place that you expected".
So now my attitude is "Let's just log it everywhere in so that whatever log the user is checking, they'll find the error".
-Tony
Quoted 16 lines · Tony
Quoted 6 lines · Tony Luck
Part 4 is where things are interesting and need a great deal more thought. A bunch of things on the chain return
NOTIFY_STOPwhich prevents anything else on the chain from being run. For the moment I ignored that semantic and added code everywhere to set the BIT even though nobody else will see it. This is because I think at least some of them should NOT beNOTIFY_STOP.
NOTIFY_STOPis just one mechanism for preventing every function on the mce chain from reporting an error.The other bit I'd like to reconsider is
edac_get_report_status(). Back in the day we seemed to be paranoid about reporting the same error more than once via all the different reporting mechanisms.
Quoted 6 lines
Since then I've had to track down numerous "Why didn't this error get reported?" questions that frequently resolved to "It was reported, but not in the place that you expected".
So now my attitude is "Let's just log it everywhere in so that whatever log the user is checking, they'll find the error"
I HATE notifier chains for exceptions, and I REALLY HATE NOTIFY_STOP. I don't suppose we could rig something up so that they are simply notifiers (for MCE and, eventually, for everything) and just outright prevent them from modifying the processing?
As an example that particularly bothers me, do_debug():
if (notify_die(DIE_DEBUG, "debug", regs, (long)&dr6, error_code,
SIGTRAP) == NOTIFY_STOP)
goto exit;There is all kind of garbage hidden in there, and it's mostly somewhere between slightly buggy and violently buggy. All this crap should be open-coded.
Borislav Petkov
maintainerQuoted 4 lines · Andy Lutomirski
I HATE notifier chains for exceptions, and I REALLY HATE
NOTIFY_STOP. I don't suppose we could rig something up so that they are simply notifiers (for MCE and, eventually, for everything) and just outright prevent them from modifying the processing?
As in: they all get executed unconditionally and there's no NOTIFY_STOP and if they're not interested in the notification, they simply return early?
Hohumm, sounds nicer.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 9 lines · Borislav Petkov
Quoted 4 lines · Andy Lutomirski
I HATE notifier chains for exceptions, and I REALLY HATE
NOTIFY_STOP. I don't suppose we could rig something up so that they are simply notifiers (for MCE and, eventually, for everything) and just outright prevent them from modifying the processing?
Quoted 6 lines
As in: they all get executed unconditionally and there's no
NOTIFY_STOPand if they're not interested in the notification, they simply return early?Hohumm, sounds nicer.
Exactly :)
Quoted 5 lines
Signature · 4 lines
Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette
Borislav Petkov
maintainerRe: [PATCH 3/5] x86/mce: Add new "handled" field to "struct mce"
In reply to Tony LuckQuoted 26 lines · Tony Luck
There can be many different subsystems register on the mce handler chain. Add a new bitmask field and define values so that handlers can indicate whether they took any action to log or otherwise handle an error.
The default handler at the end of the chain can use this information to decide whether to print to the console log.
Signed-off-by Tony Luck <[email protected]>--- arch/x86/include/uapi/asm/mce.h | 9 +++++++++ 1 file changed, 9 insertions(+)arch/x86/include/uapi/asm/mce.h +2
-0@@ -35,8 +35,17 @@ struct mce {__u64 ipid;/* MCA_IPID MSR: only valid on SMCA systems */ __u64 ppin;/* Protected Processor Inventory Number */ __u32 microcode;/* Microcode revision */ +__u32 handled;/* Bitmap of logging/handling actions */ }; +/* handled flag bits */
arch/x86/include/uapi/asm/mce.h struct mce { · line 51
Quoted 10 lines
arch/x86/include/uapi/asm/mce.h +7
-0+#define MCE_HANDLED_CEC BIT(0) +#define MCE_HANDLED_UC BIT(1) +#define MCE_HANDLED_EXTLOG BIT(2) +#define MCE_HANDLED_NFIT BIT(3) +#define MCE_HANDLED_EDAC BIT(4) +#define MCE_HANDLED_MCELOG BIT(5) +#define MCE_GET_RECORD_LEN _IOR('M', 1, int)#define MCE_GET_LOG_LEN _IOR('M', 2, int)#define MCE_GETCLEAR_FLAGS _IOR('M', 3, int)
Not sure if this should be exposed to user. I don't think it has any business poking its nose into how the MCE was handled. Or maybe it does but I cannot think of a good example ATM.
If not, this could be
... void *private; };
which userspace can't make any assumptions about. And we can put whatever we need in there...
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteBorislav Petkov
maintainerRe: [PATCH 4/5] x86/mce: Fix all mce notifiers to update the mce->handled bitmask
In reply to Tony LuckQuoted 8 lines · Tony Luck
If the handler took any action to log or deal with the error, set a bit int
mce->handledso that the default handler on the end of the machine check chain can see what has been done.[!!! What to do about
NOTIFY_STOP... any handler that returns this value short-circuits calling subsequent entries on the chain. In some cases this may be the right thing to do ... but it others we really want to keep calling other functions on the chain]
Yes, we can kill that NOTIFY_STOP thing in the mce code since it is nasty.
Then, from the looks of it, there should be a function at the end of the chain which decides whether to print or not, just by looking at ->handled.
For example, it should not print MCE_HANDLED_CEC or MCE_HANDLED_EDAC, etc cases. The assumption for the latter being that EDAC does its own printing. Which then makes me wonder whether MCE_HANDLED_EDAC is enough.
Because this one bit would basically determine whether the error gets printed or not. Which would mean that all EDAC drivers should print it...
All I'm saying is, we should think about modalities like that.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteBorislav Petkov
maintainerRe: [PATCH 5/5] x86/mce: Change default mce logger to check mce->handled
In reply to Tony LuckQuoted 17 lines · Tony Luck
Instead of keeping count of how many handlers are registered on the mce chain and printing if we are below some magic value. Look at the
mce->handledto see if anyone claims to have handled/logged this error.[debug to always print in this version]
Signed-off-by Tony Luck <[email protected]>--- arch/x86/kernel/cpu/mce/core.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)arch/x86/kernel/cpu/mce/core.c +0
-0@@ -156,29 +156,17 @@ void mce_log(struct mce *m) }
arch/x86/kernel/cpu/mce/core.c void mce_log(struct mce *m) · line 166
Quoted 10 lines
arch/x86/kernel/cpu/mce/core.c +0
-8EXPORT_SYMBOL_GPL (mce_log); -/* -* We run the default notifier if we have only the UC, the first and the -* default notifier registered. I.e., the mandatory NUM_DEFAULT_NOTIFIERS -* notifiers registered on the chain. -*/ -#define NUM_DEFAULT_NOTIFIERS 3 -static atomic_t num_notifiers; -
I definitely like where this is going.
Another thing: what do we do if we have to deviate from that sequantial path through the notifiers? What if notifier A gets to look at an error, then another notifier B needs to look at it and then the information obtained from the second notifier B, is needed by the first notifier A again to inspect the error a *second* time.
I don't think there's a case like that now but I'm just playing the devil's advocate here. Because a use case like that would break our simplistic, sequential assembly line of MCE decoding.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteLuck, Tony
maintainerRe: [PATCH 3/5] x86/mce: Add new "handled" field to "struct mce"
In reply to Borislav PetkovQuoted 42 lines · Borislav Petkov
Quoted 26 lines · Tony Luck
There can be many different subsystems register on the mce handler chain. Add a new bitmask field and define values so that handlers can indicate whether they took any action to log or otherwise handle an error.
The default handler at the end of the chain can use this information to decide whether to print to the console log.
Signed-off-by Tony Luck <[email protected]>--- arch/x86/include/uapi/asm/mce.h | 9 +++++++++ 1 file changed, 9 insertions(+)arch/x86/include/uapi/asm/mce.h +2
-0@@ -35,8 +35,17 @@ struct mce {__u64 ipid;/* MCA_IPID MSR: only valid on SMCA systems */ __u64 ppin;/* Protected Processor Inventory Number */ __u32 microcode;/* Microcode revision */ +__u32 handled;/* Bitmap of logging/handling actions */ }; +/* handled flag bits */ arch/x86/include/uapi/asm/mce.h struct mce { · line 51
Quoted 10 lines
arch/x86/include/uapi/asm/mce.h +7
-0+#define MCE_HANDLED_CEC BIT(0) +#define MCE_HANDLED_UC BIT(1) +#define MCE_HANDLED_EXTLOG BIT(2) +#define MCE_HANDLED_NFIT BIT(3) +#define MCE_HANDLED_EDAC BIT(4) +#define MCE_HANDLED_MCELOG BIT(5) +#define MCE_GET_RECORD_LEN _IOR('M', 1, int)#define MCE_GET_LOG_LEN _IOR('M', 2, int)#define MCE_GETCLEAR_FLAGS _IOR('M', 3, int)Not sure if this should be exposed to user. I don't think it has any business poking its nose into how the MCE was handled. Or maybe it does but I cannot think of a good example ATM.
Quoted 8 lines
If not, this could be
... void *private; };which userspace can't make any assumptions about. And we can put whatever we need in there...
I can see various ways to spin this:
1) It is useful to user mode. The mcelog(8) daemon (or other consumer of "struct mce") gets a record of where to look for logs from this record. This could reduce the anxiety about logging the same item multiple times. Its a bit weird though because each entity logging only sees who came before them, not who came after.
2) Not useful
2a) Keep it in the structure, but clear it in copies shown to user 2b) Make a *private to point to such things (but that really
complicates allocation of struct mce ... right now we just have local copies on kernel stack)
2c) Make a wrapper structure:
struct kernel_mce {
struct mce mce;
u32 handled;
... other hidden stuff ...
};
-Tony
Luck, Tony
maintainerRe: [PATCH 4/5] x86/mce: Fix all mce notifiers to update the mce->handled bitmask
In reply to Borislav PetkovQuoted 5 lines · Borislav Petkov
Quoted 4 lines · Tony Luck
If the handler took any action to log or deal with the error, set a bit int
mce->handledso that the default handler on the end of the machine check chain can see what has been done.
Quoted 7 lines
Quoted 4 lines
[!!! What to do about
NOTIFY_STOP... any handler that returns this value short-circuits calling subsequent entries on the chain. In some cases this may be the right thing to do ... but it others we really want to keep calling other functions on the chain]Yes, we can kill that
NOTIFY_STOPthing in the mce code since it is nasty.
Well, there are places where we want to keep NOTIFY_STOP.
1) Default case for CEC. We want it to "hide" the corrected error. That was one of the main goals for CEC. We've discussed cases where CEC shouldn't hide (when internal threshold exceeded and it tries to take a page offline ... probably something related to CMCI storms ... though we didn't really come to any conclusion)
2) Errata. Perhaps a vendor/platform specific function at the head of the notify chain that weeds out errors that should never have been reported.
Quoted 3 lines
Then, from the looks of it, there should be a function at the end of the chain which decides whether to print or not, just by looking at ->handled.
That's there now. See mce_default_notifier()
Quoted 3 lines
For example, it should not print
MCE_HANDLED_CECorMCE_HANDLED_EDAC, etc cases. The assumption for the latter being that EDAC does its own printing. Which then makes me wonder whetherMCE_HANDLED_EDACis enough.
But may need some refining.
Quoted 3 lines
Because this one bit would basically determine whether the error gets printed or not. Which would mean that all EDAC drivers should print it...
Alternative wording "An EDAC driver should only set the bit if it printed something useful about the error."
-Tony
Re: [PATCH 4/5] x86/mce: Fix all mce notifiers to update the mce->handled bitmask
Quoted 12 lines · Tony
Quoted 10 lines · Borislav Petkov
Quoted 8 lines · Tony Luck
If the handler took any action to log or deal with the error, set a bit int
mce->handledso that the default handler on the end of the machine check chain can see what has been done.[!!! What to do about
NOTIFY_STOP... any handler that returns this value short-circuits calling subsequent entries on the chain. In some cases this may be the right thing to do ... but it others we really want to keep calling other functions on the chain]
Quoted 4 lines
Quoted 2 lines
Yes, we can kill that
NOTIFY_STOPthing in the mce code since it is nasty.Well, there are places where we want to keep
NOTIFY_STOP.
I very very strongly disagree.
Quoted 6 lines
1) Default case for CEC. We want it to "hide" the corrected error. That was one of the main goals for CEC. We've discussed cases where CEC shouldn't hide (when internal threshold exceeded and it tries to take a page offline ... probably something related to CMCI storms ... though we didn't really come to any conclusion)
Then put this logic in do_machine_check() or in some sensible place that it calls via some ops structure or directly. Don't hide it in some incomprehensible, possibly nondeterministic place in a notifier chain.
Quoted 3 lines
2) Errata. Perhaps a vendor/platform specific function at the head of the notify chain that weeds out errors that should never have been reported.
No, do this before the notifier chain please.
AMA Capital Management, LLC
Luck, Tony
maintainerRe: [PATCH 5/5] x86/mce: Change default mce logger to check mce->handled
In reply to Borislav PetkovQuoted 1 line · Borislav Petkov
I definitely like where this is going.
Thanks.
Quoted 5 lines
Another thing: what do we do if we have to deviate from that sequantial path through the notifiers? What if notifier A gets to look at an error, then another notifier B needs to look at it and then the information obtained from the second notifier B, is needed by the first notifier A again to inspect the error a *second* time.
That's pretty hard with a chain. I think folks will have a conniptions if we invent an error return from a notifier chain function that means "Go back and start over". Though if we did it would make the "handled" field useful for functions that didn't want to redo ... they'd just check if "their" bit in handled was already set.
Still, seems like a terrible idea.
Quoted 3 lines
I don't think there's a case like that now but I'm just playing the devil's advocate here. Because a use case like that would break our simplistic, sequential assembly line of MCE decoding.
If some driver really wants multiple bites at an error on the chain it could register more than one handler with different priorities. In which case we should have "enum" names for the highest and lowest priorities so such a driver can go "first" or "last" (though such a thing would be dependent on whether some other driver was attempting to add a "first" or "last" entry on the chain).
-Tony
Luck, Tony
maintainerRe: [PATCH 4/5] x86/mce: Fix all mce notifiers to update the mce->handled bitmask
In reply to Andy LutomirskiQuoted 27 lines · Andy Lutomirski
Quoted 12 lines · Tony
Quoted 10 lines · Borislav Petkov
Quoted 8 lines · Tony Luck
If the handler took any action to log or deal with the error, set a bit int
mce->handledso that the default handler on the end of the machine check chain can see what has been done.[!!! What to do about
NOTIFY_STOP... any handler that returns this value short-circuits calling subsequent entries on the chain. In some cases this may be the right thing to do ... but it others we really want to keep calling other functions on the chain]Quoted 4 lines
Quoted 2 lines
Yes, we can kill that
NOTIFY_STOPthing in the mce code since it is nasty.Well, there are places where we want to keep
NOTIFY_STOP.I very very strongly disagree.
Quoted 6 lines
1) Default case for CEC. We want it to "hide" the corrected error. That was one of the main goals for CEC. We've discussed cases where CEC shouldn't hide (when internal threshold exceeded and it tries to take a page offline ... probably something related to CMCI storms ... though we didn't really come to any conclusion)
Quoted 4 lines
Then put this logic in
do_machine_check()or in some sensible place that it calls via some ops structure or directly. Don't hide it in some incomprehensible, possibly nondeterministic place in a notifier chain.
I could make the EDAC driver (and others on the chain) check to see if CEC already handled the error record:
if (mce->handled & MCE_HANDLED_CEC) return NOTIFY_DONE;
Then everyone on the chain still sees the error ... just some of them make informed decisions based on what functions earlier in the chain did with the error record.
Quoted 5 lines
Quoted 3 lines
2) Errata. Perhaps a vendor/platform specific function at the head of the notify chain that weeds out errors that should never have been reported.
No, do this before the notifier chain please.
Ok. We don't have code that does this yet. If we need some, I'll make sure to do the weed out before it gets to the notifier.
-Tony
Re: [PATCH 4/5] x86/mce: Fix all mce notifiers to update the mce->handled bitmask
In reply to Andy LutomirskiQuoted 13 lines · Andy Lutomirski
Quoted 12 lines · Tony
Quoted 10 lines · Borislav Petkov
Quoted 8 lines · Tony Luck
If the handler took any action to log or deal with the error, set a bit int
mce->handledso that the default handler on the end of the machine check chain can see what has been done.[!!! What to do about
NOTIFY_STOP... any handler that returns this value short-circuits calling subsequent entries on the chain. In some cases this may be the right thing to do ... but it others we really want to keep calling other functions on the chain]
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Yes, we can kill that
NOTIFY_STOPthing in the mce code since it is nasty.Well, there are places where we want to keep
NOTIFY_STOP.I very very strongly disagree.
Ack. The unholy mess of cpu hotplug notifiers and the at least 50 bugs which were unearthed by converting them to a comprehensible and symmetric state machine have documented the insanity of notifiers nicely.
Quoted 11 lines
Quoted 5 lines
1) Default case for CEC. We want it to "hide" the corrected error. That was one of the main goals for CEC. We've discussed cases where CEC shouldn't hide (when internal threshold exceeded and it tries to take a page offline ... probably something related to CMCI storms ... though we didn't really come to any conclusion)
Then put this logic in
do_machine_check()or in some sensible place that it calls via some ops structure or directly. Don't hide it in some incomprehensible, possibly nondeterministic place in a notifier chain.
Quoted 5 lines
Quoted 3 lines
2) Errata. Perhaps a vendor/platform specific function at the head of the notify chain that weeds out errors that should never have been reported.
No, do this before the notifier chain please.
Right. The amount of possible handlers is really not huge.
So having a well defined flow of explicit calls including the handling of magic workarounds in a central place makes tons of sense.
Thanks,
tglx
Borislav Petkov
maintainerRe: [PATCH 3/5] x86/mce: Add new "handled" field to "struct mce"
In reply to Luck, TonyQuoted 5 lines · Tony
1) It is useful to user mode. The mcelog(8) daemon (or other consumer of "struct mce") gets a record of where to look for logs from this record. This could reduce the anxiety about logging the same item multiple times. Its a bit weird though because each entity logging only sees who came before them, not who came after.
Err, doesn't mcelog get the error shoved down through /dev/mcelog? IOW, why would it even have to look?
Ditto for other consumers which read the tracepoint...
Quoted 2 lines
2) Not useful
2a) Keep it in the structure, but clear it in copies shown to user
Yah, also ok.
Quoted 3 lines
2b) Make a *private to point to such things (but that really
complicates allocation of struct mce ... right now we just have local copies on kernel stack)
Yeah..
Quoted 6 lines
2c) Make a wrapper structure:
struct kernel_mce {
struct mce mce;
u32 handled;
... other hidden stuff ...
};That too.
2a) sounds really simple to me and I like simple. And if we ever end up needing more fields, we'll just add another one and keep clearing it on copy to user.
And just to make our lives easier, we can do
u64 kflags;
and put the handled stuff there but still have a 64-bit value for future flags.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteBorislav Petkov
maintainerRe: [PATCH 4/5] x86/mce: Fix all mce notifiers to update the mce->handled bitmask
In reply to Luck, TonyQuoted 6 lines · Tony
Quoted 3 lines
Because this one bit would basically determine whether the error gets printed or not. Which would mean that all EDAC drivers should print it...
Alternative wording "An EDAC driver should only set the bit if it printed something useful about the error."
ACK.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteBorislav Petkov
maintainerRe: [PATCH 4/5] x86/mce: Fix all mce notifiers to update the mce->handled bitmask
In reply to Luck, TonyQuoted 2 lines · Tony
Ok. We don't have code that does this yet. If we need some, I'll make sure to do the weed out before it gets to the notifier.
... which would make running the CEC hook *before* running the notifiers the easiest thing. Hacking in "did-CEC-handle-it" logic in the rest of the chain is just going to be painful so the best would be IMO: if the CEC decided to consume it, it won't even go down the notifiers.
Just like the added crap^W value firmware-first thing does and we should learn from it. :-)
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteBorislav Petkov
maintainerRe: [PATCH 5/5] x86/mce: Change default mce logger to check mce->handled
In reply to Luck, TonyQuoted 1 line · Tony
That's pretty hard with a chain. I think folks will have a conniptions
LOL. And they do already for other things so let's spare them :-)
Quoted 6 lines
if we invent an error return from a notifier chain function that means "Go back and start over". Though if we did it would make the "handled" field useful for functions that didn't want to redo ... they'd just check if "their" bit in handled was already set.
Still, seems like a terrible idea.
Yap.
Quoted 7 lines
If some driver really wants multiple bites at an error on the chain it could register more than one handler with different priorities. In which case we should have "enum" names for the highest and lowest priorities so such a driver can go "first" or "last" (though such a thing would be dependent on whether some other driver was attempting to add a "first" or "last" entry on the chain).
Yap, makes sense. I'm fine with us even having a possible way to do this, *if* someone decides she wants it.
Ok, thanks!
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteTony Luck
maintainerPATCH v2 5/7 x86/mce: Change default mce logger to check mce->kflags
In reply to Tony LuckInstead of keeping count of how many handlers are registered on the mce chain and printing if we are below some magic value. Look at the mce->kflags to see if anyone claims to have handled/logged this error.
--- arch/x86/kernel/cpu/mce/core.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)
arch/x86/kernel/cpu/mce/core.c +4 -16
@@ -156,29 +156,17 @@ void mce_log(struct mce *m) }EXPORT_SYMBOL_GPL (mce_log); -/* -* We run the default notifier if we have only the UC, the first and the -* default notifier registered. I.e., the mandatory NUM_DEFAULT_NOTIFIERS -* notifiers registered on the chain. -*/ -#define NUM_DEFAULT_NOTIFIERS 3 -static atomic_t num_notifiers; -void mce_register_decode_chain (struct notifier_block *nb) {if (WARN_ON (nb->priority >MCE_PRIO_MCELOG && nb->priority <MCE_PRIO_EDAC ))return ; -atomic_inc (&num_notifiers); -blocking_notifier_chain_register (&x86_mce_decoder_chain, nb); }EXPORT_SYMBOL_GPL (mce_register_decode_chain);void mce_unregister_decode_chain (struct notifier_block *nb) { -atomic_dec (&num_notifiers); -blocking_notifier_chain_unregister (&x86_mce_decoder_chain, nb); }EXPORT_SYMBOL_GPL (mce_unregister_decode_chain);
@@ -261,6 +249,8 @@ static void __print_mce(struct mce *m) }pr_cont ("\n" ); +if (m->kflags) +pr_emerg (HW_ERR "kflags = 0x%llx\n" , m->kflags);/* * Note this output is parsed by external tools and old fields * should not be changed.
@@ -600,10 +590,8 @@ static int mce_default_notifier(struct notifier_block *nb, unsigned long val,if (!m)return NOTIFY_DONE ; -if (atomic_read (&num_notifiers) >NUM_DEFAULT_NOTIFIERS ) -return NOTIFY_DONE ; - -__print_mce (m); +if (!m->kflags) +__print_mce (m);return NOTIFY_DONE ; }
Signature · 1 line
2.21.1
Tony Luck
maintainerPATCH v2 4/7 x86/mce: Fix all mce notifiers to update the mce->kflags bitmask
In reply to Tony LuckIf the handler took any action to log or deal with the error, set a bit int mce->kflags so that the default handler on the end of the machine check chain can see what has been done.
Get rid of NOTIFY_STOP (well almost ... mce_amd.c is currently using it to filter out some GART TLB errors ... need to deal with that later).
Make the EDAC and dev-mcelog handlers skip over errors already processed by CEC.
--- arch/x86/kernel/cpu/mce/core.c | 4 +++- arch/x86/kernel/cpu/mce/dev-mcelog.c | 5 +++++ drivers/acpi/acpi_extlog.c | 5 +++-- drivers/acpi/nfit/mce.c | 1 + drivers/edac/i7core_edac.c | 5 +++-- drivers/edac/mce_amd.c | 9 +++++++-- drivers/edac/pnd2_edac.c | 5 +++-- drivers/edac/sb_edac.c | 5 ++++- drivers/edac/skx_common.c | 4 ++++ drivers/ras/cec.c | 9 ++++++--- 10 files changed, 39 insertions(+), 13 deletions(-)
arch/x86/kernel/cpu/mce/core.c +3 -1
@@ -579,8 +579,10 @@ static int uc_decode_notifier(struct notifier_block *nb, unsigned long val,return NOTIFY_DONE ; pfn = mce->addr >>PAGE_SHIFT ; -if (!memory_failure (pfn,0 )) +if (!memory_failure (pfn,0 )) {set_mce_nospec (pfn); + mce->kflags |=MCE_HANDLED_UC ; + }return NOTIFY_OK ; }
arch/x86/kernel/cpu/mce/dev-mcelog.c +5 -0
@@ -43,6 +43,9 @@ static int dev_mce_log(struct notifier_block *nb, unsigned long val,struct mce *mce = (struct mce *)data;unsigned int entry; +if (mce->kflags &MCE_HANDLED_CEC ) +return NOTIFY_DONE ; +mutex_lock (&mce_chrdev_read_mutex); entry = mcelog.next;
@@ -60,6 +63,7 @@ static int dev_mce_log(struct notifier_block *nb, unsigned long val,memcpy (mcelog.entry + entry, mce,sizeof (struct mce )); mcelog.entry[entry].finished =1 ; + mcelog.entry[entry].kflags =0 ;/* wake processes polling /dev/mcelog */ wake_up_interruptible (&mce_chrdev_wait);
@@ -67,6 +71,7 @@ static int dev_mce_log(struct notifier_block *nb, unsigned long val, unlock:mutex_unlock (&mce_chrdev_read_mutex); + mce->kflags |=MCE_HANDLED_MCELOG ;return NOTIFY_OK ; }
drivers/acpi/acpi_extlog.c +3 -2
@@ -146,7 +146,7 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,static u32 err_seq; estatus =extlog_elog_entry_check (cpu, bank); -if (estatus ==NULL ) +if (estatus ==NULL || (mce->kflags &MCE_HANDLED_CEC ))return NOTIFY_DONE ;memcpy (elog_buf, (void *)estatus,ELOG_ENTRY_LEN );
@@ -176,7 +176,8 @@ static int extlog_print(struct notifier_block *nb, unsigned long val, } out: -return NOTIFY_STOP ; + mce->kflags |=MCE_HANDLED_EXTLOG ; +return NOTIFY_OK ; }static bool __init extlog_get_l1addr (void )
drivers/acpi/nfit/mce.c +1 -0
@@ -76,6 +76,7 @@ static int nfit_handle_mce(struct notifier_block *nb, unsigned long val,*/ acpi_nfit_ars_rescan (acpi_desc,0 ); } + mce->kflags |=MCE_HANDLED_NFIT ;break ; }
drivers/edac/i7core_edac.c +3 -2
@@ -1815,7 +1815,7 @@ static int i7core_mce_check_error(struct notifier_block *nb, unsigned long val,struct mem_ctl_info *mci; i7_dev =get_i7core_dev (mce->socketid); -if (!i7_dev) +if (!i7_dev || (mce->kflags &MCE_HANDLED_CEC ))return NOTIFY_DONE ; mci = i7_dev->mci;
@@ -1834,7 +1834,8 @@ static int i7core_mce_check_error(struct notifier_block *nb, unsigned long val,i7core_check_error (mci, mce);/* Advise mcelog that the errors were handled */ -return NOTIFY_STOP ; + mce->kflags |=MCE_HANDLED_EDAC ; +return NOTIFY_OK ; }static struct notifier_block i7_mce_dec = {
drivers/edac/mce_amd.c +7 -2
@@ -1067,8 +1067,12 @@ amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data)unsigned int fam =x86_family (m->cpuid);int ecc; -if (ignore_mce (m)) +if (ignore_mce (m)) { + m->kflags |=MCE_HANDLED_EDAC ;return NOTIFY_STOP ; + } +if (m->kflags &MCE_HANDLED_CEC ) +return NOTIFY_DONE ;pr_emerg (HW_ERR "%s\n" ,decode_error_status (m));
@@ -1170,7 +1174,8 @@ amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data) err_code:amd_decode_err_code (m->status &0xffff ); -return NOTIFY_STOP ; + m->kflags |=MCE_HANDLED_EDAC ; +return NOTIFY_OK ; }static struct notifier_block amd_mce_dec_nb = {
drivers/edac/pnd2_edac.c +3 -2
@@ -1400,7 +1400,7 @@ static int pnd2_mce_check_error(struct notifier_block *nb, unsigned long val, voreturn NOTIFY_DONE ; mci = pnd2_mci; -if (!mci) +if (!mci || (mce->kflags &MCE_HANDLED_CEC ))return NOTIFY_DONE ;/*
@@ -1429,7 +1429,8 @@ static int pnd2_mce_check_error(struct notifier_block *nb, unsigned long val, vopnd2_mce_output_error (mci, mce, &daddr);/* Advice mcelog that the error were handled */ -return NOTIFY_STOP ; + mce->kflags |=MCE_HANDLED_EDAC ; +return NOTIFY_OK ; }static struct notifier_block pnd2_mce_dec = {
drivers/edac/sb_edac.c +4 -1
@@ -3136,6 +3136,8 @@ static int sbridge_mce_check_error(struct notifier_block *nb, unsigned long val,if (edac_get_report_status () ==EDAC_REPORTING_DISABLED )return NOTIFY_DONE ; +if (mce->kflags &MCE_HANDLED_CEC ) +return NOTIFY_DONE ;/* * Just let mcelog handle it if the error is
@@ -3183,7 +3185,8 @@ static int sbridge_mce_check_error(struct notifier_block *nb, unsigned long val,sbridge_mce_output_error (mci, mce);/* Advice mcelog that the error were handled */ -return NOTIFY_STOP ; + mce->kflags |=MCE_HANDLED_EDAC ; +return NOTIFY_OK ; }static struct notifier_block sbridge_mce_dec = {
drivers/edac/skx_common.c +4 -0
@@ -577,6 +577,9 @@ int skx_mce_check_error(struct notifier_block *nb, unsigned long val,if (edac_get_report_status () ==EDAC_REPORTING_DISABLED )return NOTIFY_DONE ; +if (mce->kflags &MCE_HANDLED_CEC ) +return NOTIFY_DONE ; +/* ignore unless this is memory related with an address */ if ((mce->status &0xefff ) >>7 !=1 || !(mce->status &MCI_STATUS_ADDRV ))return NOTIFY_DONE ;
@@ -616,6 +619,7 @@ int skx_mce_check_error(struct notifier_block *nb, unsigned long val,skx_mce_output_error (mci, mce, &res); + mce->kflags |=MCE_HANDLED_EDAC ;return NOTIFY_DONE ; }
drivers/ras/cec.c +6 -3
@@ -538,9 +538,12 @@ static int cec_notifier(struct notifier_block *nb, unsigned long val,/* We eat only correctable DRAM errors with usable addresses. */ if (mce_is_memory_error (m) &&mce_is_correctable (m) && -mce_usable_address (m)) -if (!cec_add_elem (m->addr >>PAGE_SHIFT )) -return NOTIFY_STOP ; +mce_usable_address (m)) { +if (!cec_add_elem (m->addr >>PAGE_SHIFT )) { + m->kflags |=MCE_HANDLED_CEC ; +return NOTIFY_OK ; + } + }return NOTIFY_DONE ; }
Signature · 1 line
2.21.1
Tony Luck
maintainerPATCH v2 1/7 x86/mce: Rename "first" function as "early"
In reply to Tony LuckIt isn't going to be first on the notifier chain when we move the CEC code to be a normal user of the notifier chain.
Fix the enum for the MCE_PRIO symbols to list them in reverse order so that the compiler can give them numbers from low to high priority. Add an entry for MCE_PRIO_CEC as the highest priority.
--- arch/x86/include/asm/mce.h | 15 ++++++++------- arch/x86/kernel/cpu/mce/core.c | 10 +++++----- 2 files changed, 13 insertions(+), 12 deletions(-)
arch/x86/include/asm/mce.h +8 -7
@@ -143,13 +143,14 @@ struct mce_log_buffer { };enum mce_notifier_prios { -MCE_PRIO_FIRST =INT_MAX , -MCE_PRIO_UC =INT_MAX -1 , -MCE_PRIO_EXTLOG =INT_MAX -2 , -MCE_PRIO_NFIT =INT_MAX -3 , -MCE_PRIO_EDAC =INT_MAX -4 , -MCE_PRIO_MCELOG =1 , -MCE_PRIO_LOWEST =0 , +MCE_PRIO_LOWEST , +MCE_PRIO_MCELOG , +MCE_PRIO_EDAC , +MCE_PRIO_NFIT , +MCE_PRIO_EXTLOG , +MCE_PRIO_UC , +MCE_PRIO_EARLY , +MCE_PRIO_CEC };struct notifier_block ;
arch/x86/kernel/cpu/mce/core.c +5 -5
@@ -557,7 +557,7 @@ static bool cec_add_mce(struct mce *m)return false; } -static int mce_first_notifier (struct notifier_block *nb,unsigned long val, +static int mce_early_notifier (struct notifier_block *nb,unsigned long val,void *data) {struct mce *m = (struct mce *)data;
@@ -578,9 +578,9 @@ static int mce_first_notifier(struct notifier_block *nb, unsigned long val,return NOTIFY_DONE ; } -static struct notifier_block first_nb = { - .notifier_call = mce_first_notifier, - .priority =MCE_PRIO_FIRST , +static struct notifier_block early_nb = { + .notifier_call = mce_early_notifier, + .priority =MCE_PRIO_EARLY , }; static int uc_decode_notifier(struct notifier_block *nb, unsigned long val,
@@ -2028,7 +2028,7 @@ __setup("mce", mcheck_enable);int __init mcheck_init (void ) {mcheck_intel_therm_init (); -mce_register_decode_chain (&first_nb); +mce_register_decode_chain (&early_nb);mce_register_decode_chain (&mce_uc_nb);mce_register_decode_chain (&mce_default_nb);mcheck_vendor_init_severity ();
Signature · 1 line
2.21.1
Tony Luck
maintainerPATCH v2 7/7 x86/mce: Drop the EDAC report status checks
In reply to Tony LuckWhen we added acpi_extlog we were worried that the same error would be reported more than once by different subsystems. But in the ensuing years I've seen complaints that people could not find an error log (because this mechanism suppressed the log they were looking for).
Rip it all out. People are smart enough to notice the same address from different reporting mechanisms.
--- drivers/acpi/acpi_extlog.c | 14 --------- drivers/edac/edac_mc.c | 61 -------------------------------------- drivers/edac/pnd2_edac.c | 3 -- drivers/edac/sb_edac.c | 4 --- drivers/edac/skx_common.c | 3 -- include/linux/edac.h | 8 ----- 6 files changed, 93 deletions(-)
drivers/acpi/acpi_extlog.c +0 -14
@@ -42,8 +42,6 @@ struct extlog_l1_head {u8 rev1[12 ]; }; -static int old_edac_report_status; -static u8 extlog_dsm_uuid[]__initdata ="663E35AF-CC10-41A4-88EA-5470AF055295" ;/* L1 table related physical address */
@@ -229,11 +227,6 @@ static int __init extlog_init(void)if (!(cap &MCG_ELOG_P ) || !extlog_get_l1addr ())return -ENODEV ; -if (edac_get_report_status () ==EDAC_REPORTING_FORCE ) { -pr_warn ("Not loading eMCA, error reporting force-enabled through EDAC.\n" ); -return -EPERM ; - } - rc = -EINVAL ;/* get L1 header to fetch necessary information */ l1_hdr_size =sizeof (struct extlog_l1_head );
@@ -281,12 +274,6 @@ static int __init extlog_init(void)if (elog_buf ==NULL ) goto err_release_elog; -/* -* eMCA event report method has higher priority than EDAC method, -* unless EDAC event report method is mandatory. -*/ - old_edac_report_status =edac_get_report_status (); -edac_set_report_status (EDAC_REPORTING_DISABLED );mce_register_decode_chain (&extlog_mce_dec);/* enable OS to be involved to take over management from BIOS */ ((struct extlog_l1_head *)extlog_l1_addr)->flags |=FLAG_OS_OPTIN ;
@@ -308,7 +295,6 @@ static int __init extlog_init(void) static void __exit extlog_exit(void) { -edac_set_report_status (old_edac_report_status);mce_unregister_decode_chain (&extlog_mce_dec); ((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN ;if (extlog_l1_addr)
drivers/edac/edac_mc.c +0 -61
73 lines not on this page · raw message
drivers/edac/pnd2_edac.c +0 -3
@@ -1396,9 +1396,6 @@ static int pnd2_mce_check_error(struct notifier_block *nb, unsigned long val, vostruct dram_addr daddr;char *type; -if (edac_get_report_status () ==EDAC_REPORTING_DISABLED ) -return NOTIFY_DONE ; - mci = pnd2_mci;if (!mci || (mce->kflags &MCE_HANDLED_CEC ))return NOTIFY_DONE ;
drivers/edac/sb_edac.c +0 -4
@@ -3134,8 +3134,6 @@ static int sbridge_mce_check_error(struct notifier_block *nb, unsigned long val,struct mem_ctl_info *mci;char *type; -if (edac_get_report_status () ==EDAC_REPORTING_DISABLED ) -return NOTIFY_DONE ;if (mce->kflags &MCE_HANDLED_CEC )return NOTIFY_DONE ;
@@ -3526,8 +3524,6 @@ static int __init sbridge_init(void)if (rc >=0 ) {mce_register_decode_chain (&sbridge_mce_dec); -if (edac_get_report_status () ==EDAC_REPORTING_DISABLED ) -sbridge_printk (KERN_WARNING ,"Loading driver, error reporting disabled.\n" );return 0 ; }
drivers/edac/skx_common.c +0 -3
@@ -574,9 +574,6 @@ int skx_mce_check_error(struct notifier_block *nb, unsigned long val,struct mem_ctl_info *mci;char *type; -if (edac_get_report_status () ==EDAC_REPORTING_DISABLED ) -return NOTIFY_DONE ; -if (mce->kflags &MCE_HANDLED_CEC )return NOTIFY_DONE ;
include/linux/edac.h +0 -8
@@ -31,14 +31,6 @@ struct device;extern int edac_op_state;struct bus_type *edac_get_sysfs_subsys (void ); -int edac_get_report_status (void ); -void edac_set_report_status (int new); - -enum { -EDAC_REPORTING_ENABLED , -EDAC_REPORTING_DISABLED , -EDAC_REPORTING_FORCE -};static inline void opstate_init (void ) {
Signature · 1 line
2.21.1
Tony Luck
maintainerPATCH v2 6/7 x86/mce: Add mce=print_all option
In reply to Tony LuckSometimes, when logs are getting lost, it's nice to just have everything dumped to the serial console.
--- arch/x86/kernel/cpu/mce/core.c | 7 ++++++- arch/x86/kernel/cpu/mce/internal.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/mce/core.c +6 -1
@@ -590,7 +590,7 @@ static int mce_default_notifier(struct notifier_block *nb, unsigned long val,if (!m)return NOTIFY_DONE ; -if (!m->kflags) +if (mca_cfg.print_all || !m->kflags)__print_mce (m);return NOTIFY_DONE ;
@@ -1950,6 +1950,7 @@ void mce_disable_bank(int bank)* mce=no_cmci Disables CMCI * mce=no_lmce Disables LMCE * mce=dont_log_ce Clears corrected events silently, no log created for CEs. +* mce=print_all Print all machine check logs to console * mce=ignore_ce Disables polling and CMCI, corrected events are not cleared. * mce=TOLERANCELEVEL[,monarchtimeout] (number, see above) * monarchtimeout is how long to wait for other CPUs on machine
@@ -1978,6 +1979,8 @@ static int __init mcheck_enable(char *str) cfg->lmce_disabled =1 ; else if (!strcmp(str, "dont_log_ce")) cfg->dont_log_ce = true; + else if (!strcmp(str, "print_all")) + cfg->print_all = true; else if (!strcmp(str, "ignore_ce")) cfg->ignore_ce = true; else if (!strcmp(str, "bootlog") || !strcmp(str, "nobootlog"))
@@ -2244,6 +2247,7 @@ static ssize_t store_int_with_restart(struct device *s, static DEVICE_INT_ATTR(tolerant, 0644, mca_cfg.tolerant); static DEVICE_INT_ATTR(monarch_timeout, 0644, mca_cfg.monarch_timeout); static DEVICE_BOOL_ATTR(dont_log_ce, 0644, mca_cfg.dont_log_ce); +static DEVICE_BOOL_ATTR(print_all, 0644, mca_cfg.print_all);static struct dev_ext_attribute dev_attr_check_interval = {__ATTR (check_interval,0644 , device_show_int, store_int_with_restart),
@@ -2268,6 +2272,7 @@ static struct device_attribute *mce_device_attrs[] = {#endif &dev_attr_monarch_timeout.attr, &dev_attr_dont_log_ce.attr, + &dev_attr_print_all.attr, &dev_attr_ignore_ce.attr, &dev_attr_cmci_disabled.attr,NULL
arch/x86/kernel/cpu/mce/internal.h +1 -0
@@ -114,6 +114,7 @@ struct mca_config {bool dont_log_ce;bool cmci_disabled;bool ignore_ce; +bool print_all; __u64 lmce_disabled : 1, disabled : 1,
Signature · 1 line
2.21.1
Tony Luck
maintainerPATCH v2 3/7 x86/mce: Add new "kflags" field to "struct mce"
In reply to Tony LuckThere can be many different subsystems register on the mce handler chain. Add a new bitmask field and define values so that handlers can indicate whether they took any action to log or otherwise handle an error.
The default handler at the end of the chain can use this information to decide whether to print to the console log.
Boris suggested a generic name and leaving plenty of spare bits for possible future use.
--- arch/x86/include/uapi/asm/mce.h | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/x86/include/uapi/asm/mce.h +9 -0
@@ -35,8 +35,17 @@ struct mce {__u64 ipid;/* MCA_IPID MSR: only valid on SMCA systems */ __u64 ppin;/* Protected Processor Inventory Number */ __u32 microcode;/* Microcode revision */ +__u64 kflags;/* Internal kernel use. See below */ }; +/* kflags flag bits for logging etc. */ +#define MCE_HANDLED_CEC BIT(0) +#define MCE_HANDLED_UC BIT(1) +#define MCE_HANDLED_EXTLOG BIT(2) +#define MCE_HANDLED_NFIT BIT(3) +#define MCE_HANDLED_EDAC BIT(4) +#define MCE_HANDLED_MCELOG BIT(5) +#define MCE_GET_RECORD_LEN _IOR('M', 1, int)#define MCE_GET_LOG_LEN _IOR('M', 2, int)#define MCE_GETCLEAR_FLAGS _IOR('M', 3, int)
Signature · 1 line
2.21.1
Tony Luck
maintainerPATCH v2 2/7 x86/mce: Convert corrected error collector to use mce notifier
In reply to Tony LuckThe CEC code has its claws in a couple of routines in mce/core.c
Convert it to just register itself on the normal mce notifier chain.
--- arch/x86/kernel/cpu/mce/core.c | 19 ------------------- drivers/ras/cec.c | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 19 deletions(-)
arch/x86/kernel/cpu/mce/core.c +0 -19
@@ -542,21 +542,6 @@ bool mce_is_correctable(struct mce *m) }EXPORT_SYMBOL_GPL (mce_is_correctable); -static bool cec_add_mce (struct mce *m) -{ -if (!m) -return false; - -/* We eat only correctable DRAM errors with usable addresses. */ -if (mce_is_memory_error (m) && -mce_is_correctable (m) && -mce_usable_address (m)) -if (!cec_add_elem (m->addr >>PAGE_SHIFT )) -return true; - -return false; -} -static int mce_early_notifier (struct notifier_block *nb,unsigned long val,void *data) {
@@ -565,9 +550,6 @@ static int mce_early_notifier(struct notifier_block *nb, unsigned long val,if (!m)return NOTIFY_DONE ; -if (cec_add_mce (m)) -return NOTIFY_STOP ; -/* Emit the trace record: */ trace_mce_record (m);
@@ -2588,7 +2570,6 @@ static int __init mcheck_late_init(void)static_branch_inc (&mcsafe_key);mcheck_debugfs_init (); -cec_init ();/* * Flush out everything that has been logged during early boot, now that
drivers/ras/cec.c +26 -0
@@ -527,6 +527,29 @@ static int __init create_debugfs_nodes(void)return 1 ; } +static int cec_notifier (struct notifier_block *nb,unsigned long val, +void *data) +{ +struct mce *m = (struct mce *)data; + +if (!m) +return NOTIFY_DONE ; + +/* We eat only correctable DRAM errors with usable addresses. */ +if (mce_is_memory_error (m) && +mce_is_correctable (m) && +mce_usable_address (m)) +if (!cec_add_elem (m->addr >>PAGE_SHIFT )) +return NOTIFY_STOP ; + +return NOTIFY_DONE ; +} + +static struct notifier_block cec_nb = { + .notifier_call = cec_notifier, + .priority =MCE_PRIO_CEC , +}; +void __init cec_init (void ) {if (ce_arr.disabled)
@@ -546,8 +569,11 @@ void __init cec_init(void)INIT_DELAYED_WORK (&cec_work, cec_work_fn);schedule_delayed_work (&cec_work,CEC_DECAY_DEFAULT_INTERVAL ); +mce_register_decode_chain (&cec_nb); +pr_info ("Correctable Errors collector initialized.\n" ); } +late_initcall (cec_init);int __init parse_cec_param (char *str) {
Signature · 1 line
2.21.1
Tony Luck
maintainerv2 cover New way to track mce notifier chain actions
In reply to Tony LuckParts 1 & 2 are just cleanup. CEC should follow the same rules as everyone else who wants to be on the mce notifier chain. No real reason for it to have direct hooks into mce/core.c
[No substantive change since RFC version 1, but note that
I have kept the change to make CEC a "normal" user of the mce notifier chain. Result is a few checks for if (mce->kflags & MCE_HANDLED_CEC) in EDAC etc. drivers.]
Part 3 adds a field to struct mce, and defines the BIT fields for each class of notifier. All EDAC drivers share the same BIT since only one of them should be active.
[Boris: Changed name of new field to "kflags" and made
it __u64, so plenty of space for possible future other uses]
Part 4 Re-done since draft based on Luto and Tglx comments that
we should kill of all usage of NOTIFY_STOP. This patch now gets rid of all but one. That's an AMD case where it looks like they don't want to decode some particular errors on a specific platform. The right fix for that is to take Luto's advice and filter out before that item gets to the notifier chain. We even already have a filter function (filter_mce) to do that! But that change needs to be handled by someone with the appropriate h/w.
Part 5 Now just checks for mce->kflags in the default handler at
the end of the chain to decide whether to print.
Part 6 NEW - add mce=print_all option to override default and
print everything to the console. Intended for debug, or desperation scenarios where other logs are lost.
Part 7 NEW - Delete the code that tries to make sure only one
out of acpi_extlog and the current loaded EDAC driver deals with an error.
Tony Luck (7):
x86/mce: Rename "first" function as "early"
x86/mce: Convert corrected error collector to use mce notifier x86/mce: Add new "kflags" field to "struct mce" x86/mce: Fix all mce notifiers to update the mce->kflags bitmask x86/mce: Change default mce logger to check mce->kflags x86/mce: Add mce=print_all option
x86/mce: Drop the EDAC report status checks
arch/x86/include/asm/mce.h | 15 +++---- arch/x86/include/uapi/asm/mce.h | 9 ++++ arch/x86/kernel/cpu/mce/core.c | 58 ++++++++------------------ arch/x86/kernel/cpu/mce/dev-mcelog.c | 5 +++ arch/x86/kernel/cpu/mce/internal.h | 1 + drivers/acpi/acpi_extlog.c | 19 ++------- drivers/acpi/nfit/mce.c | 1 + drivers/edac/edac_mc.c | 61 ---------------------------- drivers/edac/i7core_edac.c | 5 ++- drivers/edac/mce_amd.c | 9 +++- drivers/edac/pnd2_edac.c | 8 ++-- drivers/edac/sb_edac.c | 7 ++-- drivers/edac/skx_common.c | 3 +- drivers/ras/cec.c | 29 +++++++++++++ include/linux/edac.h | 8 ---- 15 files changed, 91 insertions(+), 147 deletions(-)
base-commit: b19e8c68470385dd2c5440876591fddb02c8c402
Signature · 1 line
2.21.1
Borislav Petkov
maintainerRe: [PATCH v2 4/7] x86/mce: Fix all mce notifiers to update the mce->kflags bitmask
In reply to Tony LuckQuoted 7 lines · Tony Luck
If the handler took any action to log or deal with the error, set a bit int
mce->kflagsso that the default handler on the end of the machine check chain can see what has been done.Get rid of
NOTIFY_STOP(well almost ...mce_amd.cis currently using it to filter out some GART TLB errors ... need to deal with that later).
Here's me dealing with it :-)
Btw, no need to resend with it - I'm already queueing it all locally here along with more rework ontop and send it all once done.
Thx.
---
From 3eee69c7cf32578aafe050051d0406a1e6fbacbb Mon Sep 17 00:00:00 2001
From: Borislav Petkov <[email protected]>
Date: Tue, 7 Apr 2020 09:55:10 +0200
Subject: [PATCH] x86/mce/amd, edac: Remove report_gart_errors
... because no one should be interested in spurious MCEs anyway. Make the filtering unconditional and move it to amd_filter_mce().
--- arch/x86/include/asm/mce.h | 3 ++- arch/x86/kernel/cpu/mce/amd.c | 9 +++++++-- drivers/edac/amd64_edac.c | 8 -------- drivers/edac/mce_amd.c | 24 ------------------------ drivers/edac/mce_amd.h | 2 -- 5 files changed, 9 insertions(+), 37 deletions(-)
arch/x86/include/asm/mce.h +2 -1
@@ -127,6 +127,8 @@#define MSR_AMD64_SMCA_MCx_DEADDR (x) (MSR_AMD64_SMCA_MC0_DEADDR + 0x10*(x))#define MSR_AMD64_SMCA_MCx_MISCy (x, y) ((MSR_AMD64_SMCA_MC0_MISC1 + y) + (0x10*(x))) +#define XEC (x, mask) (((x) >> 16) & mask) +/* * This structure contains all data related to the MCE log. Also * carries a signature to make it easier to find from external
@@ -347,5 +349,4 @@ umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) { return#endif static inline void mce_hygon_feature_init (struct cpuinfo_x86 *c) {return mce_amd_feature_init (c); } -#endif /* _ASM_X86_MCE_H */
arch/x86/kernel/cpu/mce/amd.c +7 -2
@@ -577,14 +577,19 @@ bool amd_filter_mce(struct mce *m) {enum smca_bank_types bank_type =smca_get_bank_type (m->bank);struct cpuinfo_x86 *c = &boot_cpu_data; -u8 xec = (m->status >>16 ) &0x3F ;/* See Family 17h Models 10h-2Fh Erratum #1114. */ if (c->x86 ==0x17 && c->x86_model >=0x10 && c->x86_model <=0x2F && - bank_type ==SMCA_IF && xec ==10 ) + bank_type ==SMCA_IF &&XEC (m->status,0x3f ) ==10 )return true; +/* NB GART TLB error reporting is disabled by default. */ +if (c->x86 <0x17 ) { +if (m->bank ==4 &&XEC (m->status,0x1f ) ==0x5 ) +return true; + } +return false; }
drivers/edac/amd64_edac.c +0 -8
@@ -4,9 +4,6 @@static struct edac_pci_ctl_info *pci_ctl; -static int report_gart_errors; -module_param (report_gart_errors, int,0644 ); -/* * Set by command line parameter. If BIOS has enabled the ECC, this override is * cleared to prevent re-enabling the hardware by this driver.
@@ -3681,9 +3678,6 @@ static int __init amd64_edac_init(void) }/* register stuff with EDAC MCE */ -if (report_gart_errors) -amd_report_gart_errors (true); -if (boot_cpu_data.x86 >=0x17 )amd_register_ecc_decoder (decode_umc_error);else
@@ -3718,8 +3712,6 @@ static void __exit amd64_edac_exit(void)edac_pci_release_generic_ctl (pci_ctl);/* unregister from EDAC MCE */ -amd_report_gart_errors (false); -if (boot_cpu_data.x86 >=0x17 )amd_unregister_ecc_decoder (decode_umc_error);else
drivers/edac/mce_amd.c +0 -24
@@ -10,15 +10,8 @@ static struct amd_decoder_ops fam_ops;static u8 xec_mask =0xf ; -static bool report_gart_errors;static void (*decode_dram_ecc)(int node_id,struct mce *m); -void amd_report_gart_errors (bool v) -{ - report_gart_errors = v; -} -EXPORT_SYMBOL_GPL (amd_report_gart_errors); -void amd_register_ecc_decoder (void (*f)(int ,struct mce *)) { decode_dram_ecc = f;
@@ -1030,20 +1023,6 @@ static inline void amd_decode_err_code(u16 ec)pr_cont ("\n" ); } -/* -* Filter out unwanted MCE signatures here. -*/ -static bool ignore_mce (struct mce *m) -{ -/* -* NB GART TLB error reporting is disabled by default. -*/ -if (m->bank ==4 &&XEC (m->status,0x1f ) ==0x5 && !report_gart_errors) -return true; - -return false; -} -static const char *decode_error_status (struct mce *m) {if (m->status &MCI_STATUS_UC ) {
@@ -1067,9 +1046,6 @@ amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data)unsigned int fam =x86_family (m->cpuid);int ecc; -if (ignore_mce (m)) -return NOTIFY_STOP ; -pr_emerg (HW_ERR "%s\n" ,decode_error_status (m)); pr_emerg(HW_ERR "CPU:%d (%x:%x:%x) MC%d_STATUS[%s|%s|%s|%s|%s",
drivers/edac/mce_amd.h +0 -2
@@ -7,7 +7,6 @@#include <asm/mce.h> #define EC (x) ((x) & 0xffff) -#define XEC (x, mask) (((x) >> 16) & mask)#define LOW_SYNDROME (x) (((x) >> 15) & 0xff)#define HIGH_SYNDROME (x) (((x) >> 24) & 0xff)
@@ -77,7 +76,6 @@ struct amd_decoder_ops {bool (*mc2_mce)(u16 ,u8 ); }; -void amd_report_gart_errors (bool );void amd_register_ecc_decoder (void (*f)(int ,struct mce *));void amd_unregister_ecc_decoder (void (*f)(int ,struct mce *));
Signature · 7 lines
2.21.0
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteBorislav Petkov
maintainerRe: [PATCH v2 5/7] x86/mce: Change default mce logger to check mce->kflags
In reply to Tony Luckarch/x86/kernel/cpu/mce/core.c static void __print_mce(struct mce *m) · line 253
Quoted 6 lines · Tony Luck
arch/x86/kernel/cpu/mce/core.c +2
-0@@ -261,6 +249,8 @@ static void __print_mce(struct mce *m) }pr_cont ("\n" ); +if (m->kflags) +pr_emerg (HW_ERR "kflags = 0x%llx\n" , m->kflags);
I've zapped that hunk. I'd like to avoid exposing those kflags to luserspace in any shape or form for now.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteBorislav Petkov
maintainerv3 cover New way to track mce notifier chain actions
In reply to Tony LuckFrom: Borislav Petkov <[email protected]>
Hi all,
here's what I have. I'd like to keep mce.kflags hidden for now.
The last patch is something tglx spotted yesterday and fixing that with the MCE flags is pretty easy - was boxing with a wrapper struct around struct mce and that gets really ugly.
Tony, I'm open to suggestions how to test it - I probably don't have an access to such box which can trigger read errors on nvdimms or what was the use case?
Thx.
Borislav Petkov (2):
x86/mce/amd, edac: Remove report_gart_errors x86/mce: Fixup exception only for the correct MCEs
Tony Luck (7):
x86/mce: Rename "first" function as "early"
x86/mce: Convert the CEC to use the MCE notifier x86/mce: Add a struct mce.kflags field
x86/mce: Fix all mce notifiers to update the mce->kflags bitmask x86/mce: Change default MCE logger to check mce->kflags x86/mce: Add mce=print_all option
EDAC: Drop the EDAC report status checks
arch/x86/include/asm/mce.h | 28 +++++++---- arch/x86/include/uapi/asm/mce.h | 1 + arch/x86/kernel/cpu/mce/amd.c | 9 +++- arch/x86/kernel/cpu/mce/core.c | 72 +++++++++++----------------- arch/x86/kernel/cpu/mce/dev-mcelog.c | 5 ++ arch/x86/kernel/cpu/mce/internal.h | 1 + arch/x86/kernel/cpu/mce/severity.c | 6 ++- drivers/acpi/acpi_extlog.c | 19 ++------ drivers/acpi/nfit/mce.c | 1 + drivers/edac/amd64_edac.c | 8 ---- drivers/edac/edac_mc.c | 61 ----------------------- drivers/edac/i7core_edac.c | 5 +- drivers/edac/mce_amd.c | 28 ++--------- drivers/edac/mce_amd.h | 2 - drivers/edac/pnd2_edac.c | 8 ++-- drivers/edac/sb_edac.c | 7 ++- drivers/edac/skx_common.c | 3 +- drivers/ras/cec.c | 33 ++++++++++++- include/linux/edac.h | 8 ---- include/linux/ras.h | 5 -- 20 files changed, 118 insertions(+), 192 deletions(-)
Signature · 1 line
2.21.0
Borislav Petkov
maintainerPATCH v3 1/9 x86/mce/amd, edac: Remove report_gart_errors
From: Borislav Petkov <[email protected]>
... because no one should be interested in spurious MCEs anyway. Make the filtering unconditional and move it to amd_filter_mce().
--- arch/x86/include/asm/mce.h | 3 ++- arch/x86/kernel/cpu/mce/amd.c | 9 +++++++-- drivers/edac/amd64_edac.c | 8 -------- drivers/edac/mce_amd.c | 24 ------------------------ drivers/edac/mce_amd.h | 2 -- 5 files changed, 9 insertions(+), 37 deletions(-)
arch/x86/include/asm/mce.h +2 -1
@@ -127,6 +127,8 @@#define MSR_AMD64_SMCA_MCx_DEADDR (x) (MSR_AMD64_SMCA_MC0_DEADDR + 0x10*(x))#define MSR_AMD64_SMCA_MCx_MISCy (x, y) ((MSR_AMD64_SMCA_MC0_MISC1 + y) + (0x10*(x))) +#define XEC (x, mask) (((x) >> 16) & mask) +/* * This structure contains all data related to the MCE log. Also * carries a signature to make it easier to find from external
@@ -347,5 +349,4 @@ umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) { return#endif static inline void mce_hygon_feature_init (struct cpuinfo_x86 *c) {return mce_amd_feature_init (c); } -#endif /* _ASM_X86_MCE_H */
arch/x86/kernel/cpu/mce/amd.c +7 -2
@@ -577,14 +577,19 @@ bool amd_filter_mce(struct mce *m) {enum smca_bank_types bank_type =smca_get_bank_type (m->bank);struct cpuinfo_x86 *c = &boot_cpu_data; -u8 xec = (m->status >>16 ) &0x3F ;/* See Family 17h Models 10h-2Fh Erratum #1114. */ if (c->x86 ==0x17 && c->x86_model >=0x10 && c->x86_model <=0x2F && - bank_type ==SMCA_IF && xec ==10 ) + bank_type ==SMCA_IF &&XEC (m->status,0x3f ) ==10 )return true; +/* NB GART TLB error reporting is disabled by default. */ +if (c->x86 <0x17 ) { +if (m->bank ==4 &&XEC (m->status,0x1f ) ==0x5 ) +return true; + } +return false; }
drivers/edac/amd64_edac.c +0 -8
@@ -4,9 +4,6 @@static struct edac_pci_ctl_info *pci_ctl; -static int report_gart_errors; -module_param (report_gart_errors, int,0644 ); -/* * Set by command line parameter. If BIOS has enabled the ECC, this override is * cleared to prevent re-enabling the hardware by this driver.
@@ -3681,9 +3678,6 @@ static int __init amd64_edac_init(void) }/* register stuff with EDAC MCE */ -if (report_gart_errors) -amd_report_gart_errors (true); -if (boot_cpu_data.x86 >=0x17 )amd_register_ecc_decoder (decode_umc_error);else
@@ -3718,8 +3712,6 @@ static void __exit amd64_edac_exit(void)edac_pci_release_generic_ctl (pci_ctl);/* unregister from EDAC MCE */ -amd_report_gart_errors (false); -if (boot_cpu_data.x86 >=0x17 )amd_unregister_ecc_decoder (decode_umc_error);else
drivers/edac/mce_amd.c +0 -24
@@ -10,15 +10,8 @@ static struct amd_decoder_ops fam_ops;static u8 xec_mask =0xf ; -static bool report_gart_errors;static void (*decode_dram_ecc)(int node_id,struct mce *m); -void amd_report_gart_errors (bool v) -{ - report_gart_errors = v; -} -EXPORT_SYMBOL_GPL (amd_report_gart_errors); -void amd_register_ecc_decoder (void (*f)(int ,struct mce *)) { decode_dram_ecc = f;
@@ -1030,20 +1023,6 @@ static inline void amd_decode_err_code(u16 ec)pr_cont ("\n" ); } -/* -* Filter out unwanted MCE signatures here. -*/ -static bool ignore_mce (struct mce *m) -{ -/* -* NB GART TLB error reporting is disabled by default. -*/ -if (m->bank ==4 &&XEC (m->status,0x1f ) ==0x5 && !report_gart_errors) -return true; - -return false; -} -static const char *decode_error_status (struct mce *m) {if (m->status &MCI_STATUS_UC ) {
@@ -1067,9 +1046,6 @@ amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data)unsigned int fam =x86_family (m->cpuid);int ecc; -if (ignore_mce (m)) -return NOTIFY_STOP ; -pr_emerg (HW_ERR "%s\n" ,decode_error_status (m)); pr_emerg(HW_ERR "CPU:%d (%x:%x:%x) MC%d_STATUS[%s|%s|%s|%s|%s",
drivers/edac/mce_amd.h +0 -2
@@ -7,7 +7,6 @@#include <asm/mce.h> #define EC (x) ((x) & 0xffff) -#define XEC (x, mask) (((x) >> 16) & mask)#define LOW_SYNDROME (x) (((x) >> 15) & 0xff)#define HIGH_SYNDROME (x) (((x) >> 24) & 0xff)
@@ -77,7 +76,6 @@ struct amd_decoder_ops {bool (*mc2_mce)(u16 ,u8 ); }; -void amd_report_gart_errors (bool );void amd_register_ecc_decoder (void (*f)(int ,struct mce *));void amd_unregister_ecc_decoder (void (*f)(int ,struct mce *));
Signature · 1 line
2.21.0
Borislav Petkov
maintainerPATCH v3 2/9 x86/mce: Rename "first" function as "early"
In reply to Borislav PetkovFrom: Tony Luck <[email protected]>
It isn't going to be first on the notifier chain when the CEC is moved to be a normal user of the notifier chain.
Fix the enum for the MCE_PRIO symbols to list them in reverse order so that the compiler can give them numbers from low to high priority. Add an entry for MCE_PRIO_CEC as the highest priority.
[ bp: Use passive voice, add comments. ]
--- arch/x86/include/asm/mce.h | 16 +++++++++------- arch/x86/kernel/cpu/mce/core.c | 10 +++++----- 2 files changed, 14 insertions(+), 12 deletions(-)
arch/x86/include/asm/mce.h +9 -7
@@ -144,14 +144,16 @@ struct mce_log_buffer {struct mce entry[]; }; +/* Highest last */ enum mce_notifier_prios { -MCE_PRIO_FIRST =INT_MAX , -MCE_PRIO_UC =INT_MAX -1 , -MCE_PRIO_EXTLOG =INT_MAX -2 , -MCE_PRIO_NFIT =INT_MAX -3 , -MCE_PRIO_EDAC =INT_MAX -4 , -MCE_PRIO_MCELOG =1 , -MCE_PRIO_LOWEST =0 , +MCE_PRIO_LOWEST , +MCE_PRIO_MCELOG , +MCE_PRIO_EDAC , +MCE_PRIO_NFIT , +MCE_PRIO_EXTLOG , +MCE_PRIO_UC , +MCE_PRIO_EARLY , +MCE_PRIO_CEC };struct notifier_block ;
arch/x86/kernel/cpu/mce/core.c +5 -5
@@ -559,7 +559,7 @@ static bool cec_add_mce(struct mce *m)return false; } -static int mce_first_notifier (struct notifier_block *nb,unsigned long val, +static int mce_early_notifier (struct notifier_block *nb,unsigned long val,void *data) {struct mce *m = (struct mce *)data;
@@ -580,9 +580,9 @@ static int mce_first_notifier(struct notifier_block *nb, unsigned long val,return NOTIFY_DONE ; } -static struct notifier_block first_nb = { - .notifier_call = mce_first_notifier, - .priority =MCE_PRIO_FIRST , +static struct notifier_block early_nb = { + .notifier_call = mce_early_notifier, + .priority =MCE_PRIO_EARLY , }; static int uc_decode_notifier(struct notifier_block *nb, unsigned long val,
@@ -2041,7 +2041,7 @@ __setup("mce", mcheck_enable);int __init mcheck_init (void ) {mcheck_intel_therm_init (); -mce_register_decode_chain (&first_nb); +mce_register_decode_chain (&early_nb);mce_register_decode_chain (&mce_uc_nb);mce_register_decode_chain (&mce_default_nb);mcheck_vendor_init_severity ();
Signature · 1 line
2.21.0
Borislav Petkov
maintainerPATCH v3 7/9 x86/mce: Add mce=print_all option
In reply to Borislav PetkovFrom: Tony Luck <[email protected]>
Sometimes, when logs are getting lost, it's nice to just have everything dumped to the serial console.
--- arch/x86/kernel/cpu/mce/core.c | 7 ++++++- arch/x86/kernel/cpu/mce/internal.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/mce/core.c +6 -1
@@ -591,7 +591,7 @@ static int mce_default_notifier(struct notifier_block *nb, unsigned long val,if (!m)return NOTIFY_DONE ; -if (!m->kflags) +if (mca_cfg.print_all || !m->kflags)__print_mce (m);return NOTIFY_DONE ;
@@ -1962,6 +1962,7 @@ void mce_disable_bank(int bank)* mce=no_cmci Disables CMCI * mce=no_lmce Disables LMCE * mce=dont_log_ce Clears corrected events silently, no log created for CEs. +* mce=print_all Print all machine check logs to console * mce=ignore_ce Disables polling and CMCI, corrected events are not cleared. * mce=TOLERANCELEVEL[,monarchtimeout] (number, see above) * monarchtimeout is how long to wait for other CPUs on machine
@@ -1990,6 +1991,8 @@ static int __init mcheck_enable(char *str) cfg->lmce_disabled =1 ; else if (!strcmp(str, "dont_log_ce")) cfg->dont_log_ce = true; + else if (!strcmp(str, "print_all")) + cfg->print_all = true; else if (!strcmp(str, "ignore_ce")) cfg->ignore_ce = true; else if (!strcmp(str, "bootlog") || !strcmp(str, "nobootlog"))
@@ -2256,6 +2259,7 @@ static ssize_t store_int_with_restart(struct device *s, static DEVICE_INT_ATTR(tolerant, 0644, mca_cfg.tolerant); static DEVICE_INT_ATTR(monarch_timeout, 0644, mca_cfg.monarch_timeout); static DEVICE_BOOL_ATTR(dont_log_ce, 0644, mca_cfg.dont_log_ce); +static DEVICE_BOOL_ATTR(print_all, 0644, mca_cfg.print_all);static struct dev_ext_attribute dev_attr_check_interval = {__ATTR (check_interval,0644 , device_show_int, store_int_with_restart),
@@ -2280,6 +2284,7 @@ static struct device_attribute *mce_device_attrs[] = {#endif &dev_attr_monarch_timeout.attr, &dev_attr_dont_log_ce.attr, + &dev_attr_print_all.attr, &dev_attr_ignore_ce.attr, &dev_attr_cmci_disabled.attr,NULL
arch/x86/kernel/cpu/mce/internal.h +1 -0
@@ -119,6 +119,7 @@ struct mca_config {bool dont_log_ce;bool cmci_disabled;bool ignore_ce; +bool print_all; __u64 lmce_disabled : 1, disabled : 1,
Signature · 1 line
2.21.0
Borislav Petkov
maintainerPATCH v3 9/9 x86/mce: Fixup exception only for the correct MCEs
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
The severity grading code returns IN_KERNEL_RECOV error context for errors which have happened in kernel space but from which the kernel can recover. Whether the recovery can happen is determined by the exception table entry having as handler ex_handler_fault() and which has been declared at build time using _ASM_EXTABLE_FAULT().
IN_KERNEL_RECOV is used in mce_severity_intel() to lookup the corresponding error severity in the severities table.
However, the mapping back from error severity to whether the error is IN_KERNEL_RECOV is ambiguous and in the very paranoid case - which might not be possible right now - but be better safe than sorry later, an exception fixup could be attempted for another MCE whose address is in the exception table and has the proper severity. Which would be unfortunate, to say the least.
Therefore, mark such MCEs explicitly as MCE_IN_KERNEL_RECOV so that the recovery attempt is done only for them.
Document the whole handling, while at it, as it is not trivial.
--- arch/x86/include/asm/mce.h | 1 + arch/x86/kernel/cpu/mce/core.c | 15 +++++++++++++-- arch/x86/kernel/cpu/mce/severity.c | 6 +++++- 3 files changed, 19 insertions(+), 3 deletions(-)
arch/x86/include/asm/mce.h +1 -0
@@ -136,6 +136,7 @@#define MCE_HANDLED_NFIT BIT_ULL(3)#define MCE_HANDLED_EDAC BIT_ULL(4)#define MCE_HANDLED_MCELOG BIT_ULL(5) +#define MCE_IN_KERNEL_RECOV BIT_ULL(6)/* * This structure contains all data related to the MCE log. Also
arch/x86/kernel/cpu/mce/core.c +13 -2
@@ -1331,8 +1331,19 @@ void notrace do_machine_check(struct pt_regs *regs, long error_code)local_irq_disable ();ist_end_non_atomic (); }else { -if (!fixup_exception (regs,X86_TRAP_MC , error_code,0 )) -mce_panic ("Failed kernel mode recovery" , &m, msg); +/* +* Handle an MCE which has happened in kernel space but from +* which the kernel can recover: ex_has_fault_handler() has +* already verified that the rIP at which the error happened is +* a rIP from which the kernel can recover (by jumping to +* recovery code specified in _ASM_EXTABLE_FAULT()) and the +* corresponding exception handler which would do that is the +* proper one. +*/ +if (m.kflags &MCE_IN_KERNEL_RECOV ) { +if (!fixup_exception (regs,X86_TRAP_MC , error_code,0 )) +mce_panic ("Failed kernel mode recovery" , &m, msg); + } } out_ist:
arch/x86/kernel/cpu/mce/severity.c +5 -1
@@ -213,8 +213,12 @@ static int error_context(struct mce *m) {if ((m->cs &3 ) ==3 )return IN_USER ; -if (mc_recoverable (m->mcgstatus) &&ex_has_fault_handler (m->ip)) + +if (mc_recoverable (m->mcgstatus) &&ex_has_fault_handler (m->ip)) { + m->kflags |=MCE_IN_KERNEL_RECOV ;return IN_KERNEL_RECOV ; + } +return IN_KERNEL ; }
Signature · 1 line
2.21.0
Borislav Petkov
maintainerPATCH v3 5/9 x86/mce: Fix all mce notifiers to update the mce->kflags bitmask
In reply to Borislav PetkovFrom: Tony Luck <[email protected]>
If the handler took any action to log or deal with the error, set a bit in mce->kflags so that the default handler on the end of the machine check chain can see what has been done.
Get rid of NOTIFY_STOP returns. Make the EDAC and dev-mcelog handlers skip over errors already processed by CEC.
--- arch/x86/kernel/cpu/mce/core.c | 4 +++- arch/x86/kernel/cpu/mce/dev-mcelog.c | 5 +++++ drivers/acpi/acpi_extlog.c | 5 +++-- drivers/acpi/nfit/mce.c | 1 + drivers/edac/i7core_edac.c | 5 +++-- drivers/edac/mce_amd.c | 6 +++++- drivers/edac/pnd2_edac.c | 5 +++-- drivers/edac/sb_edac.c | 5 ++++- drivers/edac/skx_common.c | 4 ++++ drivers/ras/cec.c | 9 ++++++--- 10 files changed, 37 insertions(+), 12 deletions(-)
arch/x86/kernel/cpu/mce/core.c +3 -1
@@ -581,8 +581,10 @@ static int uc_decode_notifier(struct notifier_block *nb, unsigned long val,return NOTIFY_DONE ; pfn = mce->addr >>PAGE_SHIFT ; -if (!memory_failure (pfn,0 )) +if (!memory_failure (pfn,0 )) {set_mce_nospec (pfn); + mce->kflags |=MCE_HANDLED_UC ; + }return NOTIFY_OK ; }
arch/x86/kernel/cpu/mce/dev-mcelog.c +5 -0
@@ -39,6 +39,9 @@ static int dev_mce_log(struct notifier_block *nb, unsigned long val,struct mce *mce = (struct mce *)data;unsigned int entry; +if (mce->kflags &MCE_HANDLED_CEC ) +return NOTIFY_DONE ; +mutex_lock (&mce_chrdev_read_mutex); entry = mcelog->next;
@@ -56,6 +59,7 @@ static int dev_mce_log(struct notifier_block *nb, unsigned long val,memcpy (mcelog->entry + entry, mce,sizeof (struct mce )); mcelog->entry[entry].finished =1 ; + mcelog->entry[entry].kflags =0 ;/* wake processes polling /dev/mcelog */ wake_up_interruptible (&mce_chrdev_wait);
@@ -63,6 +67,7 @@ static int dev_mce_log(struct notifier_block *nb, unsigned long val, unlock:mutex_unlock (&mce_chrdev_read_mutex); + mce->kflags |=MCE_HANDLED_MCELOG ;return NOTIFY_OK ; }
drivers/acpi/acpi_extlog.c +3 -2
@@ -146,7 +146,7 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,static u32 err_seq; estatus =extlog_elog_entry_check (cpu, bank); -if (estatus ==NULL ) +if (estatus ==NULL || (mce->kflags &MCE_HANDLED_CEC ))return NOTIFY_DONE ;memcpy (elog_buf, (void *)estatus,ELOG_ENTRY_LEN );
@@ -176,7 +176,8 @@ static int extlog_print(struct notifier_block *nb, unsigned long val, } out: -return NOTIFY_STOP ; + mce->kflags |=MCE_HANDLED_EXTLOG ; +return NOTIFY_OK ; }static bool __init extlog_get_l1addr (void )
drivers/acpi/nfit/mce.c +1 -0
@@ -76,6 +76,7 @@ static int nfit_handle_mce(struct notifier_block *nb, unsigned long val,*/ acpi_nfit_ars_rescan (acpi_desc,0 ); } + mce->kflags |=MCE_HANDLED_NFIT ;break ; }
drivers/edac/i7core_edac.c +3 -2
@@ -1815,7 +1815,7 @@ static int i7core_mce_check_error(struct notifier_block *nb, unsigned long val,struct mem_ctl_info *mci; i7_dev =get_i7core_dev (mce->socketid); -if (!i7_dev) +if (!i7_dev || (mce->kflags &MCE_HANDLED_CEC ))return NOTIFY_DONE ; mci = i7_dev->mci;
@@ -1834,7 +1834,8 @@ static int i7core_mce_check_error(struct notifier_block *nb, unsigned long val,i7core_check_error (mci, mce);/* Advise mcelog that the errors were handled */ -return NOTIFY_STOP ; + mce->kflags |=MCE_HANDLED_EDAC ; +return NOTIFY_OK ; }static struct notifier_block i7_mce_dec = {
drivers/edac/mce_amd.c +5 -1
@@ -1046,6 +1046,9 @@ amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data)unsigned int fam =x86_family (m->cpuid);int ecc; +if (m->kflags &MCE_HANDLED_CEC ) +return NOTIFY_DONE ; +pr_emerg (HW_ERR "%s\n" ,decode_error_status (m)); pr_emerg(HW_ERR "CPU:%d (%x:%x:%x) MC%d_STATUS[%s|%s|%s|%s|%s",
@@ -1146,7 +1149,8 @@ amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data) err_code:amd_decode_err_code (m->status &0xffff ); -return NOTIFY_STOP ; + m->kflags |=MCE_HANDLED_EDAC ; +return NOTIFY_OK ; }static struct notifier_block amd_mce_dec_nb = {
drivers/edac/pnd2_edac.c +3 -2
@@ -1400,7 +1400,7 @@ static int pnd2_mce_check_error(struct notifier_block *nb, unsigned long val, voreturn NOTIFY_DONE ; mci = pnd2_mci; -if (!mci) +if (!mci || (mce->kflags &MCE_HANDLED_CEC ))return NOTIFY_DONE ;/*
@@ -1429,7 +1429,8 @@ static int pnd2_mce_check_error(struct notifier_block *nb, unsigned long val, vopnd2_mce_output_error (mci, mce, &daddr);/* Advice mcelog that the error were handled */ -return NOTIFY_STOP ; + mce->kflags |=MCE_HANDLED_EDAC ; +return NOTIFY_OK ; }static struct notifier_block pnd2_mce_dec = {
drivers/edac/sb_edac.c +4 -1
@@ -3136,6 +3136,8 @@ static int sbridge_mce_check_error(struct notifier_block *nb, unsigned long val,if (edac_get_report_status () ==EDAC_REPORTING_DISABLED )return NOTIFY_DONE ; +if (mce->kflags &MCE_HANDLED_CEC ) +return NOTIFY_DONE ;/* * Just let mcelog handle it if the error is
@@ -3183,7 +3185,8 @@ static int sbridge_mce_check_error(struct notifier_block *nb, unsigned long val,sbridge_mce_output_error (mci, mce);/* Advice mcelog that the error were handled */ -return NOTIFY_STOP ; + mce->kflags |=MCE_HANDLED_EDAC ; +return NOTIFY_OK ; }static struct notifier_block sbridge_mce_dec = {
drivers/edac/skx_common.c +4 -0
@@ -577,6 +577,9 @@ int skx_mce_check_error(struct notifier_block *nb, unsigned long val,if (edac_get_report_status () ==EDAC_REPORTING_DISABLED )return NOTIFY_DONE ; +if (mce->kflags &MCE_HANDLED_CEC ) +return NOTIFY_DONE ; +/* ignore unless this is memory related with an address */ if ((mce->status &0xefff ) >>7 !=1 || !(mce->status &MCI_STATUS_ADDRV ))return NOTIFY_DONE ;
@@ -616,6 +619,7 @@ int skx_mce_check_error(struct notifier_block *nb, unsigned long val,skx_mce_output_error (mci, mce, &res); + mce->kflags |=MCE_HANDLED_EDAC ;return NOTIFY_DONE ; }
drivers/ras/cec.c +6 -3
@@ -538,9 +538,12 @@ static int cec_notifier(struct notifier_block *nb, unsigned long val,/* We eat only correctable DRAM errors with usable addresses. */ if (mce_is_memory_error (m) &&mce_is_correctable (m) && -mce_usable_address (m)) -if (!cec_add_elem (m->addr >>PAGE_SHIFT )) -return NOTIFY_STOP ; +mce_usable_address (m)) { +if (!cec_add_elem (m->addr >>PAGE_SHIFT )) { + m->kflags |=MCE_HANDLED_CEC ; +return NOTIFY_OK ; + } + }return NOTIFY_DONE ; }
Signature · 1 line
2.21.0
Borislav Petkov
maintainerPATCH v3 6/9 x86/mce: Change default MCE logger to check mce->kflags
In reply to Borislav PetkovFrom: Tony Luck <[email protected]>
Instead of keeping count of how many handlers are registered on the MCE notifier chain and printing if below some magic value, look at mce->kflags to see if anyone claims to have handled/logged this error.
[ bp: Do not print ->kflags in __print_mce(). ]
--- arch/x86/kernel/cpu/mce/core.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-)
arch/x86/kernel/cpu/mce/core.c +3 -16
@@ -158,29 +158,17 @@ void mce_log(struct mce *m) }EXPORT_SYMBOL_GPL (mce_log); -/* -* We run the default notifier if we have only the UC, the first and the -* default notifier registered. I.e., the mandatory NUM_DEFAULT_NOTIFIERS -* notifiers registered on the chain. -*/ -#define NUM_DEFAULT_NOTIFIERS 3 -static atomic_t num_notifiers; -void mce_register_decode_chain (struct notifier_block *nb) {if (WARN_ON (nb->priority >MCE_PRIO_MCELOG && nb->priority <MCE_PRIO_EDAC ))return ; -atomic_inc (&num_notifiers); -blocking_notifier_chain_register (&x86_mce_decoder_chain, nb); }EXPORT_SYMBOL_GPL (mce_register_decode_chain);void mce_unregister_decode_chain (struct notifier_block *nb) { -atomic_dec (&num_notifiers); -blocking_notifier_chain_unregister (&x86_mce_decoder_chain, nb); }EXPORT_SYMBOL_GPL (mce_unregister_decode_chain);
@@ -263,6 +251,7 @@ static void __print_mce(struct mce *m) }pr_cont ("\n" ); +/* * Note this output is parsed by external tools and old fields * should not be changed.
@@ -602,10 +591,8 @@ static int mce_default_notifier(struct notifier_block *nb, unsigned long val,if (!m)return NOTIFY_DONE ; -if (atomic_read (&num_notifiers) >NUM_DEFAULT_NOTIFIERS ) -return NOTIFY_DONE ; - -__print_mce (m); +if (!m->kflags) +__print_mce (m);return NOTIFY_DONE ; }
Signature · 1 line
2.21.0
Borislav Petkov
maintainerPATCH v3 8/9 EDAC: Drop the EDAC report status checks
In reply to Borislav PetkovFrom: Tony Luck <[email protected]>
When acpi_extlog was added, we were worried that the same error would be reported more than once by different subsystems. But in the ensuing years I've seen complaints that people could not find an error log (because this mechanism suppressed the log they were looking for).
Rip it all out. People are smart enough to notice the same address from different reporting mechanisms.
--- drivers/acpi/acpi_extlog.c | 14 --------- drivers/edac/edac_mc.c | 61 -------------------------------------- drivers/edac/pnd2_edac.c | 3 -- drivers/edac/sb_edac.c | 4 --- drivers/edac/skx_common.c | 3 -- include/linux/edac.h | 8 ----- 6 files changed, 93 deletions(-)
drivers/acpi/acpi_extlog.c +0 -14
@@ -42,8 +42,6 @@ struct extlog_l1_head {u8 rev1[12 ]; }; -static int old_edac_report_status; -static u8 extlog_dsm_uuid[]__initdata ="663E35AF-CC10-41A4-88EA-5470AF055295" ;/* L1 table related physical address */
@@ -229,11 +227,6 @@ static int __init extlog_init(void)if (!(cap &MCG_ELOG_P ) || !extlog_get_l1addr ())return -ENODEV ; -if (edac_get_report_status () ==EDAC_REPORTING_FORCE ) { -pr_warn ("Not loading eMCA, error reporting force-enabled through EDAC.\n" ); -return -EPERM ; - } - rc = -EINVAL ;/* get L1 header to fetch necessary information */ l1_hdr_size =sizeof (struct extlog_l1_head );
@@ -281,12 +274,6 @@ static int __init extlog_init(void)if (elog_buf ==NULL ) goto err_release_elog; -/* -* eMCA event report method has higher priority than EDAC method, -* unless EDAC event report method is mandatory. -*/ - old_edac_report_status =edac_get_report_status (); -edac_set_report_status (EDAC_REPORTING_DISABLED );mce_register_decode_chain (&extlog_mce_dec);/* enable OS to be involved to take over management from BIOS */ ((struct extlog_l1_head *)extlog_l1_addr)->flags |=FLAG_OS_OPTIN ;
@@ -308,7 +295,6 @@ static int __init extlog_init(void) static void __exit extlog_exit(void) { -edac_set_report_status (old_edac_report_status);mce_unregister_decode_chain (&extlog_mce_dec); ((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN ;if (extlog_l1_addr)
drivers/edac/edac_mc.c +0 -61
73 lines not on this page · raw message
drivers/edac/pnd2_edac.c +0 -3
@@ -1396,9 +1396,6 @@ static int pnd2_mce_check_error(struct notifier_block *nb, unsigned long val, vostruct dram_addr daddr;char *type; -if (edac_get_report_status () ==EDAC_REPORTING_DISABLED ) -return NOTIFY_DONE ; - mci = pnd2_mci;if (!mci || (mce->kflags &MCE_HANDLED_CEC ))return NOTIFY_DONE ;
drivers/edac/sb_edac.c +0 -4
@@ -3134,8 +3134,6 @@ static int sbridge_mce_check_error(struct notifier_block *nb, unsigned long val,struct mem_ctl_info *mci;char *type; -if (edac_get_report_status () ==EDAC_REPORTING_DISABLED ) -return NOTIFY_DONE ;if (mce->kflags &MCE_HANDLED_CEC )return NOTIFY_DONE ;
@@ -3526,8 +3524,6 @@ static int __init sbridge_init(void)if (rc >=0 ) {mce_register_decode_chain (&sbridge_mce_dec); -if (edac_get_report_status () ==EDAC_REPORTING_DISABLED ) -sbridge_printk (KERN_WARNING ,"Loading driver, error reporting disabled.\n" );return 0 ; }
drivers/edac/skx_common.c +0 -3
@@ -574,9 +574,6 @@ int skx_mce_check_error(struct notifier_block *nb, unsigned long val,struct mem_ctl_info *mci;char *type; -if (edac_get_report_status () ==EDAC_REPORTING_DISABLED ) -return NOTIFY_DONE ; -if (mce->kflags &MCE_HANDLED_CEC )return NOTIFY_DONE ;
include/linux/edac.h +0 -8
@@ -31,14 +31,6 @@ struct device;extern int edac_op_state;struct bus_type *edac_get_sysfs_subsys (void ); -int edac_get_report_status (void ); -void edac_set_report_status (int new); - -enum { -EDAC_REPORTING_ENABLED , -EDAC_REPORTING_DISABLED , -EDAC_REPORTING_FORCE -};static inline void opstate_init (void ) {
Signature · 1 line
2.21.0
Borislav Petkov
maintainerPATCH v3 3/9 x86/mce: Convert the CEC to use the MCE notifier
In reply to Borislav PetkovFrom: Tony Luck <[email protected]>
The CEC code has its claws in a couple of routines in mce/core.c. Convert it to just register itself on the normal MCE notifier chain.
[ bp: Make cec_add_elem() and cec_init() static. ]
--- arch/x86/kernel/cpu/mce/core.c | 19 ------------------- drivers/ras/cec.c | 30 ++++++++++++++++++++++++++++-- include/linux/ras.h | 5 ----- 3 files changed, 28 insertions(+), 26 deletions(-)
arch/x86/kernel/cpu/mce/core.c +0 -19
@@ -544,21 +544,6 @@ bool mce_is_correctable(struct mce *m) }EXPORT_SYMBOL_GPL (mce_is_correctable); -static bool cec_add_mce (struct mce *m) -{ -if (!m) -return false; - -/* We eat only correctable DRAM errors with usable addresses. */ -if (mce_is_memory_error (m) && -mce_is_correctable (m) && -mce_usable_address (m)) -if (!cec_add_elem (m->addr >>PAGE_SHIFT )) -return true; - -return false; -} -static int mce_early_notifier (struct notifier_block *nb,unsigned long val,void *data) {
@@ -567,9 +552,6 @@ static int mce_early_notifier(struct notifier_block *nb, unsigned long val,if (!m)return NOTIFY_DONE ; -if (cec_add_mce (m)) -return NOTIFY_STOP ; -/* Emit the trace record: */ trace_mce_record (m);
@@ -2612,7 +2594,6 @@ static int __init mcheck_late_init(void)static_branch_inc (&mcsafe_key);mcheck_debugfs_init (); -cec_init ();/* * Flush out everything that has been logged during early boot, now that
drivers/ras/cec.c +28 -2
@@ -309,7 +309,7 @@ static bool sanity_check(struct ce_array *ca)return ret; } -int cec_add_elem (u64 pfn) +static int cec_add_elem (u64 pfn) {struct ce_array *ca = &ce_arr;unsigned int to =0 ;
@@ -527,7 +527,30 @@ static int __init create_debugfs_nodes(void)return 1 ; } -void __init cec_init (void ) +static int cec_notifier (struct notifier_block *nb,unsigned long val, +void *data) +{ +struct mce *m = (struct mce *)data; + +if (!m) +return NOTIFY_DONE ; + +/* We eat only correctable DRAM errors with usable addresses. */ +if (mce_is_memory_error (m) && +mce_is_correctable (m) && +mce_usable_address (m)) +if (!cec_add_elem (m->addr >>PAGE_SHIFT )) +return NOTIFY_STOP ; + +return NOTIFY_DONE ; +} + +static struct notifier_block cec_nb = { + .notifier_call = cec_notifier, + .priority =MCE_PRIO_CEC , +}; + +static void __init cec_init (void ) {if (ce_arr.disabled)return ;
@@ -546,8 +569,11 @@ void __init cec_init(void)INIT_DELAYED_WORK (&cec_work, cec_work_fn);schedule_delayed_work (&cec_work,CEC_DECAY_DEFAULT_INTERVAL ); +mce_register_decode_chain (&cec_nb); +pr_info ("Correctable Errors collector initialized.\n" ); } +late_initcall (cec_init);int __init parse_cec_param (char *str) {
include/linux/ras.h +0 -5
@@ -17,12 +17,7 @@ static inline int ras_add_daemon_trace(void) { return 0; }#endif #ifdef CONFIG_RAS_CEC -void __init cec_init (void );int __init parse_cec_param (char *str); -int cec_add_elem (u64 pfn); -#else -static inline void __init cec_init (void ) { } -static inline int cec_add_elem (u64 pfn) {return -ENODEV ; }#endif #ifdef CONFIG_RAS
Signature · 1 line
2.21.0
Borislav Petkov
maintainerPATCH v3 4/9 x86/mce: Add a struct mce.kflags field
In reply to Borislav PetkovFrom: Tony Luck <[email protected]>
There can be many different subsystems register on the mce handler chain. Add a new bitmask field and define values so that handlers can indicate whether they took any action to log or otherwise handle an error.
The default handler at the end of the chain can use this information to decide whether to print to the console log.
Boris suggested a generic name and leaving plenty of spare bits for possible future use.
[ bp: Move flag bits to the internal mce.h header and use BIT_ULL(). ]
--- arch/x86/include/asm/mce.h | 8 ++++++++ arch/x86/include/uapi/asm/mce.h | 1 + 2 files changed, 9 insertions(+)
arch/x86/include/asm/mce.h +8 -0
@@ -129,6 +129,14 @@#define XEC (x, mask) (((x) >> 16) & mask) +/* mce.kflags flag bits for logging etc. */ +#define MCE_HANDLED_CEC BIT_ULL(0) +#define MCE_HANDLED_UC BIT_ULL(1) +#define MCE_HANDLED_EXTLOG BIT_ULL(2) +#define MCE_HANDLED_NFIT BIT_ULL(3) +#define MCE_HANDLED_EDAC BIT_ULL(4) +#define MCE_HANDLED_MCELOG BIT_ULL(5) +/* * This structure contains all data related to the MCE log. Also * carries a signature to make it easier to find from external
arch/x86/include/uapi/asm/mce.h +1 -0
@@ -35,6 +35,7 @@ struct mce {__u64 ipid;/* MCA_IPID MSR: only valid on SMCA systems */ __u64 ppin;/* Protected Processor Inventory Number */ __u32 microcode;/* Microcode revision */ +__u64 kflags;/* Internal kernel use. See below */ };#define MCE_GET_RECORD_LEN _IOR('M', 1, int)
Signature · 1 line
2.21.0
Luck, Tony
maintainerRE: [PATCH v2 5/7] x86/mce: Change default mce logger to check mce->kflags
In reply to Borislav PetkovQuoted 5 lines
arch/x86/kernel/cpu/mce/core.c static void __print_mce(struct mce *m) · line 253
Quoted 2 lines
arch/x86/kernel/cpu/mce/core.c +2
-0+if (m->kflags) +pr_emerg (HW_ERR "kflags = 0x%llx\n" , m->kflags);I've zapped that hunk. I'd like to avoid exposing those kflags to luserspace in any shape or form for now.
Sure. It was useful while I was debugging. But I'm sure all the bugs are gone now :-)
-Tony
Borislav Petkov
maintainerRe: [PATCH v2 5/7] x86/mce: Change default mce logger to check mce->kflags
Quoted 8 lines · Tony
Quoted 5 lines
arch/x86/kernel/cpu/mce/core.c static void __print_mce(struct mce *m) · line 253
Quoted 2 lines
arch/x86/kernel/cpu/mce/core.c +2
-0+if (m->kflags) +pr_emerg (HW_ERR "kflags = 0x%llx\n" , m->kflags);I've zapped that hunk. I'd like to avoid exposing those kflags to luserspace in any shape or form for now.
Sure. It was useful while I was debugging. But I'm sure all the bugs are gone now :-)
Do you need it for debugging?
If yes, it should be really clear that it is a debugging print and nothing should rely on it. We could do a cmdline-param controllable debugging scheme which tools cannot mistakenly start using and it becomes an ABI, all of a sudden.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteLuck, Tony
maintainerRE: [PATCH v2 5/7] x86/mce: Change default mce logger to check mce->kflags
Quoted 4 lines
Quoted 2 lines
Sure. It was useful while I was debugging. But I'm sure all the bugs are gone now :-)
Do you need it for debugging?
I doubt it. It was handy to see that CEC/EDAC/MCELOG had correctly set their own bits while I was testing.
If I ever need to see it again, I can put a printk() back in.
-Tony
Quoted 7 lines
The last patch is something tglx spotted yesterday and fixing that with the MCE flags is pretty easy - was boxing with a wrapper struct around struct mce and that gets really ugly.
Tony, I'm open to suggestions how to test it - I probably don't have an access to such box which can trigger read errors on nvdimms or what was the use case?
It passes my smoke tests (uncorrectable error consumed by application and uncorrectable error consumed by mcsafe_memcpy()).
-Tony
Borislav Petkov
maintainerQuoted 2 lines · Tony
It passes my smoke tests (uncorrectable error consumed by application and uncorrectable error consumed by
mcsafe_memcpy()).
That, of course, is even better, thanks for testing!
Quoted 1 line
Tested-by Tony Luck <[email protected]>
Thx, I'll queue the whole pile next week.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette[tip: ras/core] x86/mce: Convert the CEC to use the MCE notifier
In reply to Tony LuckThe following commit has been merged into the ras/core branch of tip:
The following commit has been merged into the ras/core branch of tip:
Commit-ID: 9554bfe403bdfc084823df8695a01f28c680af61 Gitweb: https://git.kernel.org/tip/9554bfe403bdfc084823df8695a01f28c680af61 Author: Tony Luck <[email protected]> AuthorDate: Fri, 14 Feb 2020 14:27:15 -08:00 Committer: Borislav Petkov <[email protected]> CommitterDate: Tue, 14 Apr 2020 15:58:08 +02:00
x86/mce: Convert the CEC to use the MCE notifier
The CEC code has its claws in a couple of routines in mce/core.c. Convert it to just register itself on the normal MCE notifier chain.
[ bp: Make cec_add_elem() and cec_init() static. ]
--- arch/x86/kernel/cpu/mce/core.c | 19 ------------------- drivers/ras/cec.c | 30 ++++++++++++++++++++++++++++-- include/linux/ras.h | 5 ----- 3 files changed, 28 insertions(+), 26 deletions(-)
arch/x86/kernel/cpu/mce/core.c +0 -19
@@ -544,21 +544,6 @@ bool mce_is_correctable(struct mce *m) }EXPORT_SYMBOL_GPL (mce_is_correctable); -static bool cec_add_mce (struct mce *m) -{ -if (!m) -return false; - -/* We eat only correctable DRAM errors with usable addresses. */ -if (mce_is_memory_error (m) && -mce_is_correctable (m) && -mce_usable_address (m)) -if (!cec_add_elem (m->addr >>PAGE_SHIFT )) -return true; - -return false; -} -static int mce_early_notifier (struct notifier_block *nb,unsigned long val,void *data) {
@@ -567,9 +552,6 @@ static int mce_early_notifier(struct notifier_block *nb, unsigned long val,if (!m)return NOTIFY_DONE ; -if (cec_add_mce (m)) -return NOTIFY_STOP ; -/* Emit the trace record: */ trace_mce_record (m);
@@ -2612,7 +2594,6 @@ static int __init mcheck_late_init(void)static_branch_inc (&mcsafe_key);mcheck_debugfs_init (); -cec_init ();/* * Flush out everything that has been logged during early boot, now that
drivers/ras/cec.c +28 -2
@@ -309,7 +309,7 @@ static bool sanity_check(struct ce_array *ca)return ret; } -int cec_add_elem (u64 pfn) +static int cec_add_elem (u64 pfn) {struct ce_array *ca = &ce_arr;unsigned int to =0 ;
@@ -527,7 +527,30 @@ err:return 1 ; } -void __init cec_init (void ) +static int cec_notifier (struct notifier_block *nb,unsigned long val, +void *data) +{ +struct mce *m = (struct mce *)data; + +if (!m) +return NOTIFY_DONE ; + +/* We eat only correctable DRAM errors with usable addresses. */ +if (mce_is_memory_error (m) && +mce_is_correctable (m) && +mce_usable_address (m)) +if (!cec_add_elem (m->addr >>PAGE_SHIFT )) +return NOTIFY_STOP ; + +return NOTIFY_DONE ; +} + +static struct notifier_block cec_nb = { + .notifier_call = cec_notifier, + .priority =MCE_PRIO_CEC , +}; + +static void __init cec_init (void ) {if (ce_arr.disabled)return ;
@@ -546,8 +569,11 @@ void __init cec_init(void)INIT_DELAYED_WORK (&cec_work, cec_work_fn);schedule_delayed_work (&cec_work,CEC_DECAY_DEFAULT_INTERVAL ); +mce_register_decode_chain (&cec_nb); +pr_info ("Correctable Errors collector initialized.\n" ); } +late_initcall (cec_init);int __init parse_cec_param (char *str) {
include/linux/ras.h +0 -5
@@ -17,12 +17,7 @@ static inline int ras_add_daemon_trace(void) { return 0; }#endif #ifdef CONFIG_RAS_CEC -void __init cec_init (void );int __init parse_cec_param (char *str); -int cec_add_elem (u64 pfn); -#else -static inline void __init cec_init (void ) { } -static inline int cec_add_elem (u64 pfn) {return -ENODEV ; }#endif #ifdef CONFIG_RAS
[tip: ras/core] x86/mce: Rename "first" function as "early"
In reply to Tony LuckThe following commit has been merged into the ras/core branch of tip:
The following commit has been merged into the ras/core branch of tip:
Commit-ID: c9c6d216ed28be6e2c91e3651af169eca284813a Gitweb: https://git.kernel.org/tip/c9c6d216ed28be6e2c91e3651af169eca284813a Author: Tony Luck <[email protected]> AuthorDate: Fri, 14 Feb 2020 14:27:14 -08:00 Committer: Borislav Petkov <[email protected]> CommitterDate: Tue, 14 Apr 2020 15:55:01 +02:00
x86/mce: Rename "first" function as "early"
It isn't going to be first on the notifier chain when the CEC is moved to be a normal user of the notifier chain.
Fix the enum for the MCE_PRIO symbols to list them in reverse order so that the compiler can give them numbers from low to high priority. Add an entry for MCE_PRIO_CEC as the highest priority.
[ bp: Use passive voice, add comments. ]
--- arch/x86/include/asm/mce.h | 16 +++++++++------- arch/x86/kernel/cpu/mce/core.c | 10 +++++----- 2 files changed, 14 insertions(+), 12 deletions(-)
arch/x86/include/asm/mce.h +9 -7
@@ -144,14 +144,16 @@ struct mce_log_buffer {struct mce entry[]; }; +/* Highest last */ enum mce_notifier_prios { -MCE_PRIO_FIRST =INT_MAX , -MCE_PRIO_UC =INT_MAX -1 , -MCE_PRIO_EXTLOG =INT_MAX -2 , -MCE_PRIO_NFIT =INT_MAX -3 , -MCE_PRIO_EDAC =INT_MAX -4 , -MCE_PRIO_MCELOG =1 , -MCE_PRIO_LOWEST =0 , +MCE_PRIO_LOWEST , +MCE_PRIO_MCELOG , +MCE_PRIO_EDAC , +MCE_PRIO_NFIT , +MCE_PRIO_EXTLOG , +MCE_PRIO_UC , +MCE_PRIO_EARLY , +MCE_PRIO_CEC };struct notifier_block ;
arch/x86/kernel/cpu/mce/core.c +5 -5
@@ -559,7 +559,7 @@ static bool cec_add_mce(struct mce *m)return false; } -static int mce_first_notifier (struct notifier_block *nb,unsigned long val, +static int mce_early_notifier (struct notifier_block *nb,unsigned long val,void *data) {struct mce *m = (struct mce *)data;
@@ -580,9 +580,9 @@ static int mce_first_notifier(struct notifier_block *nb, unsigned long val,return NOTIFY_DONE ; } -static struct notifier_block first_nb = { - .notifier_call = mce_first_notifier, - .priority =MCE_PRIO_FIRST , +static struct notifier_block early_nb = { + .notifier_call = mce_early_notifier, + .priority =MCE_PRIO_EARLY , }; static int uc_decode_notifier(struct notifier_block *nb, unsigned long val,
@@ -2041,7 +2041,7 @@ __setup("mce", mcheck_enable);int __init mcheck_init (void ) {mcheck_intel_therm_init (); -mce_register_decode_chain (&first_nb); +mce_register_decode_chain (&early_nb);mce_register_decode_chain (&mce_uc_nb);mce_register_decode_chain (&mce_default_nb);mcheck_vendor_init_severity ();
[tip: ras/core] x86/mce: Fixup exception only for the correct MCEs
In reply to Borislav PetkovThe following commit has been merged into the ras/core branch of tip:
The following commit has been merged into the ras/core branch of tip:
Commit-ID: 1df73b2131e3b33d518609769636b41ce00212de Gitweb: https://git.kernel.org/tip/1df73b2131e3b33d518609769636b41ce00212de Author: Borislav Petkov <[email protected]> AuthorDate: Tue, 07 Apr 2020 13:49:58 +02:00 Committer: Borislav Petkov <[email protected]> CommitterDate: Tue, 14 Apr 2020 16:01:49 +02:00
x86/mce: Fixup exception only for the correct MCEs
The severity grading code returns IN_KERNEL_RECOV error context for errors which have happened in kernel space but from which the kernel can recover. Whether the recovery can happen is determined by the exception table entry having as handler ex_handler_fault() and which has been declared at build time using _ASM_EXTABLE_FAULT().
IN_KERNEL_RECOV is used in mce_severity_intel() to lookup the corresponding error severity in the severities table.
However, the mapping back from error severity to whether the error is IN_KERNEL_RECOV is ambiguous and in the very paranoid case - which might not be possible right now - but be better safe than sorry later, an exception fixup could be attempted for another MCE whose address is in the exception table and has the proper severity. Which would be unfortunate, to say the least.
Therefore, mark such MCEs explicitly as MCE_IN_KERNEL_RECOV so that the recovery attempt is done only for them.
Document the whole handling, while at it, as it is not trivial.
--- arch/x86/include/asm/mce.h | 1 + arch/x86/kernel/cpu/mce/core.c | 15 +++++++++++++-- arch/x86/kernel/cpu/mce/severity.c | 6 +++++- 3 files changed, 19 insertions(+), 3 deletions(-)
arch/x86/include/asm/mce.h +1 -0
@@ -136,6 +136,7 @@#define MCE_HANDLED_NFIT BIT_ULL(3)#define MCE_HANDLED_EDAC BIT_ULL(4)#define MCE_HANDLED_MCELOG BIT_ULL(5) +#define MCE_IN_KERNEL_RECOV BIT_ULL(6)/* * This structure contains all data related to the MCE log. Also
arch/x86/kernel/cpu/mce/core.c +13 -2
@@ -1331,8 +1331,19 @@ void notrace do_machine_check(struct pt_regs *regs, long error_code)local_irq_disable ();ist_end_non_atomic (); }else { -if (!fixup_exception (regs,X86_TRAP_MC , error_code,0 )) -mce_panic ("Failed kernel mode recovery" , &m, msg); +/* +* Handle an MCE which has happened in kernel space but from +* which the kernel can recover: ex_has_fault_handler() has +* already verified that the rIP at which the error happened is +* a rIP from which the kernel can recover (by jumping to +* recovery code specified in _ASM_EXTABLE_FAULT()) and the +* corresponding exception handler which would do that is the +* proper one. +*/ +if (m.kflags &MCE_IN_KERNEL_RECOV ) { +if (!fixup_exception (regs,X86_TRAP_MC , error_code,0 )) +mce_panic ("Failed kernel mode recovery" , &m, msg); + } } out_ist:
arch/x86/kernel/cpu/mce/severity.c +5 -1
@@ -213,8 +213,12 @@ static int error_context(struct mce *m) {if ((m->cs &3 ) ==3 )return IN_USER ; -if (mc_recoverable (m->mcgstatus) &&ex_has_fault_handler (m->ip)) + +if (mc_recoverable (m->mcgstatus) &&ex_has_fault_handler (m->ip)) { + m->kflags |=MCE_IN_KERNEL_RECOV ;return IN_KERNEL_RECOV ; + } +return IN_KERNEL ; }
[tip: ras/core] x86/mce: Change default MCE logger to check mce->kflags
In reply to Tony LuckThe following commit has been merged into the ras/core branch of tip:
The following commit has been merged into the ras/core branch of tip:
Commit-ID: 925946cfa715a5a71639528f82b98e58f14dd4cb Gitweb: https://git.kernel.org/tip/925946cfa715a5a71639528f82b98e58f14dd4cb Author: Tony Luck <[email protected]> AuthorDate: Fri, 14 Feb 2020 14:27:18 -08:00 Committer: Borislav Petkov <[email protected]> CommitterDate: Tue, 14 Apr 2020 15:59:57 +02:00
x86/mce: Change default MCE logger to check mce->kflags
Instead of keeping count of how many handlers are registered on the MCE notifier chain and printing if below some magic value, look at mce->kflags to see if anyone claims to have handled/logged this error.
[ bp: Do not print ->kflags in __print_mce(). ]
--- arch/x86/kernel/cpu/mce/core.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-)
arch/x86/kernel/cpu/mce/core.c +3 -16
@@ -158,29 +158,17 @@ void mce_log(struct mce *m) }EXPORT_SYMBOL_GPL (mce_log); -/* -* We run the default notifier if we have only the UC, the first and the -* default notifier registered. I.e., the mandatory NUM_DEFAULT_NOTIFIERS -* notifiers registered on the chain. -*/ -#define NUM_DEFAULT_NOTIFIERS 3 -static atomic_t num_notifiers; -void mce_register_decode_chain (struct notifier_block *nb) {if (WARN_ON (nb->priority >MCE_PRIO_MCELOG && nb->priority <MCE_PRIO_EDAC ))return ; -atomic_inc (&num_notifiers); -blocking_notifier_chain_register (&x86_mce_decoder_chain, nb); }EXPORT_SYMBOL_GPL (mce_register_decode_chain);void mce_unregister_decode_chain (struct notifier_block *nb) { -atomic_dec (&num_notifiers); -blocking_notifier_chain_unregister (&x86_mce_decoder_chain, nb); }EXPORT_SYMBOL_GPL (mce_unregister_decode_chain);
@@ -263,6 +251,7 @@ static void __print_mce(struct mce *m) }pr_cont ("\n" ); +/* * Note this output is parsed by external tools and old fields * should not be changed.
@@ -602,10 +591,8 @@ static int mce_default_notifier(struct notifier_block *nb, unsigned long val,if (!m)return NOTIFY_DONE ; -if (atomic_read (&num_notifiers) >NUM_DEFAULT_NOTIFIERS ) -return NOTIFY_DONE ; - -__print_mce (m); +if (!m->kflags) +__print_mce (m);return NOTIFY_DONE ; }
[tip: ras/core] x86/mce: Add mce=print_all option
In reply to Tony LuckThe following commit has been merged into the ras/core branch of tip:
The following commit has been merged into the ras/core branch of tip:
Commit-ID: 43505646941bee217b91d064756975aa1ab6ee3b Gitweb: https://git.kernel.org/tip/43505646941bee217b91d064756975aa1ab6ee3b Author: Tony Luck <[email protected]> AuthorDate: Fri, 14 Feb 2020 14:27:19 -08:00 Committer: Borislav Petkov <[email protected]> CommitterDate: Tue, 14 Apr 2020 16:00:30 +02:00
x86/mce: Add mce=print_all option
Sometimes, when logs are getting lost, it's nice to just have everything dumped to the serial console.
--- arch/x86/kernel/cpu/mce/core.c | 7 ++++++- arch/x86/kernel/cpu/mce/internal.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/mce/core.c +6 -1
@@ -591,7 +591,7 @@ static int mce_default_notifier(struct notifier_block *nb, unsigned long val,if (!m)return NOTIFY_DONE ; -if (!m->kflags) +if (mca_cfg.print_all || !m->kflags)__print_mce (m);return NOTIFY_DONE ;
@@ -1962,6 +1962,7 @@ void mce_disable_bank(int bank)* mce=no_cmci Disables CMCI * mce=no_lmce Disables LMCE * mce=dont_log_ce Clears corrected events silently, no log created for CEs. +* mce=print_all Print all machine check logs to console * mce=ignore_ce Disables polling and CMCI, corrected events are not cleared. * mce=TOLERANCELEVEL[,monarchtimeout] (number, see above) * monarchtimeout is how long to wait for other CPUs on machine
@@ -1990,6 +1991,8 @@ static int __init mcheck_enable(char *str) cfg->lmce_disabled =1 ; else if (!strcmp(str, "dont_log_ce")) cfg->dont_log_ce = true; + else if (!strcmp(str, "print_all")) + cfg->print_all = true; else if (!strcmp(str, "ignore_ce")) cfg->ignore_ce = true; else if (!strcmp(str, "bootlog") || !strcmp(str, "nobootlog"))
@@ -2256,6 +2259,7 @@ static ssize_t store_int_with_restart(struct device *s, static DEVICE_INT_ATTR(tolerant, 0644, mca_cfg.tolerant); static DEVICE_INT_ATTR(monarch_timeout, 0644, mca_cfg.monarch_timeout); static DEVICE_BOOL_ATTR(dont_log_ce, 0644, mca_cfg.dont_log_ce); +static DEVICE_BOOL_ATTR(print_all, 0644, mca_cfg.print_all);static struct dev_ext_attribute dev_attr_check_interval = {__ATTR (check_interval,0644 , device_show_int, store_int_with_restart),
@@ -2280,6 +2284,7 @@ static struct device_attribute *mce_device_attrs[] = {#endif &dev_attr_monarch_timeout.attr, &dev_attr_dont_log_ce.attr, + &dev_attr_print_all.attr, &dev_attr_ignore_ce.attr, &dev_attr_cmci_disabled.attr,NULL
arch/x86/kernel/cpu/mce/internal.h +1 -0
@@ -119,6 +119,7 @@ struct mca_config {bool dont_log_ce;bool cmci_disabled;bool ignore_ce; +bool print_all; __u64 lmce_disabled : 1, disabled : 1,
[tip: ras/core] x86/mce/amd, edac: Remove report_gart_errors
In reply to Borislav PetkovThe following commit has been merged into the ras/core branch of tip:
The following commit has been merged into the ras/core branch of tip:
Commit-ID: 3e0fdec858d82c829774f271e88b5ceb17051551 Gitweb: https://git.kernel.org/tip/3e0fdec858d82c829774f271e88b5ceb17051551 Author: Borislav Petkov <[email protected]> AuthorDate: Tue, 07 Apr 2020 09:55:10 +02:00 Committer: Borislav Petkov <[email protected]> CommitterDate: Tue, 14 Apr 2020 15:53:46 +02:00
x86/mce/amd, edac: Remove report_gart_errors
... because no one should be interested in spurious MCEs anyway. Make the filtering unconditional and move it to amd_filter_mce().
--- arch/x86/include/asm/mce.h | 3 ++- arch/x86/kernel/cpu/mce/amd.c | 9 +++++++-- drivers/edac/amd64_edac.c | 8 -------- drivers/edac/mce_amd.c | 24 ------------------------ drivers/edac/mce_amd.h | 2 -- 5 files changed, 9 insertions(+), 37 deletions(-)
arch/x86/include/asm/mce.h +2 -1
@@ -127,6 +127,8 @@#define MSR_AMD64_SMCA_MCx_DEADDR (x) (MSR_AMD64_SMCA_MC0_DEADDR + 0x10*(x))#define MSR_AMD64_SMCA_MCx_MISCy (x, y) ((MSR_AMD64_SMCA_MC0_MISC1 + y) + (0x10*(x))) +#define XEC (x, mask) (((x) >> 16) & mask) +/* * This structure contains all data related to the MCE log. Also * carries a signature to make it easier to find from external
@@ -347,5 +349,4 @@ umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) { return#endif static inline void mce_hygon_feature_init (struct cpuinfo_x86 *c) {return mce_amd_feature_init (c); } -#endif /* _ASM_X86_MCE_H */
arch/x86/kernel/cpu/mce/amd.c +7 -2
@@ -577,14 +577,19 @@ bool amd_filter_mce(struct mce *m) {enum smca_bank_types bank_type =smca_get_bank_type (m->bank);struct cpuinfo_x86 *c = &boot_cpu_data; -u8 xec = (m->status >>16 ) &0x3F ;/* See Family 17h Models 10h-2Fh Erratum #1114. */ if (c->x86 ==0x17 && c->x86_model >=0x10 && c->x86_model <=0x2F && - bank_type ==SMCA_IF && xec ==10 ) + bank_type ==SMCA_IF &&XEC (m->status,0x3f ) ==10 )return true; +/* NB GART TLB error reporting is disabled by default. */ +if (c->x86 <0x17 ) { +if (m->bank ==4 &&XEC (m->status,0x1f ) ==0x5 ) +return true; + } +return false; }
drivers/edac/amd64_edac.c +0 -8
@@ -4,9 +4,6 @@static struct edac_pci_ctl_info *pci_ctl; -static int report_gart_errors; -module_param (report_gart_errors, int,0644 ); -/* * Set by command line parameter. If BIOS has enabled the ECC, this override is * cleared to prevent re-enabling the hardware by this driver.
@@ -3681,9 +3678,6 @@ static int __init amd64_edac_init(void) }/* register stuff with EDAC MCE */ -if (report_gart_errors) -amd_report_gart_errors (true); -if (boot_cpu_data.x86 >=0x17 )amd_register_ecc_decoder (decode_umc_error);else
@@ -3718,8 +3712,6 @@ static void __exit amd64_edac_exit(void)edac_pci_release_generic_ctl (pci_ctl);/* unregister from EDAC MCE */ -amd_report_gart_errors (false); -if (boot_cpu_data.x86 >=0x17 )amd_unregister_ecc_decoder (decode_umc_error);else
drivers/edac/mce_amd.c +0 -24
@@ -10,15 +10,8 @@ static struct amd_decoder_ops fam_ops;static u8 xec_mask =0xf ; -static bool report_gart_errors;static void (*decode_dram_ecc)(int node_id,struct mce *m); -void amd_report_gart_errors (bool v) -{ - report_gart_errors = v; -} -EXPORT_SYMBOL_GPL (amd_report_gart_errors); -void amd_register_ecc_decoder (void (*f)(int ,struct mce *)) { decode_dram_ecc = f;
@@ -1030,20 +1023,6 @@ static inline void amd_decode_err_code(u16 ec)pr_cont ("\n" ); } -/* -* Filter out unwanted MCE signatures here. -*/ -static bool ignore_mce (struct mce *m) -{ -/* -* NB GART TLB error reporting is disabled by default. -*/ -if (m->bank ==4 &&XEC (m->status,0x1f ) ==0x5 && !report_gart_errors) -return true; - -return false; -} -static const char *decode_error_status (struct mce *m) {if (m->status &MCI_STATUS_UC ) {
@@ -1067,9 +1046,6 @@ amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data)unsigned int fam =x86_family (m->cpuid);int ecc; -if (ignore_mce (m)) -return NOTIFY_STOP ; -pr_emerg (HW_ERR "%s\n" ,decode_error_status (m)); pr_emerg(HW_ERR "CPU:%d (%x:%x:%x) MC%d_STATUS[%s|%s|%s|%s|%s",
drivers/edac/mce_amd.h +0 -2
@@ -7,7 +7,6 @@#include <asm/mce.h> #define EC (x) ((x) & 0xffff) -#define XEC (x, mask) (((x) >> 16) & mask)#define LOW_SYNDROME (x) (((x) >> 15) & 0xff)#define HIGH_SYNDROME (x) (((x) >> 24) & 0xff)
@@ -77,7 +76,6 @@ struct amd_decoder_ops {bool (*mc2_mce)(u16 ,u8 ); }; -void amd_report_gart_errors (bool );void amd_register_ecc_decoder (void (*f)(int ,struct mce *));void amd_unregister_ecc_decoder (void (*f)(int ,struct mce *));
[tip: ras/core] x86/mce: Fix all mce notifiers to update the mce->kflags bitmask
In reply to Tony LuckThe following commit has been merged into the ras/core branch of tip:
The following commit has been merged into the ras/core branch of tip:
Commit-ID: 23ba710a0864108910c7531dc4c73ef65eca5568 Gitweb: https://git.kernel.org/tip/23ba710a0864108910c7531dc4c73ef65eca5568 Author: Tony Luck <[email protected]> AuthorDate: Fri, 14 Feb 2020 14:27:17 -08:00 Committer: Borislav Petkov <[email protected]> CommitterDate: Tue, 14 Apr 2020 15:59:26 +02:00
x86/mce: Fix all mce notifiers to update the mce->kflags bitmask
If the handler took any action to log or deal with the error, set a bit in mce->kflags so that the default handler on the end of the machine check chain can see what has been done.
Get rid of NOTIFY_STOP returns. Make the EDAC and dev-mcelog handlers skip over errors already processed by CEC.
--- arch/x86/kernel/cpu/mce/core.c | 4 +++- arch/x86/kernel/cpu/mce/dev-mcelog.c | 5 +++++ drivers/acpi/acpi_extlog.c | 5 +++-- drivers/acpi/nfit/mce.c | 1 + drivers/edac/i7core_edac.c | 5 +++-- drivers/edac/mce_amd.c | 6 +++++- drivers/edac/pnd2_edac.c | 5 +++-- drivers/edac/sb_edac.c | 5 ++++- drivers/edac/skx_common.c | 4 ++++ drivers/ras/cec.c | 9 ++++++--- 10 files changed, 37 insertions(+), 12 deletions(-)
arch/x86/kernel/cpu/mce/core.c +3 -1
@@ -581,8 +581,10 @@ static int uc_decode_notifier(struct notifier_block *nb, unsigned long val,return NOTIFY_DONE ; pfn = mce->addr >>PAGE_SHIFT ; -if (!memory_failure (pfn,0 )) +if (!memory_failure (pfn,0 )) {set_mce_nospec (pfn); + mce->kflags |=MCE_HANDLED_UC ; + }return NOTIFY_OK ; }
arch/x86/kernel/cpu/mce/dev-mcelog.c +5 -0
@@ -39,6 +39,9 @@ static int dev_mce_log(struct notifier_block *nb, unsigned long val,struct mce *mce = (struct mce *)data;unsigned int entry; +if (mce->kflags &MCE_HANDLED_CEC ) +return NOTIFY_DONE ; +mutex_lock (&mce_chrdev_read_mutex); entry = mcelog->next;
@@ -56,6 +59,7 @@ static int dev_mce_log(struct notifier_block *nb, unsigned long val,memcpy (mcelog->entry + entry, mce,sizeof (struct mce )); mcelog->entry[entry].finished =1 ; + mcelog->entry[entry].kflags =0 ;/* wake processes polling /dev/mcelog */ wake_up_interruptible (&mce_chrdev_wait);
@@ -63,6 +67,7 @@ static int dev_mce_log(struct notifier_block *nb, unsigned long val, unlock:mutex_unlock (&mce_chrdev_read_mutex); + mce->kflags |=MCE_HANDLED_MCELOG ;return NOTIFY_OK ; }
drivers/acpi/acpi_extlog.c +3 -2
@@ -146,7 +146,7 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,static u32 err_seq; estatus =extlog_elog_entry_check (cpu, bank); -if (estatus ==NULL ) +if (estatus ==NULL || (mce->kflags &MCE_HANDLED_CEC ))return NOTIFY_DONE ;memcpy (elog_buf, (void *)estatus,ELOG_ENTRY_LEN );
@@ -176,7 +176,8 @@ static int extlog_print(struct notifier_block *nb, unsigned long val, } out: -return NOTIFY_STOP ; + mce->kflags |=MCE_HANDLED_EXTLOG ; +return NOTIFY_OK ; }static bool __init extlog_get_l1addr (void )
drivers/acpi/nfit/mce.c +1 -0
@@ -76,6 +76,7 @@ static int nfit_handle_mce(struct notifier_block *nb, unsigned long val,*/ acpi_nfit_ars_rescan (acpi_desc,0 ); } + mce->kflags |=MCE_HANDLED_NFIT ;break ; }
drivers/edac/i7core_edac.c +3 -2
@@ -1815,7 +1815,7 @@ static int i7core_mce_check_error(struct notifier_block *nb, unsigned long val,struct mem_ctl_info *mci; i7_dev =get_i7core_dev (mce->socketid); -if (!i7_dev) +if (!i7_dev || (mce->kflags &MCE_HANDLED_CEC ))return NOTIFY_DONE ; mci = i7_dev->mci;
@@ -1834,7 +1834,8 @@ static int i7core_mce_check_error(struct notifier_block *nb, unsigned long val,i7core_check_error (mci, mce);/* Advise mcelog that the errors were handled */ -return NOTIFY_STOP ; + mce->kflags |=MCE_HANDLED_EDAC ; +return NOTIFY_OK ; }static struct notifier_block i7_mce_dec = {
drivers/edac/mce_amd.c +5 -1
@@ -1046,6 +1046,9 @@ amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data)unsigned int fam =x86_family (m->cpuid);int ecc; +if (m->kflags &MCE_HANDLED_CEC ) +return NOTIFY_DONE ; +pr_emerg (HW_ERR "%s\n" ,decode_error_status (m)); pr_emerg(HW_ERR "CPU:%d (%x:%x:%x) MC%d_STATUS[%s|%s|%s|%s|%s",
@@ -1146,7 +1149,8 @@ amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data) err_code:amd_decode_err_code (m->status &0xffff ); -return NOTIFY_STOP ; + m->kflags |=MCE_HANDLED_EDAC ; +return NOTIFY_OK ; }static struct notifier_block amd_mce_dec_nb = {
drivers/edac/pnd2_edac.c +3 -2
@@ -1400,7 +1400,7 @@ static int pnd2_mce_check_error(struct notifier_block *nb, unsigned long val, voreturn NOTIFY_DONE ; mci = pnd2_mci; -if (!mci) +if (!mci || (mce->kflags &MCE_HANDLED_CEC ))return NOTIFY_DONE ;/*
@@ -1429,7 +1429,8 @@ static int pnd2_mce_check_error(struct notifier_block *nb, unsigned long val, vopnd2_mce_output_error (mci, mce, &daddr);/* Advice mcelog that the error were handled */ -return NOTIFY_STOP ; + mce->kflags |=MCE_HANDLED_EDAC ; +return NOTIFY_OK ; }static struct notifier_block pnd2_mce_dec = {
drivers/edac/sb_edac.c +4 -1
@@ -3136,6 +3136,8 @@ static int sbridge_mce_check_error(struct notifier_block *nb, unsigned long val,if (edac_get_report_status () ==EDAC_REPORTING_DISABLED )return NOTIFY_DONE ; +if (mce->kflags &MCE_HANDLED_CEC ) +return NOTIFY_DONE ;/* * Just let mcelog handle it if the error is
@@ -3183,7 +3185,8 @@ static int sbridge_mce_check_error(struct notifier_block *nb, unsigned long val,sbridge_mce_output_error (mci, mce);/* Advice mcelog that the error were handled */ -return NOTIFY_STOP ; + mce->kflags |=MCE_HANDLED_EDAC ; +return NOTIFY_OK ; }static struct notifier_block sbridge_mce_dec = {
drivers/edac/skx_common.c +4 -0
@@ -577,6 +577,9 @@ int skx_mce_check_error(struct notifier_block *nb, unsigned long val,if (edac_get_report_status () ==EDAC_REPORTING_DISABLED )return NOTIFY_DONE ; +if (mce->kflags &MCE_HANDLED_CEC ) +return NOTIFY_DONE ; +/* ignore unless this is memory related with an address */ if ((mce->status &0xefff ) >>7 !=1 || !(mce->status &MCI_STATUS_ADDRV ))return NOTIFY_DONE ;
@@ -616,6 +619,7 @@ int skx_mce_check_error(struct notifier_block *nb, unsigned long val,skx_mce_output_error (mci, mce, &res); + mce->kflags |=MCE_HANDLED_EDAC ;return NOTIFY_DONE ; }
drivers/ras/cec.c +6 -3
@@ -538,9 +538,12 @@ static int cec_notifier(struct notifier_block *nb, unsigned long val,/* We eat only correctable DRAM errors with usable addresses. */ if (mce_is_memory_error (m) &&mce_is_correctable (m) && -mce_usable_address (m)) -if (!cec_add_elem (m->addr >>PAGE_SHIFT )) -return NOTIFY_STOP ; +mce_usable_address (m)) { +if (!cec_add_elem (m->addr >>PAGE_SHIFT )) { + m->kflags |=MCE_HANDLED_CEC ; +return NOTIFY_OK ; + } + }return NOTIFY_DONE ; }
[tip: ras/core] EDAC: Drop the EDAC report status checks
In reply to Tony LuckThe following commit has been merged into the ras/core branch of tip:
The following commit has been merged into the ras/core branch of tip:
Commit-ID: 7fc0b9b995f222646ece8d5bca528060c098ee88 Gitweb: https://git.kernel.org/tip/7fc0b9b995f222646ece8d5bca528060c098ee88 Author: Tony Luck <[email protected]> AuthorDate: Fri, 14 Feb 2020 14:27:20 -08:00 Committer: Borislav Petkov <[email protected]> CommitterDate: Tue, 14 Apr 2020 16:01:01 +02:00
EDAC: Drop the EDAC report status checks
When acpi_extlog was added, we were worried that the same error would be reported more than once by different subsystems. But in the ensuing years I've seen complaints that people could not find an error log (because this mechanism suppressed the log they were looking for).
Rip it all out. People are smart enough to notice the same address from different reporting mechanisms.
--- drivers/acpi/acpi_extlog.c | 14 +-------- drivers/edac/edac_mc.c | 61 +------------------------------------- drivers/edac/pnd2_edac.c | 3 +-- drivers/edac/sb_edac.c | 4 +-- drivers/edac/skx_common.c | 3 +-- include/linux/edac.h | 8 +----- 6 files changed, 93 deletions(-)
drivers/acpi/acpi_extlog.c +0 -14
@@ -42,8 +42,6 @@ struct extlog_l1_head {u8 rev1[12 ]; }; -static int old_edac_report_status; -static u8 extlog_dsm_uuid[]__initdata ="663E35AF-CC10-41A4-88EA-5470AF055295" ;/* L1 table related physical address */
@@ -229,11 +227,6 @@ static int __init extlog_init(void)if (!(cap &MCG_ELOG_P ) || !extlog_get_l1addr ())return -ENODEV ; -if (edac_get_report_status () ==EDAC_REPORTING_FORCE ) { -pr_warn ("Not loading eMCA, error reporting force-enabled through EDAC.\n" ); -return -EPERM ; - } - rc = -EINVAL ;/* get L1 header to fetch necessary information */ l1_hdr_size =sizeof (struct extlog_l1_head );
@@ -281,12 +274,6 @@ static int __init extlog_init(void)if (elog_buf ==NULL ) goto err_release_elog; -/* -* eMCA event report method has higher priority than EDAC method, -* unless EDAC event report method is mandatory. -*/ - old_edac_report_status =edac_get_report_status (); -edac_set_report_status (EDAC_REPORTING_DISABLED );mce_register_decode_chain (&extlog_mce_dec);/* enable OS to be involved to take over management from BIOS */ ((struct extlog_l1_head *)extlog_l1_addr)->flags |=FLAG_OS_OPTIN ;
@@ -308,7 +295,6 @@ err: static void __exit extlog_exit(void) { -edac_set_report_status (old_edac_report_status);mce_unregister_decode_chain (&extlog_mce_dec); ((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN ;if (extlog_l1_addr)
drivers/edac/edac_mc.c +0 -61
73 lines not on this page · raw message
drivers/edac/pnd2_edac.c +0 -3
@@ -1396,9 +1396,6 @@ static int pnd2_mce_check_error(struct notifier_block *nb, unsigned long val, vostruct dram_addr daddr;char *type; -if (edac_get_report_status () ==EDAC_REPORTING_DISABLED ) -return NOTIFY_DONE ; - mci = pnd2_mci;if (!mci || (mce->kflags &MCE_HANDLED_CEC ))return NOTIFY_DONE ;
drivers/edac/sb_edac.c +0 -4
@@ -3134,8 +3134,6 @@ static int sbridge_mce_check_error(struct notifier_block *nb, unsigned long val,struct mem_ctl_info *mci;char *type; -if (edac_get_report_status () ==EDAC_REPORTING_DISABLED ) -return NOTIFY_DONE ;if (mce->kflags &MCE_HANDLED_CEC )return NOTIFY_DONE ;
@@ -3526,8 +3524,6 @@ static int __init sbridge_init(void)if (rc >=0 ) {mce_register_decode_chain (&sbridge_mce_dec); -if (edac_get_report_status () ==EDAC_REPORTING_DISABLED ) -sbridge_printk (KERN_WARNING ,"Loading driver, error reporting disabled.\n" );return 0 ; }
drivers/edac/skx_common.c +0 -3
@@ -574,9 +574,6 @@ int skx_mce_check_error(struct notifier_block *nb, unsigned long val,struct mem_ctl_info *mci;char *type; -if (edac_get_report_status () ==EDAC_REPORTING_DISABLED ) -return NOTIFY_DONE ; -if (mce->kflags &MCE_HANDLED_CEC )return NOTIFY_DONE ;
include/linux/edac.h +0 -8
@@ -31,14 +31,6 @@ struct device;extern int edac_op_state;struct bus_type *edac_get_sysfs_subsys (void ); -int edac_get_report_status (void ); -void edac_set_report_status (int new); - -enum { -EDAC_REPORTING_ENABLED , -EDAC_REPORTING_DISABLED , -EDAC_REPORTING_FORCE -};static inline void opstate_init (void ) {
[tip: ras/core] x86/mce: Add a struct mce.kflags field
In reply to Tony LuckThe following commit has been merged into the ras/core branch of tip:
The following commit has been merged into the ras/core branch of tip:
Commit-ID: 1de08dccd383482a3e88845d3554094d338f5ff9 Gitweb: https://git.kernel.org/tip/1de08dccd383482a3e88845d3554094d338f5ff9 Author: Tony Luck <[email protected]> AuthorDate: Fri, 14 Feb 2020 14:27:16 -08:00 Committer: Borislav Petkov <[email protected]> CommitterDate: Tue, 14 Apr 2020 15:58:43 +02:00
x86/mce: Add a struct mce.kflags field
There can be many different subsystems register on the mce handler chain. Add a new bitmask field and define values so that handlers can indicate whether they took any action to log or otherwise handle an error.
The default handler at the end of the chain can use this information to decide whether to print to the console log.
Boris suggested a generic name and leaving plenty of spare bits for possible future use.
[ bp: Move flag bits to the internal mce.h header and use BIT_ULL(). ]
--- arch/x86/include/asm/mce.h | 8 ++++++++ arch/x86/include/uapi/asm/mce.h | 1 + 2 files changed, 9 insertions(+)
arch/x86/include/asm/mce.h +8 -0
@@ -129,6 +129,14 @@#define XEC (x, mask) (((x) >> 16) & mask) +/* mce.kflags flag bits for logging etc. */ +#define MCE_HANDLED_CEC BIT_ULL(0) +#define MCE_HANDLED_UC BIT_ULL(1) +#define MCE_HANDLED_EXTLOG BIT_ULL(2) +#define MCE_HANDLED_NFIT BIT_ULL(3) +#define MCE_HANDLED_EDAC BIT_ULL(4) +#define MCE_HANDLED_MCELOG BIT_ULL(5) +/* * This structure contains all data related to the MCE log. Also * carries a signature to make it easier to find from external
arch/x86/include/uapi/asm/mce.h +1 -0
@@ -35,6 +35,7 @@ struct mce {__u64 ipid;/* MCA_IPID MSR: only valid on SMCA systems */ __u64 ppin;/* Protected Processor Inventory Number */ __u32 microcode;/* Microcode revision */ +__u64 kflags;/* Internal kernel use. See below */ };#define MCE_GET_RECORD_LEN _IOR('M', 1, int)
Luck, Tony
maintainerRE: [tip: ras/core] x86/mce: Add a struct mce.kflags field
arch/x86/include/uapi/asm/mce.h struct mce { · line 39
Quoted 10 lines
arch/x86/include/uapi/asm/mce.h +1
-0@@ -35,6 +35,7 @@ struct mce {__u64 ipid;/* MCA_IPID MSR: only valid on SMCA systems */ __u64 ppin;/* Protected Processor Inventory Number */ __u32 microcode;/* Microcode revision */ +__u64 kflags;/* Internal kernel use. See below */ };
Minor nit. You moved the #defines for the kflags bits to internal.h (which was a good thing), but left the "See below" comment here.
-Tony
Re: [tip: ras/core] x86/mce: Add a struct mce.kflags field
Quoted 2 lines · Tony
Minor nit. You moved the #defines for the kflags bits to
internal.h(which was a good thing), but left the "See below" comment here.
Yeah, can't rebase anymore but I'd take a fix ontop.
;-)
Signature · 4 lines
Regards/Gruss,
Boris.
SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG NürnbergLuck, Tony
maintainerPATCH 1/1 x86/mce: Drop bogus comment about mce.kflags
The bit definitions for kflags are for internal use only. A late edit moved them from uapi/asm/mce.h to the internal x86 <asm/mce.h>, but the comment saying "See below" was accidentally left here.
Delete "See below". Just labelling this field as internal kernel use is sufficient.
--- arch/x86/include/uapi/asm/mce.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/uapi/asm/mce.h +1 -1
@@ -35,7 +35,7 @@ struct mce {__u64 ipid;/* MCA_IPID MSR: only valid on SMCA systems */ __u64 ppin;/* Protected Processor Inventory Number */ __u32 microcode;/* Microcode revision */ -__u64 kflags;/* Internal kernel use. See below */ +__u64 kflags;/* Internal kernel use */ };#define MCE_GET_RECORD_LEN _IOR('M', 1, int)
Signature · 1 line
2.21.1
[tip: ras/core] x86/mce: Drop bogus comment about mce.kflags
The following commit has been merged into the ras/core branch of tip:
The following commit has been merged into the ras/core branch of tip:
Commit-ID: f82cdff1aa7f6dcf6625c7219342a6e5c977098d Gitweb: https://git.kernel.org/tip/f82cdff1aa7f6dcf6625c7219342a6e5c977098d Author: Tony Luck <[email protected]> AuthorDate: Wed, 15 Apr 2020 12:58:26 -07:00 Committer: Borislav Petkov <[email protected]> CommitterDate: Fri, 17 Apr 2020 11:12:21 +02:00
x86/mce: Drop bogus comment about mce.kflags
The bit definitions for kflags are for internal use only. A late edit moved them from uapi/asm/mce.h to the internal x86 <asm/mce.h>, but the comment saying "See below" was accidentally left here.
Delete "See below". Just labelling this field as internal kernel use is sufficient.
--- arch/x86/include/uapi/asm/mce.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/uapi/asm/mce.h +1 -1
@@ -35,7 +35,7 @@ struct mce {__u64 ipid;/* MCA_IPID MSR: only valid on SMCA systems */ __u64 ppin;/* Protected Processor Inventory Number */ __u32 microcode;/* Microcode revision */ -__u64 kflags;/* Internal kernel use. See below */ +__u64 kflags;/* Internal kernel use */ };#define MCE_GET_RECORD_LEN _IOR('M', 1, int)
Re: [tip: ras/core] x86/mce: Add a struct mce.kflags field
In reply to tip-bot2 for Tony LuckQuoted 16 lines · On Wed, Apr 15, 2020 at 09:49:48AM -0000, tip-bot2 for Tony Luck wrote:
The following commit has been merged into the ras/core branch of tip:
Commit-ID: 1de08dccd383482a3e88845d3554094d338f5ff9 Gitweb: https://git.kernel.org/tip/1de08dccd383482a3e88845d3554094d338f5ff9 Author: Tony Luck <[email protected]> AuthorDate: Fri, 14 Feb 2020 14:27:16 -08:00 Committer: Borislav Petkov <[email protected]> CommitterDate: Tue, 14 Apr 2020 15:58:43 +02:00x86/mce: Add a struct mce.kflags field
There can be many different subsystems register on the mce handler chain. Add a new bitmask field and define values so that handlers can indicate whether they took any action to log or otherwise handle an error.
Quoted 7 lines
The default handler at the end of the chain can use this information to decide whether to print to the console log.
Boris suggested a generic name and leaving plenty of spare bits for possible future use.
[ bp: Move flag bits to the internal
mce.hheader and useBIT_ULL(). ]
Err, how can you add a new field to an uapi structure and not break things?
Re: [tip: ras/core] x86/mce: Add a struct mce.kflags field
Quoted 2 lines · Christoph Hellwig
Err, how can you add a new field to an uapi structure and not break things?
By adding it to the end of the structure. The mcelog tool gets the record length first, before doing anything with the records.
Signature · 4 lines
Regards/Gruss,
Boris.
SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg