Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3421561rdg; Tue, 17 Oct 2023 14:26:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFxlBjLW9GS8/UnwvsFSQO67M2nwP/NvJgPU7jOsP8uWGg8g5orw4B9Ut9fb84HUpcxGZVQ X-Received: by 2002:a05:6a20:4306:b0:157:64e4:4260 with SMTP id h6-20020a056a20430600b0015764e44260mr3739071pzk.9.1697577975594; Tue, 17 Oct 2023 14:26:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697577975; cv=none; d=google.com; s=arc-20160816; b=krhl2XKwGuID6B5uOWwtrR29w2kDG7NFjjA5M54MpeIKzf2RYn/PZutukWOBMh5RxW LWYS0j5wo7+xytfMMhugaBX6bC/9tVkz1XJhRNSieSeY0mRNnwe8yIveIV4wCmgeU4Xd 2n7ilWlap34IBF8/gL7polf/D5tuLwxw8/3t+WjmwwaBaI9/8Bg6bQSMMeOlq3geua2d jkppUVy0rHRIGxCcUG+9PNE0mToHCwYtKYk9CxEc18Peub8SILQ43OO7mAaRygq+Hixg QLF2hWme2Gb1F7iGWQud9/DjKhVrD+gvITFszLOnslalKs2MSWb3SfOLjGAdeouztviX mFKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=k082nSPppDUkOLh9xMaYiiJZSBP4qeS6H+UxEpdLYkw=; fh=8iy+GLBXZdpcs/hIddJ7mbUapYjefwP9Gb111pAzFms=; b=fBe0CZ7GRApS/VH+YW2i4LaDIWBFmWGC2fvgZKU8G1F7Y9gCLf0B1b+dWmXTU8csE9 5bYC9z8JTdNM9Y07EXJvHZMuYRR6FL1pM1yQyRK7I/zeYmvU+/LoumujaFrMtJe2X940 EJDsSLkPHF7s+Quf9yZAERKQ/9bLlx8Mv80wX3mWEdP4ccNUt6vbqvmC3/fBZs+Yr0um ZMs6Ttv60Hrn3bOQehkuXuB8ACUDaqc0mxhiFxlT1ZIIoh23JXVa3WKCCgnCOIH6FH/o VmgC84DxgjXEnq8astoZh1HBj6T26kHzUnHMyKp3i0bHOcmli0E+j1w0KTvDLkqwD9t2 BzTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=l2kPJv8n; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=oV8f795D; 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 Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id nn3-20020a17090b38c300b0027d2db562d2si2710307pjb.161.2023.10.17.14.26.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 14:26:15 -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=l2kPJv8n; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=oV8f795D; 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 2912B80A4AEC; Tue, 17 Oct 2023 14:26: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 S1344268AbjJQVY5 (ORCPT + 99 others); Tue, 17 Oct 2023 17:24:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344250AbjJQVYb (ORCPT ); Tue, 17 Oct 2023 17:24:31 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BB8910CE for ; Tue, 17 Oct 2023 14:23:51 -0700 (PDT) Message-ID: <20231017211723.018821624@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1697577830; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=k082nSPppDUkOLh9xMaYiiJZSBP4qeS6H+UxEpdLYkw=; b=l2kPJv8n4GOVejsCnVP6iRSA/vsKQw93X1p+Wb15YN96cr94WkEAWzUW5UA8qIwy0bpIa/ JItFlgQikDeguLVBCCjXYmaLqbijQoL4lIjf4h91bH0iMa2h5frCsXEloAAnZIEgBMzrBF Es5COMMDY8vHLUExrY8qWP1W+nDCCdWQQV4apAtHato/T1sFfwCXcjvLcYc4REzxQiaXeV gkB44OozvZOngaPVVTHayv3BQmlY5KaWZ0+VUph9kRFLB+O2gdROpLAw5KVgEGxMh2v7Op boesDTjxiSWGjPuR3WgutufxEJiJdiyRT2YRcnezBtqt6ZU0qd7HKmrKT4p3/Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1697577830; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=k082nSPppDUkOLh9xMaYiiJZSBP4qeS6H+UxEpdLYkw=; b=oV8f795DOcI4kzPmF1+3APolA3gE4P91Peuk7h1rbjJuGPD8VUrfISmUVS9fNdN2hWNvEi MbAHAd77DfWRHhCA== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Borislav Petkov Subject: [patch V5 19/39] x86/microcode: Remove pointless apply() invocation References: <20231017200758.877560658@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Tue, 17 Oct 2023 23:23:49 +0200 (CEST) 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]); Tue, 17 Oct 2023 14:26:01 -0700 (PDT) From: Thomas Gleixner 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: Thomas Gleixner Signed-off-by: Borislav Petkov (AMD) Signed-off-by: Thomas Gleixner --- V5: Drop the starting notifier change as that requires rework of the AMD code. --- arch/x86/kernel/cpu/microcode/core.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) --- --- 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 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); }