0024436
Path: news.gmane.org!not-for-mail
0024436
From: Borislav Petkov <borislav.petkov@amd.com>
0024436
Newsgroups: gmane.linux.kernel
0024436
Subject: [PATCH 2/2] x86, microcode: Ensure that module is only loaded for
0024436
Date: Thu, 12 Apr 2012 18:34:22 +0200
0024436
Lines: 80
0024436
Approved: news@gmane.org
0024436
Message-ID: <20120412163422.GM24549@aftab>
0024436
References: <20120411163849.GE4794@alberich.amd.com>
0024436
 <20120411200601.GC12288@kroah.com>
0024436
 <20120411201053.GF18114@aftab>
0024436
 <20120412162351.GJ24549@aftab>
0024436
NNTP-Posting-Host: plane.gmane.org
0024436
Mime-Version: 1.0
0024436
Content-Type: text/plain; charset="us-ascii"
0024436
X-Trace: dough.gmane.org 1334248500 15307 80.91.229.3 (12 Apr 2012 16:35:00 GMT)
0024436
X-Complaints-To: usenet@dough.gmane.org
0024436
NNTP-Posting-Date: Thu, 12 Apr 2012 16:35:00 +0000 (UTC)
0024436
Cc: Andreas Herrmann <andreas.herrmann3@amd.com>,
0024436
	Kay Sievers <kay.sievers@vrfy.org>,
0024436
	Dave Jones <davej@redhat.com>, <linux-kernel@vger.kernel.org>
0024436
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
0024436
Original-X-From: linux-kernel-owner@vger.kernel.org Thu Apr 12 18:34:59 2012
0024436
Return-path: <linux-kernel-owner@vger.kernel.org>
0024436
Envelope-to: glk-linux-kernel-3@plane.gmane.org
0024436
Original-Received: from vger.kernel.org ([209.132.180.67])
0024436
	by plane.gmane.org with esmtp (Exim 4.69)
0024436
	(envelope-from <linux-kernel-owner@vger.kernel.org>)
0024436
	id 1SIMz4-0008MV-3g
0024436
	for glk-linux-kernel-3@plane.gmane.org; Thu, 12 Apr 2012 18:34:58 +0200
0024436
Original-Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
0024436
	id S965760Ab2DLQep (ORCPT <rfc822;glk-linux-kernel-3@m.gmane.org>);
0024436
	Thu, 12 Apr 2012 12:34:45 -0400
0024436
Original-Received: from db3ehsobe002.messaging.microsoft.com ([213.199.154.140]:56919
0024436
	"EHLO db3outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK)
0024436
	by vger.kernel.org with ESMTP id S965553Ab2DLQen (ORCPT
0024436
	<rfc822;linux-kernel@vger.kernel.org>);
0024436
	Thu, 12 Apr 2012 12:34:43 -0400
0024436
Original-Received: from mail2-db3-R.bigfish.com (10.3.81.239) by
0024436
 DB3EHSOBE005.bigfish.com (10.3.84.25) with Microsoft SMTP Server id
0024436
 14.1.225.23; Thu, 12 Apr 2012 16:34:41 +0000
0024436
Original-Received: from mail2-db3 (localhost [127.0.0.1])	by mail2-db3-R.bigfish.com
0024436
 (Postfix) with ESMTP id E4EF14404B4;	Thu, 12 Apr 2012 16:34:41 +0000 (UTC)
0024436
X-SpamScore: 0
0024436
X-BigFish: VPS0(zzzz1202hzz8275bh8275dhz2dh668h839h944hd25hd2bh)
0024436
X-Forefront-Antispam-Report: CIP:163.181.249.108;KIP:(null);UIP:(null);IPV:NLI;H:ausb3twp01.amd.com;RD:none;EFVD:NLI
0024436
Original-Received: from mail2-db3 (localhost.localdomain [127.0.0.1]) by mail2-db3
0024436
 (MessageSwitch) id 1334248479906480_3860; Thu, 12 Apr 2012 16:34:39 +0000
0024436
 (UTC)
0024436
Original-Received: from DB3EHSMHS005.bigfish.com (unknown [10.3.81.241])	by
0024436
 mail2-db3.bigfish.com (Postfix) with ESMTP id CEB76400A4;	Thu, 12 Apr 2012
0024436
 16:34:39 +0000 (UTC)
0024436
Original-Received: from ausb3twp01.amd.com (163.181.249.108) by
0024436
 DB3EHSMHS005.bigfish.com (10.3.87.105) with Microsoft SMTP Server id
0024436
 14.1.225.23; Thu, 12 Apr 2012 16:34:38 +0000
0024436
X-WSS-ID: 0M2DKPO-01-CNU-02
0024436
X-M-MSG: 
0024436
Original-Received: from sausexedgep02.amd.com (sausexedgep02-ext.amd.com
0024436
 [163.181.249.73])	(using TLSv1 with cipher AES128-SHA (128/128 bits))	(No
0024436
 client certificate requested)	by ausb3twp01.amd.com (Axway MailGate 3.8.1)
0024436
 with ESMTP id 2C1D81028100;	Thu, 12 Apr 2012 11:34:36 -0500 (CDT)
0024436
Original-Received: from SAUSEXDAG02.amd.com (163.181.55.2) by sausexedgep02.amd.com
0024436
 (163.181.36.59) with Microsoft SMTP Server (TLS) id 8.3.192.1; Thu, 12 Apr
0024436
 2012 11:34:51 -0500
0024436
Original-Received: from storexhtp01.amd.com (172.24.4.3) by sausexdag02.amd.com
0024436
 (163.181.55.2) with Microsoft SMTP Server (TLS) id 14.1.323.3; Thu, 12 Apr
0024436
 2012 11:34:36 -0500
0024436
Original-Received: from gwo.osrc.amd.com (165.204.16.204) by storexhtp01.amd.com
0024436
 (172.24.4.3) with Microsoft SMTP Server id 8.3.213.0; Thu, 12 Apr 2012
0024436
 12:34:35 -0400
0024436
Original-Received: from aftab (aftab.osrc.amd.com [165.204.15.109])	by gwo.osrc.amd.com
0024436
 (Postfix) with ESMTP id D8E4C49C58B;	Thu, 12 Apr 2012 17:34:33 +0100 (BST)
0024436
Content-Disposition: inline
0024436
In-Reply-To: <20120412162351.GJ24549@aftab>
0024436
User-Agent: Mutt/1.5.21 (2010-09-15)
0024436
X-OriginatorOrg: amd.com
0024436
Original-Sender: linux-kernel-owner@vger.kernel.org
0024436
Precedence: bulk
0024436
List-ID: <linux-kernel.vger.kernel.org>
0024436
X-Mailing-List: linux-kernel@vger.kernel.org
0024436
Xref: news.gmane.org gmane.linux.kernel:1281050
0024436
Archived-At: <http://permalink.gmane.org/gmane.linux.kernel/1281050>
0024436
0024436
From: Andreas Herrmann <andreas.herrmann3@amd.com>
0024436
Date: Thu, 12 Apr 2012 16:51:57 +0200
0024436
Subject: [PATCH 2/2] x86, microcode: Ensure that module is only loaded for supported AMD CPUs
0024436
0024436
Exit early when there's no support for a particular CPU family. Also,
0024436
fixup the "no support for this CPU vendor" to be issued only when the
0024436
driver is attempted to be loaded on an unsupported vendor.
0024436
0024436
Cc: stable@vger.kernel.org
0024436
Cc: Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
0024436
Cc: Borislav Petkov <borislav.petkov@amd.com>
0024436
[Boris: added a commit msg because Andreas is lazy]
0024436
Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com>
0024436
---
0024436
 arch/x86/kernel/microcode_amd.c  |   12 +++++++-----
0024436
 arch/x86/kernel/microcode_core.c |    6 +++---
0024436
 2 files changed, 10 insertions(+), 8 deletions(-)
0024436
0024436
diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c
0024436
index 73465aa..8a2ce8f 100644
0024436
--- a/arch/x86/kernel/microcode_amd.c
0024436
+++ b/arch/x86/kernel/microcode_amd.c
0024436
@@ -82,11 +82,6 @@ static int collect_cpu_info_amd(int cpu, struct cpu_signature *csig)
0024436
 {
0024436
 	struct cpuinfo_x86 *c = &cpu_data(cpu);
0024436
 
0024436
-	if (c->x86_vendor != X86_VENDOR_AMD || c->x86 < 0x10) {
0024436
-		pr_warning("CPU%d: family %d not supported\n", cpu, c->x86);
0024436
-		return -1;
0024436
-	}
0024436
-
0024436
 	csig->rev = c->microcode;
0024436
 	pr_info("CPU%d: patch_level=0x%08x\n", cpu, csig->rev);
0024436
 
0024436
@@ -380,6 +375,13 @@ static struct microcode_ops microcode_amd_ops = {
0024436
 
0024436
 struct microcode_ops * __init init_amd_microcode(void)
0024436
 {
0024436
+	struct cpuinfo_x86 *c = &cpu_data(0);
0024436
+
0024436
+	if (c->x86_vendor != X86_VENDOR_AMD || c->x86 < 0x10) {
0024436
+		pr_warning("AMD CPU family 0x%x not supported\n", c->x86);
0024436
+		return NULL;
0024436
+	}
0024436
+
0024436
 	patch = (void *)get_zeroed_page(GFP_KERNEL);
0024436
 	if (!patch)
0024436
 		return NULL;
0024436
diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
0024436
index d389e74..c9bda6d 100644
0024436
--- a/arch/x86/kernel/microcode_core.c
0024436
+++ b/arch/x86/kernel/microcode_core.c
0024436
@@ -526,11 +526,11 @@ static int __init microcode_init(void)
0024436
 		microcode_ops = init_intel_microcode();
0024436
 	else if (c->x86_vendor == X86_VENDOR_AMD)
0024436
 		microcode_ops = init_amd_microcode();
0024436
-
0024436
-	if (!microcode_ops) {
0024436
+	else
0024436
 		pr_err("no support for this CPU vendor\n");
0024436
+
0024436
+	if (!microcode_ops)
0024436
 		return -ENODEV;
0024436
-	}
0024436
 
0024436
 	microcode_pdev = platform_device_register_simple("microcode", -1,
0024436
 							 NULL, 0);
0024436
-- 
0024436
1.7.8.4
0024436
0024436
-- 
0024436
Regards/Gruss,
0024436
Boris.
0024436
0024436
Advanced Micro Devices GmbH
0024436
Einsteinring 24, 85609 Dornach
0024436
GM: Alberto Bozzo
0024436
Reg: Dornach, Landkreis Muenchen
0024436
HRB Nr. 43632 WEEE Registernr: 129 19551
0024436