All of lore.kernel.org
 help / color / mirror / Atom feed
* [MODERATED] [patch 07/11] [PATCH v2 07/10] Linux Patch #7
@ 2018-04-20  2:25 konrad.wilk
  2018-04-20 17:42 ` [MODERATED] " Borislav Petkov
  0 siblings, 1 reply; 38+ messages in thread
From: konrad.wilk @ 2018-04-20  2:25 UTC (permalink / raw)
  To: speck

We do a lot of things in the check_bugs() - one of the first
things we do is identify_boot_cpu() which calls identify_cpu()
which calls this_cpu->init.

Once identify_boot_cpu() is done _then_ it walks through the
spectre_v2_select_mitigation() and alternative_assembler().

If there are some CPU fix ups _after_ spectre_v2 is done
we can't activate those on the BSP as we have already
called 'this_cpu->init'. Hence add a new function to
fixup CPUs.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 arch/x86/include/asm/processor.h | 1 +
 arch/x86/kernel/cpu/bugs.c       | 1 +
 arch/x86/kernel/cpu/common.c     | 8 ++++++++
 arch/x86/kernel/cpu/cpu.h        | 1 +
 4 files changed, 11 insertions(+)

diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index b0ccd4847a58..b22bc9be2385 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -195,6 +195,7 @@ extern void init_amd_cacheinfo(struct cpuinfo_x86 *c);
 
 extern void detect_extended_topology(struct cpuinfo_x86 *c);
 extern void detect_ht(struct cpuinfo_x86 *c);
+extern void apply_cpu_fixes(void);
 
 #ifdef CONFIG_X86_32
 extern int have_cpuid_p(void);
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index b8513a93f4b8..f02443b331f5 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -80,6 +80,7 @@ void __init check_bugs(void)
 	if (!direct_gbpages)
 		set_memory_4k((unsigned long)__va(0), 1);
 #endif
+	apply_cpu_fixes();
 }
 
 /* The kernel command line selection */
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index f7d80658cced..a59f7902a7fa 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -955,6 +955,12 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
 	setup_force_cpu_bug(X86_BUG_CPU_SSB);
 };
 
+void apply_cpu_fixes(void)
+{
+	if (this_cpu->c_bug_fix)
+		this_cpu->c_bug_fix(&boot_cpu_data);
+}
+
 /*
  * Do minimum CPU detection early.
  * Fields really needed: vendor, cpuid_level, family, model, mask,
@@ -1311,6 +1317,8 @@ static void identify_cpu(struct cpuinfo_x86 *c)
 #ifdef CONFIG_NUMA
 	numa_add_cpu(smp_processor_id());
 #endif
+	if (this_cpu->c_bug_fix)
+		this_cpu->c_bug_fix(c);
 }
 
 /*
diff --git a/arch/x86/kernel/cpu/cpu.h b/arch/x86/kernel/cpu/cpu.h
index e806b11a99af..7081634caac5 100644
--- a/arch/x86/kernel/cpu/cpu.h
+++ b/arch/x86/kernel/cpu/cpu.h
@@ -15,6 +15,7 @@ struct cpu_dev {
 	void		(*c_identify)(struct cpuinfo_x86 *);
 	void		(*c_detect_tlb)(struct cpuinfo_x86 *);
 	void		(*c_bsp_resume)(struct cpuinfo_x86 *);
+	void		(*c_bug_fix)(struct cpuinfo_x86 *);
 	int		c_x86_vendor;
 #ifdef CONFIG_X86_32
 	/* Optional vendor specific routine to obtain the cache size. */
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2018-04-24  5:32 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-20  2:25 [MODERATED] [patch 07/11] [PATCH v2 07/10] Linux Patch #7 konrad.wilk
2018-04-20 17:42 ` [MODERATED] " Borislav Petkov
2018-04-21  3:27   ` Konrad Rzeszutek Wilk
2018-04-21  9:03     ` Borislav Petkov
2018-04-21 12:21       ` Konrad Rzeszutek Wilk
2018-04-21 19:25         ` Borislav Petkov
2018-04-21 21:41           ` Linus Torvalds
2018-04-21 22:09             ` Borislav Petkov
2018-04-21 22:13               ` Jon Masters
2018-04-21 22:35                 ` Borislav Petkov
2018-04-21 22:54                   ` Jon Masters
2018-04-22  1:26                     ` Linus Torvalds
2018-04-22  3:18                       ` Jon Masters
2018-04-22  9:35                         ` Borislav Petkov
2018-04-22  9:53                           ` Jon Masters
2018-04-22 10:34                             ` Borislav Petkov
2018-04-22 15:16                               ` Jon Masters
2018-04-23 14:30                               ` Thomas Gleixner
2018-04-23 14:34                                 ` [MODERATED] " Jon Masters
2018-04-23 17:06                                   ` Jon Masters
2018-04-23 17:51                                     ` Konrad Rzeszutek Wilk
2018-04-23 18:01                                       ` Jon Masters
2018-04-23 18:02                                         ` Jon Masters
2018-04-23 18:05                                       ` Linus Torvalds
2018-04-23 18:09                                         ` Jon Masters
2018-04-23 22:23                                           ` Thomas Gleixner
2018-04-23 22:30                                             ` [MODERATED] " Jiri Kosina
2018-04-23 23:03                                               ` Andi Kleen
2018-04-24  5:32                                                 ` Jiri Kosina
2018-04-23 22:31                                             ` Andi Kleen
2018-04-24  0:44                                               ` Jon Masters
2018-04-23 23:36                                             ` Tim Chen
2018-04-23 21:13                                         ` Konrad Rzeszutek Wilk
2018-04-23 21:23                                           ` Linus Torvalds
2018-04-23 21:33                                             ` Jiri Kosina
2018-04-23 22:18                                             ` Andi Kleen
2018-04-24  0:34                                             ` Jon Masters
2018-04-21 22:09             ` Jon Masters

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.