From nobody Tue Nov 4 05:42:29 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1728251583; cv=pass; d=zohomail.com; s=zohoarc; b=J9H375Q3LFjh+65rE6yl5L4NR25NUxai0xugGzycdjcGvLG0Z/zIJ3Y0ott8+OLz8s49mTEZjUGDV6GEMuAb+c/Hq3E/j3j/PQrEri2K3X79srg+Lt+CC249s1f08eZUQDTW+uySFILATXwxVT/rbwY702NfrqDBgQUE9zMCKVA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251583; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VF4eHm6uxrTpSrtxk8vxbuolB5VgBKHNdcHv6nx9QeQ=; b=Ih6Vk/ORK8qYTfQfITnMAr6Vk9roFfpGYHfrt1pW4Qjs9yuLjQJAH4HuLhy9bO4Zg9f5eqVQgS/5MD67ZvK9qCSLGjaVVuWOUq7/Z86VCpYiWnJR8lK3w/5XkumqVBzygnnRyQN+Gbps6faJH43R6bfIkW9o7W30SDBz4shF+KM= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1728251583297872.283064594313; Sun, 6 Oct 2024 14:53:03 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.811341.1223947 (Exim 4.92) (envelope-from ) id 1sxZBF-0000B3-1q; Sun, 06 Oct 2024 21:52:45 +0000 Received: by outflank-mailman (output) from mailman id 811341.1223947; Sun, 06 Oct 2024 21:52:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZBE-0000Aw-U5; Sun, 06 Oct 2024 21:52:44 +0000 Received: by outflank-mailman (input) for mailman id 811341; Sun, 06 Oct 2024 21:52:44 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sxZBE-0007Zk-1r for xen-devel@lists.xenproject.org; Sun, 06 Oct 2024 21:52:44 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 4fbdc0bc-842d-11ef-a0bb-8be0dac302b0; Sun, 06 Oct 2024 23:52:43 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1728251426576325.80828550922445; Sun, 6 Oct 2024 14:50:26 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4fbdc0bc-842d-11ef-a0bb-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1728251428; cv=none; d=zohomail.com; s=zohoarc; b=N7iKppSVcfv0jDz46c/BvD4cZCGDru5iTva3GFu9FHVTvhmUf9lpTML2p4EIi9k9MUBmUIVXeQLPiuly8CG8ML123LKGsAA7mgAGjaNgrsNZbJwPFfvWMkJHyEwumFJnR+tGPSBZsAY9dLD1Zi9FbuW8Uvc76GXeuTD/Wed0ays= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728251428; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=VF4eHm6uxrTpSrtxk8vxbuolB5VgBKHNdcHv6nx9QeQ=; b=LJLNm2vN3suBgycEWjxJ09CR8EDgehILREXuI8TxjaGY2KRT56AuEoWTJjQ5scv3IPvg+44rj0AjobqOJcSh1vsnOX5jJ1Q0X74bZpEnxUKS+5pZyKu3ifk2VcybGsVfaSdiJlA9Hi/bIaJ6XtY+A7lhhnl4FWR85dQbiT0QYsE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1728251428; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=VF4eHm6uxrTpSrtxk8vxbuolB5VgBKHNdcHv6nx9QeQ=; b=jdwto2rbWK+65sAyB9UAyAZfy1cVxDbiBOPoToPpI6P7OBGsR3QtrR05OhORT9cT I9VVlY4HKGk8CqJ+ShLQn5YhCdW/3s0s09AUO4ZLTuYPJNrp7aLsS/JbNWlp+lLcMXZ hngLz9gRcYCJmjyAKs2gHJNOrO8hH6vCSqhyQgH4= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v5 19/44] x86/boot: use consumed boot module flag for microcode Date: Sun, 6 Oct 2024 17:49:30 -0400 Message-Id: <20241006214956.24339-20-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241006214956.24339-1-dpsmith@apertussolutions.com> References: <20241006214956.24339-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1728251584967116600 Content-Type: text/plain; charset="utf-8" To track if the microcode boot module was loaded, a copy of the boot module= is kept. The size element of this copy is set to zero as the indicator that the microcode was loaded. A side effect is that the modules have to be rescanne= d to find the boot module post-relocation, so the cache copy can be created. Use the consumed boot module flag to track the loading of the microcode boot module. This removes the need to manipulate the boot module size element, no longer requiring the copy, thus allowing it to be replaced by a reference. = As a result it is no longer necessary to rescan the boot modules after relocation has occurred. Signed-off-by: Daniel P. Smith --- xen/arch/x86/cpu/microcode/core.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index 7bcc17e0ab2f..5b42aad2fdd0 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -58,7 +58,7 @@ */ #define MICROCODE_UPDATE_TIMEOUT_US 1000000 =20 -static struct boot_module __initdata ucode_mod; +static struct boot_module __initdata *ucode_mod; static signed int __initdata ucode_mod_idx; static bool __initdata ucode_mod_forced; static unsigned int nr_cores; @@ -211,7 +211,7 @@ static void __init microcode_grab_module( !__test_and_clear_bit(ucode_mod_idx, module_map) ) goto scan; bi->mods[ucode_mod_idx].type =3D BOOTMOD_MICROCODE; - ucode_mod =3D bi->mods[ucode_mod_idx]; + ucode_mod =3D &bi->mods[ucode_mod_idx]; scan: if ( ucode_scan ) microcode_scan_module(module_map, bi); @@ -769,10 +769,10 @@ static int __init cf_check microcode_init(void) ucode_blob.size =3D 0; ucode_blob.data =3D NULL; } - else if ( ucode_mod.size ) + else if ( ucode_mod && !(ucode_mod->flags & BOOTMOD_FLAG_X86_CONSUMED)= ) { bootstrap_map_bm(NULL); - ucode_mod.size =3D 0; + ucode_mod->flags |=3D BOOTMOD_FLAG_X86_CONSUMED; } =20 return 0; @@ -826,14 +826,14 @@ int __init microcode_init_cache( if ( !ucode_ops.apply_microcode ) return -ENODEV; =20 - if ( ucode_scan ) - /* Need to rescan the modules because they might have been relocat= ed */ + /* Scan if microcode was not detected earlier */ + if ( !ucode_mod ) microcode_scan_module(module_map, bi); =20 - if ( ucode_mod.size ) - rc =3D early_update_cache(bootstrap_map_bm(&ucode_mod), - ucode_mod.size); - else if ( ucode_blob.size ) + if ( ucode_mod && !(ucode_mod->flags & BOOTMOD_FLAG_X86_CONSUMED) ) + rc =3D early_update_cache(bootstrap_map_bm(ucode_mod), + ucode_mod->size); + else if ( ucode_mod && ucode_blob.size ) rc =3D early_update_cache(ucode_blob.data, ucode_blob.size); =20 return rc; @@ -851,10 +851,10 @@ static int __init early_microcode_update_cpu(void) len =3D ucode_blob.size; data =3D ucode_blob.data; } - else if ( ucode_mod.size ) + else if ( ucode_mod && !(ucode_mod->flags & BOOTMOD_FLAG_X86_CONSUMED)= ) { - len =3D ucode_mod.size; - data =3D bootstrap_map_bm(&ucode_mod); + len =3D ucode_mod->size; + data =3D bootstrap_map_bm(ucode_mod); } =20 if ( !data ) @@ -920,7 +920,7 @@ int __init early_microcode_init(unsigned long *module_m= ap, =20 microcode_grab_module(module_map, bi); =20 - if ( ucode_mod.size || ucode_blob.size ) + if ( ucode_mod || ucode_blob.size ) rc =3D early_microcode_update_cpu(); =20 /* --=20 2.30.2