x86, MCE, fix MSR_IA32_MCI_CTL2 CMCI threshold setup
PATCH 1/1 x86, MCE, fix MSR_IA32_MCI_CTL2 CMCI threshold setup
It is reported that CMCI is not raised when number of corrected error reaches preset threshold. After inspection, it is found that MSR_IA32_MCI_CTL2 threshold field is not setup properly. This patch fixed it.
--- arch/x86/include/asm/mce.h | 3 +++ arch/x86/kernel/cpu/mcheck/mce_intel.c | 1 + 2 files changed, 4 insertions(+), 0 deletions(-)
arch/x86/include/asm/mce.h +3 -0
@@ -38,6 +38,9 @@#define MCM_ADDR_MEM 3/* memory address */ #define MCM_ADDR_GENERIC 7/* generic */ +/* CTL2 register defines */ +#define MCI_CTL2_THRESHOLD_MASK 0x7fff +#define MCJ_CTX_MASK 3#define MCJ_CTX (flags) ((flags) & MCJ_CTX_MASK)#define MCJ_CTX_RANDOM 0/* inject context: random */
arch/x86/kernel/cpu/mcheck/mce_intel.c +1 -0
@@ -101,6 +101,7 @@ static void cmci_discover(int banks, int boot)continue ; } + val &= ~MCI_CTL2_THRESHOLD_MASK ; val |=CMCI_EN |CMCI_THRESHOLD ;wrmsrl (MSR_IA32_MCx_CTL2 (i), val);rdmsrl (MSR_IA32_MCx_CTL2 (i), val);
Quoted 32 lines · Huang Ying
It is reported that CMCI is not raised when number of corrected error reaches preset threshold. After inspection, it is found that
MSR_IA32_MCI_CTL2threshold field is not setup properly. This patch fixed it.Reported-by Shaohui Zheng <[email protected]>Signed-off-by Huang Ying <[email protected]>Acked-by Andi Kleen <[email protected]>--- arch/x86/include/asm/mce.h | 3 +++ arch/x86/kernel/cpu/mcheck/mce_intel.c | 1 + 2 files changed, 4 insertions(+), 0 deletions(-)arch/x86/include/asm/mce.h +3
-0@@ -38,6 +38,9 @@#define MCM_ADDR_MEM 3/* memory address */ #define MCM_ADDR_GENERIC 7/* generic */ +/* CTL2 register defines */ +#define MCI_CTL2_THRESHOLD_MASK 0x7fff +#define MCJ_CTX_MASK 3#define MCJ_CTX (flags) ((flags) & MCJ_CTX_MASK)#define MCJ_CTX_RANDOM 0/* inject context: random */ arch/x86/kernel/cpu/mcheck/mce_intel.c +0
-0
arch/x86/kernel/cpu/mcheck/mce_intel.c static void cmci_discover(int banks, int boot) · line 107
Quoted 7 lines
arch/x86/kernel/cpu/mcheck/mce_intel.c +1
-0@@ -101,6 +101,7 @@ static void cmci_discover(int banks, int boot)continue ; } + val &= ~MCI_CTL2_THRESHOLD_MASK ; val |=CMCI_EN |CMCI_THRESHOLD ;wrmsrl (MSR_IA32_MCx_CTL2 (i), val);rdmsrl (MSR_IA32_MCx_CTL2 (i), val);
Hum, it seems that the CTL2 of reported environment had be initialized to have more than CMCI_THRESHOLD(=1) by BIOS etc. Could you explain more about your inspection?
Maybe we could handle this environment if kernel supports APEI's firmware-first for corrected MCE and if this is in that case.
Patch looks good. How about cc-ing stable?
Thanks,
H.Seto
Hi, Seto san,
Thanks for review.
Quoted 36 lines · Hidetoshi Seto
Quoted 35 lines · Huang Ying
It is reported that CMCI is not raised when number of corrected error reaches preset threshold. After inspection, it is found that
MSR_IA32_MCI_CTL2threshold field is not setup properly. This patch fixed it.Reported-by Shaohui Zheng <[email protected]>Signed-off-by Huang Ying <[email protected]>Acked-by Andi Kleen <[email protected]>--- arch/x86/include/asm/mce.h | 3 +++ arch/x86/kernel/cpu/mcheck/mce_intel.c | 1 + 2 files changed, 4 insertions(+), 0 deletions(-)arch/x86/include/asm/mce.h +3
-0@@ -38,6 +38,9 @@#define MCM_ADDR_MEM 3/* memory address */ #define MCM_ADDR_GENERIC 7/* generic */ +/* CTL2 register defines */ +#define MCI_CTL2_THRESHOLD_MASK 0x7fff +#define MCJ_CTX_MASK 3#define MCJ_CTX (flags) ((flags) & MCJ_CTX_MASK)#define MCJ_CTX_RANDOM 0/* inject context: random */ arch/x86/kernel/cpu/mcheck/mce_intel.c +0
-0@@ -101,6 +101,7 @@ static void cmci_discover(int banks, int boot)continue ; }
Quoted 8 lines
arch/x86/kernel/cpu/mcheck/mce_intel.c static void cmci_discover(int banks, int boot) · line 107
Quoted 4 lines
arch/x86/kernel/cpu/mcheck/mce_intel.c +1
-0+ val &= ~MCI_CTL2_THRESHOLD_MASK ; val |=CMCI_EN |CMCI_THRESHOLD ;wrmsrl (MSR_IA32_MCx_CTL2 (i), val);rdmsrl (MSR_IA32_MCx_CTL2 (i), val);Hum, it seems that the CTL2 of reported environment had be initialized to have more than
CMCI_THRESHOLD(=1)by BIOS etc. Could you explain more about your inspection?
In CTL2, threshold is initialized to 10 by BIOS.
Quoted 3 lines
Maybe we could handle this environment if kernel supports APEI's firmware-first for corrected MCE and if this is in that case.
I still don't know much about the details of the interaction between BIOS and OS here.
Best Regards,
Huang Ying
Quoted 4 lines · Hidetoshi Seto
Maybe we could handle this environment if kernel supports APEI's firmware-first for corrected MCE and if this is in that case.
The problem at hand has nothing to do with firmware first or APEI.
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only.