Skip to contentSkip to conversation

Linux Patch #1

PATCH Superseded [email protected] 2 participants 2 messages Apr 20, 2018 x86

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/10 Linux Patch #1

Combine the various logic which goes through all those x86_cpu_id matching structures in one function.

---
v2: New patch

---
 arch/x86/kernel/cpu/common.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
arch/x86/kernel/cpu/common.c +12 -11
index 348cf4821240..9ddbfbefa5cf 100644
@@ -918,22 +918,28 @@ static const __initconst struct x86_cpu_id cpu_no_meltdown[] = {
 	{}
 };
 
-static bool __init cpu_vulnerable_to_meltdown(struct cpuinfo_x86 *c)
+static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
 {
 	u64 ia32_cap = 0;
 
+	if (x86_match_cpu(cpu_no_speculation))
+		return;
+
+	setup_force_cpu_bug(X86_BUG_SPECTRE_V1);
+	setup_force_cpu_bug(X86_BUG_SPECTRE_V2);
+
 	if (x86_match_cpu(cpu_no_meltdown))
-		return false;
+		return;
 
 	if (cpu_has(c, X86_FEATURE_ARCH_CAPABILITIES))
 		rdmsrl(MSR_IA32_ARCH_CAPABILITIES, ia32_cap);
 
 	/* Rogue Data Cache Load? No! */
 	if (ia32_cap & ARCH_CAP_RDCL_NO)
-		return false;
+		return;
 
-	return true;
-}
+	setup_force_cpu_bug(X86_BUG_CPU_MELTDOWN);
+};
 
 /*
  * Do minimum CPU detection early.
@@ -982,12 +988,7 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
 
 	setup_force_cpu_cap(X86_FEATURE_ALWAYS);
 
-	if (!x86_match_cpu(cpu_no_speculation)) {
-		if (cpu_vulnerable_to_meltdown(c))
-			setup_force_cpu_bug(X86_BUG_CPU_MELTDOWN);
-		setup_force_cpu_bug(X86_BUG_SPECTRE_V1);
-		setup_force_cpu_bug(X86_BUG_SPECTRE_V2);
-	}
+	cpu_set_bug_bits(c);
 
 	fpu__init_system(c);
 
Signature · 1 line
2.14.3
Reviewed-by on v2 1/10
#1 lore raw
Quoted 5 lines · speck for konrad.wilk_at_oracle.com

x86/spectre/meltdown: Mash them in common function (cpu_set_bug_bits)

Combine the various logic which goes through all those x86_cpu_id matching structures in one function.

Quoted 7 lines

---
v2: New patch

---
 arch/x86/kernel/cpu/common.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
--