MCE, AMD: Make MC2 decoding part of amd_decoder_ops as well
Subsystems (2)
PATCH 1/2 MCE, AMD: Make MC2 decoding part of amd_decoder_ops as well
Currently only AMD Family 15h processors have special handling for MC2 errors, since upcoming Family 16h will also need unique handling, let's make MC2 handling part of amd_decoder_ops.
--- drivers/edac/mce_amd.c | 58 ++++++++++++++++++++++++++---------------------- drivers/edac/mce_amd.h | 1 + 2 files changed, 32 insertions(+), 27 deletions(-)
drivers/edac/mce_amd.c +31 -27
@@ -399,12 +399,9 @@ static void decode_mc1_mce(struct mce *m)pr_emerg (HW_ERR "Corrupted MC1 MCE info?\n" ); } -static void decode_mc2_mce (struct mce *m) +static bool k8_mc2_mce (u16 ec,u8 xec) { -u16 ec =EC (m->status); -u8 xec =XEC (m->status, xec_mask); - -pr_emerg (HW_ERR "MC2 Error" ); +bool ret = true;if (xec ==0x1 )pr_cont (" in the write data buffers.\n" );
@@ -429,24 +426,18 @@ static void decode_mc2_mce(struct mce *m)pr_cont (": %s parity/ECC error during data " "access from L2.\n" ,R4_MSG (ec)); else - goto wrong_mc2_mce; + ret = false; }else - goto wrong_mc2_mce; + ret = false; }else - goto wrong_mc2_mce; - -return ; + ret = false; - wrong_mc2_mce: -pr_emerg (HW_ERR "Corrupted MC2 MCE info?\n" ); +return ret; } -static void decode_f15_mc2_mce (struct mce *m) +static bool f15h_mc2_mce (u16 ec,u8 xec) { -u16 ec =EC (m->status); -u8 xec =XEC (m->status, xec_mask); - -pr_emerg (HW_ERR "MC2 Error: " ); +bool ret = true;if (TLB_ERROR (ec)) {if (xec ==0x0 )
@@ -454,10 +445,10 @@ static void decode_f15_mc2_mce(struct mce *m)else if (xec ==0x1 )pr_cont ("Poison data provided for TLB fill.\n" );else - goto wrong_f15_mc2_mce; + ret = false; }else if (BUS_ERROR (ec)) {if (xec >2 ) - goto wrong_f15_mc2_mce; + ret = false;pr_cont ("Error during attempted NB data read.\n" ); }else if (MEM_ERROR (ec)) {
@@ -471,14 +462,24 @@ static void decode_f15_mc2_mce(struct mce *m)break ;default : - goto wrong_f15_mc2_mce; + ret = false; } } -return ; +return ret; +} - wrong_f15_mc2_mce: -pr_emerg (HW_ERR "Corrupted MC2 MCE info?\n" ); +static void decode_mc2_mce (struct mce *m) +{ +u16 ec =EC (m->status); +u8 xec =XEC (m->status, xec_mask); + +pr_emerg (HW_ERR "MC2 Error: " ); + +if (fam_ops->mc2_mce (ec, xec)) + ; +else +pr_emerg (HW_ERR "Corrupted MC2 MCE info?\n" ); }static void decode_mc3_mce (struct mce *m)
@@ -702,10 +703,7 @@ int amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data)break ;case 2 : -if (c->x86 ==0x15 ) -decode_f15_mc2_mce (m); -else -decode_mc2_mce (m); +decode_mc2_mce (m);break ;case 3 :
@@ -783,33 +781,39 @@ static int __init mce_amd_init(void)case 0xf : fam_ops->mc0_mce = k8_mc0_mce; fam_ops->mc1_mce = k8_mc1_mce; + fam_ops->mc2_mce = k8_mc2_mce;break ;case 0x10 : fam_ops->mc0_mce = f10h_mc0_mce; fam_ops->mc1_mce = k8_mc1_mce; + fam_ops->mc2_mce = k8_mc2_mce;break ;case 0x11 : fam_ops->mc0_mce = k8_mc0_mce; fam_ops->mc1_mce = k8_mc1_mce; + fam_ops->mc2_mce = k8_mc2_mce;break ;case 0x12 : fam_ops->mc0_mce = f12h_mc0_mce; fam_ops->mc1_mce = k8_mc1_mce; + fam_ops->mc2_mce = k8_mc2_mce;break ;case 0x14 : nb_err_cpumask =0x3 ; fam_ops->mc0_mce = f14h_mc0_mce; fam_ops->mc1_mce = f14h_mc1_mce; + fam_ops->mc2_mce = k8_mc2_mce;break ;case 0x15 : xec_mask =0x1f ; fam_ops->mc0_mce = f15h_mc0_mce; fam_ops->mc1_mce = f15h_mc1_mce; + fam_ops->mc2_mce = f15h_mc2_mce;break ;default :
drivers/edac/mce_amd.h +1 -0
@@ -78,6 +78,7 @@ extern const char * const ii_msgs[];struct amd_decoder_ops {bool (*mc0_mce)(u16 ,u8 );bool (*mc1_mce)(u16 ,u8 ); +bool (*mc2_mce)(u16 ,u8 ); };void amd_report_gart_errors (bool );
Signature · 1 line
1.7.9.5
PATCH 2/2 MCE, AMD: MCE decoding support for AMD Family 16h
Add MCE decoding logic for AMD Family 16h processors.
--- drivers/edac/mce_amd.c | 120 ++++++++++++++++++++++++++++++++++++++++++++++-- drivers/edac/mce_amd.h | 6 +++ 2 files changed, 122 insertions(+), 4 deletions(-)
drivers/edac/mce_amd.c +116 -4
@@ -64,6 +64,10 @@ EXPORT_SYMBOL_GPL(to_msgs);const char *const ii_msgs[] = {"MEM" ,"RESV" ,"IO" ,"GEN" };EXPORT_SYMBOL_GPL (ii_msgs); +/* internal error type */ +const char *const uu_msgs[] = {"RESV" ,"RESV" ,"HWA" ,"RESV" }; +EXPORT_SYMBOL_GPL (uu_msgs); +static const char *const f15h_mc1_mce_desc[] = {"UC during a demand linefill from L2" ,"Parity error during data load from IC" ,
@@ -275,6 +279,23 @@ static bool f15h_mc0_mce(u16 ec, u8 xec)return ret; } +static bool f16h_mc0_mce (u16 ec,u8 xec) +{ +u8 r4 =R4 (ec); + +if (MEM_ERROR (ec) &&TT (ec) ==TT_DATA &&LL (ec) ==LL_L1 && + (r4 ==R4_DRD || r4 ==R4_DWR )) { + +pr_cont ("%s parity error due to %s.\n" , + (xec ==0x0 ?"Data" :"Tag" ), + (r4 ==R4_DRD ?"load" :"store" )); + +return true; + } + +return f14h_mc0_mce (ec, xec); +} +static void decode_mc0_mce (struct mce *m) {u16 ec =EC (m->status);
@@ -379,6 +400,36 @@ static bool f15h_mc1_mce(u16 ec, u8 xec)return ret; } +static bool f16h_mc1_mce (u16 ec,u8 xec) +{ +u8 r4 =R4 (ec); +bool ret = true; + +if (MEM_ERROR (ec)) { +if (TT (ec) !=TT_INSTR ) + ret = false; + +else if (r4 ==R4_IRD ) +pr_cont ("%s array parity error for a tag hit.\n" , + (xec ==0x0 ?"Data" :"Tag" )); + +else if (r4 ==R4_SNOOP ) +pr_cont ("Tag error during snoop/victimization.\n" ); + +else if (xec ==0x0 ) +pr_cont ("Tag parity error from victim castout.\n" ); + +else if (xec ==0x2 ) +pr_cont ("Microcode patch RAM parity error.\n" ); + +else + ret = false; + }else + ret = false; + +return ret; +} +static void decode_mc1_mce (struct mce *m) {u16 ec =EC (m->status);
@@ -469,6 +520,48 @@ static bool f15h_mc2_mce(u16 ec, u8 xec)return ret; } +static bool f16h_mc2_mce (u16 ec,u8 xec) +{ +u8 r4 =R4 (ec); +bool ret = true; + +if (MEM_ERROR (ec) &&TT (ec) ==TT_GEN &&LL (ec) ==LL_L2 ) { +switch (xec) { + case 0x04 ... 0x05: +pr_cont ("Parity error in %s.\n" , + (r4 ==R4_RD ?"IBUFF" :"OBUFF" )); +break ; + + case 0x09 ... 0x0b: + case 0x0d ... 0x0f: +pr_cont ("ECC error in L2 tag (%s).\n" , + (r4 ==R4_GEN ?"BankReq" : + (r4 ==R4_SNOOP ?"Probe" :"Fill" ))); +break ; + + case 0x10 ... 0x1b: +pr_cont ("ECC error in L2 data array (%s).\n" , + (r4 ==R4_RD ?"Hit" : + (r4 ==R4_GEN ?"Attr" : + (r4 ==R4_EVICT ?"Vict" :"Fill" )))); +break ; + + case 0x1c ... 0x1f: +pr_cont ("Parity error in L2 attribute bits (%s).\n" , + (r4 ==R4_RD ?"Hit" : + (r4 ==R4_GEN ?"Attr" :"Fill" ))); +break ; + +default : + ret = false; +break ; + } + }else + ret = false; + +return ret; +} +static void decode_mc2_mce (struct mce *m) {u16 ec =EC (m->status);
@@ -548,7 +641,7 @@ static void decode_mc4_mce(struct mce *m)return ;case 0x19 : -if (boot_cpu_data.x86 ==0x15 ) +if (boot_cpu_data.x86 ==0x15 || boot_cpu_data.x86 ==0x16 )pr_cont ("Compute Unit Data Error.\n" );else goto wrong_mc4_mce;
@@ -634,6 +727,10 @@ static void decode_mc6_mce(struct mce *m)static inline void amd_decode_err_code (u16 ec) { +if (INT_ERROR (ec)) { +pr_emerg (HW_ERR "internal: %s\n" ,LL_MSG (ec)); +return ; + }pr_emerg (HW_ERR "cache level: %s" ,LL_MSG (ec));
@@ -738,10 +835,18 @@ int amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data) ((m->status &MCI_STATUS_PCC ) ?"PCC" :"-" ), ((m->status & MCI_STATUS_ADDRV) ? "AddrV" : "-")); -if (c->x86 ==0x15 ) -pr_cont ("|%s|%s" , +if (c->x86 ==0x15 || c->x86 ==0x16 ) { +char coreid[16 ]; + +if (m->status &MCI_STATUS_COREIDV ) +sprintf (coreid,"CoreIdV(Core%d)" , + (int )ERR_CORE_ID (m->status)); + +pr_cont ("|%s|%s|%s" , + ((m->status &MCI_STATUS_COREIDV ) ? coreid :"-" ), ((m->status &MCI_STATUS_DEFERRED ) ?"Deferred" :"-" ), ((m->status &MCI_STATUS_POISON ) ?"Poison" :"-" )); + }/* do the two bits[14:13] together */ ecc = (m->status >>45 ) &0x3 ;
@@ -770,7 +875,7 @@ static int __init mce_amd_init(void)if (c->x86_vendor !=X86_VENDOR_AMD )return 0 ; -if (c->x86 <0xf || c->x86 >0x15 ) +if (c->x86 <0xf || c->x86 >0x16 )return 0 ; fam_ops =kzalloc (sizeof (struct amd_decoder_ops ),GFP_KERNEL );
@@ -816,6 +921,13 @@ static int __init mce_amd_init(void) fam_ops->mc2_mce = f15h_mc2_mce;break ; +case 0x16 : + xec_mask =0x1f ; + fam_ops->mc0_mce = f16h_mc0_mce; + fam_ops->mc1_mce = f16h_mc1_mce; + fam_ops->mc2_mce = f16h_mc2_mce; +break ; +default :printk (KERN_WARNING "Huh? What family is it: 0x%x?!\n" , c->x86);kfree (fam_ops);
drivers/edac/mce_amd.h +6 -0
@@ -11,9 +11,12 @@#define LOW_SYNDROME (x) (((x) >> 15) & 0xff)#define HIGH_SYNDROME (x) (((x) >> 24) & 0xff) +#define ERR_CORE_ID (x) (((x) >> 32) & 0xf) +#define TLB_ERROR (x) (((x) & 0xFFF0) == 0x0010)#define MEM_ERROR (x) (((x) & 0xFF00) == 0x0100)#define BUS_ERROR (x) (((x) & 0xF800) == 0x0800) +#define INT_ERROR (x) (((x) & 0xF4FF) == 0x0400)#define TT (x) (((x) >> 2) & 0x3)#define TT_MSG (x) tt_msgs[TT(x)]
@@ -25,10 +28,13 @@#define TO_MSG (x) to_msgs[TO(x)]#define PP (x) (((x) >> 9) & 0x3)#define PP_MSG (x) pp_msgs[PP(x)] +#define UU (x) (((x) >> 8) & 0x3) +#define UU_MSG (x) uu_msgs[UU(x)]#define R4 (x) (((x) >> 4) & 0xf)#define R4_MSG (x) ((R4(x) < 9) ? rrrr_msgs[R4(x)] : "Wrong R4!") +#define MCI_STATUS_COREIDV BIT_64(56)#define MCI_STATUS_DEFERRED BIT_64(44)#define MCI_STATUS_POISON BIT_64(43)
Signature · 1 line
1.7.9.5
Quoted 3 lines · Jacob Shin
Currently only AMD Family 15h processors have special handling for MC2 errors, since upcoming Family 16h will also need unique handling, let's make MC2 handling part of
amd_decoder_ops.
[]
drivers/edac/mce_amd.c
Quoted 1 line
drivers/edac/mce_amd.c +0
-0
[]
Quoted 5 lines
drivers/edac/mce_amd.c +0
-1@@ -399,12 +399,9 @@ static void decode_mc1_mce(struct mce *m)pr_emerg (HW_ERR "Corrupted MC1 MCE info?\n" ); } -static void decode_mc2_mce (struct mce *m)
drivers/edac/mce_amd.c static void decode_mc1_mce(struct mce *m) · line 407
Quoted 10 lines
drivers/edac/mce_amd.c +2
-4+static bool k8_mc2_mce (u16 ec,u8 xec) { -u16 ec =EC (m->status); -u8 xec =XEC (m->status, xec_mask); - -pr_emerg (HW_ERR "MC2 Error" ); +bool ret = true;if (xec ==0x1 )pr_cont (" in the write data buffers.\n" );
It'd be better to change the pr_cont uses to pr_emerg
[]
drivers/edac/mce_amd.c static void decode_f15_mc2_mce(struct mce *m) · line 477
Quoted 6 lines
drivers/edac/mce_amd.c +6
-0+static void decode_mc2_mce (struct mce *m) +{ +u16 ec =EC (m->status); +u8 xec =XEC (m->status, xec_mask); + +pr_emerg (HW_ERR "MC2 Error: " );
Remove this and
drivers/edac/mce_amd.c static void decode_f15_mc2_mce(struct mce *m) · line 483
Quoted 5 lines
drivers/edac/mce_amd.c +4
-0+if (fam_ops->mc2_mce (ec, xec)) + ; +else +pr_emerg (HW_ERR "Corrupted MC2 MCE info?\n" ); }
And make this
if (!fam_ops->mc2_mce(ec, xec)) pr_emerg(etc...);
Borislav Petkov
maintainerQuoted 21 lines · Joe Perches
It'd be better to change the
pr_contuses topr_emerg[]
drivers/edac/mce_amd.c static void decode_f15_mc2_mce(struct mce *m) · line 477
Quoted 6 lines
drivers/edac/mce_amd.c +6
-0+static void decode_mc2_mce (struct mce *m) +{ +u16 ec =EC (m->status); +u8 xec =XEC (m->status, xec_mask); + +pr_emerg (HW_ERR "MC2 Error: " );Remove this and
drivers/edac/mce_amd.c static void decode_f15_mc2_mce(struct mce *m) · line 483
Quoted 5 lines
drivers/edac/mce_amd.c +4
-0+if (fam_ops->mc2_mce (ec, xec)) + ; +else +pr_emerg (HW_ERR "Corrupted MC2 MCE info?\n" ); }And make this
Quoted 2 lines
if (!fam_ops->mc2_mce(ec, xec)) pr_emerg(etc...);
No, this is not how we do this here. We do pr_emerg in the main per-bank function, i.e. mc0, mc1, mc2... and we finish the line in the respective function with pr_cont.
If your fear is line interleaving, then this shouldn't happen in most cases because we're in atomic #MC context and nothing else is executing in that case. (And I haven't seen it interleave in all my testing so far).
If it does interleave when we have a non-critical error detected and reported in process context, then this whole decoding code needs a lot more work than this.
Thanks.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Quoted 30 lines · Borislav Petkov
Quoted 22 lines · Joe Perches
It'd be better to change the
pr_contuses topr_emerg[]
drivers/edac/mce_amd.c static void decode_f15_mc2_mce(struct mce *m) · line 477
Quoted 6 lines
drivers/edac/mce_amd.c +6
-0+static void decode_mc2_mce (struct mce *m) +{ +u16 ec =EC (m->status); +u8 xec =XEC (m->status, xec_mask); + +pr_emerg (HW_ERR "MC2 Error: " );Remove this and
drivers/edac/mce_amd.c static void decode_f15_mc2_mce(struct mce *m) · line 483
Quoted 5 lines
drivers/edac/mce_amd.c +4
-0+if (fam_ops->mc2_mce (ec, xec)) + ; +else +pr_emerg (HW_ERR "Corrupted MC2 MCE info?\n" ); }And make this
Quoted 2 lines
if (!fam_ops->mc2_mce(ec, xec)) pr_emerg(etc...);No, this is not how we do this here. We do
pr_emergin the main per-bank function, i.e. mc0, mc1, mc2... and we finish the line in the respective function withpr_cont.
Quoted 9 lines
If your fear is line interleaving, then this shouldn't happen in most cases because we're in atomic #MC context and nothing else is executing in that case. (And I haven't seen it interleave in all my testing so far).
If it does interleave when we have a non-critical error detected and reported in process context, then this whole decoding code needs a lot more work than this.
You also have paths where you start a pr_emerg and do not terminate it when there is no apparent error at all.
Borislav Petkov
maintainerQuoted 2 lines · Joe Perches
You also have paths where you start a
pr_emergand do not terminate it when there is no apparent error at all.
For example?
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Quoted 6 lines · Borislav Petkov
Quoted 2 lines · Joe Perches
You also have paths where you start a
pr_emergand do not terminate it when there is no apparent error at all.For example?
decode_mc2_mce does
pr_emerg(HW_ERR "MC2 Error: "); calls fam_ops->mc2_mce() which may not emit anything and if it doesn't, does pr_emerg(HW_ERR "Corrupted ...");
on another line leaving a trailing colon without
newline from the pr_emerg above.
I believe the second pr_emerg should be pr_cont
cheers, Joe
Borislav Petkov
maintainerQuoted 10 lines · Joe Perches
decode_mc2_mcedoespr_emerg(HW_ERR "MC2 Error: "); calls fam_ops->mc2_mce() which may not emit anything and if it doesn't, does pr_emerg(HW_ERR "Corrupted ...");on another line leaving a trailing colon without
newline from thepr_emergabove.
Ok, this is in Jacob's patch AFAICT, I'll review those tomorrow but thanks for the heads-up.
Quoted 1 line
I believe the second
pr_emergshould bepr_cont
Actually, it should be
pr_emerg(HW_ERR "\nCorrupted...\n");
to finish the initial pr_emerg.
Thanks.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Quoted 12 lines · Borislav Petkov
Quoted 10 lines · Joe Perches
decode_mc2_mcedoespr_emerg(HW_ERR "MC2 Error: "); calls fam_ops->mc2_mce() which may not emit anything and if it doesn't, does pr_emerg(HW_ERR "Corrupted ...");on another line leaving a trailing colon without
newline from thepr_emergabove.
Quoted 2 lines
Ok, this is in Jacob's patch AFAICT, I'll review those tomorrow but thanks for the heads-up.
Okay, I'll wait until your feedback before sending V2
Quoted 8 lines
Quoted 2 lines
I believe the second
pr_emergshould bepr_contActually, it should be
pr_emerg(HW_ERR "\nCorrupted...\n");to finish the initial
pr_emerg.
Okay, all of the other decode_mc*_mce functions needs to change then.
Thanks!
Quoted 10 lines
Thanks.
Signature · 5 lines
Regards/Gruss, Boris. Sent from a fat crate under my desk. Formatting is fine. --
Quoted 21 lines · Jacob Shin
Quoted 12 lines · Borislav Petkov
Quoted 10 lines · Joe Perches
decode_mc2_mcedoespr_emerg(HW_ERR "MC2 Error: "); calls fam_ops->mc2_mce() which may not emit anything and if it doesn't, does pr_emerg(HW_ERR "Corrupted ...");on another line leaving a trailing colon without
newline from thepr_emergabove.Quoted 2 lines
Ok, this is in Jacob's patch AFAICT, I'll review those tomorrow but thanks for the heads-up.
Okay, I'll wait until your feedback before sending V2
Quoted 3 lines
Quoted 2 lines
I believe the second
pr_emergshould bepr_cont
Quoted 7 lines
Quoted 5 lines
Actually, it should be
pr_emerg(HW_ERR "\nCorrupted...\n");to finish the initial
pr_emerg.Okay, all of the other decode_mc*_mce functions needs to change then.
Hi Jacob.
I don't think that's necessary.
Using any pr_<level>("\n...") is just not good form. I think the pr_cont would be fine, it's the same form as all the other decoded continuations.
The new pr_emerg is effectively a termination of the previous one. There's no need for 2 consecutive uses of pr_emerg(HW_ERR ...) here.
cheers, Joe
Borislav Petkov
maintainerQuoted 3 lines · Joe Perches
The new
pr_emergis effectively a termination of the previous one. There's no need for 2 consecutive uses ofpr_emerg(HW_ERR ...)here.
Actually, in decode_mc5_mce(), the second pr_emerg needs to stay like what it is now.
So Jacob, please leave those changes out, I'll sort them out later.
Thanks.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Quoted 34 lines · Joe Perches
Quoted 21 lines · Jacob Shin
Quoted 12 lines · Borislav Petkov
Quoted 10 lines · Joe Perches
decode_mc2_mcedoespr_emerg(HW_ERR "MC2 Error: "); calls fam_ops->mc2_mce() which may not emit anything and if it doesn't, does pr_emerg(HW_ERR "Corrupted ...");on another line leaving a trailing colon without
newline from thepr_emergabove.Quoted 2 lines
Ok, this is in Jacob's patch AFAICT, I'll review those tomorrow but thanks for the heads-up.
Okay, I'll wait until your feedback before sending V2
Quoted 3 lines
Quoted 2 lines
I believe the second
pr_emergshould bepr_contQuoted 7 lines
Quoted 5 lines
Actually, it should be
pr_emerg(HW_ERR "\nCorrupted...\n");to finish the initial
pr_emerg.Okay, all of the other decode_mc*_mce functions needs to change then.
Hi Jacob.
I don't think that's necessary.
Quoted 7 lines
Using any pr_<level>("\n...") is just not good form. I think the
pr_contwould be fine, it's the same form as all the other decoded continuations.The new
pr_emergis effectively a termination of the previous one. There's no need for 2 consecutive uses ofpr_emerg(HW_ERR ...)here.
Ah, okay, I'll use pr_cont. Thanks!
-Jacob
Quoted 4 lines
cheers, Joe
Quoted 9 lines · Borislav Petkov
Quoted 3 lines · Joe Perches
The new
pr_emergis effectively a termination of the previous one. There's no need for 2 consecutive uses ofpr_emerg(HW_ERR ...)here.Actually, in
decode_mc5_mce(), the secondpr_emergneeds to stay like what it is now.So Jacob, please leave those changes out, I'll sort them out later.
Okay, will do, I'll change fix it in my changes then. But I'll wait for your feedback tomorrow, before sending out V2.
Thanks!
-Jacob
Quoted 10 lines
Thanks.
Signature · 5 lines
Regards/Gruss, Boris. Sent from a fat crate under my desk. Formatting is fine. --
Borislav Petkov
maintainerRe: [PATCH 2/2] MCE, AMD: MCE decoding support for AMD Family 16h
In reply to Jacob ShinQuoted 13 lines · Jacob Shin
Add MCE decoding logic for AMD Family 16h processors.
Signed-off-by Jacob Shin <[email protected]>--- drivers/edac/mce_amd.c | 120 ++++++++++++++++++++++++++++++++++++++++++++++-- drivers/edac/mce_amd.h | 6 +++ 2 files changed, 122 insertions(+), 4 deletions(-)drivers/edac/mce_amd.c +0
-0
drivers/edac/mce_amd.c EXPORT_SYMBOL_GPL(to_msgs); · line 69
Quoted 6 lines
drivers/edac/mce_amd.c +3
-0@@ -64,6 +64,10 @@ EXPORT_SYMBOL_GPL(to_msgs);const char *const ii_msgs[] = {"MEM" ,"RESV" ,"IO" ,"GEN" };EXPORT_SYMBOL_GPL (ii_msgs); +/* internal error type */ +const char *const uu_msgs[] = {"RESV" ,"RESV" ,"HWA" ,"RESV" }; +EXPORT_SYMBOL_GPL (uu_msgs);
Seems like those aren't used anywhere?
Quoted 12 lines
drivers/edac/mce_amd.c +5
-0static const char *const f15h_mc1_mce_desc[] = {"UC during a demand linefill from L2" ,"Parity error during data load from IC" ,@@ -275,6 +279,23 @@ static bool f15h_mc0_mce(u16 ec, u8 xec)return ret; } +static bool f16h_mc0_mce (u16 ec,u8 xec) +{ +u8 r4 =R4 (ec); + + if (MEM_ERROR(ec) && TT(ec) == TT_DATA && LL(ec) == LL_L1 &&
drivers/edac/mce_amd.c static bool f15h_mc0_mce(u16 ec, u8 xec) · line 296
Quoted 10 lines
drivers/edac/mce_amd.c +10
-0+ (r4 == R4_DRD || r4 == R4_DWR)) { + +pr_cont ("%s parity error due to %s.\n" , + (xec ==0x0 ?"Data" :"Tag" ), + (r4 ==R4_DRD ?"load" :"store" )); + +return true; + } + +return f14h_mc0_mce (ec, xec);
Looks like this could be merged with f14h_mc0_mce no? You can call the function then cat_mc0_mce (for all the *cat cores) and assign it to fam_ops->mc0_mce in the f14h and f16h case.
Quoted 20 lines
drivers/edac/mce_amd.c +13
-0+} +static void decode_mc0_mce (struct mce *m) {u16 ec =EC (m->status);@@ -379,6 +400,36 @@ static bool f15h_mc1_mce(u16 ec, u8 xec)return ret; } +static bool f16h_mc1_mce (u16 ec,u8 xec) +{ +u8 r4 =R4 (ec); +bool ret = true; + +if (MEM_ERROR (ec)) { +if (TT (ec) !=TT_INSTR ) + ret = false; + +else if (r4 ==R4_IRD ) + pr_cont("%s array parity error for a tag hit.\n",
drivers/edac/mce_amd.c static bool f15h_mc1_mce(u16 ec, u8 xec) · line 423
Quoted 10 lines
drivers/edac/mce_amd.c +10
-0+ (xec == 0x0 ? "Data" : "Tag")); + + else if (r4 == R4_SNOOP) + pr_cont("Tag error during snoop/victimization.\n"); + + else if (xec == 0x0) + pr_cont("Tag parity error from victim castout.\n"); + + else if (xec == 0x2) + pr_cont("Microcode patch RAM parity error.\n");
Also no need for a family-special function - just rename f14h_mc1_mce to cat_mc1_mce() as above and add a special case like this as the last else-branch of the if conditional there:
+ if (boot_cpu_data.x86 == 0x16) {
+ if (LL(ec) == LL_LG && xec == 2)
+ pr_cont("Microcode patch RAM parity error.\n");
+ else
+ pr_cont("IC Tag parity error from victim castout.\n");
+ return true;
+ }
Quoted 13 lines
drivers/edac/mce_amd.c +9
-0+ +else + ret = false; + }else + ret = false; + +return ret; +} +static void decode_mc1_mce (struct mce *m) {u16 ec =EC (m->status);
drivers/edac/mce_amd.c static bool f15h_mc2_mce(u16 ec, u8 xec) · line 528
Quoted 9 lines
drivers/edac/mce_amd.c +6
-0@@ -469,6 +520,48 @@ static bool f15h_mc2_mce(u16 ec, u8 xec)return ret; } +static bool f16h_mc2_mce (u16 ec,u8 xec) +{ +u8 r4 =R4 (ec); +bool ret = true; + +if (MEM_ERROR (ec) &&TT (ec) ==TT_GEN &&LL (ec) ==LL_L2 ) {
You can exit early here:
if (!MEM_ERROR(ec)) return false;
Also, no need to test for TT and LL - we're relying on the hardware here and if those values are b0rked then we have a more serious problem.
drivers/edac/mce_amd.c static bool f15h_mc2_mce(u16 ec, u8 xec) · line 532
Quoted 4 lines
drivers/edac/mce_amd.c +4
-0+switch (xec) { + case 0x04 ... 0x05: +pr_cont ("Parity error in %s.\n" , + (r4 ==R4_RD ?"IBUFF" :"OBUFF" ));
or
pr_cont("%sBUFF parity error.\n", ((xec == 4) ? "I" : "O"));Quoted 45 lines
drivers/edac/mce_amd.c +33
-1+break ; + + case 0x09 ... 0x0b: + case 0x0d ... 0x0f: +pr_cont ("ECC error in L2 tag (%s).\n" , + (r4 ==R4_GEN ?"BankReq" : + (r4 ==R4_SNOOP ?"Probe" :"Fill" ))); +break ; + + case 0x10 ... 0x1b: +pr_cont ("ECC error in L2 data array (%s).\n" , + (r4 ==R4_RD ?"Hit" : + (r4 ==R4_GEN ?"Attr" : + (r4 ==R4_EVICT ?"Vict" :"Fill" )))); +break ; + + case 0x1c ... 0x1f: +pr_cont ("Parity error in L2 attribute bits (%s).\n" , + (r4 ==R4_RD ?"Hit" : + (r4 ==R4_GEN ?"Attr" :"Fill" ))); +break ; + +default : + ret = false; +break ; + } + }else + ret = false; + +return ret; +} +static void decode_mc2_mce (struct mce *m) {u16 ec =EC (m->status);@@ -548,7 +641,7 @@ static void decode_mc4_mce(struct mce *m)return ;case 0x19 : -if (boot_cpu_data.x86 ==0x15 ) +if (boot_cpu_data.x86 ==0x15 || boot_cpu_data.x86 ==0x16 )pr_cont ("Compute Unit Data Error.\n" );else goto wrong_mc4_mce;
drivers/edac/mce_amd.c static void decode_mc6_mce(struct mce *m) · line 733
Quoted 7 lines
drivers/edac/mce_amd.c +4
-0@@ -634,6 +727,10 @@ static void decode_mc6_mce(struct mce *m)static inline void amd_decode_err_code (u16 ec) { +if (INT_ERROR (ec)) { +pr_emerg (HW_ERR "internal: %s\n" ,LL_MSG (ec)); +return ; + }
Is this correct? I'm just confirming because I don't have the internal info anymore.
Uuh, hold on, maybe those otherwise unused uu_msgs above were meant to be used here instead of the LL_MSG? IOW,
pr_emerg(HW_ERR "internal: %s\n", UU_MSG(ec));
Right?
Quoted 5 lines
drivers/edac/mce_amd.c +0
-0pr_emerg (HW_ERR "cache level: %s" ,LL_MSG (ec));@@ -738,10 +835,18 @@ int amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data) ((m->status & MCI_STATUS_PCC) ? "PCC" : "-"),
drivers/edac/mce_amd.c int amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data) · line 843
Quoted 10 lines
drivers/edac/mce_amd.c +6
-2((m->status & MCI_STATUS_ADDRV) ? "AddrV" : "-")); -if (c->x86 ==0x15 ) - pr_cont("|%s|%s", +if (c->x86 ==0x15 || c->x86 ==0x16 ) { +char coreid[16 ]; + +if (m->status &MCI_STATUS_COREIDV ) +sprintf (coreid,"CoreIdV(Core%d)" , + (int )ERR_CORE_ID (m->status));
Uuh, no, this is probably dumping the core which detected the error.. No need since we're dumping the core reporting the error anyway above. And if that's mismatched for some reason, we're also dumping full MCi_STATUS contents so you can decypher CoreId from there if needed.
Thanks.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Re: [PATCH 2/2] MCE, AMD: MCE decoding support for AMD Family 16h
Quoted 41 lines · Borislav Petkov
Quoted 13 lines · Jacob Shin
Add MCE decoding logic for AMD Family 16h processors.
Signed-off-by Jacob Shin <[email protected]>--- drivers/edac/mce_amd.c | 120 ++++++++++++++++++++++++++++++++++++++++++++++-- drivers/edac/mce_amd.h | 6 +++ 2 files changed, 122 insertions(+), 4 deletions(-)drivers/edac/mce_amd.c +0
-0drivers/edac/mce_amd.c EXPORT_SYMBOL_GPL(to_msgs); · line 69
Quoted 6 lines
drivers/edac/mce_amd.c +3
-0@@ -64,6 +64,10 @@ EXPORT_SYMBOL_GPL(to_msgs);const char *const ii_msgs[] = {"MEM" ,"RESV" ,"IO" ,"GEN" };EXPORT_SYMBOL_GPL (ii_msgs); +/* internal error type */ +const char *const uu_msgs[] = {"RESV" ,"RESV" ,"HWA" ,"RESV" }; +EXPORT_SYMBOL_GPL (uu_msgs);Seems like those aren't used anywhere?
Quoted 18 lines
drivers/edac/mce_amd.c +11
-0static const char *const f15h_mc1_mce_desc[] = {"UC during a demand linefill from L2" ,"Parity error during data load from IC" ,@@ -275,6 +279,23 @@ static bool f15h_mc0_mce(u16 ec, u8 xec)return ret; } +static bool f16h_mc0_mce (u16 ec,u8 xec) +{ +u8 r4 =R4 (ec); + +if (MEM_ERROR (ec) &&TT (ec) ==TT_DATA &&LL (ec) ==LL_L1 && + (r4 ==R4_DRD || r4 ==R4_DWR )) { + +pr_cont ("%s parity error due to %s.\n" , + (xec ==0x0 ?"Data" :"Tag" ), + (r4 ==R4_DRD ?"load" :"store" )); +
Quoted 8 lines
drivers/edac/mce_amd.c static bool f15h_mc0_mce(u16 ec, u8 xec) · line 296
Quoted 4 lines
drivers/edac/mce_amd.c +4
-0+return true; + } + +return f14h_mc0_mce (ec, xec);Looks like this could be merged with
f14h_mc0_mceno? You can call the function thencat_mc0_mce(for all the *cat cores) and assign it tofam_ops->mc0_mcein the f14h and f16h case.
Okay
Quoted 27 lines
Quoted 27 lines
drivers/edac/mce_amd.c +19
-0+} +static void decode_mc0_mce (struct mce *m) {u16 ec =EC (m->status);@@ -379,6 +400,36 @@ static bool f15h_mc1_mce(u16 ec, u8 xec)return ret; } +static bool f16h_mc1_mce (u16 ec,u8 xec) +{ +u8 r4 =R4 (ec); +bool ret = true; + +if (MEM_ERROR (ec)) { +if (TT (ec) !=TT_INSTR ) + ret = false; + +else if (r4 ==R4_IRD ) +pr_cont ("%s array parity error for a tag hit.\n" , + (xec ==0x0 ?"Data" :"Tag" )); + +else if (r4 ==R4_SNOOP ) +pr_cont ("Tag error during snoop/victimization.\n" ); + +else if (xec ==0x0 )
Quoted 8 lines
drivers/edac/mce_amd.c static bool f15h_mc1_mce(u16 ec, u8 xec) · line 423
Quoted 4 lines
drivers/edac/mce_amd.c +4
-0+pr_cont ("Tag parity error from victim castout.\n" ); + + else if (xec == 0x2) + pr_cont("Microcode patch RAM parity error.\n");Also no need for a family-special function - just rename
f14h_mc1_mcetocat_mc1_mce()as above and add a special case like this as the last else-branch of the if conditional there:
Okay
Quoted 34 lines
(quoted diff) +7
-0+ if (boot_cpu_data.x86 == 0x16) { + if (LL(ec) == LL_LG && xec == 2) + pr_cont("Microcode patch RAM parity error.\n"); + else + pr_cont("IC Tag parity error from victim castout.\n"); + return true; + }Quoted 14 lines
drivers/edac/mce_amd.c +9
-0+ +else + ret = false; + }else + ret = false; + +return ret; +} +static void decode_mc1_mce (struct mce *m) {u16 ec =EC (m->status);drivers/edac/mce_amd.c static bool f15h_mc2_mce(u16 ec, u8 xec) · line 528
Quoted 9 lines
drivers/edac/mce_amd.c +6
-0@@ -469,6 +520,48 @@ static bool f15h_mc2_mce(u16 ec, u8 xec)return ret; } +static bool f16h_mc2_mce (u16 ec,u8 xec) +{ +u8 r4 =R4 (ec); +bool ret = true; + +if (MEM_ERROR (ec) &&TT (ec) ==TT_GEN &&LL (ec) ==LL_L2 ) {You can exit early here:
Quoted 5 lines
if (!MEM_ERROR(ec)) return false;Also, no need to test for TT and LL - we're relying on the hardware here and if those values are b0rked then we have a more serious problem.
Okay
Quoted 65 lines
drivers/edac/mce_amd.c static bool f15h_mc2_mce(u16 ec, u8 xec) · line 532
Quoted 5 lines
drivers/edac/mce_amd.c +4
-0+switch (xec) { + case 0x04 ... 0x05: +pr_cont ("Parity error in %s.\n" , + (r4 ==R4_RD ?"IBUFF" :"OBUFF" ));or
pr_cont("%sBUFF parity error.\n", ((xec == 4) ? "I" : "O"));Quoted 45 lines
drivers/edac/mce_amd.c +33
-1+break ; + + case 0x09 ... 0x0b: + case 0x0d ... 0x0f: +pr_cont ("ECC error in L2 tag (%s).\n" , + (r4 ==R4_GEN ?"BankReq" : + (r4 ==R4_SNOOP ?"Probe" :"Fill" ))); +break ; + + case 0x10 ... 0x1b: +pr_cont ("ECC error in L2 data array (%s).\n" , + (r4 ==R4_RD ?"Hit" : + (r4 ==R4_GEN ?"Attr" : + (r4 ==R4_EVICT ?"Vict" :"Fill" )))); +break ; + + case 0x1c ... 0x1f: +pr_cont ("Parity error in L2 attribute bits (%s).\n" , + (r4 ==R4_RD ?"Hit" : + (r4 ==R4_GEN ?"Attr" :"Fill" ))); +break ; + +default : + ret = false; +break ; + } + }else + ret = false; + +return ret; +} +static void decode_mc2_mce (struct mce *m) {u16 ec =EC (m->status);@@ -548,7 +641,7 @@ static void decode_mc4_mce(struct mce *m)return ;case 0x19 : -if (boot_cpu_data.x86 ==0x15 ) +if (boot_cpu_data.x86 ==0x15 || boot_cpu_data.x86 ==0x16 )pr_cont ("Compute Unit Data Error.\n" );else goto wrong_mc4_mce;drivers/edac/mce_amd.c static void decode_mc6_mce(struct mce *m) · line 733
Quoted 7 lines
drivers/edac/mce_amd.c +4
-0@@ -634,6 +727,10 @@ static void decode_mc6_mce(struct mce *m)static inline void amd_decode_err_code (u16 ec) { +if (INT_ERROR (ec)) { +pr_emerg (HW_ERR "internal: %s\n" ,LL_MSG (ec)); +return ; + }Is this correct? I'm just confirming because I don't have the internal info anymore.
Quoted 7 lines
Uuh, hold on, maybe those otherwise unused
uu_msgsabove were meant to be used here instead of theLL_MSG? IOW,pr_emerg(HW_ERR "internal: %s\n", UU_MSG(ec));Right?
Ah, yes thats right, sorry about the typo. It looks like:
Error Code Error Code Type Description 0000 01UU 0000 0000 Internal Unclassified UU = Internal Error Type
And the UU encoding is as is in the mce_amd.h file
Quoted 8 lines
Quoted 8 lines
drivers/edac/mce_amd.c +0
-0pr_emerg (HW_ERR "cache level: %s" ,LL_MSG (ec));@@ -738,10 +835,18 @@ int amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data) ((m->status &MCI_STATUS_PCC ) ?"PCC" :"-" ), ((m->status & MCI_STATUS_ADDRV) ? "AddrV" : "-"));
Quoted 13 lines
drivers/edac/mce_amd.c int amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data) · line 843
Quoted 8 lines
drivers/edac/mce_amd.c +6
-2-if (c->x86 ==0x15 ) - pr_cont("|%s|%s", +if (c->x86 ==0x15 || c->x86 ==0x16 ) { +char coreid[16 ]; + +if (m->status &MCI_STATUS_COREIDV ) +sprintf (coreid,"CoreIdV(Core%d)" , + (int )ERR_CORE_ID (m->status));Uuh, no, this is probably dumping the core which detected the error.. No need since we're dumping the core reporting the error anyway above. And if that's mismatched for some reason, we're also dumping full
MCi_STATUScontents so you can decypher CoreId from there if needed.
Okay, will take this out.
Thanks for the feedback! I'll spin a V2 and send it out later today.
-Jacob
Quoted 10 lines
Thanks.
Signature · 5 lines
Regards/Gruss, Boris. Sent from a fat crate under my desk. Formatting is fine. --
Re: [PATCH 2/2] MCE, AMD: MCE decoding support for AMD Family 16h
Quoted 27 lines · Jacob Shin
Quoted 26 lines · Borislav Petkov
drivers/edac/mce_amd.c EXPORT_SYMBOL_GPL(to_msgs); · line 69
Quoted 3 lines · Jacob Shin
drivers/edac/mce_amd.c +3
-0+/* internal error type */ +const char *const uu_msgs[] = {"RESV" ,"RESV" ,"HWA" ,"RESV" }; +EXPORT_SYMBOL_GPL (uu_msgs);Seems like those aren't used anywhere?
drivers/edac/mce_amd.c static void decode_mc6_mce(struct mce *m) · line 733
Quoted 8 lines
drivers/edac/mce_amd.c +4
-0@@ -634,6 +727,10 @@ static void decode_mc6_mce(struct mce *m)static inline void amd_decode_err_code (u16 ec) { +if (INT_ERROR (ec)) { +pr_emerg (HW_ERR "internal: %s\n" ,LL_MSG (ec)); +return ; + }Is this correct? I'm just confirming because I don't have the internal info anymore.
Uuh, hold on, maybe those otherwise unused
uu_msgsabove were meant to be used here instead of theLL_MSG? IOW,pr_emerg(HW_ERR "internal: %s\n", UU_MSG(ec));
Quoted 8 lines
Quoted 1 line
Right?
Ah, yes thats right, sorry about the typo. It looks like:
Error Code Error Code Type Description 0000 01UU 0000 0000 Internal Unclassified UU = Internal Error TypeAnd the UU encoding is as is in the
mce_amd.hfile
I think I meant to say as in uu_msgs[] above. HWA stands for "Hardware Assertion" ..
Re: [PATCH 2/2] MCE, AMD: MCE decoding support for AMD Family 16h
In reply to Borislav PetkovQuoted 2 lines · Borislav Petkov
Quoted 1 line · Jacob Shin
Add MCE decoding logic for AMD Family 16h processors.
[]
Quoted 7 lines
drivers/edac/mce_amd.c static bool f15h_mc2_mce(u16 ec, u8 xec) · line 532
Quoted 4 lines
drivers/edac/mce_amd.c +4
-0+switch (xec) { + case 0x04 ... 0x05: +pr_cont ("Parity error in %s.\n" , + (r4 ==R4_RD ?"IBUFF" :"OBUFF" ));or
pr_cont("%sBUFF parity error.\n", ((xec == 4) ? "I" : "O"));
or without all the unnecessary parens and using char:
pr_cont("%cBUFF parity error\n", xec == 4 ? 'I' : 'O');Borislav Petkov
maintainerRe: [PATCH 2/2] MCE, AMD: MCE decoding support for AMD Family 16h
In reply to Jacob ShinQuoted 2 lines · Jacob Shin
I think I meant to say as in uu_msgs[] above. HWA stands for "Hardware Assertion" ..
Yep, I got it. You mean this:
const char * const uu_msgs[] = { "RESV", "RESV", "HWA", "RESV" };
and HWA is bit setting 0x2. You don't need to add a comment to say what HWA means because I'm assuming the BKDG will have it when it comes out.
Thanks.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Borislav Petkov
maintainerRe: [PATCH 2/2] MCE, AMD: MCE decoding support for AMD Family 16h
In reply to Joe PerchesQuoted 3 lines · Joe Perches
or without all the unnecessary parens and using char:
pr_cont("%cBUFF parity error\n", xec == 4 ? 'I' : 'O');
Char is fine, the parens make this more readable when you look at it again after a couple of months :-).
Thanks.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Re: [PATCH 2/2] MCE, AMD: MCE decoding support for AMD Family 16h
Quoted 7 lines · Borislav Petkov
Quoted 3 lines · Joe Perches
or without all the unnecessary parens and using char:
pr_cont("%cBUFF parity error\n", xec == 4 ? 'I' : 'O');Char is fine, the parens make this more readable when you look at it again after a couple of months :-).
<shrug>
I think the unnecessary parens make it _less_ readable because you need to parse more stuff and it's easy to misplace those parens.
cheers, Joe
Re: [PATCH 2/2] MCE, AMD: MCE decoding support for AMD Family 16h
Em 18-12-2012 16:37, Joe Perches escreveu:
Quoted 6 lines · Borislav Petkov
Quoted 5 lines · Joe Perches
Quoted 3 lines
or without all the unnecessary parens and using char:
pr_cont("%cBUFF parity error\n", xec == 4 ? 'I' : 'O');
Quoted 8 lines
Quoted 2 lines
Char is fine, the parens make this more readable when you look at it again after a couple of months :-).
<shrug>
I think the unnecessary parens make it _less_ readable because you need to parse more stuff and it's easy to misplace those parens.
I agree with Boris: the parenthesis at the test (xec == 4) makes it easier to read, IMO.
Regards,
Mauro