Return-path: Received: from edison.jonmasters.org ([173.255.233.168]) by Galois.linutronix.de with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1fACxA-00050u-8G for speck@linutronix.de; Sun, 22 Apr 2018 13:14:44 +0200 Received: from jcm by edison.jonmasters.org with local (Exim 4.71) (envelope-from ) id 1fABiO-0003fy-Gu for speck@linutronix.de; Sun, 22 Apr 2018 09:55:24 +0000 Message-Id: <20180422094127.969167045@washington.bos.jonmasters.org> Date: Sun, 22 Apr 2018 05:35:24 -0400 From: jcm@redhat.com Subject: [MODERATED] [patch 1/7] [PATCH v2.1-jcm 1/7] x86/spectre/meltdown: Mash them in common function (cpu_set_bug_bits) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: Combine the various logic which goes through all those x86_cpu_id matching structures in one function. XXX-Suggested-by: Borislav Petkov Signed-off-by: Konrad Rzeszutek Wilk --- arch/x86/kernel/cpu/common.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 8a5b185..62f2f04 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -923,22 +923,28 @@ static void identify_cpu_without_cpuid(struct cpuinfo_x86 *c) {} }; -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. @@ -988,12 +994,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); -- 1.8.3.1