From patchwork Fri Oct 20 11:37: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: 156079 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp995441vqb; Fri, 20 Oct 2023 04:48:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHQGBqtOxBCTj87Oaq4DUQe68IhAS2MivAh4s+HkgGBXdf1baLUAkFB21lFVrdd39nhvngF X-Received: by 2002:a17:90b:4b47:b0:27d:298e:ec4f with SMTP id mi7-20020a17090b4b4700b0027d298eec4fmr1531540pjb.4.1697802524080; Fri, 20 Oct 2023 04:48:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697802524; cv=none; d=google.com; s=arc-20160816; b=WH3jdSrOUF8DnMga2D57NmqIWXfYNUBm19MY86OhXjFr2Ixt7XVIxXRoATa5xwKupp ZmFMvdqo6Blz8Qz+2qg2G7l6gm9wjoB6h0a5xA7r/NdXuq4Fc8PhvzoQOGDwp99fJBJH P2lRaWTPGIegXUZDRJoXW38Yq06DxGzDsVb74PDrd/shtZ1mO1kMnxEVAfQ50HmgDvuf 4t4GEvA6mnFXI0F8UfyxmRjr2um64JPAW0M8GJbbl++RvL/8oR7m0/ZotlMqspdzvzB2 baI1NVxOYFLVtJXeD2CcYvg9bNtrz4zmEq3cxaI82RZMRiopBELOk7j53nENran/CVdS duvA== 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=nc4d6Zj4XHgr1Xjl54x/oqf+uff/SWLYOAPpNjI0yAs=; fh=21oOLqZrsdqszPj8OgnjfQavEO8hJ4yT0sqEMQ3fADg=; b=h7eIkUl0SXGI/iHWUIQ0bKsOnoibkQmLBV6P7fRBgSCu+EMlkAHs6D7wCS/LQdZ+Q+ UPCAZY6tDc8IUNb2s6A6spbbO32yfx9xb3OXLBtDP9VVwQcnSVQoodogPBmVObIehZsc GHtc99e21IwqQ02ncVZD+cW8B1OiHpBjbthMu515BZBS+BFJnd9CciwbwD3r+oGh3jUR 6yUUW8CMnVaAJCchjS1QdI8aXB8EaainQmxYyaTUmX3YG8qhC3J7/ksUfq162LlJHCWO YNl6BjQAAEsQ1cLDeVdtDrWOSDK8hoQ8XIXW/NwJ0JdJ1iV38juPXBdOfHgEBxqXbchT Roiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=jAxdUzEC; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id fz15-20020a17090b024f00b002680e08a877si4112732pjb.186.2023.10.20.04.48.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 04:48:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=jAxdUzEC; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 9C849832B731; Fri, 20 Oct 2023 04:48:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377302AbjJTLsa (ORCPT + 25 others); Fri, 20 Oct 2023 07:48:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377377AbjJTLsO (ORCPT ); Fri, 20 Oct 2023 07:48:14 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAE1310EA; Fri, 20 Oct 2023 04:38:27 -0700 (PDT) Date: Fri, 20 Oct 2023 11:37:56 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1697801876; 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=nc4d6Zj4XHgr1Xjl54x/oqf+uff/SWLYOAPpNjI0yAs=; b=jAxdUzEC0OfC3B3QAmbYAFT9oTiCy/iiImRK/iVd+vEZEs5OGOlEp7Ux29iEjN255ODHBa WPXMvCJLEsv7xLeqGt/xxNn0YOaVbWOHwhHKVaGm4FbcAOV9+P6rs+hCJEPAOFBB6aMUcG sTBLIgpblBYoQ4dH0Dn5VVfsxSh0uD5AKL/sWksFH9xnobYuKAZiKK5bXNnB6x7BsVTSbA WgaMzHk6aUuUOW1HfZa/0pr3h237PSgTQ4Ta+ezOtGhIuaMH5GlShyCf+EKlzSoAQGWptx jq1RzUj4N6Q5Q1+BiWlNRR/Hnp3ZkDf2q+/oTLkJGzDim7XDlQNwANocdCg1Lg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1697801876; 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=nc4d6Zj4XHgr1Xjl54x/oqf+uff/SWLYOAPpNjI0yAs=; b=kFEB+FY9A9hGQkC8BI+FM0Tdxe5Qj3CQiEfDgftKLSsy755usF3rHBvkVCHfM4QcN6U0I+ iXHbDO5Bqt+pRfCg== From: "tip-bot2 for Thomas Gleixner" 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: Remove pointless apply() invocation Cc: "Borislav Petkov (AMD)" , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231017211723.018821624@linutronix.de> References: <20231017211723.018821624@linutronix.de> MIME-Version: 1.0 Message-ID: <169780187623.3135.2371077022889402294.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Fri, 20 Oct 2023 04:48:41 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780039482963706401 X-GMAIL-MSGID: 1780274979506234462 The following commit has been merged into the x86/microcode branch of tip: Commit-ID: e7aeaa830bb161b700dfd295ce972d1035b46864 Gitweb: https://git.kernel.org/tip/e7aeaa830bb161b700dfd295ce972d1035b46864 Author: Thomas Gleixner AuthorDate: Tue, 17 Oct 2023 23:23:49 +02:00 Committer: Borislav Petkov (AMD) CommitterDate: Thu, 19 Oct 2023 15:37:54 +02:00 x86/microcode: Remove pointless apply() invocation Microcode is applied on the APs during early bringup. There is no point in trying to apply the microcode again during the hotplug operations and neither at the point where the microcode device is initialized. Collect CPU info and microcode revision in setup_online_cpu() for now. This will move to the CPU hotplug callback later. [ bp: Leave the starting notifier for the following scenario: - boot, late load, suspend to disk, resume without the starting notifier, only the last core manages to update the microcode upon resume: # rdmsr -a 0x8b 10000bf 10000bf 10000bf 10000bf 10000bf 10000dc <---- This is on an AMD F10h machine. For the future, one should check whether potential unification of the CPU init path could cover the resume path too so that this can be simplified even more. tglx: This is caused by the odd handling of APs which try to find the microcode blob in builtin or initrd instead of caching the microcode blob during early init before the APs are brought up. Will be cleaned up in a later step. ] Signed-off-by: Borislav Petkov (AMD) Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/r/20231017211723.018821624@linutronix.de --- arch/x86/kernel/cpu/microcode/core.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 2b742fe..cfc1f7a 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -487,17 +487,6 @@ static void microcode_fini_cpu(int cpu) microcode_ops->microcode_fini_cpu(cpu); } -static enum ucode_state microcode_init_cpu(int cpu) -{ - struct ucode_cpu_info *uci = ucode_cpu_info + cpu; - - memset(uci, 0, sizeof(*uci)); - - microcode_ops->collect_cpu_info(cpu, &uci->cpu_sig); - - return microcode_ops->apply_microcode(cpu); -} - /** * microcode_bsp_resume - Update boot CPU microcode during resume. */ @@ -552,14 +541,14 @@ static int mc_cpu_down_prep(unsigned int cpu) static void setup_online_cpu(struct work_struct *work) { int cpu = smp_processor_id(); - enum ucode_state err; + struct ucode_cpu_info *uci = ucode_cpu_info + cpu; - err = microcode_init_cpu(cpu); - if (err == UCODE_ERROR) { - pr_err("Error applying microcode on CPU%d\n", cpu); - return; - } + memset(uci, 0, sizeof(*uci)); + microcode_ops->collect_cpu_info(cpu, &uci->cpu_sig); + cpu_data(cpu).microcode = uci->cpu_sig.rev; + if (!cpu) + boot_cpu_data.microcode = uci->cpu_sig.rev; mc_cpu_online(cpu); }