From patchwork Fri Oct 28 14:26:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 12342 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp863876wru; Fri, 28 Oct 2022 07:29:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Y9Xj1OSiKNNpo9f3110cpVFVcmLuBE2bSDFeUjyTIsHlWgFZ37SHd9yvV2R/d/j/hO4Du X-Received: by 2002:a05:6402:40d0:b0:462:7b99:d424 with SMTP id z16-20020a05640240d000b004627b99d424mr10835271edb.62.1666967398299; Fri, 28 Oct 2022 07:29:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666967398; cv=none; d=google.com; s=arc-20160816; b=Y78tD9OYHp4DzuEPpMutNUBt8z0JeicSAwQ8V+fifdSZaaPdPHf+IVV98YOKcCN/R5 IbVfMaAl+kN6nMrguLH8U2Ys0Y7vKLnuxpwUMvFMlzbRLM5cpdeORxfw4T74LerA5OkF H58aFfUsrQr+7VqYbPl9yViYVrQqkT4wdA3TU3x+nudmo0nPlUEcaCEmCnO6zFkkLdy8 JFqaT/JvZpw+nWgJWyizyxqb0RVgMzZFkVOTAcKbJ0mMSDCkJLWOcQ5KbaLtzf0PO4GZ +oGlcda99ghbpSX0H+yTXvpHXKbMHzEMoTyPEdHM0rECCi2DYdEe8i86SKkgqq0CpeJa KgZw== 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=icVBqQtN/2qbFKLGC8qRSzXbS2OQA1vb457jcP4mYeE=; b=uaGQpSGc3sw3/mWMKi4SS+ksruH2cEqNMBWyCLHUCoK8GDHkpr0NYAzAPpKHUTnHCo Zu0Jd0BUkp72UuDQUNkDJK7okCpwRvQ7+FVyReIgszyeUBE0d+Ipb1k+3nuASuCkk2Bf qMvaVDGXc1cB3TDo1AzqzOmdzI/ORyEadpdMWTxkAt04FnMrRN38YLfEvFkNTgG2Awwk d0IhcoV6luoLY/7aaz0OLzp2RR8DI/p7PVAl3jeoOZ2kTr5k2R94kAYcfu3IhrtfZZRU lM92qYUG2MDPgYzhh13RafHaJpnGFFT8GNcahtDKfFc9DD1Bg1HRTyhD+gi7/DnnD1Ei AFSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=FAxyopjU; 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 hs39-20020a1709073ea700b0073d8e4e8c77si730058ejc.1005.2022.10.28.07.29.33; Fri, 28 Oct 2022 07:29:58 -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=FAxyopjU; 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 S230296AbiJ1O1p (ORCPT + 99 others); Fri, 28 Oct 2022 10:27:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230408AbiJ1O1W (ORCPT ); Fri, 28 Oct 2022 10:27:22 -0400 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6D127A753 for ; Fri, 28 Oct 2022 07:26:47 -0700 (PDT) Received: from zn.tnic (p200300ea9733e7ce329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:9733:e7ce: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 3335C1EC026E; Fri, 28 Oct 2022 16:26:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1666967206; 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=icVBqQtN/2qbFKLGC8qRSzXbS2OQA1vb457jcP4mYeE=; b=FAxyopjUXFhUYgnIvoRzfXL3Bgkb9OIhOoVlhcyp8vv80aVzoNowLMK5VyL+hfcAO8ArYP tXbytbRawD8u2nbadsEb1x+P8LGt5/WcjFlE04xVAyJSck8zXFkJAgjCeflcu5ox6aexKK 66sGmiffOIr+W5tYIrll0rBzhw+VLrY= From: Borislav Petkov To: Ashok Raj Cc: X86 ML , LKML Subject: [PATCH 1/5] x86/microcode: Rip out the subsys interface gunk Date: Fri, 28 Oct 2022 16:26:34 +0200 Message-Id: <20221028142638.28498-2-bp@alien8.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221028142638.28498-1-bp@alien8.de> References: <20221028142638.28498-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?1747942006455493463?= X-GMAIL-MSGID: =?utf-8?q?1747942006455493463?= 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, which that subsys interface callback is doing. The only other 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. Use schedule_on_each_cpu() which can block because the sysfs creating code does kmem_cache_zalloc() which can block too and the initial version of this where it did that setup in an IPI handler of on_each_cpu() can cause a deadlock of the sort: lock(fs_reclaim); lock(fs_reclaim); as the IPI handler runs in IRQ context. Signed-off-by: Borislav Petkov --- arch/x86/kernel/cpu/microcode/core.c | 78 +++++++--------------------- 1 file changed, 20 insertions(+), 58 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 6a41cee242f6..4c222e667567 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(struct work_struct *work) +{ + 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,17 @@ 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 */ + schedule_on_each_cpu(setup_online_cpu); + register_syscore_ops(&mc_syscore_ops); cpuhp_setup_state_nocalls(CPUHP_AP_MICROCODE_LOADER, "x86/microcode:starting", mc_cpu_starting, NULL); @@ -782,15 +753,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 Fri Oct 28 14:26:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 12349 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp864753wru; Fri, 28 Oct 2022 07:31:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5WAscNSq18CLuEcVRDYDDIs5D/W/OTsJvGXNoWe5v1BbrK88tRS6ZnfBCT6QcdAmaOtVvg X-Received: by 2002:a05:6a00:1ace:b0:565:f52a:d998 with SMTP id f14-20020a056a001ace00b00565f52ad998mr54720970pfv.25.1666967493067; Fri, 28 Oct 2022 07:31:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666967493; cv=none; d=google.com; s=arc-20160816; b=FIspCFsKReSWpM1/mqIi9DUiT5UTHz4lJ2uIOoeE2B6xTNrVcF1rAJMS0h7s6R/hQR flhFDOMPFrWIr905Ju9v+y7jtScefJzpTpPcwaIK7lL/roTK+mqTY0RjOJK4hFP5bFoL LbPd18TheyL0NID+Iy2KuRaMrrpsou6iKgbUeVB2foemU2IODlOXuxmur9JXb5Fd8qu3 ZQZ/cSYGYRzZIFWQ5OoshF+WsAiyYv/vIoiBlxOSkgcCLMLYaY0K5PUljRFY08Qb9wZg YNL7dUdlbBvOm67gXpItXXFj8PJJBpnnxhZU48EWuu/7N0+XR5TJJUVr3IjgcUJU9FTJ YC0w== 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=mav6KMGb8CiUNcHVuiIE28N3tUmXGA9j/5krq1Vd03A=; b=R9Mpz+uRd8hWsGEMWKxAmYS67uiQAOCxppcaBkGacH8neFKM5OYaaEyKofQtw1M5EH jQ/DdBQyEc09NmVLmFhH6bvqu1vx3GZV4mKM6apvjTbotJdsze17gCcAnS9bKx8+91+P EbXsnLNdCRiPPn3rwgYPQcO2/eIUu3zky+UnlarAE7p3f20gIkF/NCkrMXVig+UxYTHt N0PKD8mMqIbJ7Y1eeLoGPteIPwVV5A27So6js6TWRZ1YMetWQ1jprlm94bfdR61t/Q/I 3pI1izYknQBecPPtE/OZwG9dDsrP1SIYepyLemrjVbsqHgEVRUsStsUgAYDff/UzDpsr 9cCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=ZGwhkfDS; 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 t25-20020a056a00139900b00561fb77aed3si850155pfg.368.2022.10.28.07.31.19; Fri, 28 Oct 2022 07:31:33 -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=ZGwhkfDS; 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 S230389AbiJ1O1t (ORCPT + 99 others); Fri, 28 Oct 2022 10:27:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231235AbiJ1O1W (ORCPT ); Fri, 28 Oct 2022 10:27:22 -0400 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1653F7CE1E for ; Fri, 28 Oct 2022 07:26:48 -0700 (PDT) Received: from zn.tnic (p200300ea9733e7ce329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:9733:e7ce: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 AD5031EC0676; Fri, 28 Oct 2022 16:26:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1666967206; 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=mav6KMGb8CiUNcHVuiIE28N3tUmXGA9j/5krq1Vd03A=; b=ZGwhkfDSqIBxQ6dePovBjH3xsRiE2Vliv0qwI8Scdaa30O6MjQZXi9DXeQzl8bxoGJoWUo 007wNheMMfHpo9XHKglxdpCqf9YXBCo6wdQ6VRfH4FA4IIAcmsP0g/+Zo3W8V0JjNXTYAr Ja1Ng1IuDVfbqn2elhztTFVzAORvnsA= From: Borislav Petkov To: Ashok Raj Cc: X86 ML , LKML Subject: [PATCH 2/5] x86/microcode: Simplify init path even more Date: Fri, 28 Oct 2022 16:26:35 +0200 Message-Id: <20221028142638.28498-3-bp@alien8.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221028142638.28498-1-bp@alien8.de> References: <20221028142638.28498-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?1747942105961637722?= X-GMAIL-MSGID: =?utf-8?q?1747942105961637722?= 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. Even if the driver init function is a late initcall, there is no filesystem by then (not even a hdd driver has been loaded yet) so a new firmware load attempt cannot simply be done. It is pointless anyway - for that there's late loading if one really needs it. Signed-off-by: Borislav Petkov --- arch/x86/kernel/cpu/microcode/core.c | 120 ++++----------------------- 1 file changed, 16 insertions(+), 104 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 4c222e667567..63f7678743be 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(struct work_struct *work) { 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); } From patchwork Fri Oct 28 14:26:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 12350 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp864865wru; Fri, 28 Oct 2022 07:31:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5wpeeuVc3In91dJvkqqybPyrEJWV9s0h3rh+0mkpZwrqX+Hmtoko18jjt7gzHUPxRRjt11 X-Received: by 2002:a17:902:7446:b0:186:a3a1:782d with SMTP id e6-20020a170902744600b00186a3a1782dmr28125117plt.76.1666967506702; Fri, 28 Oct 2022 07:31:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666967506; cv=none; d=google.com; s=arc-20160816; b=nagtDGoGXu/7Z2zIbqSdrLwaWnqOGXCgwFF80NTKBeMaa2devpavR1RViPxH95rBd9 +5vSVT1QfH+5d2233SzLcvvbLsNLF1uzHtTSAMGTkLsrozfoe/LRycHYbOXQlxdWlw6r rhqkSJ+IJxJSxpFBQVNCqPoKzf2845uBWqnFZ9hGLPOxkGLJwsR4J8860NnZCHkQWKEE 1yUWHRr/7CKDRonkDtF60wKaUkEDrcQz+tawd16xUACWNU4DS0vvsjtGIMgx2FW31bIC 09GqOH70+xP7q2mS1znE/rgBlFjm6zC67kp+bB9dEOwqhr8p3ZEmWCnnRffDZnxhWfcX WOFg== 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=QJIf89KSwzJWm9JqbRoQ+vSQXO2nZLHSd4du3DdJICo=; b=Caj+EIbalKlLQjFutxW+24YtUwBn5biV0J6MHLNNfGg7B+UnyBSKpKhoQgK7h5ew5w CfyV3Uki/PTq7QnMaeAASfQDBXKWB3SjoKR88OKU/gTZQwShYXwPCkwEaMLen1hzOi6Y Pba5sYfeX9+sB/qmewiy9bU0bDyI0YC8xKT9WaOfSC0dR/AcZ2hMSOwyISF32LdWIPLw 1J9IeWaT0sOP+i6cX0Kwzf7ZffWxDhevm6ohq1bvLCGX2whFiOlKS8R/uo2RF4CBg6sj mULT8DnY/vT7OkXctUNGtKBQF/Gigvwp6JHiBrtJmPAYU/KVIsRNi9yn9CKrnkvutPPC +56w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=l2sh8wzl; 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 q64-20020a634343000000b00453d2790c49si2384632pga.11.2022.10.28.07.31.33; Fri, 28 Oct 2022 07:31:46 -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=l2sh8wzl; 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 S230462AbiJ1O2D (ORCPT + 99 others); Fri, 28 Oct 2022 10:28:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230482AbiJ1O1X (ORCPT ); Fri, 28 Oct 2022 10:27:23 -0400 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95C517E028 for ; Fri, 28 Oct 2022 07:26:48 -0700 (PDT) Received: from zn.tnic (p200300ea9733e7ce329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:9733:e7ce: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 414261EC072E; Fri, 28 Oct 2022 16:26:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1666967207; 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=QJIf89KSwzJWm9JqbRoQ+vSQXO2nZLHSd4du3DdJICo=; b=l2sh8wzlwUyITJW1IwqsQNYoMAxHJabFqa9JcBCzsoMFU6FytznN4AvqxCYCF308eyMISO uxQXjX8ASrYzDN72pmNWB0lDUdWX6BTFZiQA0cev1fDp6gyIjeVb7qsUTca6mW2ZJjiC5X uBcnqPhrUvvUWez+onMJ4eF/fhqLbdQ= From: Borislav Petkov To: Ashok Raj Cc: X86 ML , LKML Subject: [PATCH 3/5] x86/microcode: Kill refresh_fw Date: Fri, 28 Oct 2022 16:26:36 +0200 Message-Id: <20221028142638.28498-4-bp@alien8.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221028142638.28498-1-bp@alien8.de> References: <20221028142638.28498-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?1747942120312507130?= X-GMAIL-MSGID: =?utf-8?q?1747942120312507130?= 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 | 2 +- arch/x86/kernel/cpu/microcode/intel.c | 3 +-- 4 files changed, 5 insertions(+), 8 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 63f7678743be..7c41e0132fa1 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; 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 Fri Oct 28 14:26:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 12344 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp863999wru; Fri, 28 Oct 2022 07:30:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5qbZ3h2vBqfm8Me23vPNdA4DQvrrJb0kglRjEczR5GottK+fB7XAS047NDYOrdyYOp0psZ X-Received: by 2002:a17:90b:4d0e:b0:1f7:ae99:4d7f with SMTP id mw14-20020a17090b4d0e00b001f7ae994d7fmr16431328pjb.200.1666967410837; Fri, 28 Oct 2022 07:30:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666967410; cv=none; d=google.com; s=arc-20160816; b=bYFbliwLzgfUgmBWl3pAJFL0MQer0tdrXqBw9f/8hxEBnRDYhgv4A1MmYtGHVj1xrA pl34Ag5Mn2OW7KxJap1og+q0fNW/6WewEuwEfR24pAke9XUs1RI7dcNYNCPWNt7qypcH cAdzBQUtejWRToQpkfWwRrqT6k5d9bwaPmbYDrn+6xRyOJ2dhFAxMtYC2MfTzkkRTcHc lc3d4Axaw3Ms+d8s0KSA1jrljWX6hITlVWBSRVM/JNgFsc0nZsa4NOOC2n4unhroLsmf P2bmf+hCAkBF+2Zl4rBAfsQt5ltqrCxV8ERKsarsjNynETjKFYxdQraK8bRDaVm8LboQ RcGA== 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=awd9cZozCZs++lKu/R+oRT9FZWWyrMeXGKmrwed6L8c=; b=HtY1RinY3mmrGiRZe3JQL6PsAy4b0Njp56LC36a/mQTHm1U3rrLcXFdQK79M9uMZjo IxHTlwZaGo5fjbTzfJIhWLjPYYMkU28w9Ufaf/3bdPMNm8+tIN5X5ucIJltZF23DM+Iq KWcj3pqP81tIT9fPXqe+DpB4vhiCHYHyuq3qooF4ilG7Ozavw8VaguRK+lmPG6xgsr/1 EJvgVinlFiAFK6ITDaK+aTXzJvMiZMOkEzsiMoRzH9iyyaoBEP1dVZdg8myOaGPSYqVT FzmD5Vqyt1zMawJ7yIv5rbXQMRHqKxVPDDimG5ycUcVnvR/QNjd8CGWHexERABxwdWPW 02AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=lEiXigve; 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 x127-20020a633185000000b0046408c6d349si5668185pgx.478.2022.10.28.07.29.48; Fri, 28 Oct 2022 07:30:10 -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=lEiXigve; 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 S230494AbiJ1O2I (ORCPT + 99 others); Fri, 28 Oct 2022 10:28:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231239AbiJ1O1X (ORCPT ); Fri, 28 Oct 2022 10:27:23 -0400 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 146F080BFE for ; Fri, 28 Oct 2022 07:26:49 -0700 (PDT) Received: from zn.tnic (p200300ea9733e7ce329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:9733:e7ce: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 BBBAD1EC0754; Fri, 28 Oct 2022 16:26:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1666967207; 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=awd9cZozCZs++lKu/R+oRT9FZWWyrMeXGKmrwed6L8c=; b=lEiXigve4v6BmnN6n8o3AL+2QkwaLHt8EOnPNQdoZ+4k1KqONaZ0ljkxfJO6bb4vakAFrH HsP2c7DxSPsuLc0BDsL3eSTBoNFo/4g4jG9NqCrktl7Xlasy3A8bP8pRVe2K7HyMT8Va4Y O5PP6VClDkuh/yeoNyvqQEeeNshn7Yc= From: Borislav Petkov To: Ashok Raj Cc: X86 ML , LKML Subject: [PATCH 4/5] x86/microcode: Do some minor fixups Date: Fri, 28 Oct 2022 16:26:37 +0200 Message-Id: <20221028142638.28498-5-bp@alien8.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221028142638.28498-1-bp@alien8.de> References: <20221028142638.28498-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?1747942020029573345?= X-GMAIL-MSGID: =?utf-8?q?1747942020029573345?= 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 7c41e0132fa1..ffb249c29f30 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 Fri Oct 28 14:26:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 12346 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp864201wru; Fri, 28 Oct 2022 07:30:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4NE69k4GQqSVvQI24mHFsGlnnptntuhyxmRugPEvqRQXHRVTV6WprGwphcDljd1flpYY3t X-Received: by 2002:a17:903:183:b0:184:5b9a:24e7 with SMTP id z3-20020a170903018300b001845b9a24e7mr55986899plg.79.1666967437372; Fri, 28 Oct 2022 07:30:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666967437; cv=none; d=google.com; s=arc-20160816; b=RCejkqMyesJjod1ScMMEqs2sExsrfFCWhyInDhdwgoHb0xV/nfgExmfifdg7Frlaes 381+LnCWX1PqGIDHe3fyEMGwaJJJxqTJ4RF2IXqSYbnuMgzKJT0jX1PVSzO/TSqHgQQ5 a3mx843zG73pgqxp6Lj6fMAxAC+7zrfmUBg2T34FHPYBXpUxo5OhsUph0nguv3um1UT6 EGjAWJvjersqklEXOUlZOpIWgwePCpezg6pxkDKnxm9zQ1mly2zNxnHyCovYgRFikPiB 1A2a9G3/0iaJj7u86YbQokHEUd5H0lY4kCxyBNCgGZCetOhPqRNcMW1RoRv+80DhMQvf 44dQ== 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=EUzepTEbA+PjW41liMbq12+QwoMLZTumivAWH3EYXPA=; b=n2ZQnS90sWw5SZzSMt8aokobQmWwJ40B3S0QOf+NVHb/yreud+UigHCx/K1Cyfo2G+ Mt+kqutgVYgKi3kwmQLrYKog9XLFg4CO3xhM84x4U6k7JGpL0bo7s5W0fjPp9F2IAvXR fpII0NbvwGvh7fNZ1f9NjBeN8J+pvGluGRwXZMi5hQNggyFQiQKOUNhQFt7M7xA91cgb SlAtFyHfxxzCXu8NafGkbDsX3L7T85gtBMN6hjtmtGLrkCLXUzObD0uWpdDdm/AWL74H vSSyD8SlnM459PV5jrvNA0FK7Y+xfCv7OmXwlPIOWCYj8NMaOOF91HHRiu6XROcObQYS A8zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=OTIjjUkT; 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 127-20020a630285000000b0046f5ffc935asi4622006pgc.413.2022.10.28.07.30.22; Fri, 28 Oct 2022 07:30:37 -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=OTIjjUkT; 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 S231196AbiJ1O2M (ORCPT + 99 others); Fri, 28 Oct 2022 10:28:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231244AbiJ1O1X (ORCPT ); Fri, 28 Oct 2022 10:27:23 -0400 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD2508286B for ; Fri, 28 Oct 2022 07:26:50 -0700 (PDT) Received: from zn.tnic (p200300ea9733e7ce329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:9733:e7ce: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 423DE1EC0779; Fri, 28 Oct 2022 16:26:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1666967208; 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=EUzepTEbA+PjW41liMbq12+QwoMLZTumivAWH3EYXPA=; b=OTIjjUkTU+7DslvPHPJVlMGazN5sWoqfKdrHoNrgcBCLSxHeModOVgvfhpbAubQ+CLoG0x uTUQxU6GhEj0viKoKlZU9bejAcl4Ss3sYOZt6hRBtN4+IPqPuT4od0ut+lhapaIFDPsWhF civAaisHtMdTJS0rT+9WKGxvd7WTduc= From: Borislav Petkov To: Ashok Raj Cc: X86 ML , LKML Subject: [PATCH 5/5] x86/microcode: Drop struct ucode_cpu_info.valid Date: Fri, 28 Oct 2022 16:26:38 +0200 Message-Id: <20221028142638.28498-6-bp@alien8.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221028142638.28498-1-bp@alien8.de> References: <20221028142638.28498-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?1747942047994013025?= X-GMAIL-MSGID: =?utf-8?q?1747942047994013025?= From: Borislav Petkov It is not needed anymore. Signed-off-by: Borislav Petkov Reviewed-by: Ashok Raj --- 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 ffb249c29f30..712aafff96e0 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(); }