Received: by 10.223.185.116 with SMTP id b49csp2386543wrg; Thu, 15 Feb 2018 10:49:34 -0800 (PST) X-Google-Smtp-Source: AH8x224NMMB7BqVLm5mj7/NeXstwCYlfnRvd8qymyRR8uM6XdZmJZT6ioknXNPg/lAfAybcgMhGp X-Received: by 2002:a17:902:5a88:: with SMTP id r8-v6mr3509215pli.426.1518720574609; Thu, 15 Feb 2018 10:49:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518720574; cv=none; d=google.com; s=arc-20160816; b=AE49ZjInBq8XIw/szyJIC87YI9O5GsSK78yHvLUswCXQCB7vRgCcFmedRZBaAxp2Re EUFONoEpc3cmoqp950sloKdBc42f7eyvn9+fOge3/jiC3oDH8fj6omjpcsm63UI/9I1t 8GaAKBuZSPG1iYujB7JTWVm8WC85Jxg8zscp93S1uY334nk86OF3WBBUcBEgUYHvhXxW bLBIpBV7k9hkkG+q+wZhGBI+TuDmtQMI1t1kQCCfaZvaATMQSCY4GLCESipr4o3NCEZd qKKDzjd/X7OnuZaxEvui43UQUTwYHRaql/Kc+GjX7ITBr6y42Zf1PL80QqmH2mqEbJvr fFWg== 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=fYLIg73O2kzrZyxVLurjPgDvoU9B+cAYbp66lnsZMso=; b=LryvjGxfcLWLOzgbEBB6VeP4BybKocRxfBwlbA7gdX1V8dSBCc5C0y6iT/SQeZ72hd n7vQG0YfQktORHxtmr0Abqpxlg39ZLrf5boTDoknlHEukeXFK3+LfnWJ5D/kkIWh7pmo k01oaySh+hk76pgrnTf1ct/oTcOx72JZp9sZUn/1dZ03KcrPkvw07406ZaeJhBVL29+1 jbEhn4gcmqJ1uMZs2Il3wiST518/fLjawjTHQPkEk4MBhDZ5T4+0f0VbLKZOREqGkVN9 Hqny50s1RvQjg6pZBNeTuKa8+ytm19wVDtCXL1quhIgXIQAmEsbLwVc/SzoUcZj5RQFg Tu1A== 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 q25si1450042pge.457.2018.02.15.10.49.19; Thu, 15 Feb 2018 10:49:34 -0800 (PST) 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 S1162319AbeBOPWL (ORCPT + 99 others); Thu, 15 Feb 2018 10:22:11 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:49388 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162248AbeBOPWH (ORCPT ); Thu, 15 Feb 2018 10:22:07 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A0190DD6; Thu, 15 Feb 2018 15:22:06 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Borislav Petkov , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Rolf Neugebauer Subject: [PATCH 4.4 038/108] x86/microcode: Do the family check first Date: Thu, 15 Feb 2018 16:16:35 +0100 Message-Id: <20180215151227.742442946@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151222.267507937@linuxfoundation.org> References: <20180215151222.267507937@linuxfoundation.org> User-Agent: quilt/0.65 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: Borislav Petkov commit 1f161f67a272cc4f29f27934dd3f74cb657eb5c4 upstream with adjustments. On CPUs like AMD's Geode, for example, we shouldn't even try to load microcode because they do not support the modern microcode loading interface. However, we do the family check *after* the other checks whether the loader has been disabled on the command line or whether we're running in a guest. So move the family checks first in order to exit early if we're being loaded on an unsupported family. Reported-and-tested-by: Sven Glodowski Signed-off-by: Borislav Petkov Cc: # 4.11.. Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://bugzilla.suse.com/show_bug.cgi?id=1061396 Link: http://lkml.kernel.org/r/20171012112316.977-1-bp@alien8.de Signed-off-by: Ingo Molnar Signed-off-by: Rolf Neugebauer Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/microcode/core.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -94,9 +94,6 @@ static bool __init check_loader_disabled bool *res = &dis_ucode_ldr; #endif - if (!have_cpuid_p()) - return *res; - a = 1; c = 0; native_cpuid(&a, &b, &c, &d); @@ -138,8 +135,9 @@ void __init load_ucode_bsp(void) { int vendor; unsigned int family; + bool intel = true; - if (check_loader_disabled_bsp()) + if (!have_cpuid_p()) return; vendor = x86_vendor(); @@ -147,16 +145,27 @@ void __init load_ucode_bsp(void) switch (vendor) { case X86_VENDOR_INTEL: - if (family >= 6) - load_ucode_intel_bsp(); + if (family < 6) + return; break; + case X86_VENDOR_AMD: - if (family >= 0x10) - load_ucode_amd_bsp(family); + if (family < 0x10) + return; + intel = false; break; + default: - break; + return; } + + if (check_loader_disabled_bsp()) + return; + + if (intel) + load_ucode_intel_bsp(); + else + load_ucode_amd_bsp(family); } static bool check_loader_disabled_ap(void)