tip-queue 2016-01-25
Subsystems (3)
Borislav Petkov
maintainercover tip-queue 2016-01-25
From: Borislav Petkov <[email protected]>
Hi,
here's the first pile. It contains mainly the RAS pile for 4.6 and a couple of small cleanups.
Please apply,
thanks.
Alexander Kuleshov (1):
x86/traps.c: Refactor preemption and interrupt flag handling
Aravind Gopalakrishnan (5):
x86/mce: Fix order of AMD MCE init function call x86/mce/AMD: Do not perform shared bank check for future processors x86/mce/AMD: Reduce number of blocks scanned per bank x86/mce/AMD: Fix LVT offset configuration for thresholding x86/mce/AMD: Set MCAX Enable bit
Borislav Petkov (1):
x86/mce/AMD: Carve out threshold block preparation
Huaitong Han (1):
x86/cpufeature: Use enum cpuid_leafs instead of magic numbers
arch/x86/include/asm/elf.h | 2 +- arch/x86/include/asm/msr-index.h | 4 ++ arch/x86/kernel/cpu/mcheck/mce.c | 2 +- arch/x86/kernel/cpu/mcheck/mce_amd.c | 112 ++++++++++++++++++++++++++--------- arch/x86/kernel/mpparse.c | 2 +- arch/x86/kernel/traps.c | 47 ++++++--------- arch/x86/lguest/boot.c | 2 +- arch/x86/xen/enlighten.c | 2 +- 8 files changed, 113 insertions(+), 60 deletions(-)
Signature · 1 line
2.3.5
Borislav Petkov
maintainerPATCH 1/8 x86/traps.c: Refactor preemption and interrupt flag handling
From: Alexander Kuleshov <[email protected]>
Make the preemption and interrupt flag handling more readable by removing preempt_conditional_sti() and preempt_conditional_cli() helpers and using preempt_disable() and preempt_enable_no_resched() instead.
Rename contitional_sti() and conditional_cli() to the more understandable cond_local_irq_enable() and cond_local_irq_disable() respectively, while at it.
--- arch/x86/kernel/traps.c | 47 +++++++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 28 deletions(-)
arch/x86/kernel/traps.c +19 -28
@@ -83,30 +83,16 @@ gate_desc idt_table[NR_VECTORS] __page_aligned_bss;DECLARE_BITMAP (used_vectors,NR_VECTORS );EXPORT_SYMBOL_GPL (used_vectors); -static inline void conditional_sti (struct pt_regs *regs) +static inline void cond_local_irq_enable (struct pt_regs *regs) {if (regs->flags &X86_EFLAGS_IF )local_irq_enable (); } -static inline void preempt_conditional_sti (struct pt_regs *regs) -{ -preempt_count_inc (); -if (regs->flags &X86_EFLAGS_IF ) -local_irq_enable (); -} - -static inline void conditional_cli (struct pt_regs *regs) -{ -if (regs->flags &X86_EFLAGS_IF ) -local_irq_disable (); -} - -static inline void preempt_conditional_cli (struct pt_regs *regs) +static inline void cond_local_irq_disable (struct pt_regs *regs) {if (regs->flags &X86_EFLAGS_IF )local_irq_disable (); -preempt_count_dec (); }void ist_enter (struct pt_regs *regs)
@@ -286,7 +272,7 @@ static void do_error_trap(struct pt_regs *regs, long error_code, char *str,if (notify_die (DIE_TRAP , str, regs, error_code, trapnr, signr) !=NOTIFY_STOP ) { -conditional_sti (regs); +cond_local_irq_enable (regs);do_trap (trapnr, signr, str, regs, error_code,fill_trap_info (regs, signr, trapnr, &info)); }
@@ -368,7 +354,7 @@ dotraplinkage void do_bounds(struct pt_regs *regs, long error_code)if (notify_die (DIE_TRAP ,"bounds" , regs, error_code,X86_TRAP_BR ,SIGSEGV ) ==NOTIFY_STOP )return ; -conditional_sti (regs); +cond_local_irq_enable (regs);if (!user_mode (regs))die ("bounds" , regs, error_code);
@@ -443,7 +429,7 @@ do_general_protection(struct pt_regs *regs, long error_code)struct task_struct *tsk;RCU_LOCKDEP_WARN (!rcu_is_watching (),"entry code didn't wake RCU" ); -conditional_sti (regs); +cond_local_irq_enable (regs);if (v8086_mode (regs)) {local_irq_enable ();
@@ -517,9 +503,11 @@ dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code)* as we may switch to the interrupt stack. */ debug_stack_usage_inc (); -preempt_conditional_sti (regs); +preempt_disable (); +cond_local_irq_enable (regs);do_trap (X86_TRAP_BP ,SIGTRAP ,"int3" , regs, error_code,NULL ); -preempt_conditional_cli (regs); +cond_local_irq_disable (regs); +preempt_enable_no_resched ();debug_stack_usage_dec (); exit:ist_exit (regs);
@@ -648,12 +636,14 @@ dotraplinkage void do_debug(struct pt_regs *regs, long error_code)debug_stack_usage_inc ();/* It's safe to allow irq's after DR6 has been saved */ -preempt_conditional_sti (regs); +preempt_disable (); +cond_local_irq_enable (regs);if (v8086_mode (regs)) {handle_vm86_trap ((struct kernel_vm86_regs *) regs, error_code,X86_TRAP_DB ); -preempt_conditional_cli (regs); +cond_local_irq_disable (regs); +preempt_enable_no_resched ();debug_stack_usage_dec (); goto exit; }
@@ -673,7 +663,8 @@ dotraplinkage void do_debug(struct pt_regs *regs, long error_code) si_code =get_si_code (tsk->thread.debugreg6);if (tsk->thread.debugreg6 & (DR_STEP |DR_TRAP_BITS ) || user_icebp)send_sigtrap (tsk, regs, error_code, si_code); -preempt_conditional_cli (regs); +cond_local_irq_disable (regs); +preempt_enable_no_resched ();debug_stack_usage_dec (); exit:
@@ -696,7 +687,7 @@ static void math_error(struct pt_regs *regs, int error_code, int trapnr)if (notify_die (DIE_TRAP , str, regs, error_code, trapnr,SIGFPE ) ==NOTIFY_STOP )return ; -conditional_sti (regs); +cond_local_irq_enable (regs);if (!user_mode (regs)) {if (!fixup_exception (regs)) {
@@ -743,7 +734,7 @@ do_simd_coprocessor_error(struct pt_regs *regs, long error_code) dotraplinkage voiddo_spurious_interrupt_bug (struct pt_regs *regs,long error_code) { -conditional_sti (regs); +cond_local_irq_enable (regs); }dotraplinkage void
@@ -756,7 +747,7 @@ do_device_not_available(struct pt_regs *regs, long error_code)if (read_cr0 () &X86_CR0_EM ) {struct math_emu_info info = { }; -conditional_sti (regs); +cond_local_irq_enable (regs); info.regs = regs;math_emulate (&info);
@@ -765,7 +756,7 @@ do_device_not_available(struct pt_regs *regs, long error_code)#endif fpu__restore (¤t->thread.fpu);/* interrupts still off */ #ifdef CONFIG_X86_32 -conditional_sti (regs); +cond_local_irq_enable (regs);#endif }NOKPROBE_SYMBOL (do_device_not_available);
Signature · 1 line
2.3.5
tip-bot for Alexander Kuleshov
merge bot[tip:x86/asm] x86/entry/traps: Refactor preemption and interrupt flag handling
x86/entry/traps: Refactor preemption and interrupt flag handling
Commit-ID: d99e1bd175f4291ddb6e62b22bb5bdbe3976389a Gitweb: http://git.kernel.org/tip/d99e1bd175f4291ddb6e62b22bb5bdbe3976389a Author: Alexander Kuleshov <[email protected]> AuthorDate: Mon, 25 Jan 2016 20:41:46 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 1 Feb 2016 10:45:14 +0100
x86/entry/traps: Refactor preemption and interrupt flag handling
Make the preemption and interrupt flag handling more readable by removing preempt_conditional_sti() and preempt_conditional_cli() helpers and using preempt_disable() and preempt_enable_no_resched() instead.
Rename contitional_sti() and conditional_cli() to the more understandable cond_local_irq_enable() and cond_local_irq_disable() respectively, while at it.
--- arch/x86/kernel/traps.c | 47 +++++++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 28 deletions(-)
arch/x86/kernel/traps.c +19 -28
@@ -83,30 +83,16 @@ gate_desc idt_table[NR_VECTORS] __page_aligned_bss;DECLARE_BITMAP (used_vectors,NR_VECTORS );EXPORT_SYMBOL_GPL (used_vectors); -static inline void conditional_sti (struct pt_regs *regs) +static inline void cond_local_irq_enable (struct pt_regs *regs) {if (regs->flags &X86_EFLAGS_IF )local_irq_enable (); } -static inline void preempt_conditional_sti (struct pt_regs *regs) -{ -preempt_count_inc (); -if (regs->flags &X86_EFLAGS_IF ) -local_irq_enable (); -} - -static inline void conditional_cli (struct pt_regs *regs) -{ -if (regs->flags &X86_EFLAGS_IF ) -local_irq_disable (); -} - -static inline void preempt_conditional_cli (struct pt_regs *regs) +static inline void cond_local_irq_disable (struct pt_regs *regs) {if (regs->flags &X86_EFLAGS_IF )local_irq_disable (); -preempt_count_dec (); }void ist_enter (struct pt_regs *regs)
@@ -286,7 +272,7 @@ static void do_error_trap(struct pt_regs *regs, long error_code, char *str,if (notify_die (DIE_TRAP , str, regs, error_code, trapnr, signr) !=NOTIFY_STOP ) { -conditional_sti (regs); +cond_local_irq_enable (regs);do_trap (trapnr, signr, str, regs, error_code,fill_trap_info (regs, signr, trapnr, &info)); }
@@ -368,7 +354,7 @@ dotraplinkage void do_bounds(struct pt_regs *regs, long error_code)if (notify_die (DIE_TRAP ,"bounds" , regs, error_code,X86_TRAP_BR ,SIGSEGV ) ==NOTIFY_STOP )return ; -conditional_sti (regs); +cond_local_irq_enable (regs);if (!user_mode (regs))die ("bounds" , regs, error_code);
@@ -443,7 +429,7 @@ do_general_protection(struct pt_regs *regs, long error_code)struct task_struct *tsk;RCU_LOCKDEP_WARN (!rcu_is_watching (),"entry code didn't wake RCU" ); -conditional_sti (regs); +cond_local_irq_enable (regs);if (v8086_mode (regs)) {local_irq_enable ();
@@ -517,9 +503,11 @@ dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code)* as we may switch to the interrupt stack. */ debug_stack_usage_inc (); -preempt_conditional_sti (regs); +preempt_disable (); +cond_local_irq_enable (regs);do_trap (X86_TRAP_BP ,SIGTRAP ,"int3" , regs, error_code,NULL ); -preempt_conditional_cli (regs); +cond_local_irq_disable (regs); +preempt_enable_no_resched ();debug_stack_usage_dec (); exit:ist_exit (regs);
@@ -648,12 +636,14 @@ dotraplinkage void do_debug(struct pt_regs *regs, long error_code)debug_stack_usage_inc ();/* It's safe to allow irq's after DR6 has been saved */ -preempt_conditional_sti (regs); +preempt_disable (); +cond_local_irq_enable (regs);if (v8086_mode (regs)) {handle_vm86_trap ((struct kernel_vm86_regs *) regs, error_code,X86_TRAP_DB ); -preempt_conditional_cli (regs); +cond_local_irq_disable (regs); +preempt_enable_no_resched ();debug_stack_usage_dec (); goto exit; }
@@ -673,7 +663,8 @@ dotraplinkage void do_debug(struct pt_regs *regs, long error_code) si_code =get_si_code (tsk->thread.debugreg6);if (tsk->thread.debugreg6 & (DR_STEP |DR_TRAP_BITS ) || user_icebp)send_sigtrap (tsk, regs, error_code, si_code); -preempt_conditional_cli (regs); +cond_local_irq_disable (regs); +preempt_enable_no_resched ();debug_stack_usage_dec (); exit:
@@ -696,7 +687,7 @@ static void math_error(struct pt_regs *regs, int error_code, int trapnr)if (notify_die (DIE_TRAP , str, regs, error_code, trapnr,SIGFPE ) ==NOTIFY_STOP )return ; -conditional_sti (regs); +cond_local_irq_enable (regs);if (!user_mode (regs)) {if (!fixup_exception (regs)) {
@@ -743,7 +734,7 @@ do_simd_coprocessor_error(struct pt_regs *regs, long error_code) dotraplinkage voiddo_spurious_interrupt_bug (struct pt_regs *regs,long error_code) { -conditional_sti (regs); +cond_local_irq_enable (regs); }dotraplinkage void
@@ -756,7 +747,7 @@ do_device_not_available(struct pt_regs *regs, long error_code)if (read_cr0 () &X86_CR0_EM ) {struct math_emu_info info = { }; -conditional_sti (regs); +cond_local_irq_enable (regs); info.regs = regs;math_emulate (&info);
@@ -765,7 +756,7 @@ do_device_not_available(struct pt_regs *regs, long error_code)#endif fpu__restore (¤t->thread.fpu);/* interrupts still off */ #ifdef CONFIG_X86_32 -conditional_sti (regs); +cond_local_irq_enable (regs);#endif }NOKPROBE_SYMBOL (do_device_not_available);
Borislav Petkov
maintainerPATCH 2/8 x86/cpufeature: Use enum cpuid_leafs instead of magic numbers
In reply to Borislav PetkovFrom: Huaitong Han <[email protected]>
Most of magic numbers of x86_capability have been converted to enum cpuid_leafs, and this patch does update the remaining part.
--- arch/x86/include/asm/elf.h | 2 +- arch/x86/kernel/mpparse.c | 2 +- arch/x86/lguest/boot.c | 2 +- arch/x86/xen/enlighten.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
arch/x86/include/asm/elf.h +1 -1
@@ -256,7 +256,7 @@ extern int force_personality32;instruction set this CPU supports. This could be done in user space, but it's not easy, and we've already done it here. */ -#define ELF_HWCAP (boot_cpu_data.x86_capability[0]) +#define ELF_HWCAP (boot_cpu_data.x86_capability[CPUID_1_EDX])/* This yields a string that ld.so will use to load implementation specific libraries for optimization. This is more specific in
arch/x86/kernel/mpparse.c +1 -1
@@ -408,7 +408,7 @@ static inline void __init construct_default_ISA_mptable(int mpc_default_type) processor.cpuflag =CPU_ENABLED ; processor.cpufeature = (boot_cpu_data.x86 <<8 ) | (boot_cpu_data.x86_model <<4 ) | boot_cpu_data.x86_mask; - processor.featureflag = boot_cpu_data.x86_capability[0 ]; + processor.featureflag = boot_cpu_data.x86_capability[CPUID_1_EDX ]; processor.reserved[0 ] =0 ; processor.reserved[1 ] =0 ;for (i =0 ; i <2 ; i++) {
arch/x86/lguest/boot.c +1 -1
@@ -1535,7 +1535,7 @@ __init void lguest_init(void)*/ cpu_detect (&new_cpu_data);/* head.S usually sets up the first capability word, so do it here. */ - new_cpu_data.x86_capability[0 ] =cpuid_edx (1 ); + new_cpu_data.x86_capability[CPUID_1_EDX ] =cpuid_edx (1 );/* Math is always hard! */ set_cpu_cap (&new_cpu_data,X86_FEATURE_FPU );
arch/x86/xen/enlighten.c +1 -1
@@ -1654,7 +1654,7 @@ asmlinkage __visible void __init xen_start_kernel(void)cpu_detect (&new_cpu_data);set_cpu_cap (&new_cpu_data,X86_FEATURE_FPU ); new_cpu_data.wp_works_ok =1 ; - new_cpu_data.x86_capability[0 ] =cpuid_edx (1 ); + new_cpu_data.x86_capability[CPUID_1_EDX ] =cpuid_edx (1 );#endif if (xen_start_info->mod_start) {
Signature · 1 line
2.3.5
tip-bot for Huaitong Han
merge bot[tip:x86/cpu] x86/cpufeature: Use enum cpuid_leafs instead of magic numbers
x86/cpufeature: Use enum cpuid_leafs instead of magic numbers
Commit-ID: 16aaa53756501914a863ae7a15fcb070dc27c3d7 Gitweb: http://git.kernel.org/tip/16aaa53756501914a863ae7a15fcb070dc27c3d7 Author: Huaitong Han <[email protected]> AuthorDate: Mon, 25 Jan 2016 20:41:47 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 1 Feb 2016 10:46:48 +0100
x86/cpufeature: Use enum cpuid_leafs instead of magic numbers
Most of the magic numbers in x86_capability[] have been converted to 'enum cpuid_leafs', and this patch updates the remaining part.
--- arch/x86/include/asm/elf.h | 2 +- arch/x86/kernel/mpparse.c | 2 +- arch/x86/lguest/boot.c | 2 +- arch/x86/xen/enlighten.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
arch/x86/include/asm/elf.h +1 -1
@@ -256,7 +256,7 @@ extern int force_personality32;instruction set this CPU supports. This could be done in user space, but it's not easy, and we've already done it here. */ -#define ELF_HWCAP (boot_cpu_data.x86_capability[0]) +#define ELF_HWCAP (boot_cpu_data.x86_capability[CPUID_1_EDX])/* This yields a string that ld.so will use to load implementation specific libraries for optimization. This is more specific in
arch/x86/kernel/mpparse.c +1 -1
@@ -408,7 +408,7 @@ static inline void __init construct_default_ISA_mptable(int mpc_default_type) processor.cpuflag =CPU_ENABLED ; processor.cpufeature = (boot_cpu_data.x86 <<8 ) | (boot_cpu_data.x86_model <<4 ) | boot_cpu_data.x86_mask; - processor.featureflag = boot_cpu_data.x86_capability[0 ]; + processor.featureflag = boot_cpu_data.x86_capability[CPUID_1_EDX ]; processor.reserved[0 ] =0 ; processor.reserved[1 ] =0 ;for (i =0 ; i <2 ; i++) {
arch/x86/lguest/boot.c +1 -1
@@ -1535,7 +1535,7 @@ __init void lguest_init(void)*/ cpu_detect (&new_cpu_data);/* head.S usually sets up the first capability word, so do it here. */ - new_cpu_data.x86_capability[0 ] =cpuid_edx (1 ); + new_cpu_data.x86_capability[CPUID_1_EDX ] =cpuid_edx (1 );/* Math is always hard! */ set_cpu_cap (&new_cpu_data,X86_FEATURE_FPU );
arch/x86/xen/enlighten.c +1 -1
@@ -1654,7 +1654,7 @@ asmlinkage __visible void __init xen_start_kernel(void)cpu_detect (&new_cpu_data);set_cpu_cap (&new_cpu_data,X86_FEATURE_FPU ); new_cpu_data.wp_works_ok =1 ; - new_cpu_data.x86_capability[0 ] =cpuid_edx (1 ); + new_cpu_data.x86_capability[CPUID_1_EDX ] =cpuid_edx (1 );#endif if (xen_start_info->mod_start) {
Borislav Petkov
maintainerPATCH 3/8 x86/mce: Fix order of AMD MCE init function call
In reply to Borislav PetkovFrom: Aravind Gopalakrishnan <[email protected]>
In mce_amd_feature_init() we take decisions based on mce_flags being set or not. So the feature detection using CPUID should naturally be ordered before we call mce_amd_feature_init().
Fix that here.
--- arch/x86/kernel/cpu/mcheck/mce.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/mcheck/mce.c +1 -1
@@ -1617,10 +1617,10 @@ static void __mcheck_cpu_init_vendor(struct cpuinfo_x86 *c)case X86_VENDOR_AMD : {u32 ebx =cpuid_ebx (0x80000007 ); -mce_amd_feature_init (c); mce_flags.overflow_recov = !!(ebx &BIT (0 )); mce_flags.succor = !!(ebx &BIT (1 )); mce_flags.smca = !!(ebx &BIT (3 )); +mce_amd_feature_init (c);break ; }
Signature · 1 line
2.3.5
tip-bot for Aravind Gopalakrishnan
merge bot[tip:ras/core] x86/mce: Fix order of AMD MCE init function call
x86/mce: Fix order of AMD MCE init function call
Commit-ID: bfbe0eeb769e2aff2cb1fc6845c4e4b7eac40bb3 Gitweb: http://git.kernel.org/tip/bfbe0eeb769e2aff2cb1fc6845c4e4b7eac40bb3 Author: Aravind Gopalakrishnan <[email protected]> AuthorDate: Mon, 25 Jan 2016 20:41:48 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 1 Feb 2016 10:53:55 +0100
x86/mce: Fix order of AMD MCE init function call
In mce_amd_feature_init() we take decisions based on mce_flags being set or not. So the feature detection using CPUID should naturally be ordered before we call mce_amd_feature_init().
Fix that here.
--- arch/x86/kernel/cpu/mcheck/mce.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/mcheck/mce.c +1 -1
@@ -1617,10 +1617,10 @@ static void __mcheck_cpu_init_vendor(struct cpuinfo_x86 *c)case X86_VENDOR_AMD : {u32 ebx =cpuid_ebx (0x80000007 ); -mce_amd_feature_init (c); mce_flags.overflow_recov = !!(ebx &BIT (0 )); mce_flags.succor = !!(ebx &BIT (1 )); mce_flags.smca = !!(ebx &BIT (3 )); +mce_amd_feature_init (c);break ; }
Borislav Petkov
maintainerPATCH 4/8 x86/mce/AMD: Do not perform shared bank check for future processors
In reply to Borislav PetkovFrom: Aravind Gopalakrishnan <[email protected]>
Fam17h and above should not require a check to see if a bank is shared or not. For shared banks, there will always be only one core that has visibility over the MSRs and only that particular core will be allowed to write to the MSRs.
Fix the code to return early if we have Scalable MCA support. No change in functionality for earlier processors.
Boris: Fold in fix from kbuild test robot for:
arch/x86/kernel/cpu/mcheck/mce_amd.c:93:9-10: WARNING: return of 0/1 in function 'is_shared_bank' with return type bool Generated by: scripts/coccinelle/misc/boolreturn.cocci
--- arch/x86/kernel/cpu/mcheck/mce_amd.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/x86/kernel/cpu/mcheck/mce_amd.c +7 -0
@@ -84,6 +84,13 @@ struct thresh_restart {static inline bool is_shared_bank (int bank) { +/* +* Scalable MCA provides for only one core to have access to the MSRs of +* a shared bank. +*/ +if (mce_flags.smca) +return false; +/* Bank 4 is for northbridge reporting and is thus shared */ return (bank ==4 ); }
Signature · 1 line
2.3.5
tip-bot for Aravind Gopalakrishnan
merge bot[tip:ras/core] x86/mce/AMD: Do not perform shared bank check for future processors
x86/mce/AMD: Do not perform shared bank check for future processors
Commit-ID: 284b965c146f482b4a411133f62288d52b7e3a72 Gitweb: http://git.kernel.org/tip/284b965c146f482b4a411133f62288d52b7e3a72 Author: Aravind Gopalakrishnan <[email protected]> AuthorDate: Mon, 25 Jan 2016 20:41:49 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 1 Feb 2016 10:53:56 +0100
x86/mce/AMD: Do not perform shared bank check for future processors
Fam17h and above should not require a check to see if a bank is shared or not. For shared banks, there will always be only one core that has visibility over the MSRs and only that particular core will be allowed to write to the MSRs.
Fix the code to return early if we have Scalable MCA support. No change in functionality for earlier processors.
--- arch/x86/kernel/cpu/mcheck/mce_amd.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/x86/kernel/cpu/mcheck/mce_amd.c +7 -0
@@ -84,6 +84,13 @@ struct thresh_restart {static inline bool is_shared_bank (int bank) { +/* +* Scalable MCA provides for only one core to have access to the MSRs of +* a shared bank. +*/ +if (mce_flags.smca) +return false; +/* Bank 4 is for northbridge reporting and is thus shared */ return (bank ==4 ); }
Borislav Petkov
maintainerPATCH 5/8 x86/mce/AMD: Reduce number of blocks scanned per bank
In reply to Borislav PetkovFrom: Aravind Gopalakrishnan <[email protected]>
Quoted 1 line
From Fam17h onwards, the number of extended
MCx_MISCregister blocks is
reduced to 4. It is an architectural change from what we had on earlier processors.
Although theoritically the total number of extended MCx_MISC registers was 8 in earlier processor families, in practice we only had to use the extra registers for MC4. And only 2 of those were used. So this change does not affect older processors. Tested on Fam10h and Fam15h systems.
--- arch/x86/kernel/cpu/mcheck/mce_amd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/mcheck/mce_amd.c +1 -1
@@ -28,7 +28,7 @@#include <asm/msr.h> #include <asm/trace/irq_vectors.h> -#define NR_BLOCKS 9 +#define NR_BLOCKS 5#define THRESHOLD_MAX 0xFFF#define INT_TYPE_APIC 0x00020000#define MASK_VALID_HI 0x80000000
Signature · 1 line
2.3.5
tip-bot for Aravind Gopalakrishnan
merge bot[tip:ras/core] x86/mce/AMD: Reduce number of blocks scanned per bank
x86/mce/AMD: Reduce number of blocks scanned per bank
Commit-ID: 60f116fca162d9488f783f5014779463243ab7a2 Gitweb: http://git.kernel.org/tip/60f116fca162d9488f783f5014779463243ab7a2 Author: Aravind Gopalakrishnan <[email protected]> AuthorDate: Mon, 25 Jan 2016 20:41:50 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 1 Feb 2016 10:53:57 +0100
x86/mce/AMD: Reduce number of blocks scanned per bank
Quoted 1 line
From Fam17h onwards, the number of extended
MCx_MISCregister blocks is
reduced to 4. It is an architectural change from what we had on earlier processors.
Although theoritically the total number of extended MCx_MISC registers was 8 in earlier processor families, in practice we only had to use the extra registers for MC4. And only 2 of those were used. So this change does not affect older processors. Tested on Fam10h and Fam15h systems.
--- arch/x86/kernel/cpu/mcheck/mce_amd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/mcheck/mce_amd.c +1 -1
@@ -28,7 +28,7 @@#include <asm/msr.h> #include <asm/trace/irq_vectors.h> -#define NR_BLOCKS 9 +#define NR_BLOCKS 5#define THRESHOLD_MAX 0xFFF#define INT_TYPE_APIC 0x00020000#define MASK_VALID_HI 0x80000000
Borislav Petkov
maintainerPATCH 6/8 x86/mce/AMD: Fix LVT offset configuration for thresholding
In reply to Borislav PetkovFrom: Aravind Gopalakrishnan <[email protected]>
For processor families with the Scalable MCA feature, the LVT offset for threshold interrupts is configured only in MSR 0xC0000410 and not in each per bank MISC register as was done in earlier families.
Obtain the LVT offset from the correct MSR for those families.
--- arch/x86/kernel/cpu/mcheck/mce_amd.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/mcheck/mce_amd.c +26 -1
@@ -49,6 +49,11 @@#define DEF_LVT_OFF 0x2#define DEF_INT_TYPE_APIC 0x2 +/* Scalable MCA: */ + +/* Threshold LVT offset is at MSR0xC0000410[15:12] */ +#define SMCA_THR_LVT_OFF 0xF000 +static const char *const th_names[] = {"load_store" ,"insn_fetch" ,
@@ -142,6 +147,14 @@ static int lvt_off_valid(struct threshold_block *b, int apic, u32 lo, u32 hi) }if (apic != msr) { +/* +* On SMCA CPUs, LVT offset is programmed at different MSR and +* BIOS provides the value. The original field where LVT offset +* was set is Reserved. Return early here. +*/ +if (mce_flags.smca) +return 0 ; +pr_err (FW_BUG "cpu %d, invalid threshold interrupt offset %d " "for bank %d, block %d (MSR%08X=0x%x%08x)\n" , b->cpu, apic, b->bank, b->block, b->address, hi, lo);
@@ -300,7 +313,19 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c) goto init; b.interrupt_enable =1 ; - new = (high &MASK_LVTOFF_HI ) >>20 ; + +if (mce_flags.smca) { +u32 smca_low, smca_high; + +/* Gather LVT offset for thresholding */ +if (rdmsr_safe (MSR_CU_DEF_ERR , &smca_low, &smca_high)) +break ; + + new = (smca_low &SMCA_THR_LVT_OFF ) >>12 ; + }else { + new = (high &MASK_LVTOFF_HI ) >>20 ; + } + offset =setup_APIC_mce_threshold (offset, new); if ((offset == new) &&
Signature · 1 line
2.3.5
tip-bot for Aravind Gopalakrishnan
merge bot[tip:ras/core] x86/mce/AMD: Fix LVT offset configuration for thresholding
x86/mce/AMD: Fix LVT offset configuration for thresholding
Commit-ID: f57a1f3c14b9182f1fea667f5a38a1094699db7c Gitweb: http://git.kernel.org/tip/f57a1f3c14b9182f1fea667f5a38a1094699db7c Author: Aravind Gopalakrishnan <[email protected]> AuthorDate: Mon, 25 Jan 2016 20:41:51 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 1 Feb 2016 10:53:57 +0100
x86/mce/AMD: Fix LVT offset configuration for thresholding
For processor families with the Scalable MCA feature, the LVT offset for threshold interrupts is configured only in MSR 0xC0000410 and not in each per bank MISC register as was done in earlier families.
Obtain the LVT offset from the correct MSR for those families.
--- arch/x86/kernel/cpu/mcheck/mce_amd.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/mcheck/mce_amd.c +26 -1
@@ -49,6 +49,11 @@#define DEF_LVT_OFF 0x2#define DEF_INT_TYPE_APIC 0x2 +/* Scalable MCA: */ + +/* Threshold LVT offset is at MSR0xC0000410[15:12] */ +#define SMCA_THR_LVT_OFF 0xF000 +static const char *const th_names[] = {"load_store" ,"insn_fetch" ,
@@ -142,6 +147,14 @@ static int lvt_off_valid(struct threshold_block *b, int apic, u32 lo, u32 hi) }if (apic != msr) { +/* +* On SMCA CPUs, LVT offset is programmed at a different MSR, and +* the BIOS provides the value. The original field where LVT offset +* was set is reserved. Return early here: +*/ +if (mce_flags.smca) +return 0 ; +pr_err (FW_BUG "cpu %d, invalid threshold interrupt offset %d " "for bank %d, block %d (MSR%08X=0x%x%08x)\n" , b->cpu, apic, b->bank, b->block, b->address, hi, lo);
@@ -300,7 +313,19 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c) goto init; b.interrupt_enable =1 ; - new = (high &MASK_LVTOFF_HI ) >>20 ; + +if (mce_flags.smca) { +u32 smca_low, smca_high; + +/* Gather LVT offset for thresholding: */ +if (rdmsr_safe (MSR_CU_DEF_ERR , &smca_low, &smca_high)) +break ; + + new = (smca_low &SMCA_THR_LVT_OFF ) >>12 ; + }else { + new = (high &MASK_LVTOFF_HI ) >>20 ; + } + offset =setup_APIC_mce_threshold (offset, new); if ((offset == new) &&
Borislav Petkov
maintainerPATCH 7/8 x86/mce/AMD: Carve out threshold block preparation
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
mce_amd_feature_init() was getting pretty fat, carve out the threshold_block setup into a separate function in order to simplify flow and make it more understandable.
No functionality change.
--- arch/x86/kernel/cpu/mcheck/mce_amd.c | 88 ++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 38 deletions(-)
arch/x86/kernel/cpu/mcheck/mce_amd.c +50 -38
@@ -267,14 +267,60 @@ static void deferred_error_interrupt_enable(struct cpuinfo_x86 *c)wrmsr (MSR_CU_DEF_ERR , low, high); } +static int +prepare_threshold_block (unsigned int bank,unsigned int block,u32 addr, +int offset,u32 misc_high) +{ +unsigned int cpu =smp_processor_id (); +struct threshold_block b; +int new; + +if (!block) +per_cpu (bank_map, cpu) |= (1 << bank); + +memset (&b,0 ,sizeof (b)); + b.cpu = cpu; + b.bank = bank; + b.block = block; + b.address = addr; + b.interrupt_capable =lvt_interrupt_supported (bank, misc_high); + +if (!b.interrupt_capable) + goto done; + + b.interrupt_enable =1 ; + +if (mce_flags.smca) { +u32 smca_low, smca_high; + +/* Gather LVT offset for thresholding */ +if (rdmsr_safe (MSR_CU_DEF_ERR , &smca_low, &smca_high)) + goto out; + + new = (smca_low &SMCA_THR_LVT_OFF ) >>12 ; + }else { + new = (misc_high &MASK_LVTOFF_HI ) >>20 ; + } + + offset =setup_APIC_mce_threshold (offset, new); + +if ((offset == new) && + (mce_threshold_vector != amd_threshold_interrupt)) + mce_threshold_vector = amd_threshold_interrupt; + +done: +mce_threshold_block_init (&b, offset); + +out: +return offset; +} +/* cpu init entry point, called from mce.c with preempt off */ void mce_amd_feature_init (struct cpuinfo_x86 *c) { -struct threshold_block b; -unsigned int cpu =smp_processor_id ();u32 low =0 , high =0 , address =0 ;unsigned int bank, block; -int offset =-1 , new; +int offset =-1 ;for (bank =0 ; bank < mca_cfg.banks; ++bank) {for (block =0 ; block <NR_BLOCKS ; ++block) {
@@ -299,41 +345,7 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c) (high & MASK_LOCKED_HI))continue ; -if (!block) -per_cpu (bank_map, cpu) |= (1 << bank); - -memset (&b,0 ,sizeof (b)); - b.cpu = cpu; - b.bank = bank; - b.block = block; - b.address = address; - b.interrupt_capable =lvt_interrupt_supported (bank, high); - -if (!b.interrupt_capable) - goto init; - - b.interrupt_enable =1 ; - -if (mce_flags.smca) { -u32 smca_low, smca_high; - -/* Gather LVT offset for thresholding */ -if (rdmsr_safe (MSR_CU_DEF_ERR , &smca_low, &smca_high)) -break ; - - new = (smca_low &SMCA_THR_LVT_OFF ) >>12 ; - }else { - new = (high &MASK_LVTOFF_HI ) >>20 ; - } - - offset =setup_APIC_mce_threshold (offset, new); - -if ((offset == new) && - (mce_threshold_vector != amd_threshold_interrupt)) - mce_threshold_vector = amd_threshold_interrupt; - -init: -mce_threshold_block_init (&b, offset); + offset =prepare_threshold_block (bank, block, address, offset, high); } }
Signature · 1 line
2.3.5
tip-bot for Borislav Petkov
merge bot[tip:ras/core] x86/mce/AMD: Carve out threshold block preparation
x86/mce/AMD: Carve out threshold block preparation
Commit-ID: 429893b16d35d309ed6b35136aad5f908a08d9b9 Gitweb: http://git.kernel.org/tip/429893b16d35d309ed6b35136aad5f908a08d9b9 Author: Borislav Petkov <[email protected]> AuthorDate: Mon, 25 Jan 2016 20:41:52 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 1 Feb 2016 10:53:58 +0100
x86/mce/AMD: Carve out threshold block preparation
mce_amd_feature_init() was getting pretty fat, carve out the threshold_block setup into a separate function in order to simplify flow and make it more understandable.
No functionality change.
--- arch/x86/kernel/cpu/mcheck/mce_amd.c | 87 ++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 38 deletions(-)
arch/x86/kernel/cpu/mcheck/mce_amd.c +49 -38
@@ -267,14 +267,59 @@ static void deferred_error_interrupt_enable(struct cpuinfo_x86 *c)wrmsr (MSR_CU_DEF_ERR , low, high); } +static int +prepare_threshold_block (unsigned int bank,unsigned int block,u32 addr, +int offset,u32 misc_high) +{ +unsigned int cpu =smp_processor_id (); +struct threshold_block b; +int new; + +if (!block) +per_cpu (bank_map, cpu) |= (1 << bank); + +memset (&b,0 ,sizeof (b)); + b.cpu = cpu; + b.bank = bank; + b.block = block; + b.address = addr; + b.interrupt_capable =lvt_interrupt_supported (bank, misc_high); + +if (!b.interrupt_capable) + goto done; + + b.interrupt_enable =1 ; + +if (mce_flags.smca) { +u32 smca_low, smca_high; + +/* Gather LVT offset for thresholding: */ +if (rdmsr_safe (MSR_CU_DEF_ERR , &smca_low, &smca_high)) + goto out; + + new = (smca_low &SMCA_THR_LVT_OFF ) >>12 ; + }else { + new = (misc_high &MASK_LVTOFF_HI ) >>20 ; + } + + offset =setup_APIC_mce_threshold (offset, new); + +if ((offset == new) && (mce_threshold_vector != amd_threshold_interrupt)) + mce_threshold_vector = amd_threshold_interrupt; + +done: +mce_threshold_block_init (&b, offset); + +out: +return offset; +} +/* cpu init entry point, called from mce.c with preempt off */ void mce_amd_feature_init (struct cpuinfo_x86 *c) { -struct threshold_block b; -unsigned int cpu =smp_processor_id ();u32 low =0 , high =0 , address =0 ;unsigned int bank, block; -int offset =-1 , new; +int offset =-1 ;for (bank =0 ; bank < mca_cfg.banks; ++bank) {for (block =0 ; block <NR_BLOCKS ; ++block) {
@@ -299,41 +344,7 @@ void mce_amd_feature_init(struct cpuinfo_x86 *c) (high & MASK_LOCKED_HI))continue ; -if (!block) -per_cpu (bank_map, cpu) |= (1 << bank); - -memset (&b,0 ,sizeof (b)); - b.cpu = cpu; - b.bank = bank; - b.block = block; - b.address = address; - b.interrupt_capable =lvt_interrupt_supported (bank, high); - -if (!b.interrupt_capable) - goto init; - - b.interrupt_enable =1 ; - -if (mce_flags.smca) { -u32 smca_low, smca_high; - -/* Gather LVT offset for thresholding: */ -if (rdmsr_safe (MSR_CU_DEF_ERR , &smca_low, &smca_high)) -break ; - - new = (smca_low &SMCA_THR_LVT_OFF ) >>12 ; - }else { - new = (high &MASK_LVTOFF_HI ) >>20 ; - } - - offset =setup_APIC_mce_threshold (offset, new); - -if ((offset == new) && - (mce_threshold_vector != amd_threshold_interrupt)) - mce_threshold_vector = amd_threshold_interrupt; - -init: -mce_threshold_block_init (&b, offset); + offset =prepare_threshold_block (bank, block, address, offset, high); } }
Borislav Petkov
maintainerPATCH 8/8 x86/mce/AMD: Set MCAX Enable bit
In reply to Borislav PetkovFrom: Aravind Gopalakrishnan <[email protected]>
It is required for the OS to acknowledge that it is using the MCAX register set and its associated fields by setting the 'McaXEnable' bit in each bank's MCi_CONFIG register. If it is not set, then all UC errors will cause a system panic.
--- arch/x86/include/asm/msr-index.h | 4 ++++ arch/x86/kernel/cpu/mcheck/mce_amd.c | 14 ++++++++++++++ 2 files changed, 18 insertions(+)
arch/x86/include/asm/msr-index.h +4 -0
@@ -264,6 +264,10 @@#define MSR_IA32_MC0_CTL2 0x00000280#define MSR_IA32_MCx_CTL2 (x) (MSR_IA32_MC0_CTL2 + (x)) +/* AMD64 Scalable MCA */ +#define MSR_AMD64_SMCA_MC0_CONFIG 0xc0002004 +#define MSR_AMD64_SMCA_MCx_CONFIG (x) (MSR_AMD64_SMCA_MC0_CONFIG + 0x10*(x)) +#define MSR_P6_PERFCTR0 0x000000c1#define MSR_P6_PERFCTR1 0x000000c2#define MSR_P6_EVNTSEL0 0x00000186
arch/x86/kernel/cpu/mcheck/mce_amd.c +14 -0
@@ -54,6 +54,14 @@/* Threshold LVT offset is at MSR0xC0000410[15:12] */ #define SMCA_THR_LVT_OFF 0xF000 +/* +* OS is required to set the MCAX bit to acknowledge that it is now using the +* new MSR ranges and new registers under each bank. It also means that OS will +* configure Deferred errors in the new MCx_CONFIG register. If the bit is not +* set, uncorrectable errors will cause system panic. +*/ +#define SMCA_MCAX_EN_OFF 0x1 +static const char *const th_names[] = {"load_store" ,"insn_fetch" ,
@@ -292,6 +300,12 @@ prepare_threshold_block(unsigned int bank, unsigned int block, u32 addr,if (mce_flags.smca) {u32 smca_low, smca_high; +u32 smca_addr =MSR_AMD64_SMCA_MCx_CONFIG (bank); + +if (!rdmsr_safe (smca_addr, &smca_low, &smca_high)) { + smca_high |=SMCA_MCAX_EN_OFF ; +wrmsr (smca_addr, smca_low, smca_high); + }/* Gather LVT offset for thresholding */ if (rdmsr_safe (MSR_CU_DEF_ERR , &smca_low, &smca_high))
Signature · 1 line
2.3.5
tip-bot for Aravind Gopalakrishnan
merge bot[tip:ras/core] x86/mce/AMD: Set MCAX Enable bit
x86/mce/AMD: Set MCAX Enable bit
Commit-ID: e6c8f1873be8a14c7e44202df1f7e6ea61bf3352 Gitweb: http://git.kernel.org/tip/e6c8f1873be8a14c7e44202df1f7e6ea61bf3352 Author: Aravind Gopalakrishnan <[email protected]> AuthorDate: Mon, 25 Jan 2016 20:41:53 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 1 Feb 2016 10:53:59 +0100
x86/mce/AMD: Set MCAX Enable bit
It is required for the OS to acknowledge that it is using the MCAX register set and its associated fields by setting the 'McaXEnable' bit in each bank's MCi_CONFIG register. If it is not set, then all UC errors will cause a system panic.
--- arch/x86/include/asm/msr-index.h | 4 ++++ arch/x86/kernel/cpu/mcheck/mce_amd.c | 14 ++++++++++++++ 2 files changed, 18 insertions(+)
arch/x86/include/asm/msr-index.h +4 -0
@@ -264,6 +264,10 @@#define MSR_IA32_MC0_CTL2 0x00000280#define MSR_IA32_MCx_CTL2 (x) (MSR_IA32_MC0_CTL2 + (x)) +/* 'SMCA': AMD64 Scalable MCA */ +#define MSR_AMD64_SMCA_MC0_CONFIG 0xc0002004 +#define MSR_AMD64_SMCA_MCx_CONFIG (x) (MSR_AMD64_SMCA_MC0_CONFIG + 0x10*(x)) +#define MSR_P6_PERFCTR0 0x000000c1#define MSR_P6_PERFCTR1 0x000000c2#define MSR_P6_EVNTSEL0 0x00000186
arch/x86/kernel/cpu/mcheck/mce_amd.c +14 -0
@@ -54,6 +54,14 @@/* Threshold LVT offset is at MSR0xC0000410[15:12] */ #define SMCA_THR_LVT_OFF 0xF000 +/* +* OS is required to set the MCAX bit to acknowledge that it is now using the +* new MSR ranges and new registers under each bank. It also means that the OS +* will configure deferred errors in the new MCx_CONFIG register. If the bit is +* not set, uncorrectable errors will cause a system panic. +*/ +#define SMCA_MCAX_EN_OFF 0x1 +static const char *const th_names[] = {"load_store" ,"insn_fetch" ,
@@ -292,6 +300,12 @@ prepare_threshold_block(unsigned int bank, unsigned int block, u32 addr,if (mce_flags.smca) {u32 smca_low, smca_high; +u32 smca_addr =MSR_AMD64_SMCA_MCx_CONFIG (bank); + +if (!rdmsr_safe (smca_addr, &smca_low, &smca_high)) { + smca_high |=SMCA_MCAX_EN_OFF ; +wrmsr (smca_addr, smca_low, smca_high); + }/* Gather LVT offset for thresholding: */ if (rdmsr_safe (MSR_CU_DEF_ERR , &smca_low, &smca_high))