From patchwork Wed Oct 19 17:54:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 5800 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp462957wrs; Wed, 19 Oct 2022 11:03:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM48XWUZhAZWgYVvFSSXIkaWCDvOYTjMGXpY4Nbg73hTIp/CmUcaBwogzs/bVZ8T5AcuLZWx X-Received: by 2002:a17:907:2c78:b0:78d:eacd:1060 with SMTP id ib24-20020a1709072c7800b0078deacd1060mr7690145ejc.244.1666202596100; Wed, 19 Oct 2022 11:03:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666202596; cv=none; d=google.com; s=arc-20160816; b=YQLZ20EcjmycWa/kvFlap2YhhhXz5+eFLrm6JxXGF9LJf2o2/Ap++5U7toLj8hajVM TrUGKZ09ZUhFDaHZV1fxWIdSjiGGihPPZFbPqd1Y+48tsu8KlKIKv5hDZI9QuMREYhEa 8GZk/Z8r4QEj1R4kpnySnm1zBjnTTgI4v4UE7GGallebTstGYR3nXb4zaGFntwo+s3/Z f81WN2H2SKu0YtIr69zu13bYGpVAyR2xF0tlV6eojtHGKaQKF6GOOZl4TsA2xNkuGRVQ tGsTnHXt7SYj6iv35Jhjuqwo8AOgjaKJWNz9GulbfSqzjn43yKCKuxlcCi4LXd5bQ4fy NPcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Q93ShTvEggLz8vFs7jtmpnZoj08o0mqF/huoUqDzUw4=; b=LTKfX2t6k8cmwKR68YL06UTIyOWx8hzoYgppuSIBqVf1sPNoU7XSB1cT/KOs3xGniB feTWHP6Nd+0w+wmSKa/wL/4kh7y/PKUvgkjzJ95v5V/LF3XxKoBrlldV7dk+P7S349Hk G78yyQB2D+mqkfYOSOaUy5A/gqDXKKoWldkNSsOc4y1LHMXrvG4wI+FwJ9cM9/rEtVMW bwQBKJq5IoKoXV/YqlGrwy0XiI8Vk3Oo0rAYfJ1KvLmKXTt0dprfnnHvTL0/xEwtxC6S CVsnVk4WakQlHmukUi2Su4Y2SZCFOnJGhKmN0h6HPrmU+kRvdT9VMN2ON+jisjkRL1ho Iikg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=rAhyslLf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dp20-20020a170906c15400b0078ded36fa42si15357973ejc.292.2022.10.19.11.02.29; Wed, 19 Oct 2022 11:03:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=rAhyslLf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230233AbiJSRyk (ORCPT + 99 others); Wed, 19 Oct 2022 13:54:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229826AbiJSRyf (ORCPT ); Wed, 19 Oct 2022 13:54:35 -0400 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 384F81181B for ; Wed, 19 Oct 2022 10:54:29 -0700 (PDT) Received: from zn.tnic (p200300ea9733e7c5329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:9733:e7c5:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id D11351EC06F6; Wed, 19 Oct 2022 19:54:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1666202067; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q93ShTvEggLz8vFs7jtmpnZoj08o0mqF/huoUqDzUw4=; b=rAhyslLfC0YdwJR3cT8notU91W5PfYsaZAhB7rWPj/O3IEaXgbOgUvKY0F6+r2QyIqdm3e bLzIr6YIPlmNog4mBx/OvAlqLQjVFehtZ6EZWiitIgkJ95+OWpRah2h4XocacM2NblGC9w pTrqaP+UiVv0OkW2qYAsPM4ATliu180= From: Borislav Petkov To: Ashok Raj Cc: Tony Luck , Tom Lendacky , Arjan van de Ven , Jacob Jun Pan , X86 ML , LKML Subject: [PATCH 1/5] x86/microcode: Rip out the subsys interface gunk Date: Wed, 19 Oct 2022 19:54:22 +0200 Message-Id: <20221019175426.31025-1-bp@alien8.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747140053457882756?= X-GMAIL-MSGID: =?utf-8?q?1747140053457882756?= From: Borislav Petkov This is a left-over from the old days when CPU hotplug wasn't as robust as it is now. Currently, microcode gets loaded early on the CPU init path and there's no need to attempt to load it again. The only thing that the subsys interface init path was doing is adding the /sys/devices/system/cpu/cpu*/microcode/ hierarchy. So add a function which gets called on each CPU after all the necessary driver setup has happened. Signed-off-by: Borislav Petkov --- arch/x86/kernel/cpu/microcode/core.c | 80 ++++++++-------------------- 1 file changed, 22 insertions(+), 58 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 6a41cee242f6..a3aedc93afd9 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -601,8 +601,8 @@ static enum ucode_state microcode_resume_cpu(int cpu) static enum ucode_state microcode_init_cpu(int cpu, bool refresh_fw) { - enum ucode_state ustate; struct ucode_cpu_info *uci = ucode_cpu_info + cpu; + enum ucode_state ustate; if (uci->valid) return UCODE_OK; @@ -636,44 +636,6 @@ static enum ucode_state microcode_update_cpu(int cpu) return microcode_init_cpu(cpu, false); } -static int mc_device_add(struct device *dev, struct subsys_interface *sif) -{ - int err, cpu = dev->id; - - if (!cpu_online(cpu)) - return 0; - - pr_debug("CPU%d added\n", cpu); - - err = sysfs_create_group(&dev->kobj, &mc_attr_group); - if (err) - return err; - - if (microcode_init_cpu(cpu, true) == UCODE_ERROR) - return -EINVAL; - - return err; -} - -static void mc_device_remove(struct device *dev, struct subsys_interface *sif) -{ - int cpu = dev->id; - - if (!cpu_online(cpu)) - return; - - pr_debug("CPU%d removed\n", cpu); - microcode_fini_cpu(cpu); - sysfs_remove_group(&dev->kobj, &mc_attr_group); -} - -static struct subsys_interface mc_cpu_interface = { - .name = "microcode", - .subsys = &cpu_subsys, - .add_dev = mc_device_add, - .remove_dev = mc_device_remove, -}; - /** * microcode_bsp_resume - Update boot CPU microcode during resume. */ @@ -713,6 +675,9 @@ static int mc_cpu_down_prep(unsigned int cpu) struct device *dev; dev = get_cpu_device(cpu); + + microcode_fini_cpu(cpu); + /* Suspend is in progress, only remove the interface */ sysfs_remove_group(&dev->kobj, &mc_attr_group); pr_debug("CPU%d removed\n", cpu); @@ -720,6 +685,18 @@ static int mc_cpu_down_prep(unsigned int cpu) return 0; } +static void setup_online_cpu(void *info) +{ + int cpu = smp_processor_id(); + struct ucode_cpu_info *uci = ucode_cpu_info + cpu; + + memset(uci, 0, sizeof(*uci)); + + microcode_ops->collect_cpu_info(cpu, &uci->cpu_sig); + + mc_cpu_online(cpu); +} + static struct attribute *cpu_root_microcode_attrs[] = { #ifdef CONFIG_MICROCODE_LATE_LOADING &dev_attr_reload.attr, @@ -755,23 +732,19 @@ static int __init microcode_init(void) if (IS_ERR(microcode_pdev)) return PTR_ERR(microcode_pdev); - cpus_read_lock(); - mutex_lock(µcode_mutex); - error = subsys_interface_register(&mc_cpu_interface); - mutex_unlock(µcode_mutex); - cpus_read_unlock(); - - if (error) - goto out_pdev; - error = sysfs_create_group(&cpu_subsys.dev_root->kobj, &cpu_root_microcode_group); if (error) { pr_err("Error creating microcode group!\n"); - goto out_driver; + goto out_pdev; } + /* Do per-CPU setup */ + cpus_read_lock(); + on_each_cpu(setup_online_cpu, NULL, 0); + cpus_read_unlock(); + register_syscore_ops(&mc_syscore_ops); cpuhp_setup_state_nocalls(CPUHP_AP_MICROCODE_LOADER, "x86/microcode:starting", mc_cpu_starting, NULL); @@ -782,15 +755,6 @@ static int __init microcode_init(void) return 0; - out_driver: - cpus_read_lock(); - mutex_lock(µcode_mutex); - - subsys_interface_unregister(&mc_cpu_interface); - - mutex_unlock(µcode_mutex); - cpus_read_unlock(); - out_pdev: platform_device_unregister(microcode_pdev); return error; From patchwork Wed Oct 19 17:54:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 5799 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp462912wrs; Wed, 19 Oct 2022 11:03:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM63cbiPguvt0gb+UVAPv8EnD4UfeceaaKCqQyTw6i0LByoN4q0WXAqrp4683t4/3LR+HgDX X-Received: by 2002:a50:fb0f:0:b0:458:df03:c3aa with SMTP id d15-20020a50fb0f000000b00458df03c3aamr8483279edq.83.1666202592179; Wed, 19 Oct 2022 11:03:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666202592; cv=none; d=google.com; s=arc-20160816; b=AXX9bovKuYUAm7sRf/gEBCXURBeCdCiP69xpr5L4aL4i2kx/R6GiPQpYQVrC1rHWQz uf03gasmG3P9YxFFyXe2AJmZ4Bq8Tg0/pAxaWCx6k5G8lp2cIw0CEy6icaV/SXsgWiTN 5shL8OqCu/oTONKCJTSwka/kjGe9CrAJW2rUexi3E6noyvOza6UOFvFcWqgiTUhAsRHX jb2onqMmZgG2Z8BIeq3FxfcV75MX5rPZOPNVm9HjAv2qpUpRMPXnNB3Mp/Qh+qc2fcCu +j8ARddK4FcQ8cCvm+LjTYJ+TVbnaJOaV2HFjzeaRdxqkXulmdd7bDI4hKKX2DvSVhiS YsyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ice+Zpi8zqJzSIBZbKVrhqcEXHbvGajZDt3Qb7Qrcbw=; b=sjEh1pRxrSdaa9GbtisFnMsnK21lR4ItJ/wrCpLuJd5DsrWbByVyeeAeotGr5QhDyy 7fEg+pYXbXyu9WD7bVdRxULzayb6GdTbbleefmRX1VInVJKiZLHdVHEW6yqmrNIMwlBV Ned/VSDFpWn3Y9YF5kYwykN3LIkIViMTbPpx7ikYrJSGT/ZbOFJ0Ba0aKY7Wz1VPv379 gX4vTQTFhXbvWCgifQyP6Q5RLKUO/1JAyD62bopL2bXjW0PgOdSQnbeC/O9+491mqepi svmwGa3pMLXxHdhZdtHm5WOEt5MH/Qh3AcXNRkOHS+OWTSlxzIQWx2xQ2LvFjbqzWrln p6fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=jKjaecV5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u26-20020a056402065a00b004514cd5ec24si13635533edx.630.2022.10.19.11.02.24; Wed, 19 Oct 2022 11:03:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=jKjaecV5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230175AbiJSRyi (ORCPT + 99 others); Wed, 19 Oct 2022 13:54:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229732AbiJSRyf (ORCPT ); Wed, 19 Oct 2022 13:54:35 -0400 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3873C11A1B for ; Wed, 19 Oct 2022 10:54:29 -0700 (PDT) Received: from zn.tnic (p200300ea9733e7c5329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:9733:e7c5:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 5765F1EC0715; Wed, 19 Oct 2022 19:54:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1666202068; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ice+Zpi8zqJzSIBZbKVrhqcEXHbvGajZDt3Qb7Qrcbw=; b=jKjaecV5WEdb4cujmDjYvR2CCmguOOuhdR+mtB9OD8y+m78filHR9OpVZzZ9SVjRM60ccw 0Gzuuw2DEHBisWYROPg1GJZ0SIDf8aaRUz3vG7KnXE7IteJ8+g3ZzHvoPbk8vMu74sLlQp HUByZi3iik6cBMQR3FhDPS/nAo72OoM= From: Borislav Petkov To: Ashok Raj Cc: Tony Luck , Tom Lendacky , Arjan van de Ven , Jacob Jun Pan , X86 ML , LKML Subject: [PATCH 2/5] x86/microcode: Simplify init path even more Date: Wed, 19 Oct 2022 19:54:23 +0200 Message-Id: <20221019175426.31025-2-bp@alien8.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221019175426.31025-1-bp@alien8.de> References: <20221019175426.31025-1-bp@alien8.de> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747140048939576698?= X-GMAIL-MSGID: =?utf-8?q?1747140048939576698?= From: Borislav Petkov Get rid of all the IPI-sending functions and their wrappers and use those which are supposed to be called on each CPU. Thus: - microcode_init_cpu() gets called on each CPU on init, applying any new microcode that the driver might've found on the filesystem. - mc_cpu_starting() simply tries to apply cached microcode as this is the cpuhp starting callback which gets called on CPU resume too. And since the driver init function is a late initcall, there is filesystem by then so a new firmware load attempt can simply be done. In case a new one is there. Which is weird to begin with - how would the initrd contain an older revision than what's on the fs since former gets created by using the blobs from the filesystem. Oh well, it is cheap to do so why not... Signed-off-by: Borislav Petkov --- arch/x86/kernel/cpu/microcode/core.c | 127 +++++---------------------- 1 file changed, 23 insertions(+), 104 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index a3aedc93afd9..0aa6609e748c 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -319,60 +319,6 @@ void reload_early_microcode(void) } } -static void collect_cpu_info_local(void *arg) -{ - struct cpu_info_ctx *ctx = arg; - - ctx->err = microcode_ops->collect_cpu_info(smp_processor_id(), - ctx->cpu_sig); -} - -static int collect_cpu_info_on_target(int cpu, struct cpu_signature *cpu_sig) -{ - struct cpu_info_ctx ctx = { .cpu_sig = cpu_sig, .err = 0 }; - int ret; - - ret = smp_call_function_single(cpu, collect_cpu_info_local, &ctx, 1); - if (!ret) - ret = ctx.err; - - return ret; -} - -static int collect_cpu_info(int cpu) -{ - struct ucode_cpu_info *uci = ucode_cpu_info + cpu; - int ret; - - memset(uci, 0, sizeof(*uci)); - - ret = collect_cpu_info_on_target(cpu, &uci->cpu_sig); - if (!ret) - uci->valid = 1; - - return ret; -} - -static void apply_microcode_local(void *arg) -{ - enum ucode_state *err = arg; - - *err = microcode_ops->apply_microcode(smp_processor_id()); -} - -static int apply_microcode_on_target(int cpu) -{ - enum ucode_state err; - int ret; - - ret = smp_call_function_single(cpu, apply_microcode_local, &err, 1); - if (!ret) { - if (err == UCODE_ERROR) - ret = 1; - } - return ret; -} - /* fake device for request_firmware */ static struct platform_device *microcode_pdev; @@ -458,7 +404,7 @@ static int __reload_late(void *info) * below. */ if (cpumask_first(topology_sibling_cpumask(cpu)) == cpu) - apply_microcode_local(&err); + err = microcode_ops->apply_microcode(cpu); else goto wait_for_siblings; @@ -480,7 +426,7 @@ static int __reload_late(void *info) * revision. */ if (cpumask_first(topology_sibling_cpumask(cpu)) != cpu) - apply_microcode_local(&err); + err = microcode_ops->apply_microcode(cpu); return ret; } @@ -589,51 +535,15 @@ static void microcode_fini_cpu(int cpu) microcode_ops->microcode_fini_cpu(cpu); } -static enum ucode_state microcode_resume_cpu(int cpu) -{ - if (apply_microcode_on_target(cpu)) - return UCODE_ERROR; - - pr_debug("CPU%d updated upon resume\n", cpu); - - return UCODE_OK; -} - -static enum ucode_state microcode_init_cpu(int cpu, bool refresh_fw) -{ - struct ucode_cpu_info *uci = ucode_cpu_info + cpu; - enum ucode_state ustate; - - if (uci->valid) - return UCODE_OK; - - if (collect_cpu_info(cpu)) - return UCODE_ERROR; - - /* --dimm. Trigger a delayed update? */ - if (system_state != SYSTEM_RUNNING) - return UCODE_NFOUND; - - ustate = microcode_ops->request_microcode_fw(cpu, µcode_pdev->dev, refresh_fw); - if (ustate == UCODE_NEW) { - pr_debug("CPU%d updated upon init\n", cpu); - apply_microcode_on_target(cpu); - } - - return ustate; -} - -static enum ucode_state microcode_update_cpu(int cpu) +static enum ucode_state microcode_init_cpu(int cpu) { struct ucode_cpu_info *uci = ucode_cpu_info + cpu; - /* Refresh CPU microcode revision after resume. */ - collect_cpu_info(cpu); + memset(uci, 0, sizeof(*uci)); - if (uci->valid) - return microcode_resume_cpu(cpu); + microcode_ops->collect_cpu_info(cpu, &uci->cpu_sig); - return microcode_init_cpu(cpu, false); + return microcode_ops->apply_microcode(cpu); } /** @@ -651,14 +561,14 @@ void microcode_bsp_resume(void) } static struct syscore_ops mc_syscore_ops = { - .resume = microcode_bsp_resume, + .resume = microcode_bsp_resume, }; static int mc_cpu_starting(unsigned int cpu) { - microcode_update_cpu(cpu); - pr_debug("CPU%d added\n", cpu); - return 0; + enum ucode_state err = microcode_ops->apply_microcode(cpu); + + return err == UCODE_ERROR; } static int mc_cpu_online(unsigned int cpu) @@ -688,11 +598,13 @@ static int mc_cpu_down_prep(unsigned int cpu) static void setup_online_cpu(void *info) { int cpu = smp_processor_id(); - struct ucode_cpu_info *uci = ucode_cpu_info + cpu; - - memset(uci, 0, sizeof(*uci)); + enum ucode_state err; - microcode_ops->collect_cpu_info(cpu, &uci->cpu_sig); + err = microcode_init_cpu(cpu); + if (err == UCODE_ERROR) { + pr_err("Error applying microcode on CPU%d\n", cpu); + return; + } mc_cpu_online(cpu); } @@ -740,6 +652,13 @@ static int __init microcode_init(void) goto out_pdev; } + /* + * Try to load microcode once on the BSP in case the initrd has older revision. + * Frankly, I have no clue how that can happen but hey, loading here is cheap so + * why not. + */ + microcode_ops->request_microcode_fw(boot_cpu_data.cpu_index, µcode_pdev->dev, true); + /* Do per-CPU setup */ cpus_read_lock(); on_each_cpu(setup_online_cpu, NULL, 0); From patchwork Wed Oct 19 17:54:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 5801 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp463494wrs; Wed, 19 Oct 2022 11:04:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4bBJ52mXQGTtvadE9ysqCglJtAitDmXLuF0AP5ACOE538zMXdYoaZyN5P+TCaMzuOQ0w6q X-Received: by 2002:a05:6402:2804:b0:439:83c2:8be2 with SMTP id h4-20020a056402280400b0043983c28be2mr8741681ede.292.1666202652709; Wed, 19 Oct 2022 11:04:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666202652; cv=none; d=google.com; s=arc-20160816; b=A+vIqVhRTa4kfJZ1LN4AGuDmx4CjPhFuqJXnAk6E3/qGHffwwlAhhcVpo2I25xdwYd 1fNLDFXXbiFFoJj0FwI9xNq4+xMFa1TFLoKC7Bhn/K9tP5CkXIHp/im457EZikPSuvw/ 307yaU/48eH4K9v/vPlxATWTSYyhw32vov/qaA6sbKHaKS0/sdioWbS6kUpdMLagUhW2 iKbwp2lpy6BsBQomfgL19AImlEHNcHO9nID0/sFuxx8ifI3ocwpIhGSSmDpVxPYPY/Jq XfT2wWZM7/V822kgJyxvAoHV4z/QIC8sDTsA/LmM8kGOHVOhZJnJAfLPbVvFE/pztRgQ /xQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PjHXVZjpCpm9rYxfyt9yqu2jH5RX/dPYyJdOoev5Gl0=; b=f1xVL8WY7hPGNx/kAn2rQnbAquJ6kRDtuxnYqUH0/BDetZBTs29foAhFO1Pk2K82ck enAwmLNw3UgBcnwJCVff/Jveq+OSLZFQngISxFTsO6iIByb7rL1MMWfvuCA944WX75QA Fp7/Z0dffQIdJRjN5AzpEhzXU2aGHhFTTjNorwq9WT/2Ffr39g1356NTTAdTWMsDT/5y PvNl+xgeYrKpfBUQoz8FVx/cjgFd6bZ1QwAwYZtNpOuKF6+fFNo2Nzt9yeBhBGWZw1aX JiN1y2B6dFP2+MpUe7gLYSFDeBdA/AuvnDcjYkkTNqyxgWgbDldI3pgrkBaAU60nP1ja Ak7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b="lND6/zft"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g24-20020a056402115800b00446fdce2a62si13487057edw.420.2022.10.19.11.03.42; Wed, 19 Oct 2022 11:04:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b="lND6/zft"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230327AbiJSRyq (ORCPT + 99 others); Wed, 19 Oct 2022 13:54:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229890AbiJSRyf (ORCPT ); Wed, 19 Oct 2022 13:54:35 -0400 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C95111C07 for ; Wed, 19 Oct 2022 10:54:30 -0700 (PDT) Received: from zn.tnic (p200300ea9733e7c5329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:9733:e7c5:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id CE8201EC0716; Wed, 19 Oct 2022 19:54:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1666202068; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PjHXVZjpCpm9rYxfyt9yqu2jH5RX/dPYyJdOoev5Gl0=; b=lND6/zftAY27YhEaP294ZEdtAdlo31RdawHc8GKqkDMKJOyRc0c6kcQ2T9LFQwOyO3lKTY YexBv8QKIQKXBKL2nDn/nZU2YiMQ9EZMx25pkdMgSUgHl74QiS8QMH72EqyeMIZvX+yxte f65ZjtCNYDfUDeVA0KQVJ34kvVzCI0I= From: Borislav Petkov To: Ashok Raj Cc: Tony Luck , Tom Lendacky , Arjan van de Ven , Jacob Jun Pan , X86 ML , LKML Subject: [PATCH 3/5] x86/microcode: Kill refresh_fw Date: Wed, 19 Oct 2022 19:54:24 +0200 Message-Id: <20221019175426.31025-3-bp@alien8.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221019175426.31025-1-bp@alien8.de> References: <20221019175426.31025-1-bp@alien8.de> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747140113011421421?= X-GMAIL-MSGID: =?utf-8?q?1747140113011421421?= From: Borislav Petkov request_microcode_fw() can always request firmware now so drop this superfluous argument. Signed-off-by: Borislav Petkov --- arch/x86/include/asm/microcode.h | 3 +-- arch/x86/kernel/cpu/microcode/amd.c | 5 ++--- arch/x86/kernel/cpu/microcode/core.c | 4 ++-- arch/x86/kernel/cpu/microcode/intel.c | 3 +-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/arch/x86/include/asm/microcode.h b/arch/x86/include/asm/microcode.h index 74ecc2bd6cd0..d4c36fbd1d39 100644 --- a/arch/x86/include/asm/microcode.h +++ b/arch/x86/include/asm/microcode.h @@ -33,8 +33,7 @@ enum ucode_state { }; struct microcode_ops { - enum ucode_state (*request_microcode_fw) (int cpu, struct device *, - bool refresh_fw); + enum ucode_state (*request_microcode_fw) (int cpu, struct device *); void (*microcode_fini_cpu) (int cpu); diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c index e7410e98fc1f..b103d5e5f447 100644 --- a/arch/x86/kernel/cpu/microcode/amd.c +++ b/arch/x86/kernel/cpu/microcode/amd.c @@ -891,8 +891,7 @@ load_microcode_amd(bool save, u8 family, const u8 *data, size_t size) * * These might be larger than 2K. */ -static enum ucode_state request_microcode_amd(int cpu, struct device *device, - bool refresh_fw) +static enum ucode_state request_microcode_amd(int cpu, struct device *device) { char fw_name[36] = "amd-ucode/microcode_amd.bin"; struct cpuinfo_x86 *c = &cpu_data(cpu); @@ -901,7 +900,7 @@ static enum ucode_state request_microcode_amd(int cpu, struct device *device, const struct firmware *fw; /* reload ucode container only on the boot cpu */ - if (!refresh_fw || !bsp) + if (!bsp) return UCODE_OK; if (c->x86 >= 0x15) diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 0aa6609e748c..8401b7235a68 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -477,7 +477,7 @@ static ssize_t reload_store(struct device *dev, if (ret) goto put; - tmp_ret = microcode_ops->request_microcode_fw(bsp, µcode_pdev->dev, true); + tmp_ret = microcode_ops->request_microcode_fw(bsp, µcode_pdev->dev); if (tmp_ret != UCODE_NEW) goto put; @@ -657,7 +657,7 @@ static int __init microcode_init(void) * Frankly, I have no clue how that can happen but hey, loading here is cheap so * why not. */ - microcode_ops->request_microcode_fw(boot_cpu_data.cpu_index, µcode_pdev->dev, true); + microcode_ops->request_microcode_fw(boot_cpu_data.cpu_index, µcode_pdev->dev); /* Do per-CPU setup */ cpus_read_lock(); diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c index 1fcbd671f1df..8c35c70029bf 100644 --- a/arch/x86/kernel/cpu/microcode/intel.c +++ b/arch/x86/kernel/cpu/microcode/intel.c @@ -885,8 +885,7 @@ static bool is_blacklisted(unsigned int cpu) return false; } -static enum ucode_state request_microcode_fw(int cpu, struct device *device, - bool refresh_fw) +static enum ucode_state request_microcode_fw(int cpu, struct device *device) { struct cpuinfo_x86 *c = &cpu_data(cpu); const struct firmware *firmware; From patchwork Wed Oct 19 17:54:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 5802 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp463502wrs; Wed, 19 Oct 2022 11:04:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4svpOvdc6PCA+ujLWfsOU1Ea/xBIjk1ZpYbDFCo2mDmsi4HeNQo0Ig7bU6pH9bGJSdomsA X-Received: by 2002:a05:6402:3512:b0:45d:4f99:6151 with SMTP id b18-20020a056402351200b0045d4f996151mr8511096edd.74.1666202653017; Wed, 19 Oct 2022 11:04:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666202653; cv=none; d=google.com; s=arc-20160816; b=lzN1yPDpyJ/3eG5zDL40HTEo/cSAF3i8R41T3t5sC82fl9+NUwK3xABN/zk8SMfH7H SB4v3W3pivv8KVFQLBrHi+5+nEpKYnf7Kl3/Zuz/5qi38Qlj+/L+Ac5y5IXWw5lSfNHP 3TfK6ndfk7DvVitbzzTMe+w76uZrEJOIRYlcclpRr434Sv1ipZAuUm/52JaRk6EF3f1D TYfpkcHYpz0j7uO/tSfyvio8yoj65wcy1winfIinzLLA8cedTjxhece9Tc1yEp2VINCA 5df8VXvI8JDmlsIRUOHio22/xoNYlGSGERfH7Yc0t6f0m4Pl7YWe9VrUE7Df81vnZnM1 i1aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8pgpm5JAh0V/litpZ4Q9lGMM3/tmEtRFA/DKiwzEQ9g=; b=z4wiPPrOrxSgZrg+THwuzabevqTTJnPe1SHs3eCO3ALKUy6Wv//sScEvbtUlFvgpar VJSF3bXy/yWbQ2rd/sA9aNAAcah292e00DODLuLmBze4VKEp7znX8eUvTwqD4O8UokRf ENYKEdKIb1tHeDTN0VpSXfbD/rVeFvOCRKpy0Y1UI/0iRD46hFa1AK6a5QUgyye/im18 V1liH7l8sJ2RMFgmzm6GYqm+2E/WaBb+teaEn8vFbV3NCyhidbqY2g4vD7gVQeSMwOw3 IEsqDW0tKnl1Mv+9dzrKGcPsmB8GlUHXrAWXrbP6EML2ppYcYBPBU2Mm9Of6vRsIKQiF fAMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=OfriYxZS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e3-20020a17090658c300b0079198b89adbsi6471200ejs.890.2022.10.19.11.03.44; Wed, 19 Oct 2022 11:04:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=OfriYxZS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230426AbiJSRyt (ORCPT + 99 others); Wed, 19 Oct 2022 13:54:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229911AbiJSRyf (ORCPT ); Wed, 19 Oct 2022 13:54:35 -0400 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4D5F12ADB for ; Wed, 19 Oct 2022 10:54:30 -0700 (PDT) Received: from zn.tnic (p200300ea9733e7c5329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:9733:e7c5:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 4DFE31EC071C; Wed, 19 Oct 2022 19:54:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1666202069; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8pgpm5JAh0V/litpZ4Q9lGMM3/tmEtRFA/DKiwzEQ9g=; b=OfriYxZSlcOTNCYmQFuyzbEWUFXSyMHHQVcDZliy3wf2Z3Cbtg3SU1ATR/Hq0AA4hj9At6 tiJtTGeQGpybG8k3peiS48eOVNgxSNvV1AIAanSRaFyLcsuGuPn24m+n/0bOS3LadcU4l8 GbPlBMw3bU7j21eEetKc7CD+tDbE0EQ= From: Borislav Petkov To: Ashok Raj Cc: Tony Luck , Tom Lendacky , Arjan van de Ven , Jacob Jun Pan , X86 ML , LKML Subject: [PATCH 4/5] x86/microcode: Do some minor fixups Date: Wed, 19 Oct 2022 19:54:25 +0200 Message-Id: <20221019175426.31025-4-bp@alien8.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221019175426.31025-1-bp@alien8.de> References: <20221019175426.31025-1-bp@alien8.de> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747140112767426011?= X-GMAIL-MSGID: =?utf-8?q?1747140112767426011?= From: Borislav Petkov Improve debugging printks and fixup formatting. Signed-off-by: Borislav Petkov --- arch/x86/kernel/cpu/microcode/core.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 8401b7235a68..6b025143b073 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -568,6 +568,8 @@ static int mc_cpu_starting(unsigned int cpu) { enum ucode_state err = microcode_ops->apply_microcode(cpu); + pr_debug("%s: CPU%d, err: %d\n", __func__, cpu, err); + return err == UCODE_ERROR; } @@ -590,7 +592,7 @@ static int mc_cpu_down_prep(unsigned int cpu) /* Suspend is in progress, only remove the interface */ sysfs_remove_group(&dev->kobj, &mc_attr_group); - pr_debug("CPU%d removed\n", cpu); + pr_debug("%s: CPU%d\n", __func__, cpu); return 0; } @@ -639,14 +641,11 @@ static int __init microcode_init(void) if (!microcode_ops) return -ENODEV; - microcode_pdev = platform_device_register_simple("microcode", -1, - NULL, 0); + microcode_pdev = platform_device_register_simple("microcode", -1, NULL, 0); if (IS_ERR(microcode_pdev)) return PTR_ERR(microcode_pdev); - error = sysfs_create_group(&cpu_subsys.dev_root->kobj, - &cpu_root_microcode_group); - + error = sysfs_create_group(&cpu_subsys.dev_root->kobj, &cpu_root_microcode_group); if (error) { pr_err("Error creating microcode group!\n"); goto out_pdev; From patchwork Wed Oct 19 17:54:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 5803 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp463914wrs; Wed, 19 Oct 2022 11:04:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7AygwuzoG7KajknGHIeCIH0hO0GTjzcl3QphVdUhfpD9uFX5S7j+id0lcGuxHQfyMtbM5f X-Received: by 2002:a05:6402:4150:b0:44a:ec16:def4 with SMTP id x16-20020a056402415000b0044aec16def4mr8727521eda.21.1666202695193; Wed, 19 Oct 2022 11:04:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666202695; cv=none; d=google.com; s=arc-20160816; b=JUUyYapYphVza4nzG35qk1yUR8lkB46gRuiE1V4n9LhLWMejjlmGnUxYBjPuI/JGGC bQUnjZAI0TUslavL9qAZYpkREibhXVFhS03qKrGZU/xeCwJryPRSdcadicu9cmEP2pDa E2Pxe3gJ+KnRYM3IeGwayQQei4CMEdIdBTw0M/CiB95Q9J2SoxPkANjl07CwbyEEwF6L 0fmlTkUYUcpliaNuh2MRoM0ekFB6Wivok9zyv6hWdvRdG2WKQ3B+2C+UaJQI7YY0R7Wh e0KDXDm6BK+flt9s2DbS10FNOkK4Ah3pj2IpBiKQsKh282U+SJo/QQVAk8hijp/QsGHI 1XUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JL5d16xQ4WYM5xYTGulLQehtXJra7XYyLAqvFFhLyno=; b=gIKSRJRs2QEV6rlKu+ReD0NuBYt83l74kf9cDFl/uZ7+KHbn6hu5vE9ZD5X/96oDrU eShjYjU+psEuirPd05jmcX+3nYAXQU3xb2t8rmynrfHjzfj1gFeZiNwjUt3MMhz6b7mO ATrPHCfzLBVnEFFK2PP3Iz1A4FDmbs5BrStVlq+ZGpmsV0vmLw5fgXKhwiXIg+Ku+ZAs BufetShCcDGVYuPVXCJdEPA4PfKXWmwH7LrYI3I8eNMc9hh3yGl8oydPbfSTP28Il6kL 5Qi5exCiLHbuwFXR+pu/EXnN2MdwkksPEWfpZ4p8D4LQtAKuSul+o8WhE/AFRwzVA1KP M8rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=DBBrIcNM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ds1-20020a170907724100b0078e18bd3073si15408418ejc.820.2022.10.19.11.04.21; Wed, 19 Oct 2022 11:04:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=DBBrIcNM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230245AbiJSRyy (ORCPT + 99 others); Wed, 19 Oct 2022 13:54:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229974AbiJSRyh (ORCPT ); Wed, 19 Oct 2022 13:54:37 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D3A313D5B for ; Wed, 19 Oct 2022 10:54:31 -0700 (PDT) Received: from zn.tnic (p200300ea9733e7c5329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:9733:e7c5:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id BAD081EC071E; Wed, 19 Oct 2022 19:54:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1666202069; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JL5d16xQ4WYM5xYTGulLQehtXJra7XYyLAqvFFhLyno=; b=DBBrIcNM8mBxCHwDSf7km4Z4m7l/Ys6v9YDzfnMA1JG/TuH3UPbgqazLLE7+TGWgo/oYDj LFILzlDzBQ3WSNFNlkNIegHnq41OEvpLpQmiL4oP1obqbs/MYEyfYlFQdE08SHGHt/lLbT kg5NnOG2y6SXk+vtgM9QgN+TAHQ+xsU= From: Borislav Petkov To: Ashok Raj Cc: Tony Luck , Tom Lendacky , Arjan van de Ven , Jacob Jun Pan , X86 ML , LKML Subject: [PATCH 5/5] x86/microcode: Drop struct ucode_cpu_info.valid Date: Wed, 19 Oct 2022 19:54:26 +0200 Message-Id: <20221019175426.31025-5-bp@alien8.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221019175426.31025-1-bp@alien8.de> References: <20221019175426.31025-1-bp@alien8.de> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747140157762509694?= X-GMAIL-MSGID: =?utf-8?q?1747140157762509694?= From: Borislav Petkov It is not needed anymore. Signed-off-by: Borislav Petkov --- arch/x86/include/asm/microcode.h | 1 - arch/x86/kernel/cpu/intel.c | 1 - arch/x86/kernel/cpu/microcode/core.c | 4 ++-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/microcode.h b/arch/x86/include/asm/microcode.h index d4c36fbd1d39..d5a58bde091c 100644 --- a/arch/x86/include/asm/microcode.h +++ b/arch/x86/include/asm/microcode.h @@ -49,7 +49,6 @@ struct microcode_ops { struct ucode_cpu_info { struct cpu_signature cpu_sig; - int valid; void *mc; }; extern struct ucode_cpu_info ucode_cpu_info[]; diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index 2d7ea5480ec3..beb8ca596784 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -210,7 +210,6 @@ int intel_cpu_collect_info(struct ucode_cpu_info *uci) csig.rev = intel_get_microcode_revision(); uci->cpu_sig = csig; - uci->valid = 1; return 0; } diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 6b025143b073..026bf644344a 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -554,9 +554,9 @@ void microcode_bsp_resume(void) int cpu = smp_processor_id(); struct ucode_cpu_info *uci = ucode_cpu_info + cpu; - if (uci->valid && uci->mc) + if (uci->mc) microcode_ops->apply_microcode(cpu); - else if (!uci->mc) + else reload_early_microcode(); }