From nobody Fri Jan 2 15:07:55 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53886CD8CA8 for ; Tue, 10 Oct 2023 15:09:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233389AbjJJPI4 (ORCPT ); Tue, 10 Oct 2023 11:08:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233294AbjJJPIv (ORCPT ); Tue, 10 Oct 2023 11:08:51 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E8F9B7 for ; Tue, 10 Oct 2023 08:08:45 -0700 (PDT) Message-ID: <20231010150702.433454320@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696950522; 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=/dRmcfKTBD1nPb/bBtlpyqt18JVyxAdIVX4toDGASiY=; b=DzcjhKjec/HHmzId8VVPKDDwwFMm/I+4Yd/trZfPPuxIgG+eObrHAnLgf0/u2vF2ZJoSJ1 xqqmNksAUH2KKabDwfwHcceeYK9fDzwvc7QxQqOxkR4LtLQRq6c9gdpOKVspbQq7nEZYPV h58lNiXIQGpkHkmBi5T/lVX+phVETaWnmodWj7dstXfMboi1lk7SyBiyoZQb6/xvgwJ7Sl 66XmQFXS0wnfJPjLAuK14jws7qITYQ/URCZyTF82JJFyLQRXQLPcsWU6mmZrWGBwvKVETF Dic3its1C/wUQpG88IbFXkXOP4kFsWZ1ItzKRXREtZWzlgD1skc4S6K55IugAg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696950522; 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=/dRmcfKTBD1nPb/bBtlpyqt18JVyxAdIVX4toDGASiY=; b=IGTbKaraLoDpbolKmIG2d1HTGDgUpBWIx+aPe56XLk/PWuYYQEMayKIqnWQR1A4s8uUGdu DN/k2H6kz754k4BQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Borislav Petkov Subject: [patch 1/5] x86/microcode/amd: Use correct per CPU ucode_cpu_info References: <20231010145130.987300357@linutronix.de> MIME-Version: 1.0 Date: Tue, 10 Oct 2023 17:08:41 +0200 (CEST) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" find_blobs_in_containers() is invoked on every CPU but overwrites uncoditionally ucode_cpu_info of CPU0. Fix this by using the proper CPU data and move the assignment into the call site apply_ucode_from_containers() so that the function can be reused. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/cpu/microcode/amd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/arch/x86/kernel/cpu/microcode/amd.c +++ b/arch/x86/kernel/cpu/microcode/amd.c @@ -503,9 +503,6 @@ static void find_blobs_in_containers(uns if (!get_builtin_microcode(&cp, x86_family(cpuid_1_eax))) cp =3D find_microcode_in_initrd(ucode_path); =20 - /* Needed in load_microcode_amd() */ - ucode_cpu_info->cpu_sig.sig =3D cpuid_1_eax; - *ret =3D cp; } =20 @@ -513,6 +510,9 @@ static void apply_ucode_from_containers( { struct cpio_data cp =3D { }; =20 + /* Needed in load_microcode_amd() */ + ucode_cpu_info[smp_processor_id()].cpu_sig.sig =3D cpuid_1_eax; + find_blobs_in_containers(cpuid_1_eax, &cp); if (!(cp.data && cp.size)) return; From nobody Fri Jan 2 15:07:55 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 308EBCD8CA6 for ; Tue, 10 Oct 2023 15:09:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233315AbjJJPIx (ORCPT ); Tue, 10 Oct 2023 11:08:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232771AbjJJPIu (ORCPT ); Tue, 10 Oct 2023 11:08:50 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05F3DB6 for ; Tue, 10 Oct 2023 08:08:45 -0700 (PDT) Message-ID: <20231010150702.495139089@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696950523; 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=/T+TzF884nNOcfjx73gfiSU4BbvmUfK//JWS9uWIFHE=; b=UjYOvh2VC6Qb27nBg0v5biPxpMwuhhQtZW6sc/vHworpZJWFUmmL1xs9xvUH5Q7bHov+Zo O3EJUgZCFv6JsmVenu4muN+hwxmC85oC3XUv7fkZsVczJLGNIMfk1XTDS0pAMdjAN7Yvij OmZnp1tPOnaS1iQ1qsXgvKxViMY08SlnC8qIpY+RQSOeM/GpF+JH/VCXfZroj0Z/A7ORnV gxPx0OCySchgvDvdY76I/W01PuvoDGvhoNOObe6g4yNn9jI/umpJBw+PU7RqG8zBxC1EAt 3d1JcXusqK36cWnu+DJ1uAUOVNSRfeDI9+0AUki/3WHM/zX62Xra6CAiklthbA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696950523; 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=/T+TzF884nNOcfjx73gfiSU4BbvmUfK//JWS9uWIFHE=; b=Npgb09TuRPXz3VxOCdmN5TGC1qv8YH6pOzkUvF9voFqfDFS3bOjGpYBkfQhKqzucwwSUlV LhtveAMaQLv5t4AA== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Borislav Petkov Subject: [patch 2/5] x86/microcode/amd: Cache builtin microcode too References: <20231010145130.987300357@linutronix.de> MIME-Version: 1.0 Date: Tue, 10 Oct 2023 17:08:43 +0200 (CEST) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" save_microcode_in_initrd_amd() fails to cache builtin microcode and only scans initrd. Use find_blobs_in_containers() instead which covers both. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/cpu/microcode/amd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/kernel/cpu/microcode/amd.c +++ b/arch/x86/kernel/cpu/microcode/amd.c @@ -533,7 +533,7 @@ int __init save_microcode_in_initrd_amd( enum ucode_state ret; struct cpio_data cp; =20 - cp =3D find_microcode_in_initrd(ucode_path); + find_blobs_in_containers(cpuid_1_eax, &cp); if (!(cp.data && cp.size)) return -EINVAL; From nobody Fri Jan 2 15:07:55 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74C99CD8CA7 for ; Tue, 10 Oct 2023 15:09:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233414AbjJJPI6 (ORCPT ); Tue, 10 Oct 2023 11:08:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233293AbjJJPIv (ORCPT ); Tue, 10 Oct 2023 11:08:51 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 643FCB8 for ; Tue, 10 Oct 2023 08:08:46 -0700 (PDT) Message-ID: <20231010150702.551141238@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696950524; 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=g/Yygr9A2Il7UvnXxciW5CWUkAO8Yu2F0f5qpSzvguA=; b=144ei3NnW+bCXOx31fsFaFPjODLcJ4BuZdguAbxZW8FQayQc/LZ65jfFRGFxy9LSHIJnrM BFo+VFyKc1EkoNbJd7wIk8cAkw93McVCL9JOqnXwSbjrZcI2prCs6fb/4hi4kiXY55IAeP QS5MhbJA/3SW9UOyxP44jFQpMoIQmI39ZdfT2F3xQrPEDAeaECqfQGRdR5wBDOd6lX6rlN iDSgal6RFT9Oyyw0z4G7PgIQ2idJRBZ4ZTYEBKtcc/s1I9pma+SASf9ZZlGVFRjJj6pJkq q/0vESVJ6N3jTrC1iRXCbnp8zjd+56hFP44f5YLtVC2fpmguHFllgpakwWFEvQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696950524; 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=g/Yygr9A2Il7UvnXxciW5CWUkAO8Yu2F0f5qpSzvguA=; b=XkO1cBpyl7r/ik0f1fyWT5d2N0ZgKCx1IcXv18nXfhCEIR4nrDbwDs4gRdkcdMMSz1BVYS DDs0KgiruzBzwfCQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Borislav Petkov Subject: [patch 3/5] x86/microcode/amd: Cache builtin/initrd microcode early References: <20231010145130.987300357@linutronix.de> MIME-Version: 1.0 Date: Tue, 10 Oct 2023 17:08:44 +0200 (CEST) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There is no reason to scan builtin/initrd microcode on each AP. Cache the builtin/initrd microcode in an early initcall so that the early AP loader can utilize the cache. The existing fs initcall which invoked save_microcode_in_initrd_amd() is still required to maintain the initrd_gone flag. Rename it accordingly. This will be removed once the AP loader code is converted to use the cache. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/cpu/microcode/amd.c | 8 +++++++- arch/x86/kernel/cpu/microcode/core.c | 20 ++++---------------- 2 files changed, 11 insertions(+), 17 deletions(-) --- a/arch/x86/kernel/cpu/microcode/amd.c +++ b/arch/x86/kernel/cpu/microcode/amd.c @@ -527,12 +527,17 @@ void load_ucode_amd_early(unsigned int c =20 static enum ucode_state load_microcode_amd(u8 family, const u8 *data, size= _t size); =20 -int __init save_microcode_in_initrd_amd(unsigned int cpuid_1_eax) +static int __init save_microcode_in_initrd(void) { + unsigned int cpuid_1_eax =3D native_cpuid_eax(1); + struct cpuinfo_x86 *c =3D &boot_cpu_data; struct cont_desc desc =3D { 0 }; enum ucode_state ret; struct cpio_data cp; =20 + if (c->x86_vendor !=3D X86_VENDOR_AMD || c->x86 < 0x10) + return 0; + find_blobs_in_containers(cpuid_1_eax, &cp); if (!(cp.data && cp.size)) return -EINVAL; @@ -549,6 +554,7 @@ int __init save_microcode_in_initrd_amd( =20 return 0; } +early_initcall(save_microcode_in_initrd); =20 /* * a small, trivial cache of per-family ucode patches --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -185,24 +185,13 @@ void load_ucode_ap(void) } } =20 -static int __init save_microcode_in_initrd(void) +/* Temporary workaround until find_microcode_in_initrd() is __init */ +static int __init mark_initrd_gone(void) { - struct cpuinfo_x86 *c =3D &boot_cpu_data; - int ret =3D -EINVAL; - - switch (c->x86_vendor) { - case X86_VENDOR_AMD: - if (c->x86 >=3D 0x10) - ret =3D save_microcode_in_initrd_amd(cpuid_eax(1)); - break; - default: - break; - } - initrd_gone =3D true; - - return ret; + return 0; } +fs_initcall(mark_initrd_gone); =20 struct cpio_data find_microcode_in_initrd(const char *path) { @@ -895,5 +884,4 @@ static int __init microcode_init(void) return error; =20 } -fs_initcall(save_microcode_in_initrd); late_initcall(microcode_init); From nobody Fri Jan 2 15:07:55 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43328CD8CA5 for ; Tue, 10 Oct 2023 15:09:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233348AbjJJPIy (ORCPT ); Tue, 10 Oct 2023 11:08:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233240AbjJJPIu (ORCPT ); Tue, 10 Oct 2023 11:08:50 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7267D93 for ; Tue, 10 Oct 2023 08:08:47 -0700 (PDT) Message-ID: <20231010150702.606691031@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696950525; 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=t0IcpvLhad8KFsm8A/vXcS685lwQ2BubUPwtUH49A0A=; b=YeLPjQGzO30pqfs82S6WkphU4cPRx9OxHauEEpFZAEsberhwcFY2WbiV//Z/WLUvM7+D3w q5H6iiOf+zXGMTiqvihrBchAF7Yih6fHlPJlvsRAB9hbi5UGLLpjTrUz/hFhekh2rcFZLQ knUGZj+9RUcNbcZUud5vKbIvdd1Pey+JH8q0CuFVz0dop+8lK6Xh5QojLjz2BYC3jBHfe5 pj/epnmqP63XcAdirJdlPCvrWVCBGjyNbI0vquMUfaieDtGXQFaxDN2Ytl/5nZyUPXFzw8 9wJ0P9jabCz0nYy08Zl8MARJIpOdVNHELTkZRQTiJbavwu1qyD3oSbeDn3jPeg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696950525; 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=t0IcpvLhad8KFsm8A/vXcS685lwQ2BubUPwtUH49A0A=; b=NkF8O8ydvZvVzah70iFyiWGa/+4tmn/Pn9r0lhEnV78FI9SD0U8zSau/8SB8etkOzhIx2O Y778RGSRJhE1WUAQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Borislav Petkov Subject: [patch 4/5] x86/microcode/amd: Use cached microcode for AP load References: <20231010145130.987300357@linutronix.de> MIME-Version: 1.0 Date: Tue, 10 Oct 2023 17:08:45 +0200 (CEST) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now that the microcode cache is initialized before the APs are brought up, there is no point to scan builtin/initrd microcode during AP loading. Convert the AP loader to utilize the cache, which in turn makes the CPU hotplug callback which applies the microcode after initrd/builtin is gone obsolete as the early loading during late hotplug operations including the resume path depends now only on the cache. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/cpu/microcode/amd.c | 20 +++++++++++--------- arch/x86/kernel/cpu/microcode/core.c | 15 ++------------- arch/x86/kernel/cpu/microcode/internal.h | 2 -- 3 files changed, 13 insertions(+), 24 deletions(-) --- a/arch/x86/kernel/cpu/microcode/amd.c +++ b/arch/x86/kernel/cpu/microcode/amd.c @@ -496,7 +496,7 @@ static bool get_builtin_microcode(struct return false; } =20 -static void find_blobs_in_containers(unsigned int cpuid_1_eax, struct cpio= _data *ret) +static void __init find_blobs_in_containers(unsigned int cpuid_1_eax, stru= ct cpio_data *ret) { struct cpio_data cp; =20 @@ -506,12 +506,12 @@ static void find_blobs_in_containers(uns *ret =3D cp; } =20 -static void apply_ucode_from_containers(unsigned int cpuid_1_eax) +void __init load_ucode_amd_bsp(unsigned int cpuid_1_eax) { struct cpio_data cp =3D { }; =20 /* Needed in load_microcode_amd() */ - ucode_cpu_info[smp_processor_id()].cpu_sig.sig =3D cpuid_1_eax; + ucode_cpu_info[0].cpu_sig.sig =3D cpuid_1_eax; =20 find_blobs_in_containers(cpuid_1_eax, &cp); if (!(cp.data && cp.size)) @@ -520,11 +520,6 @@ static void apply_ucode_from_containers( early_apply_microcode(cpuid_1_eax, cp.data, cp.size); } =20 -void load_ucode_amd_early(unsigned int cpuid_1_eax) -{ - return apply_ucode_from_containers(cpuid_1_eax); -} - static enum ucode_state load_microcode_amd(u8 family, const u8 *data, size= _t size); =20 static int __init save_microcode_in_initrd(void) @@ -608,7 +603,6 @@ static struct ucode_patch *find_patch(un struct ucode_cpu_info *uci =3D ucode_cpu_info + cpu; u16 equiv_id; =20 - equiv_id =3D find_equiv_id(&equiv_table, uci->cpu_sig.sig); if (!equiv_id) return NULL; @@ -710,6 +704,14 @@ static enum ucode_state apply_microcode_ return ret; } =20 +void load_ucode_amd_ap(unsigned int cpuid_1_eax) +{ + unsigned int cpu =3D smp_processor_id(); + + ucode_cpu_info[cpu].cpu_sig.sig =3D cpuid_1_eax; + apply_microcode_amd(cpu); +} + static size_t install_equiv_cpu_table(const u8 *buf, size_t buf_size) { u32 equiv_tbl_len; --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -159,7 +159,7 @@ void __init load_ucode_bsp(void) if (intel) load_ucode_intel_bsp(); else - load_ucode_amd_early(cpuid_1_eax); + load_ucode_amd_bsp(cpuid_1_eax); } =20 void load_ucode_ap(void) @@ -178,7 +178,7 @@ void load_ucode_ap(void) break; case X86_VENDOR_AMD: if (x86_family(cpuid_1_eax) >=3D 0x10) - load_ucode_amd_early(cpuid_1_eax); + load_ucode_amd_ap(cpuid_1_eax); break; default: break; @@ -789,15 +789,6 @@ static struct syscore_ops mc_syscore_ops .resume =3D microcode_bsp_resume, }; =20 -static int mc_cpu_starting(unsigned int cpu) -{ - enum ucode_state err =3D microcode_ops->apply_microcode(cpu); - - pr_debug("%s: CPU%d, err: %d\n", __func__, cpu, err); - - return err =3D=3D UCODE_ERROR; -} - static int mc_cpu_online(unsigned int cpu) { struct ucode_cpu_info *uci =3D ucode_cpu_info + cpu; @@ -870,8 +861,6 @@ static int __init microcode_init(void) } =20 register_syscore_ops(&mc_syscore_ops); - cpuhp_setup_state_nocalls(CPUHP_AP_MICROCODE_LOADER, "x86/microcode:start= ing", - mc_cpu_starting, NULL); cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/microcode:online", mc_cpu_online, mc_cpu_down_prep); =20 --- a/arch/x86/kernel/cpu/microcode/internal.h +++ b/arch/x86/kernel/cpu/microcode/internal.h @@ -95,7 +95,6 @@ extern bool initrd_gone; #ifdef CONFIG_CPU_SUP_AMD void load_ucode_amd_bsp(unsigned int family); void load_ucode_amd_ap(unsigned int family); -void load_ucode_amd_early(unsigned int cpuid_1_eax); int save_microcode_in_initrd_amd(unsigned int family); void reload_ucode_amd(unsigned int cpu); struct microcode_ops *init_amd_microcode(void); @@ -103,7 +102,6 @@ void exit_amd_microcode(void); #else /* CONFIG_CPU_SUP_AMD */ static inline void load_ucode_amd_bsp(unsigned int family) { } static inline void load_ucode_amd_ap(unsigned int family) { } -static inline void load_ucode_amd_early(unsigned int family) { } static inline int save_microcode_in_initrd_amd(unsigned int family) { retu= rn -EINVAL; } static inline void reload_ucode_amd(unsigned int cpu) { } static inline struct microcode_ops *init_amd_microcode(void) { return NULL= ; } From nobody Fri Jan 2 15:07:55 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56249CD8CA6 for ; Tue, 10 Oct 2023 15:09:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233252AbjJJPJF (ORCPT ); Tue, 10 Oct 2023 11:09:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231865AbjJJPIw (ORCPT ); Tue, 10 Oct 2023 11:08:52 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0424993 for ; Tue, 10 Oct 2023 08:08:51 -0700 (PDT) Message-ID: <20231010150702.662293885@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696950527; 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=IhNNCBkZDu722mghkA1YDoOAV6ExbYvs7YIlqtUCfyk=; b=zaJ0NwORFtKCxUHt5o1b0JpRAPX6MwX3ZtWXdl623+w4GTIkYBD748069YKSx65upHVmid pyuZO9de3oYgj1KWaDRFCNuHFGKdVwlk2rlibB0D8oI7zUYSTXxtGdy7Rvq8o2MuxW9vvV Yk7ybfCRKSJpY6mPW6zkcIdzutFi6FRujyctmb+UpEojZd+nwr8YCfpmRS160zBWFRMXuR dkGSADxOEAh1E5VbSGqZP3AE7D/2KltmP4HeUjTlYBkHdw1zDNMHy6DqU7VlWnsGSjZS9L L/Ciq7BcpmSlxqHadMgDrjMKU8STpDF7lZdKW/SnqsWZKMMDU69Bsy8LahYOXw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696950527; 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=IhNNCBkZDu722mghkA1YDoOAV6ExbYvs7YIlqtUCfyk=; b=puecydyczdwg+Ys1hOCfWLBsA4EvL5lna9tjhjl5OfmCwNvjyGnouT60LL8OpuwT85CR3z hBvj7RoEALTbxuCw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Borislav Petkov Subject: [patch 5/5] x86/microcode: Mop up early loading leftovers References: <20231010145130.987300357@linutronix.de> MIME-Version: 1.0 Date: Tue, 10 Oct 2023 17:08:46 +0200 (CEST) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Get rid of the initrd_gone hack which was required to keep find_microcode_in_initrd() functional after init. As find_microcode_in_initrd() is now only used during init, mark it accordingly. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/cpu/microcode/core.c | 17 +---------------- arch/x86/kernel/cpu/microcode/internal.h | 2 -- 2 files changed, 1 insertion(+), 18 deletions(-) --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -49,8 +49,6 @@ static bool dis_ucode_ldr =3D true; bool force_minrev =3D IS_ENABLED(CONFIG_MICROCODE_LATE_FORCE_MINREV); module_param(force_minrev, bool, S_IRUSR | S_IWUSR); =20 -bool initrd_gone; - /* * Synchronization. * @@ -185,15 +183,7 @@ void load_ucode_ap(void) } } =20 -/* Temporary workaround until find_microcode_in_initrd() is __init */ -static int __init mark_initrd_gone(void) -{ - initrd_gone =3D true; - return 0; -} -fs_initcall(mark_initrd_gone); - -struct cpio_data find_microcode_in_initrd(const char *path) +struct cpio_data __init find_microcode_in_initrd(const char *path) { #ifdef CONFIG_BLK_DEV_INITRD unsigned long start =3D 0; @@ -224,12 +214,7 @@ struct cpio_data find_microcode_in_initr * has the virtual address of the beginning of the initrd. It also * possibly relocates the ramdisk. In either case, initrd_start contains * the updated address so use that instead. - * - * initrd_gone is for the hotplug case where we've thrown out initrd - * already. */ - if (initrd_gone) - return (struct cpio_data){ NULL, 0, "" }; if (initrd_start) start =3D initrd_start; =20 --- a/arch/x86/kernel/cpu/microcode/internal.h +++ b/arch/x86/kernel/cpu/microcode/internal.h @@ -90,8 +90,6 @@ static inline unsigned int x86_cpuid_fam return x86_family(eax); } =20 -extern bool initrd_gone; - #ifdef CONFIG_CPU_SUP_AMD void load_ucode_amd_bsp(unsigned int family); void load_ucode_amd_ap(unsigned int family);