From patchwork Tue Oct 24 13:21:04 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: 157462 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1938410vqx; Tue, 24 Oct 2023 06:23:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEX8/1lUwibWuEwyqPxE+AM8MaovygAkgRkiIhDFp7kYalFlKIRoFiJ59PG3uku5vV0eE5R X-Received: by 2002:a05:6a00:b4f:b0:6be:2081:f66d with SMTP id p15-20020a056a000b4f00b006be2081f66dmr14407434pfo.27.1698153819842; Tue, 24 Oct 2023 06:23:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698153819; cv=none; d=google.com; s=arc-20160816; b=Taxm6bqD3frrXosmERe/3Uc3HkISbWE1WHANkKDoGiawqL0RyywVZLpbTlCBor2Mvv vUEPbpswP6HZrxBbXs6qtC1LpkoryuFq7UmwPf6M2XDGmhxCu7Dcr++DgzxRPutLNaZk AwLDQGxzs7pipd0DWiYutIO1qbkBB396GQ1wQLTNZKDe2KghFCo0XU/qXun1WucS7ltj KbwxshTutvNpF7u1zHv7UlfkRwcmPfWBl19IG5dw/151RdknAPmHQg1cWHNSeDsy2Twx Tyk7shRcT4cpMyHNX2Dk/e+lt5kyEswoE/6aPEJ9JLaj/pr7H10O5KwDcPrn1F1SOHLG 7azg== 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=gdUwx0H61gTB8NR9dIpzgdjW5wYXel7BrvBQyLGBxd4=; fh=21oOLqZrsdqszPj8OgnjfQavEO8hJ4yT0sqEMQ3fADg=; b=SH/TxgAXPAqYctsUZEGmpagay9p+UtIgnA9mH+464wkqMUN/nOOM+IV9eY2FPSOgvH WVM83qyvp0NbHIwW4obDNE+YgAs1jaHyVg+Eo1Bqh62C47HXh1YLrQ5xi0qn+dXlJD4J wwOG1U2adoa36V/1AOG3sEspBzJrHwsz2/A7FJIl4+WhxbvUh2toBrOCa19n9itHep5H BLBjj1YypD+vIyEB4mOY4A4mf77XbFJZww54SnqT4Nkft7byngxWch5hnLfl9Zc6iitF SkL3i3wAhTnlBM4RHrwmWAHSjt8WdhsJUQduoZNM1Om6dG9qadYy0+KTjIsniAZIhmHi J1bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="tmlkb1/Z"; 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:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id d24-20020a63f258000000b00578d5a135dasi8619867pgk.891.2023.10.24.06.23.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 06:23:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="tmlkb1/Z"; 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:2 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 agentk.vger.email (Postfix) with ESMTP id ECDED803FF85; Tue, 24 Oct 2023 06:23:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343567AbjJXNW4 (ORCPT + 26 others); Tue, 24 Oct 2023 09:22:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234487AbjJXNWD (ORCPT ); Tue, 24 Oct 2023 09:22:03 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55A3119A0; Tue, 24 Oct 2023 06:21:07 -0700 (PDT) Date: Tue, 24 Oct 2023 13:21:04 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1698153665; 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=gdUwx0H61gTB8NR9dIpzgdjW5wYXel7BrvBQyLGBxd4=; b=tmlkb1/ZrYyd45t1+sB3LFpDtBQfWHfmX/il2lHuxDzYDske6/J0HbluW9QLLhJvSslfZ3 N1Z9Y1No1KDYOXFENt/5lO0Z6cqkx/iI3iSBf+Y4oV6gPONxXrxjK1/aCN+dK4eXyPZsB4 kmFlhz4oRoVbN6CPv6lahYq3QOHiM7u89HqU40Yy++hYsmd1p6bRp9Lx/dJqP0bIBLvW+o bJGuwASAI6Z/75B1QuMSzCXTC8OerywYx743N3I4+yOWFHD3w8jGUiOafZPjoh4I+FhkKr 223RMssjmkUSQf4Y3qicNfLhtxsHj2EARRE0Xxcw8WfQpbt+x6ppbVDWsNL5CA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1698153665; 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=gdUwx0H61gTB8NR9dIpzgdjW5wYXel7BrvBQyLGBxd4=; b=f1t9brjflWwWyRmYruCWb4UU55AuuPhl0lnDyAxu6OhHP0toTpEqr9OlDOYBedJQJo+gZO M9ucSt5Icm2eOuBg== 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: <169815366429.3135.13131206121862202196.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 agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 24 Oct 2023 06:23:30 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780039482963706401 X-GMAIL-MSGID: 1780643340033325816 The following commit has been merged into the x86/microcode branch of tip: Commit-ID: b48b26f992a3828b4ae274669f99ce68451d4904 Gitweb: https://git.kernel.org/tip/b48b26f992a3828b4ae274669f99ce68451d4904 Author: Thomas Gleixner AuthorDate: Tue, 17 Oct 2023 23:23:49 +02:00 Committer: Borislav Petkov (AMD) CommitterDate: Tue, 24 Oct 2023 15:05: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); }