From patchwork Sun Dec 3 11:15:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 172936 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2184378vqy; Sun, 3 Dec 2023 03:16:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IF6cEu+SP+1BVhXPZ+Gl21aMFJntGnC45PAYYC7CQeDhkg7Sic6CaYHNco5Szwlm9Ec5RJh X-Received: by 2002:a17:903:22c6:b0:1d0:83af:fa0d with SMTP id y6-20020a17090322c600b001d083affa0dmr1541581plg.112.1701602207981; Sun, 03 Dec 2023 03:16:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701602207; cv=none; d=google.com; s=arc-20160816; b=QnoIpX3vwb1heZz3ygFKEibGH6I3DTA8APPWbXGLqNgPf+N/288fzLA1+rYNBDUaCs kL7YJJ8iIcz/BtGtxYNBXI2WNWPPegpvcFzPoU2FNgKuurw7/6w6sidiBfRVRF6DzAxm cbFGvcOA0a9LLO0iGstnrz9OQRmiF0JcNLeWQAnfBnfS9xIdOqPdWPzhtOAPu85gOTsH VYZwp8uwQFOvRAA1E7YX2oRIHOu//oQUyUiEwGv6m3U0OifZQ3IvWVV88AiHmnmHAPx5 VqSG+rgNHRWYzQDTZViF4f0KBwFmXz00DxLMnI8Eu9COfKX+U8P48e6qBKAKy2MCtIav +eHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=YQ+VBXklhmVch7Sg2vc0ARJ1AeCnK1tBH54ISC203KI=; fh=FR+zK3Yh2EueN45Yakz1a5ZjKRaWHM8H88LO8rGxyUk=; b=sXAelT7cgUWlT8KjhkSVSErc8HzNt1y0asgRAjIKF3FfjsPWi5P4YDcBvyjvbuXgKs AVVQ900ZZMckwtOLZ8adbsaEm7LKuLmM2LJhEpK6157z7e/4N7wOLeJ11uIQhMOkCbyH PRye4OydJ+B4msJet3xIAkx0ukK78PvaM6PlogWmMtMoOT2D7Vd+Qmf2vq10i0vGjyPb EQwgVaFjlb0fHVviIfauydrGsaTqRC74UZF6FK2yxIQ84RAXbtLR/itlapW+tpteAn43 aqdqS1thPwdV7rct8VvKD9od/TVmrAEXhR3X+/QL6ma8SXb9k1UXb6GPuklw475DByTL 1A2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=aCiqE0gJ; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id s11-20020a170902ea0b00b001cfa2728007si6458159plg.231.2023.12.03.03.16.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 03:16:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=aCiqE0gJ; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 77FB68089E7B; Sun, 3 Dec 2023 03:16:32 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230256AbjLCLP4 (ORCPT + 99 others); Sun, 3 Dec 2023 06:15:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjLCLPz (ORCPT ); Sun, 3 Dec 2023 06:15:55 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFA3CA2; Sun, 3 Dec 2023 03:16:00 -0800 (PST) Date: Sun, 03 Dec 2023 11:15:56 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1701602158; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YQ+VBXklhmVch7Sg2vc0ARJ1AeCnK1tBH54ISC203KI=; b=aCiqE0gJlIwkgJbAP7VryY/SfHO2newtiJlJsbMsBdAnC/qthTaU+JRoXoakp9XrGLjxVD UnEILmt5H9vLjrjwuv/w3P572/pbDUrEx1aC6aqsWx3NMCsARcVf8No7J1Cce392F5Q89t GbK2ZTyP4MzgKOewnNDxuGFQLNaxIjCH2J82hTiZQjh5Pt7UqQ1QjFAhb7mGVbBVsrX5Pd 8l/roLWkOqK9opU9Au0KWdgqseAbZnezB4Hchmmz75LJFsiH9sMK+Y7dbwYHPDMTUCBEo7 qpm4yooV0Eh0WzlflzZ03nNxibLdmfSAf7Ti6aqMiUJozc/utyPXHaYj0XMvww== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1701602158; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YQ+VBXklhmVch7Sg2vc0ARJ1AeCnK1tBH54ISC203KI=; b=8JGd6ffJHHd6dgW56m4o+GfX6/Rt1zNYXkDBMR1PopCo2xT98Ho9XXGQBYkgWUfimrFjgN nOiqMeAHSH4LWkCA== From: "tip-bot2 for Borislav Petkov (AMD)" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/microcode] x86/microcode/intel: Set new revision only after a successful update Cc: Ashok Raj , "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: References: MIME-Version: 1.0 Message-ID: <170160215680.398.309337215455167122.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sun, 03 Dec 2023 03:16:32 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784259236754448653 X-GMAIL-MSGID: 1784259236754448653 The following commit has been merged into the x86/microcode branch of tip: Commit-ID: 9c21ea53e6bd1104c637b80a0688040f184cc761 Gitweb: https://git.kernel.org/tip/9c21ea53e6bd1104c637b80a0688040f184cc761 Author: Borislav Petkov (AMD) AuthorDate: Fri, 01 Dec 2023 14:35:06 +01:00 Committer: Borislav Petkov (AMD) CommitterDate: Sun, 03 Dec 2023 11:49:53 +01:00 x86/microcode/intel: Set new revision only after a successful update This was meant to be done only when early microcode got updated successfully. Move it into the if-branch. Also, make sure the current revision is read unconditionally and only once. Fixes: 080990aa3344 ("x86/microcode: Rework early revisions reporting") Reported-by: Ashok Raj Signed-off-by: Borislav Petkov (AMD) Tested-by: Ashok Raj Link: https://lore.kernel.org/r/ZWjVt5dNRjbcvlzR@a4bf019067fa.jf.intel.com --- arch/x86/kernel/cpu/microcode/intel.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c index 5d6ea87..857e608 100644 --- a/arch/x86/kernel/cpu/microcode/intel.c +++ b/arch/x86/kernel/cpu/microcode/intel.c @@ -370,14 +370,14 @@ static __init struct microcode_intel *get_microcode_blob(struct ucode_cpu_info * { struct cpio_data cp; + intel_collect_cpu_info(&uci->cpu_sig); + if (!load_builtin_intel_microcode(&cp)) cp = find_microcode_in_initrd(ucode_path); if (!(cp.data && cp.size)) return NULL; - intel_collect_cpu_info(&uci->cpu_sig); - return scan_microcode(cp.data, cp.size, uci, save); } @@ -410,13 +410,13 @@ void __init load_ucode_intel_bsp(struct early_load_data *ed) { struct ucode_cpu_info uci; - ed->old_rev = intel_get_microcode_revision(); - uci.mc = get_microcode_blob(&uci, false); - if (uci.mc && apply_microcode_early(&uci) == UCODE_UPDATED) - ucode_patch_va = UCODE_BSP_LOADED; + ed->old_rev = uci.cpu_sig.rev; - ed->new_rev = uci.cpu_sig.rev; + if (uci.mc && apply_microcode_early(&uci) == UCODE_UPDATED) { + ucode_patch_va = UCODE_BSP_LOADED; + ed->new_rev = uci.cpu_sig.rev; + } } void load_ucode_intel_ap(void)