From patchwork Mon Oct 9 12:29:50 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: 150042 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1833025vqo; Mon, 9 Oct 2023 05:31:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF76Qhojy7paKlNZggJEEYVtc1MPaLDRdDJgFlktjazm/5SwkQpq/9LjOKIgCuOubwSL0oq X-Received: by 2002:a05:6a21:3294:b0:13b:9d80:673d with SMTP id yt20-20020a056a21329400b0013b9d80673dmr15032897pzb.48.1696854676617; Mon, 09 Oct 2023 05:31:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696854676; cv=none; d=google.com; s=arc-20160816; b=t2gWr4IvtPsVBRLU//Hb3FZiZTTAx4kLcAJXn6QXVilt82nsOdFLaYT92PTBfJjmuB E80a5wzsM7BTt8zNcTJkUqermks3JTJPCZBHYiiE5TWRyndEoQiwivcvMDW6kgdP6SsR kDuxhUCG6UOHwt5AC3FMPd+ZnydSrlrgtB4VOcrE4JnxonpP1NT+BGloSI/kVjGHbhxC eFvI/2LOLbadHEDhqI7aSZXHhzPNi6Iub4gvl+0SUFchXq17URJhHCkpGm6hRsHSTr+T u+G2JiSSXxLC45fbRKzEmPHejCo0LKhiIzGeZctk2fDXidQbgOf4VhcIr/dY1YfK1ZjA Pcqg== 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=X6HXIET/otN3KifdQZCPd+uA8cL2iqdKRID32+CQ2iI=; fh=LWlv3U+xZ3+vQt4tlJRIlKl5VzN7iFjjE/bzRmlxKDA=; b=kK7bDvZtwsAiQzesAD1Vh5xhEXEuX7U00eBio0BB2tOdwY75sHQ9udH5ujbsDLE19V zxbvrZGC4lAPrIWpUexqxgUxX13EhfDtzdrbIC+QdMuPnbW3IodyxgQ8IWrnW8CJGX/7 UOYBH98DjaVp9azL0ESG+CU1lXjRuPmc7O5yFWiBnkRK/dLuKjJ6oxrSLgv5GafFx1zQ 1+jHLkC6b7wT1lqQIG08lbHU8phDieI373+ux4L4n9hDJAAkeNb774JzrXappfh7upeR 16QTvBWwbGOTMH4vrx9uYRMoG6947NmT+kOm+GJ7TB2QYArYreR/cjqAr9sXsBzBVbB1 Y3aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=fY4Hqd0b; 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:8 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. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id z13-20020a630a4d000000b0057458518e21si9335998pgk.630.2023.10.09.05.31.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 05:31:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=fY4Hqd0b; 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:8 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 C854D801BB5B; Mon, 9 Oct 2023 05:31:01 -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 S1376578AbjJIMa0 (ORCPT + 18 others); Mon, 9 Oct 2023 08:30:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346565AbjJIM3z (ORCPT ); Mon, 9 Oct 2023 08:29:55 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69C56E1; Mon, 9 Oct 2023 05:29:52 -0700 (PDT) Date: Mon, 09 Oct 2023 12:29:50 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696854591; 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=X6HXIET/otN3KifdQZCPd+uA8cL2iqdKRID32+CQ2iI=; b=fY4Hqd0bEtrWs9ABIspohchpXkrisQYuwXiirOB4cOGCbB1h2p7kaD863Go69UEOtn4bps h8zhXcVacXdVBLM5ZjequSfAxFs9BtVUu3f/GQSbct5y1XcwGlDol/4R6vxw6r0ya8WumE w6y/rB1HukBA9mtlFRH2pKnHWAGGXYlHoBjL/4rb7PhDeLh9RtEOUhUMN0wVmN9zLTEyS5 gNAoDw2qrFCd6ZTfbC7dUpmCZZMkzDcHnOfp2+cGLRbSBgiDP1+NGxjQw7VROXB2bscbko eW5i+02xPgjnFbkP8G5G37os1CayUDkfid1Wpsl2PiX1s8f3fy9W/+wgRz6jtQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696854591; 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=X6HXIET/otN3KifdQZCPd+uA8cL2iqdKRID32+CQ2iI=; b=pbCxxxA4lDNdW9MADRYc4ZX/WSWqIv7CxBCk/EhlvGktpW1szFVdbB0JggWETVKC+sgpPl gTGPb5rG6xvAywDg== 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: Thomas Gleixner , "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231002115902.914469212@linutronix.de> References: <20231002115902.914469212@linutronix.de> MIME-Version: 1.0 Message-ID: <169685459037.3135.12296630487916849982.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no 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]); Mon, 09 Oct 2023 05:31:01 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778646488754740687 X-GMAIL-MSGID: 1779281089569407741 The following commit has been merged into the x86/microcode branch of tip: Commit-ID: 034eaca8e03547ebff0b3974b88d2b772d858533 Gitweb: https://git.kernel.org/tip/034eaca8e03547ebff0b3974b88d2b772d858533 Author: Thomas Gleixner AuthorDate: Mon, 02 Oct 2023 13:59:52 +02:00 Committer: Borislav Petkov (AMD) CommitterDate: Fri, 06 Oct 2023 15:05:18 +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. ] Signed-off-by: Thomas Gleixner Signed-off-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/r/20231002115902.914469212@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 0d99d5e..6f7632f 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -490,17 +490,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. */ @@ -555,14 +544,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); }