x86/mce: Add Zhaoxin CMCI support
Subsystems (3)
PATCH v2 3/4 x86/mce: Add Zhaoxin CMCI support
All Zhaoxin newer CPUs support CMCI that compatible with Intel's "Machine-Check Architecture", so add support for Zhaoxin CMCI in mce/core.c and mce/intel.c.
---v1->v2:
- Fix redefinition of "mce_zhaoxin_feature_init"
arch/x86/include/asm/mce.h | 6 ++++++ arch/x86/kernel/cpu/mce/core.c | 27 +++++++++++++++++++++++++++ arch/x86/kernel/cpu/mce/intel.c | 3 ++- 3 files changed, 35 insertions(+), 1 deletion(-)
arch/x86/include/asm/mce.h +6 -0
@@ -350,4 +350,10 @@ umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr) { returnstatic inline void mce_hygon_feature_init (struct cpuinfo_x86 *c) {return mce_amd_feature_init (c); } +#ifdef CONFIG_CPU_SUP_ZHAOXIN +void mce_zhaoxin_feature_init (struct cpuinfo_x86 *c); +#else +static inline void mce_zhaoxin_feature_init (struct cpuinfo_x86 *c) { } +#endif +#endif /* _ASM_X86_MCE_H */
arch/x86/kernel/cpu/mce/core.c +27 -0
@@ -1777,6 +1777,29 @@ static void mce_centaur_feature_init(struct cpuinfo_x86 *c) } } +#ifdef CONFIG_CPU_SUP_ZHAOXIN +void mce_zhaoxin_feature_init (struct cpuinfo_x86 *c) +{ +struct mce_bank *mce_banks =this_cpu_ptr (mce_banks_array); + +/* +* These CPUs bank8 SVAD error may be triggered unexpected when +* bringup virtual machine. it is not hardware bug. Always disable +* bank8 SVAD error by default. +*/ +if ((c->x86 ==6 && c->x86_model ==0x19 && + (c->x86_stepping >3 && c->x86_stepping <8 )) || + (c->x86 ==6 && c->x86_model ==0x1f ) || + (c->x86 ==7 && c->x86_model ==0x1b )) { +if (this_cpu_read (mce_num_banks) >8 ) + mce_banks[8 ].ctl =0 ; + } + +intel_init_cmci (); + mce_adjust_timer = cmci_intel_adjust_timer; +} +#endif +static void __mcheck_cpu_init_vendor (struct cpuinfo_x86 *c) {switch (c->x86_vendor) {
@@ -1798,6 +1821,10 @@ static void __mcheck_cpu_init_vendor(struct cpuinfo_x86 *c)mce_centaur_feature_init (c);break ; +case X86_VENDOR_ZHAOXIN : +mce_zhaoxin_feature_init (c); +break ; +default :break ; }
arch/x86/kernel/cpu/mce/intel.c +2 -1
@@ -85,7 +85,8 @@ static int cmci_supported(int *banks)* initialization is vendor keyed and this * makes sure none of the backdoors are entered otherwise. */ -if (boot_cpu_data.x86_vendor !=X86_VENDOR_INTEL ) +if (boot_cpu_data.x86_vendor !=X86_VENDOR_INTEL && + boot_cpu_data.x86_vendor !=X86_VENDOR_ZHAOXIN )return 0 ;if (!boot_cpu_has (X86_FEATURE_APIC ) ||lapic_get_maxlvt () <6 )return 0 ;
Signature · 1 line
2.7.4
Borislav Petkov
maintainerarch/x86/kernel/cpu/mce/core.c static void mce_centaur_feature_init(struct cpuinfo_x86 *c) · line 1780
Quoted 5 lines · Tony W Wang-oc
arch/x86/kernel/cpu/mce/core.c +1
-0@@ -1777,6 +1777,29 @@ static void mce_centaur_feature_init(struct cpuinfo_x86 *c) } } +#ifdef CONFIG_CPU_SUP_ZHAOXIN
What's that ifdeffery for since you have it in the header already?
arch/x86/kernel/cpu/mce/core.c static void mce_centaur_feature_init(struct cpuinfo_x86 *c) · line 1786
Quoted 6 lines
arch/x86/kernel/cpu/mce/core.c +6
-0+void mce_zhaoxin_feature_init (struct cpuinfo_x86 *c) +{ +struct mce_bank *mce_banks =this_cpu_ptr (mce_banks_array); + +/* +* These CPUs bank8 SVAD error may be triggered unexpected when
"These CPUs bank8 SVAD"??
arch/x86/kernel/cpu/mce/core.c static void mce_centaur_feature_init(struct cpuinfo_x86 *c) · line 1789
Quoted 3 lines
arch/x86/kernel/cpu/mce/core.c +3
-0+* bringup virtual machine. it is not hardware bug. Always disable +* bank8 SVAD error by default. +*/
That comment is incomprehensible. Please rewrite.
arch/x86/kernel/cpu/mce/core.c static void mce_centaur_feature_init(struct cpuinfo_x86 *c) · line 1793
Quoted 4 lines
arch/x86/kernel/cpu/mce/core.c +4
-0+if ((c->x86 ==6 && c->x86_model ==0x19 && + (c->x86_stepping >3 && c->x86_stepping <8 )) || + (c->x86 ==6 && c->x86_model ==0x1f ) || + (c->x86 ==7 && c->x86_model ==0x1b )) {
As before: potential to simplify the test here?
Quoted 28 lines
arch/x86/kernel/cpu/mce/core.c +13
-0+if (this_cpu_read (mce_num_banks) >8 ) + mce_banks[8].ctl = 0; + } + +intel_init_cmci (); + mce_adjust_timer = cmci_intel_adjust_timer; +} +#endif +static void __mcheck_cpu_init_vendor (struct cpuinfo_x86 *c) {switch (c->x86_vendor) {@@ -1798,6 +1821,10 @@ static void __mcheck_cpu_init_vendor(struct cpuinfo_x86 *c)mce_centaur_feature_init (c);break ; +case X86_VENDOR_ZHAOXIN : +mce_zhaoxin_feature_init (c); +break ; +default :break ; }arch/x86/kernel/cpu/mce/intel.c +0
-0
arch/x86/kernel/cpu/mce/intel.c static int cmci_supported(int *banks) · line 87
Quoted 3 lines
arch/x86/kernel/cpu/mce/intel.c +0
-0@@ -85,7 +85,8 @@ static int cmci_supported(int *banks)* initialization is vendor keyed and this * makes sure none of the backdoors are entered otherwise. */
That comment above needs fixing too.
arch/x86/kernel/cpu/mce/intel.c static int cmci_supported(int *banks) · line 90
Quoted 4 lines
arch/x86/kernel/cpu/mce/intel.c +2
-1-if (boot_cpu_data.x86_vendor !=X86_VENDOR_INTEL ) +if (boot_cpu_data.x86_vendor !=X86_VENDOR_INTEL && + boot_cpu_data.x86_vendor !=X86_VENDOR_ZHAOXIN )return 0 ;
<---- newline here.
Quoted 4 lines
arch/x86/kernel/cpu/mce/intel.c +0
-0if (!boot_cpu_has (X86_FEATURE_APIC ) ||lapic_get_maxlvt () <6 )return 0 ;Signature · 1 line
2.7.4
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 9 lines · Borislav Petkov
Review static void mce_centaur_feature_init(struct
Quoted 1 line · Tony W Wang-oc
(quoted diff) +0
-0@@ -1777,6 +1777,29 @@ static void mce_centaur_feature_init(struct
cpuinfo_x86*c)arch/x86/kernel/cpu/mce/core.c static void mce_centaur_feature_init(struct cpuinfo_x86 *c) · line 1780
Quoted 4 lines
arch/x86/kernel/cpu/mce/core.c +1
-0} } +#ifdef CONFIG_CPU_SUP_ZHAOXIN What's that ifdeffery for since you have it in the header already?
Sorry for that.
Since this function actually be called only in mce/core.c, will remove the declare in the header file and make this function static.
Quoted 9 lines
arch/x86/kernel/cpu/mce/core.c static void mce_centaur_feature_init(struct cpuinfo_x86 *c) · line 1786
Quoted 7 lines
arch/x86/kernel/cpu/mce/core.c +6
-0+void mce_zhaoxin_feature_init (struct cpuinfo_x86 *c) +{ +struct mce_bank *mce_banks =this_cpu_ptr (mce_banks_array); + +/* +* These CPUs bank8 SVAD error may be triggered unexpected when "These CPUs bank8 SVAD"??
These Zhaoxin CPUs have MCA bank 8, that only have one error called SVAD( System View Address Decoder) which be controlled by IA32_MC8_CTL.0
Quoted 6 lines
arch/x86/kernel/cpu/mce/core.c static void mce_centaur_feature_init(struct cpuinfo_x86 *c) · line 1789
Quoted 4 lines
arch/x86/kernel/cpu/mce/core.c +3
-0+* bringup virtual machine. it is not hardware bug. Always disable +* bank8 SVAD error by default. +*/ That comment is incomprehensible. Please rewrite.
Ok, will rewrite comment in v3.
Quoted 7 lines
arch/x86/kernel/cpu/mce/core.c static void mce_centaur_feature_init(struct cpuinfo_x86 *c) · line 1793
Quoted 5 lines
arch/x86/kernel/cpu/mce/core.c +4
-0+if ((c->x86 ==6 && c->x86_model ==0x19 && + (c->x86_stepping >3 && c->x86_stepping <8 )) || + (c->x86 ==6 && c->x86_model ==0x1f ) || + (c->x86 ==7 && c->x86_model ==0x1b )) {As before: potential to simplify the test here?
Ok, will simplify as before.
Quoted 27 lines
arch/x86/kernel/cpu/mce/core.c static void __mcheck_cpu_init_vendor(struct
Quoted 14 lines
arch/x86/kernel/cpu/mce/core.c +9
-0+if (this_cpu_read (mce_num_banks) >8 ) + mce_banks[8].ctl = 0; + } + +intel_init_cmci (); + mce_adjust_timer = cmci_intel_adjust_timer; +} +#endif +static void __mcheck_cpu_init_vendor (struct cpuinfo_x86 *c) {switch (c->x86_vendor) {@@ -1798,6 +1821,10 @@ static void __mcheck_cpu_init_vendor(struct
cpuinfo_x86*c)Quoted 12 lines
arch/x86/kernel/cpu/mce/core.c +4
-0mce_centaur_feature_init (c);break ; +case X86_VENDOR_ZHAOXIN : +mce_zhaoxin_feature_init (c); +break ; +default :break ; }arch/x86/kernel/cpu/mce/intel.c +0
-0
Quoted 8 lines
arch/x86/kernel/cpu/mce/intel.c static int cmci_supported(int *banks) · line 87
Quoted 6 lines
arch/x86/kernel/cpu/mce/intel.c +0
-0@@ -85,7 +85,8 @@ static int cmci_supported(int *banks)* initialization is vendor keyed and this * makes sure none of the backdoors are entered otherwise. */ That comment above needs fixing too.
Ok.
Quoted 7 lines
arch/x86/kernel/cpu/mce/intel.c static int cmci_supported(int *banks) · line 90
Quoted 5 lines
arch/x86/kernel/cpu/mce/intel.c +2
-1-if (boot_cpu_data.x86_vendor !=X86_VENDOR_INTEL ) +if (boot_cpu_data.x86_vendor !=X86_VENDOR_INTEL && + boot_cpu_data.x86_vendor !=X86_VENDOR_ZHAOXIN )return 0 ;<---- newline here.
Ok.
Sincerely
TonyWWang-oc