Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7299203imu; Thu, 31 Jan 2019 08:08:24 -0800 (PST) X-Google-Smtp-Source: ALg8bN7pqtjISc8V6uBQI0HKm08OIOObqwzQN24AAHFD3SvWF32Z8ARwRkqxTpx/gzhBTrNwgTw4 X-Received: by 2002:a63:24c2:: with SMTP id k185mr30970211pgk.406.1548950904618; Thu, 31 Jan 2019 08:08:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548950904; cv=none; d=google.com; s=arc-20160816; b=GGPHk46iyunPvzhWyvIytViGCaTt3xhjb0Q0fZ0TznDcOaYyerYjFj1NKOvTBtqwBK WGG2GPiwkdWtmgigydBisXM11PhWo+lKZvZqWdLHsu8JbOCZv+E5UWXCiUWLpx8hqKpP wl49wjI5324A6G64YdDkMto/IxDoqBM0gWQdfplVjjIsnHxktTFpnBfRTKR8RWLlF6y6 Un8XGEO/g8IuOCT86+3HS5kSg5V8S5ek0GQrZFXRBD8yRAUsBqIxks1FoqI9RcE+7/Mb f0UsunH0mfPqDS6GiSipbUBiqOxTlFiAJLM6tkNt3FAg+FcjGaBfHx/jsHonBck9QHAJ x9dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=wwTHNGpngeqWxh2zGccm5EKXSlG2fjaGSsd1FwqRMLc=; b=R9gVOv6vg8XNAPfuiH8ayaBW0mgXEOGlqVpG7tif3oqWDvQbF0mRzyokhW65S0THMq JpIPkwRqLZ28BZZODqiUoqZm+mi3GmaMrn3kwTQ7BowwGT7l4oX2DVDbIEpjH/3lK+cB sIPR83eu+9JLtSFbaobBxbgKhIck8SSUm/bGZFfUYDvJyv78SyoobYjFpa0wGjhLioTi pJ78Qadwar9H0taDePpYoEz3fbuzxjOBhBjWiCLiG7SIBz8uY7h/kXAFHjNVfnGqok6B XT96+LXBGTsqBJfE9gZvGGHAo47SHRnuR1ljmNlULrHxEoTkT/6RDJsREe4l0pQNwy2C VrbA== 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 s24si4965946plq.41.2019.01.31.08.08.05; Thu, 31 Jan 2019 08:08:24 -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 S2388066AbfAaQHL (ORCPT + 99 others); Thu, 31 Jan 2019 11:07:11 -0500 Received: from terminus.zytor.com ([198.137.202.136]:52469 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733167AbfAaQHK (ORCPT ); Thu, 31 Jan 2019 11:07:10 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x0VG6tBx2939635 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Thu, 31 Jan 2019 08:06:55 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x0VG6sZM2939632; Thu, 31 Jan 2019 08:06:54 -0800 Date: Thu, 31 Jan 2019 08:06:54 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Thomas Lendacky Message-ID: Cc: mingo@redhat.com, linux-kernel@vger.kernel.org, x86@kernel.org, tglx@linutronix.de, mingo@kernel.org, hpa@zytor.com, thomas.lendacky@amd.com, Thomas.Lendacky@amd.com, bp@suse.de Reply-To: mingo@kernel.org, hpa@zytor.com, tglx@linutronix.de, x86@kernel.org, mingo@redhat.com, linux-kernel@vger.kernel.org, bp@suse.de, Thomas.Lendacky@amd.com, thomas.lendacky@amd.com In-Reply-To: <154894518427.9406.8246222496874202773.stgit@tlendack-t1.amdoffice.net> References: <154894518427.9406.8246222496874202773.stgit@tlendack-t1.amdoffice.net> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/microcode/amd: Don't falsely trick the late loading mechanism Git-Commit-ID: 912139cfbfa6a2bc1da052314d2c29338dae1f6a X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 912139cfbfa6a2bc1da052314d2c29338dae1f6a Gitweb: https://git.kernel.org/tip/912139cfbfa6a2bc1da052314d2c29338dae1f6a Author: Thomas Lendacky AuthorDate: Thu, 31 Jan 2019 14:33:06 +0000 Committer: Borislav Petkov CommitDate: Thu, 31 Jan 2019 16:54:32 +0100 x86/microcode/amd: Don't falsely trick the late loading mechanism The load_microcode_amd() function searches for microcode patches and attempts to apply a microcode patch if it is of different level than the currently installed level. While the processor won't actually load a level that is less than what is already installed, the logic wrongly returns UCODE_NEW thus signaling to its caller reload_store() that a late loading should be attempted. If the file-system contains an older microcode revision than what is currently running, such a late microcode reload can result in these misleading messages: x86/CPU: CPU features have changed after loading microcode, but might not take effect. x86/CPU: Please consider either early loading through initrd/built-in or a potential BIOS update. These messages were issued on a system where SME/SEV are not enabled by the BIOS (MSR C001_0010[23] = 0b) because during boot, early_detect_mem_encrypt() is called and cleared the SME and SEV features in this case. However, after the wrong late load attempt, get_cpu_cap() is called and reloads the SME and SEV feature bits, resulting in the messages. Update the microcode level check to not attempt microcode loading if the current level is greater than(!) and not only equal to the current patch level. [ bp: massage commit message. ] Fixes: 2613f36ed965 ("x86/microcode: Attempt late loading only when new microcode is present") Signed-off-by: Tom Lendacky Signed-off-by: Borislav Petkov Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: Thomas Gleixner Cc: x86-ml Link: https://lkml.kernel.org/r/154894518427.9406.8246222496874202773.stgit@tlendack-t1.amdoffice.net --- arch/x86/kernel/cpu/microcode/amd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c index 51adde0a0f1a..e1f3ba19ba54 100644 --- a/arch/x86/kernel/cpu/microcode/amd.c +++ b/arch/x86/kernel/cpu/microcode/amd.c @@ -855,7 +855,7 @@ load_microcode_amd(bool save, u8 family, const u8 *data, size_t size) if (!p) { return ret; } else { - if (boot_cpu_data.microcode == p->patch_id) + if (boot_cpu_data.microcode >= p->patch_id) return ret; ret = UCODE_NEW;