Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5763015imm; Mon, 23 Jul 2018 05:46:43 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd7PnuPsI5hM3tAYFEdbVBYdVLRRszwz2guIbd7945gelkRiTkLtw8uOZ4l+b9WTdnuhm2S X-Received: by 2002:a17:902:6f02:: with SMTP id w2-v6mr927462plk.216.1532350003524; Mon, 23 Jul 2018 05:46:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532350003; cv=none; d=google.com; s=arc-20160816; b=xIUtzHs1YN9POWZ4+6IV36cUEKxWUcoue75ohwThn1+pLBJ+Eu8H5JS4BYvEw1GtRY LJ/pD7RzwC4WvutD37n3lR+YbqBxNJ1A4VaFzRdHGAI9cwfa1zMSEr1LdiX3zbrMtBue 8wjEk9OUj3RVCWrujYOEH1bftOpYUz1DElci4S6rcFyYiyfJEBto7Bw3qhzBKWLUhn5D J2Vmf5tWnzqC1U/Z/ZAwgXpOHsrE8Yh73d0KKuHfcIEf87sY//Dza+HTB+1zTJfltNOv /wQdE0R1v47OSAASdkKQnY3/pfA3m3hdQ398F3Rm39V7QmDIZj1m49LlLJQzitO1dA4h Fo9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=D7e15MQTPX+i/JYpLEtj3lL476wYtA74ipHKNHH13uc=; b=nVb2WilxDjvwf4K8AcxMta+vcQV5g7/MuwHLqI4LFBm2w3Qfeu2ielWnvHf595zM0Q cufxijWMJvaqmeiM98WzYgxrjJ+eK/kVNAyZBZyMduzUInSFjwFt8svR918NRUFvieoN gSDy/dt7VQhZCb9t55hQy8ZDDVlCsBy45hASGbe8A8AOiq81KKFR5VMCJzt7U+T+YOPt zirs5LozDRcX4Bx4p/CT5p7NWmt7vlnnxzNVgpCK6dRf7qALUxr+Usj4EWo+dMwGCB+c g5lN7wg8ee9TF7NA40j/iBRwA0SYmrwZVRWG7z2FI/aqtQKbeX8+74mUEy4ShHpuLv/+ n5Vw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j1-v6si7543907plt.126.2018.07.23.05.46.28; Mon, 23 Jul 2018 05:46:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388860AbeGWNqV (ORCPT + 99 others); Mon, 23 Jul 2018 09:46:21 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50230 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388274AbeGWNqU (ORCPT ); Mon, 23 Jul 2018 09:46:20 -0400 Received: from localhost (LFbn-1-12238-233.w90-92.abo.wanadoo.fr [90.92.53.233]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 27B41C77; Mon, 23 Jul 2018 12:44:42 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Borislav Petkov , Konrad Rzeszutek Wilk , Thomas Gleixner , Ingo Molnar , David Woodhouse , "Srivatsa S. Bhat" , "Matt Helsley (VMware)" , Alexey Makhalov , Bo Gan Subject: [PATCH 4.4 049/107] x86/bugs: Concentrate bug detection into a separate function Date: Mon, 23 Jul 2018 14:41:43 +0200 Message-Id: <20180723122415.392349510@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180723122413.003644357@linuxfoundation.org> References: <20180723122413.003644357@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Konrad Rzeszutek Wilk commit 4a28bfe3267b68e22c663ac26185aa16c9b879ef upstream Combine the various logic which goes through all those x86_cpu_id matching structures in one function. Suggested-by: Borislav Petkov Signed-off-by: Konrad Rzeszutek Wilk Signed-off-by: Thomas Gleixner Reviewed-by: Borislav Petkov Reviewed-by: Ingo Molnar Signed-off-by: David Woodhouse Signed-off-by: Greg Kroah-Hartman Signed-off-by: Srivatsa S. Bhat Reviewed-by: Matt Helsley (VMware) Reviewed-by: Alexey Makhalov Reviewed-by: Bo Gan Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/common.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -835,21 +835,27 @@ static const __initconst struct x86_cpu_ {} }; -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); } /* @@ -898,12 +904,7 @@ static void __init early_identify_cpu(st 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);