From nobody Wed Dec 4 09:14:19 2024 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=1729471628; cv=pass; d=zohomail.com; s=zohoarc; b=GB19iPALemmgh5C1DJUwnI7ti2D8XQOjQnVZmZfIsefnBbRz0y/1c5DJbmiIEBm1YIQSXa50BFm5n5JW0pVPq350M5pW7GZoMRW1K9VisYGYA5CG8qgPnhjiaEqTHA4zJHMo6gJVvmbMZhv3ZRb5OGfRpZw5y72dAC3j9wBiA+4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471628; 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=VV/xki6IWbJcCiOta+71vA6COU5u0Y4wCmksjgvwz50=; b=iPZN5yei3QUoEWJEQNLnY6Cz8rx/VTbsDOC6vSvBTEZFZccdg1NnzsjwY1Thvskfy833b7HWDA9MF+Gtvnr80tscm3kU0ksOz4udyT2Mic25O0HsFzcljmD3KyTRp6EiuQEcBjlGNWo23j/2xNcm9HDLP3H5pMODE0Ypn7xT4/0= 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 1729471628081790.7348299803837; Sun, 20 Oct 2024 17:47:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822875.1236772 (Exim 4.92) (envelope-from ) id 1t2gZC-0007Hr-O2; Mon, 21 Oct 2024 00:46:38 +0000 Received: by outflank-mailman (output) from mailman id 822875.1236772; Mon, 21 Oct 2024 00:46:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gZC-0007Hk-L6; Mon, 21 Oct 2024 00:46:38 +0000 Received: by outflank-mailman (input) for mailman id 822875; Mon, 21 Oct 2024 00:46:38 +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 1t2gZB-000738-Vl for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:46:37 +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 ec7b1db2-8f45-11ef-a0be-8be0dac302b0; Mon, 21 Oct 2024 02:46:37 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471584878605.8210982846448; Sun, 20 Oct 2024 17:46:24 -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: ec7b1db2-8f45-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729471587; cv=none; d=zohomail.com; s=zohoarc; b=mtYfdajC466EsrRkIugo5XkE5Sbcn0nEWOwxgeFNWIBOjJwjv5YKUtENqGzroxTEp7n0y3SS/DcIDfeK3pHrVJ8a7znXwSCwqmsDYi+D/V12euOLBrNKEHdJRSCtnP5y1qY83yAps35G8TtYPCMy+ImWnviaQj5Tp6NLJzCQZ3w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471587; 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=VV/xki6IWbJcCiOta+71vA6COU5u0Y4wCmksjgvwz50=; b=De0yF6l4trKCbWupE0SIWHu4Pa0XxVuLY0whkTnpQjM1RpuYpdFvY/Wimrwb69IdtFDm6XEWHE/BK29GxGTjdclDenAfZDXhIBkJSBDLJYTJafzhZ0bq3jgDzR7WeAxNL3yyoLJJfqZWx+GsT0TKMixlml6tOgEFDel6j2OZXo8= 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=1729471587; 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=VV/xki6IWbJcCiOta+71vA6COU5u0Y4wCmksjgvwz50=; b=kmbCr/1XhspE9MpwHoFLyV7m5ulNl43qmvPk2PI3NZ7EmjjLW9g2pMB5hqgUv+4D qwdZ9lJ/HETKhBD62lyjSBxFX4Y/m4wharIuY6H4wuY8+roqpLjLCuYxaxOAsnb8UOI fRga7vrvDWpmmwdH2I4aIgHPxuN5pc0tV+jzk4fM= 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 v7 01/38] x86/boot: introduce struct boot_module Date: Sun, 20 Oct 2024 20:45:36 -0400 Message-Id: <20241021004613.18793-2-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729471629743116600 Content-Type: text/plain; charset="utf-8" This will introduce a new struct boot_module to provide a rich state representation around modules provided by the boot loader. Support is for 64 boot modules, one held in reserve for Xen, and up to 63 can be provided by = the boot loader. The array of struct boot_modules will be accessible via a reference held in struct boot_info. A temporary `mod` parameter is included in struct boot_module to ease the transition from using Multiboot v1 structures over to struct boot_module. O= nce the transition is complete, the parameter will be dropped from the structur= e. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v6: - add guard to prevent OOB access of the boot module array - pulled the setting of the Xen entry back out as independently set - updated comment to understand why Xen entry has to be explicitly set Changes since v5: - reword comment --- xen/arch/x86/include/asm/bootinfo.h | 10 ++++++++++ xen/arch/x86/setup.c | 26 ++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index e7821e0603f8..ffa443406747 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -8,8 +8,17 @@ #ifndef X86_BOOTINFO_H #define X86_BOOTINFO_H =20 +#include #include =20 +/* Max number of boot modules a bootloader can provide in addition to Xen = */ +#define MAX_NR_BOOTMODS 63 + +struct boot_module { + /* Transitionary only */ + module_t *mod; +}; + /* * Xen internal representation of information provided by the * bootloader/environment, or derived from the information. @@ -22,6 +31,7 @@ struct boot_info { size_t memmap_length; =20 unsigned int nr_modules; + struct boot_module mods[MAX_NR_BOOTMODS + 1]; }; =20 #endif /* X86_BOOTINFO_H */ diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index bfede5064e8c..db670258d650 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -287,6 +287,8 @@ static struct boot_info *__init multiboot_fill_boot_inf= o(unsigned long mbi_p) { struct boot_info *bi =3D &xen_boot_info; const multiboot_info_t *mbi =3D __va(mbi_p); + module_t *mods =3D __va(mbi->mods_addr); + unsigned int i; =20 if ( mbi->flags & MBI_MODULES ) bi->nr_modules =3D mbi->mods_count; @@ -303,6 +305,21 @@ static struct boot_info *__init multiboot_fill_boot_in= fo(unsigned long mbi_p) bi->memmap_length =3D mbi->mmap_length; } =20 + /* + * The multiboot entry point will reserve mods_count + 1 instances of + * module_t, with the last one being for Xen. First iterate over nr_mo= dules + * module_t entries, or MAX_NR_BOOTMODS if more than the max was passe= d. + * + * As the Xen entry may be beyond MAX_NR_BOOTMODS, explicitly set the = last + * entry in mods to point at the last module_t entry which the entry p= oint + * reserved for Xen. + */ + for ( i =3D 0; i < MAX_NR_BOOTMODS && i < bi->nr_modules; i++ ) + bi->mods[i].mod =3D &mods[i]; + + /* Variable 'i' should be one entry past the last module. */ + bi->mods[i].mod =3D &mods[bi->nr_modules]; + return bi; } =20 @@ -1163,9 +1180,14 @@ void asmlinkage __init noreturn __start_xen(unsigned= long mbi_p) panic("dom0 kernel not specified. Check bootloader configuration\n= "); =20 /* Check that we don't have a silly number of modules. */ - if ( bi->nr_modules > sizeof(module_map) * 8 ) + if ( bi->nr_modules > MAX_NR_BOOTMODS ) { - bi->nr_modules =3D sizeof(module_map) * 8; + /* + * Only MAX_NR_BOOTMODS were populated in bootinfo, truncate nr_mo= dules + * now that it can be report that an excess number of modules were + * passed. + */ + bi->nr_modules =3D MAX_NR_BOOTMODS; printk("Excessive boot modules - using the first %u only\n", bi->nr_modules); } --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729471632; cv=pass; d=zohomail.com; s=zohoarc; b=e9cOHqy7rsxiz/80TAW3iQaKhBJtU2IZQf8LC/T9yjUv7IHMvrDX5PPlzft6vDtG6vWV510UtM52z9r09kJc5sgxVasfVN96OaaFUSZ1HwastiAih15U44BvP5iMA3MlDXYJBLGjbbnIDvNO9V+yIumMUL1jETsVbAoybJDjBOU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471632; 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=5BxR907iR5u9/6Q1o/EHkq0aEkes4oDlkRcMr/AbvX4=; b=DX6aAX56n0mZkG9Ut6vjistdhMxM8eqNNBdcZKz40k11F5e+lcMAD6ughGiRc6FcdybW6K0MrBIw2o7vxzzDgXofPmn9lsSxQ9rtTS4x1Ta557DP4+Wd1Rq3gZwzk8TvY8cw2AvsU4IT6b0SyerVfk+ldWBcgRpi3EVjeB9GZLw= 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 1729471632405634.761901775993; Sun, 20 Oct 2024 17:47:12 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822876.1236782 (Exim 4.92) (envelope-from ) id 1t2gZK-0007aJ-V5; Mon, 21 Oct 2024 00:46:46 +0000 Received: by outflank-mailman (output) from mailman id 822876.1236782; Mon, 21 Oct 2024 00:46:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gZK-0007a9-SL; Mon, 21 Oct 2024 00:46:46 +0000 Received: by outflank-mailman (input) for mailman id 822876; Mon, 21 Oct 2024 00:46:45 +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 1t2gZJ-000738-Lq for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:46:45 +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 f120f82e-8f45-11ef-a0be-8be0dac302b0; Mon, 21 Oct 2024 02:46:44 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471586110575.2544669844197; Sun, 20 Oct 2024 17:46: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: f120f82e-8f45-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729471587; cv=none; d=zohomail.com; s=zohoarc; b=jz96BrikdNvb6h+sW+8+QNhXkT6jvzLV4UgMHDxoVjQxpOjOBQ0i21LTZ2YW/Ja4uV0HabLx3G1inbGLGXxg0mzmafHMSuUZ5nC2bPf0NmexJvvxT6/VjXq197H6GqoFMpco1jZ1l8rWWB/fFRY4Jdm4tnjpll8kMhAX8oASiVM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471587; 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=5BxR907iR5u9/6Q1o/EHkq0aEkes4oDlkRcMr/AbvX4=; b=FLwMYW6bbSr35RkxwEd34DlEHCt2o7cDwPuu+G0gvxroyezK7blnL61mVafWiSojhS+RzRSVNl5zsGhNxoLVlKl/N5EsF7wR99uObp63rzjtFp0/KXanEehk4Yqp+hPEJkXPjKyfdG1ah7NPRE9yFiRcsJwqgLvML6Ghfv8Ykgo= 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=1729471587; 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=5BxR907iR5u9/6Q1o/EHkq0aEkes4oDlkRcMr/AbvX4=; b=iFb+ctHZTLWhQhMF92wcvY/sYWmZ+9HBVvgD5c4F4JuA/B39N310cWu2lNnMEEXD s6of4wzioysICSnkLrTD/2bE/4u0yh0F2JmZ5bQGtOVpn5Iwq9rNcOVH0wxjij3ys6w ECW3ckhZCKVErBZig0aMFg0NibsDqP5/cwlk2XOg= 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 v7 02/38] x86/boot: convert consider_modules to struct boot_module Date: Sun, 20 Oct 2024 20:45:37 -0400 Message-Id: <20241021004613.18793-3-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729471633315116600 Content-Type: text/plain; charset="utf-8" To start transitioning consider_modules() over to struct boot_module, begin with taking the array of struct boot_modules but use the temporary struct element mod. No functional change intended. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v5: - drop unnecessary type cast --- xen/arch/x86/setup.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index db670258d650..1eafa0a61e0e 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -645,7 +645,7 @@ static void __init noinline move_xen(void) #undef BOOTSTRAP_MAP_LIMIT =20 static uint64_t __init consider_modules( - uint64_t s, uint64_t e, uint32_t size, const module_t *mod, + uint64_t s, uint64_t e, uint32_t size, const struct boot_module mods[], unsigned int nr_mods, unsigned int this_mod) { unsigned int i; @@ -655,20 +655,20 @@ static uint64_t __init consider_modules( =20 for ( i =3D 0; i < nr_mods ; ++i ) { - uint64_t start =3D (uint64_t)mod[i].mod_start << PAGE_SHIFT; - uint64_t end =3D start + PAGE_ALIGN(mod[i].mod_end); + uint64_t start =3D pfn_to_paddr(mods[i].mod->mod_start); + uint64_t end =3D start + PAGE_ALIGN(mods[i].mod->mod_end); =20 if ( i =3D=3D this_mod ) continue; =20 if ( s < end && start < e ) { - end =3D consider_modules(end, e, size, mod + i + 1, + end =3D consider_modules(end, e, size, &mods[i + 1], nr_mods - i - 1, this_mod - i - 1); if ( end ) return end; =20 - return consider_modules(s, start, size, mod + i + 1, + return consider_modules(s, start, size, &mods[i + 1], nr_mods - i - 1, this_mod - i - 1); } } @@ -1451,7 +1451,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) { /* Don't overlap with modules. */ end =3D consider_modules(s, e, reloc_size + mask, - mod, bi->nr_modules, -1); + bi->mods, bi->nr_modules, -1); end &=3D ~mask; } else @@ -1486,7 +1486,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) continue; =20 /* Don't overlap with other modules (or Xen itself). */ - end =3D consider_modules(s, e, size, mod, + end =3D consider_modules(s, e, size, bi->mods, bi->nr_modules + relocated, j); =20 if ( highmem_start && end > highmem_start ) @@ -1513,7 +1513,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) while ( !kexec_crash_area.start ) { /* Don't overlap with modules (or Xen itself). */ - e =3D consider_modules(s, e, PAGE_ALIGN(kexec_crash_area.size)= , mod, + e =3D consider_modules(s, e, PAGE_ALIGN(kexec_crash_area.size)= , bi->mods, bi->nr_modules + relocated, -1); if ( s >=3D e ) break; --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729471633; cv=pass; d=zohomail.com; s=zohoarc; b=UWc92/yY85wS1w4VnaWA2AVodxE4+DDPazgtTJ6pGKlLyESrElZho0gVl70BQyhFfGD7hp6Z9wTjVkdKrwvtDeo2ROHJDooOqv5R846WYSSiRojSoFZ6/gL5FndHwu49zSGgOr8GSKAWX5MgspyQ6Qhe1SyabisyiZHCyOjA60U= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471633; 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=4OnSYGb1tvM1Q1JcgOyBkYudm2zIjXBaFQ9ShM2msC8=; b=GhyzDzCZarBhaqtwLiSAqHiyfomUi3sXys+KsUvzz6y5DR4QnVHm3gohIZsSBhxebvKVC9W9FsMzUAt9QWExxgLnDTnC0JXzLH6yTGXVClvCgV0ryrRHQYxt9uPFuVFh0oX2PMVeOg7cFPto8ZJ9ZsDq2lcAdVeJtI4He27DDz0= 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 1729471633293424.6189829124239; Sun, 20 Oct 2024 17:47:13 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822877.1236793 (Exim 4.92) (envelope-from ) id 1t2gZS-0007xP-8P; Mon, 21 Oct 2024 00:46:54 +0000 Received: by outflank-mailman (output) from mailman id 822877.1236793; Mon, 21 Oct 2024 00:46:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gZS-0007xG-46; Mon, 21 Oct 2024 00:46:54 +0000 Received: by outflank-mailman (input) for mailman id 822877; Mon, 21 Oct 2024 00:46:52 +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 1t2gZQ-000738-Bb for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:46:52 +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 f53e2ef6-8f45-11ef-a0be-8be0dac302b0; Mon, 21 Oct 2024 02:46:51 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471587294458.09984789376335; Sun, 20 Oct 2024 17:46:27 -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: f53e2ef6-8f45-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729471588; cv=none; d=zohomail.com; s=zohoarc; b=jlh7GxHfaUm5qhXtMauf6Tf5AX8pJebhqnLsMrD9ahbn4ICgUXVkFnXvjQw+mDaA55qSBIvnZ4A7jmiYydgkStJWhgAaHOfDVmkXCXese6ptmd1p23s84B2CdNEc6Q7FLEW1JfbeWbwhmQdXg3qioPpcEJWwShdHe7Yt6tAX7Sw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471588; 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=4OnSYGb1tvM1Q1JcgOyBkYudm2zIjXBaFQ9ShM2msC8=; b=KKVC+RnFgNC23zCDpwax22gldl40n6wIn2P1JcY6/Mb0Vc2RSswOZvJ7oyXm2xxNxYhd03XYAbLd3gDr7wfRpdVMj7d+TRSahC4xRCHu8QnxKioLxrWPqos8GI5kmg04oWXV0lf1vmcre9Tjwbs2b1pzFJ1/jvr25xgoh6Yn6os= 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=1729471588; 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=4OnSYGb1tvM1Q1JcgOyBkYudm2zIjXBaFQ9ShM2msC8=; b=oK7Lm+cehUnPixaqW7H5dhzaVWm4kLqkz12buA77UcMW068nFlzjj9mjaHzMoruw bkcZJ5QmbOg8DnuKeuGaPYPi+v4qZFAr5CCtzT8fDr9h4WKzKjGW6sOu+Pzpq/f3Dxz vzQIBez/1DIPP/O5HgCFAmQRvx2pzyqX6lHSYZBU= 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 v7 03/38] x86/boot: move headroom to boot modules Date: Sun, 20 Oct 2024 20:45:38 -0400 Message-Id: <20241021004613.18793-4-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729471635325116600 Content-Type: text/plain; charset="utf-8" The purpose of struct boot_module is to encapsulate the state of boot modul= e as it is processed by Xen. Locating boot module state struct boot_module reduc= es the number of global variables as well as the number of state variables that must be passed around. It also lays the groundwork for hyperlaunch mult-dom= ain construction, where multiple instances of state variables like headroom wil= l be needed. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v6: - add blank line to separate comment from line above it Changes since v5: - reword and expand comment on headroom - consolidated declaration and assignment --- xen/arch/x86/include/asm/bootinfo.h | 14 ++++++++++++++ xen/arch/x86/setup.c | 21 ++++++++++++--------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index ffa443406747..59e6696f9671 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -17,6 +17,20 @@ struct boot_module { /* Transitionary only */ module_t *mod; + + /* + * A boot module may contain a compressed kernel that will require + * additional space, before the module data, into which the kernel wil= l be + * decompressed. + * + * Memory layout at boot: + * [ compressed kernel ] + * After boot module relocation: + * [ estimated headroom + PAGE_SIZE rounding ][ compressed kernel ] + * After kernel decompression: + * [ decompressed kernel ][ unused rounding ] + */ + unsigned long headroom; }; =20 /* diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 1eafa0a61e0e..48809aa94451 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1028,7 +1028,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) struct boot_info *bi; multiboot_info_t *mbi; module_t *mod; - unsigned long nr_pages, raw_max_page, modules_headroom, module_map[1]; + unsigned long nr_pages, raw_max_page, module_map[1]; int i, j, e820_warn =3D 0, bytes =3D 0; unsigned long eb_start, eb_end; bool acpi_boot_table_init_done =3D false, relocated =3D false; @@ -1394,7 +1394,10 @@ void asmlinkage __init noreturn __start_xen(unsigned= long mbi_p) mod[bi->nr_modules].mod_end =3D __2M_rwdata_end - _stext; } =20 - modules_headroom =3D bzimage_headroom(bootstrap_map(mod), mod->mod_end= ); + bi->mods[0].headroom =3D + bzimage_headroom(bootstrap_map(bi->mods[0].mod), + bi->mods[0].mod->mod_end); + bootstrap_map(NULL); =20 #ifndef highmem_start @@ -1479,8 +1482,8 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) * decompressor overheads of mod[0] (the dom0 kernel). When we * move mod[0], we incorporate this as extra space at the star= t. */ - unsigned long headroom =3D j ? 0 : modules_headroom; - unsigned long size =3D PAGE_ALIGN(headroom + mod[j].mod_end); + struct boot_module *bm =3D &bi->mods[j]; + unsigned long size =3D PAGE_ALIGN(bm->headroom + mod[j].mod_en= d); =20 if ( mod[j].reserved ) continue; @@ -1493,14 +1496,14 @@ void asmlinkage __init noreturn __start_xen(unsigne= d long mbi_p) continue; =20 if ( s < end && - (headroom || + (bm->headroom || ((end - size) >> PAGE_SHIFT) > mod[j].mod_start) ) { - move_memory(end - size + headroom, + move_memory(end - size + bm->headroom, (uint64_t)mod[j].mod_start << PAGE_SHIFT, mod[j].mod_end); mod[j].mod_start =3D (end - size) >> PAGE_SHIFT; - mod[j].mod_end +=3D headroom; + mod[j].mod_end +=3D bm->headroom; mod[j].reserved =3D 1; } } @@ -1527,7 +1530,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) #endif } =20 - if ( modules_headroom && !mod->reserved ) + if ( bi->mods[0].headroom && !mod->reserved ) panic("Not enough memory to relocate the dom0 kernel image\n"); for ( i =3D 0; i < bi->nr_modules; ++i ) { @@ -2079,7 +2082,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) * We're going to setup domain0 using the module(s) that we stashed sa= fely * above our heap. The second module, if present, is an initrd ramdisk. */ - dom0 =3D create_dom0(mod, modules_headroom, + dom0 =3D create_dom0(mod, bi->mods[0].headroom, initrdidx < bi->nr_modules ? mod + initrdidx : NULL, kextra, bi->loader); if ( !dom0 ) --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729471644; cv=pass; d=zohomail.com; s=zohoarc; b=d8v9aJcel1uIuEDX8HNauBw/OTLhEzj4U7JU4OxCKtjyBg7pwiY3BA87YZaqws47wxn/6Wlv5l0rNZsvaBqzvAurYeca4vhgYlQPgf1oMwz8DEoINjprt2P5k5HGnrKS/prDMNbxNbsyjUvR41sRkrFun6AVr3WvIp6CKNifpnM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471644; 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=0hf/GPWorDxYmQn+gugUE/WDMvvSA827DeL6H9WXctU=; b=FXkDnqCkx7vO5h0z2bxj/xtI3rqIgqItk58ht8YPhUyGKmcwW96I1xMgJCZ75f4iBRDHSuOGHE6faiiHjsufxEAFzP+6ZnoLI58i+0Y8bAzYKbV32+h4AbVjzEkAIRI0htqxacKrCHxI2g4r5xAJpxPIh1Do4VkEkT7kCqhmHTM= 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 1729471644659533.678507247641; Sun, 20 Oct 2024 17:47:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822880.1236801 (Exim 4.92) (envelope-from ) id 1t2gZY-0008SF-Ev; Mon, 21 Oct 2024 00:47:00 +0000 Received: by outflank-mailman (output) from mailman id 822880.1236801; Mon, 21 Oct 2024 00:47:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gZY-0008S6-Bi; Mon, 21 Oct 2024 00:47:00 +0000 Received: by outflank-mailman (input) for mailman id 822880; Mon, 21 Oct 2024 00:46:58 +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 1t2gZW-000738-OH for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:46:58 +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 f90525c6-8f45-11ef-a0be-8be0dac302b0; Mon, 21 Oct 2024 02:46:58 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471588434168.99853711437606; Sun, 20 Oct 2024 17:46:28 -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: f90525c6-8f45-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729471589; cv=none; d=zohomail.com; s=zohoarc; b=BXZsbouImeuGsUjuRGIu2CdEllsZmH12CZS4CxQ4p+IRXDXTbjcX1V5IXGcNms8RBImFHrNMksLu7oCNu+DmQonnx8aklfJyexKUAWJ23ipDlJJGygGGuH/oqRrc2w5L8yIBDO3obY+g9/FQt9E87DHTbT05aOaR8agKZwwbh8k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471589; 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=0hf/GPWorDxYmQn+gugUE/WDMvvSA827DeL6H9WXctU=; b=RJlHBziQUaOFTrEREf8DjJ8jz52wdMkS88PSomo/hbXZ/K0ON3ohMarJUtXR3jdGnkWf9MtfIlS2lj2IbzXdkE7k0odZu14GXtORhRRwANl4ddOrzBTBqSyYIQunTA3D4RFp9eV1wjMLliVDwgkzRkIIGsPimY0rUwNFUsUENHk= 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=1729471589; 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=0hf/GPWorDxYmQn+gugUE/WDMvvSA827DeL6H9WXctU=; b=eFGrbTJAYWMY95Rdi5DkjzkE8UI8f3HGYTgT1NhY7lau/bZByvUgTl5X87SsX96v 9sRzLazkd6dL10ikAh98SlqpJskgmWqOdTnOqr+l6mqq09Iy55j2KO+BkOTHXpiacNH YfBPrI6cwK05wYtMvZKj8tHjW9eQ+dGeyIltbjaY= 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 v7 04/38] x86/boot: convert mod refs to boot_module mod Date: Sun, 20 Oct 2024 20:45:39 -0400 Message-Id: <20241021004613.18793-5-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729471645401116600 Content-Type: text/plain; charset="utf-8" To allow a slow conversion of x86 over to struct boot_module, start with replacing all references to module_t mod, only in setup.c, to the mod eleme= nt of struct boot_module. These serves twofold, first to allow the incremental transition from module_t fields to struct boot_module fields. The second is= to allow the conversion of function definitions from taking module_t parameter= s to accepting struct boot_module as needed when a transitioned field will be accessed. Signed-off-by: Daniel P. Smith --- Changes since v6: - code style - switched to a local ref Changes since v5: - rewrote commit message - coding style changes - added comment for initial_images assignment --- xen/arch/x86/setup.c | 62 +++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 48809aa94451..b6d688f8fe5e 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1364,15 +1364,19 @@ void asmlinkage __init noreturn __start_xen(unsigne= d long mbi_p) set_kexec_crash_area_size((u64)nr_pages << PAGE_SHIFT); kexec_reserve_area(); =20 - initial_images =3D mod; + /* + * The field bi->mods[0].mod points to the first element of the module= _t + * array. + */ + initial_images =3D bi->mods[0].mod; =20 for ( i =3D 0; !efi_enabled(EFI_LOADER) && i < bi->nr_modules; i++ ) { - if ( mod[i].mod_start & (PAGE_SIZE - 1) ) + if ( bi->mods[i].mod->mod_start & (PAGE_SIZE - 1) ) panic("Bootloader didn't honor module alignment request\n"); - mod[i].mod_end -=3D mod[i].mod_start; - mod[i].mod_start >>=3D PAGE_SHIFT; - mod[i].reserved =3D 0; + bi->mods[i].mod->mod_end -=3D bi->mods[i].mod->mod_start; + bi->mods[i].mod->mod_start >>=3D PAGE_SHIFT; + bi->mods[i].mod->reserved =3D 0; } =20 /* @@ -1383,6 +1387,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) =20 if ( xen_phys_start ) { + unsigned int xen =3D bi->nr_modules; relocated =3D true; =20 /* @@ -1390,8 +1395,8 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) * respective reserve_e820_ram() invocation below. No need to * query efi_boot_mem_unused() here, though. */ - mod[bi->nr_modules].mod_start =3D virt_to_mfn(_stext); - mod[bi->nr_modules].mod_end =3D __2M_rwdata_end - _stext; + bi->mods[xen].mod->mod_start =3D virt_to_mfn(_stext); + bi->mods[xen].mod->mod_end =3D __2M_rwdata_end - _stext; } =20 bi->mods[0].headroom =3D @@ -1483,9 +1488,9 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) * move mod[0], we incorporate this as extra space at the star= t. */ struct boot_module *bm =3D &bi->mods[j]; - unsigned long size =3D PAGE_ALIGN(bm->headroom + mod[j].mod_en= d); + unsigned long size =3D PAGE_ALIGN(bm->headroom + bm->mod->mod_= end); =20 - if ( mod[j].reserved ) + if ( bm->mod->reserved ) continue; =20 /* Don't overlap with other modules (or Xen itself). */ @@ -1497,14 +1502,14 @@ void asmlinkage __init noreturn __start_xen(unsigne= d long mbi_p) =20 if ( s < end && (bm->headroom || - ((end - size) >> PAGE_SHIFT) > mod[j].mod_start) ) + ((end - size) >> PAGE_SHIFT) > bm->mod->mod_start) ) { move_memory(end - size + bm->headroom, - (uint64_t)mod[j].mod_start << PAGE_SHIFT, - mod[j].mod_end); - mod[j].mod_start =3D (end - size) >> PAGE_SHIFT; - mod[j].mod_end +=3D bm->headroom; - mod[j].reserved =3D 1; + (uint64_t)bm->mod->mod_start << PAGE_SHIFT, + bm->mod->mod_end); + bm->mod->mod_start =3D (end - size) >> PAGE_SHIFT; + bm->mod->mod_end +=3D bm->headroom; + bm->mod->reserved =3D 1; } } =20 @@ -1530,13 +1535,14 @@ void asmlinkage __init noreturn __start_xen(unsigne= d long mbi_p) #endif } =20 - if ( bi->mods[0].headroom && !mod->reserved ) + if ( bi->mods[0].headroom && !bi->mods[0].mod->reserved ) panic("Not enough memory to relocate the dom0 kernel image\n"); for ( i =3D 0; i < bi->nr_modules; ++i ) { - uint64_t s =3D (uint64_t)mod[i].mod_start << PAGE_SHIFT; + uint64_t s =3D (uint64_t)bi->mods[i].mod->mod_start << PAGE_SHIFT; =20 - reserve_e820_ram(&boot_e820, s, s + PAGE_ALIGN(mod[i].mod_end)); + reserve_e820_ram(&boot_e820, s, + s + PAGE_ALIGN(bi->mods[i].mod->mod_end)); } =20 if ( !xen_phys_start ) @@ -1614,8 +1620,8 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) map_e =3D boot_e820.map[j].addr + boot_e820.map[j].size; for ( j =3D 0; j < bi->nr_modules; ++j ) { - uint64_t end =3D pfn_to_paddr(mod[j].mod_start) + - mod[j].mod_end; + uint64_t end =3D pfn_to_paddr(bi->mods[j].mod->mod_sta= rt) + + bi->mods[j].mod->mod_end; =20 if ( map_e < end ) map_e =3D end; @@ -1689,11 +1695,12 @@ void asmlinkage __init noreturn __start_xen(unsigne= d long mbi_p) =20 for ( i =3D 0; i < bi->nr_modules; ++i ) { - set_pdx_range(mod[i].mod_start, - mod[i].mod_start + PFN_UP(mod[i].mod_end)); - map_pages_to_xen((unsigned long)mfn_to_virt(mod[i].mod_start), - _mfn(mod[i].mod_start), - PFN_UP(mod[i].mod_end), PAGE_HYPERVISOR); + set_pdx_range(bi->mods[i].mod->mod_start, + bi->mods[i].mod->mod_start + + PFN_UP(bi->mods[i].mod->mod_end)); + map_pages_to_xen((unsigned long)mfn_to_virt(bi->mods[i].mod->mod_s= tart), + _mfn(bi->mods[i].mod->mod_start), + PFN_UP(bi->mods[i].mod->mod_end), PAGE_HYPERVISOR= ); } =20 #ifdef CONFIG_KEXEC @@ -2082,8 +2089,9 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) * We're going to setup domain0 using the module(s) that we stashed sa= fely * above our heap. The second module, if present, is an initrd ramdisk. */ - dom0 =3D create_dom0(mod, bi->mods[0].headroom, - initrdidx < bi->nr_modules ? mod + initrdidx : NULL, + dom0 =3D create_dom0(bi->mods[0].mod, bi->mods[0].headroom, + initrdidx < bi->nr_modules ? bi->mods[initrdidx].mod + : NULL, kextra, bi->loader); if ( !dom0 ) panic("Could not set up DOM0 guest OS\n"); --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729471649; cv=pass; d=zohomail.com; s=zohoarc; b=K5pd9/sJqNecke7XrFEb4SX8Njrlqn9EroLDAdCRaP36Y9aEK15cPlqag6BKhL2MLbnP5BSbsLJQ3EWf1oaTpZBz2N2+TBSn12yiHd32yXP8Z6hPILuiMHq2iiCQ3k+O0bRtldO9J3O0yxPoZU0hGvpVYxKDbB7fK8oHCDUbJfI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471649; 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=34cklPGzHZTKAMY1dl5kem1MkF+P5eeKqClixrNkoNU=; b=iN2hG4QbrQw3y7jZJEFRE3dxOY3qSOCvUe/gO45pap31J7L/8PL0lq7jRVIwpaw6qMYyrsNNjR0V/v4rgRjWpnodyWE7IMmPp8ZYtq+p7lF5D8KvlEGoHkb03950NaiS4uQQ6Mvi2Ue8yJfYljGa7VbuQUhbr+QPVoKfbsO2j+Y= 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 1729471649390586.1031177543363; Sun, 20 Oct 2024 17:47:29 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822888.1236812 (Exim 4.92) (envelope-from ) id 1t2gZf-0000Zx-U2; Mon, 21 Oct 2024 00:47:07 +0000 Received: by outflank-mailman (output) from mailman id 822888.1236812; Mon, 21 Oct 2024 00:47:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gZf-0000Zk-QT; Mon, 21 Oct 2024 00:47:07 +0000 Received: by outflank-mailman (input) for mailman id 822888; Mon, 21 Oct 2024 00:47:06 +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 1t2gZe-000738-Cw for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:47:06 +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 fd092f93-8f45-11ef-a0be-8be0dac302b0; Mon, 21 Oct 2024 02:47:04 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471589554240.44779013138236; Sun, 20 Oct 2024 17:46:29 -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: fd092f93-8f45-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729471591; cv=none; d=zohomail.com; s=zohoarc; b=RjyG3Vl5JYgQf2EuO5BGJO/EDHuK5ukSioKgYb6ErZM+kTzXA+uePusSxVb2MUnMHFfBnHHYPRfHkI5MRsV/hUgFDMxJFYuCdZvxuJNkYTt7a0cx2bsd12x1ISxMf0Scfozz7fs0OG6qGD6bmCy2dbACedBfW7AUg5e9qtG94rY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471591; 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=34cklPGzHZTKAMY1dl5kem1MkF+P5eeKqClixrNkoNU=; b=KlhbN00pLjObScO62rZchS/gTiN13VlWMA/HEhY8BfmozMGQoHnEAi8yLpRxwnm1Euy7YpXjiHHVIsJ69/SXazXXiF64E4SC8ectKeMWSmIH6kUv5i7/STWDlTi6WMufuJ/3KFKBPLwzRa76YxJZdvZAU5tOu9Fnl/inCAmjr+k= 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=1729471591; 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=34cklPGzHZTKAMY1dl5kem1MkF+P5eeKqClixrNkoNU=; b=FkpQN5mXrg2DRKxDTzJeKotzle/sZQgnDI4dWg9Cr6XjbiHQkhBVZzaXR49IRhOY krMouJM4kUM9qsfnOE36k4w+vEgQ9TBXX+TWKXAl6PyUUA+TbO+bx4OHQhY2Ocxhq9R mlLftEc4ne5OKziKrIMVH5gMXlHb90FUjWJ/fu/I= 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 v7 05/38] x86/boot: introduce boot module types Date: Sun, 20 Oct 2024 20:45:40 -0400 Message-Id: <20241021004613.18793-6-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729471651332116600 Content-Type: text/plain; charset="utf-8" This commit introduces module types of xen, kernel, and ramdisk to allow bo= ot module detect code to tag the purpose of a boot module. This reduces the ne= ed for hard coded order assumptions and global variables to be used by consume= rs of boot modules, such as domain construction. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v5: - added guard around initrd type assignment - removed a missed rebase artifact --- xen/arch/x86/include/asm/bootinfo.h | 9 +++++++++ xen/arch/x86/setup.c | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index 59e6696f9671..ec005a97d6d5 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -14,6 +14,14 @@ /* Max number of boot modules a bootloader can provide in addition to Xen = */ #define MAX_NR_BOOTMODS 63 =20 +/* Boot module binary type / purpose */ +enum bootmod_type { + BOOTMOD_UNKNOWN, + BOOTMOD_XEN, + BOOTMOD_KERNEL, + BOOTMOD_RAMDISK, +}; + struct boot_module { /* Transitionary only */ module_t *mod; @@ -31,6 +39,7 @@ struct boot_module { * [ decompressed kernel ][ unused rounding ] */ unsigned long headroom; + enum bootmod_type type; }; =20 /* diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index b6d688f8fe5e..496f0900890d 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -319,6 +319,7 @@ static struct boot_info *__init multiboot_fill_boot_inf= o(unsigned long mbi_p) =20 /* Variable 'i' should be one entry past the last module. */ bi->mods[i].mod =3D &mods[bi->nr_modules]; + bi->mods[i].type =3D BOOTMOD_XEN; =20 return bi; } @@ -1194,6 +1195,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) =20 bitmap_fill(module_map, bi->nr_modules); __clear_bit(0, module_map); /* Dom0 kernel is always first */ + bi->mods[0].type =3D BOOTMOD_KERNEL; =20 if ( pvh_boot ) { @@ -2080,6 +2082,8 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) cpu_has_nx ? "" : "not "); =20 initrdidx =3D find_first_bit(module_map, bi->nr_modules); + if ( initrdidx < bi->nr_modules ) + bi->mods[initrdidx].type =3D BOOTMOD_RAMDISK; if ( bitmap_weight(module_map, bi->nr_modules) > 1 ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729472241; cv=pass; d=zohomail.com; s=zohoarc; b=MR2nbZbxezeOHy7/6fd5tSLssgnKtXsN2VGQC5YVs1hgRmLb30eJHK2r+99yATzNcyNaNeXbIKENIMM3imECeyk8IYZHvkoarDtpiWfhe4GvepL4bpae/yFXtH1PB7HI9Rse31qXHO12tek4FafvGoReF6yLhDqeV0yWu/kGIxs= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729472241; 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=0R4FqS7cm2ZwHrj01Lkx0kaLT9LesczGLcvq3CBN3bk=; b=Lgi6g5Rzyr2y7d17LIvG7L3GpMDWR+nyD9ocakHe9QfLv7QBf4fDHm7BeuTrmrv0hzZRdpLg9c2RhW/ylWy5I3YWFCXw8bSAqA2PjjGnGtiuuCuFh8lCF+LJ9siqSUlO50PAfAepLQAkmgXyj0kPb9hTTiKGSvqkznAXaxKAfw4= 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 1729472241116708.8347585048227; Sun, 20 Oct 2024 17:57:21 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822987.1237021 (Exim 4.92) (envelope-from ) id 1t2gj3-0003d4-NX; Mon, 21 Oct 2024 00:56:49 +0000 Received: by outflank-mailman (output) from mailman id 822987.1237021; Mon, 21 Oct 2024 00:56:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gj3-0003cs-Ik; Mon, 21 Oct 2024 00:56:49 +0000 Received: by outflank-mailman (input) for mailman id 822987; Mon, 21 Oct 2024 00:56:48 +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 1t2gZl-000738-Ag for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:47:13 +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 0192cad4-8f46-11ef-a0be-8be0dac302b0; Mon, 21 Oct 2024 02:47:12 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 172947159069489.25305881589452; Sun, 20 Oct 2024 17:46:30 -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: 0192cad4-8f46-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729471592; cv=none; d=zohomail.com; s=zohoarc; b=RtaK8huPFpAEWBdzWn/hxL55Dfn4Yd1PxHRIcSw/jQmn+GesVOzy7JzmKjWQPQ448pVa7mU5aRGFDyA0g6pTn4e0n98f7FdRZjmpqj7oe5LT8VSSReOBaJkZ3/ZKTXA3npbR+6Ha0QqAy/Be1+3BbTE0BzjNPUVvYOUPqq4PHwA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471592; 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=0R4FqS7cm2ZwHrj01Lkx0kaLT9LesczGLcvq3CBN3bk=; b=At3Wtwyx59FEnmOhNzEYotwOQThLmtlEoZTLH7P+1Lu/pIP/bO3xap8x9Fpr3bN2bApOz70Nh/gX/g4rSuq3nh5f0rI8F+6n63xRhAbUU24EZQlwkMepCqdqqPr3rTBdS7+23/Qc5Whovt+KTbsDWZsl8abZ4GXbEcJpTeL05vs= 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=1729471592; 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=0R4FqS7cm2ZwHrj01Lkx0kaLT9LesczGLcvq3CBN3bk=; b=qU11rr3Lls/dnbh0qxnLqRQ45dQuNB1Wr+5plXknMMvooG3vCQNqSvedlCtc9H/S pkwUcGf9DpAGnIOBQb08Lv/Wqj9LOSUvIF5h1oo1m4VS4+EIIeq4uHfiWTh+rDwQTOa ao3Ds7XEWHbROB121FjM137gQNDvmodzEpVBTHTU= 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 v7 06/38] x86/boot: introduce boot module flags Date: Sun, 20 Oct 2024 20:45:41 -0400 Message-Id: <20241021004613.18793-7-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729472241599116600 Content-Type: text/plain; charset="utf-8" The existing startup code employs various ad-hoc state tracking about certa= in boot module types by each area of the code. A boot module flags bitfield is added to enable tracking these different states. The first state to be transition by this commit is module relocation. Signed-off-by: Daniel P. Smith --- Changes since v6: - replaced bitmask flags field with the bitfield, relocated - slight update to commit message to mention bitfield - dropped Rb and Ab due to approach change Changes since v5: - removed trailing blank line. --- xen/arch/x86/include/asm/bootinfo.h | 6 ++++++ xen/arch/x86/setup.c | 7 +++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index ec005a97d6d5..e8fba66eedc5 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -40,6 +40,12 @@ struct boot_module { */ unsigned long headroom; enum bootmod_type type; + + /* + * Module State Flags: + * relocated: indicates module has been relocated in memory. + */ + bool relocated:1; }; =20 /* diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 496f0900890d..17f74384b5c1 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1378,7 +1378,6 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) panic("Bootloader didn't honor module alignment request\n"); bi->mods[i].mod->mod_end -=3D bi->mods[i].mod->mod_start; bi->mods[i].mod->mod_start >>=3D PAGE_SHIFT; - bi->mods[i].mod->reserved =3D 0; } =20 /* @@ -1492,7 +1491,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) struct boot_module *bm =3D &bi->mods[j]; unsigned long size =3D PAGE_ALIGN(bm->headroom + bm->mod->mod_= end); =20 - if ( bm->mod->reserved ) + if ( bm->relocated ) continue; =20 /* Don't overlap with other modules (or Xen itself). */ @@ -1511,7 +1510,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) bm->mod->mod_end); bm->mod->mod_start =3D (end - size) >> PAGE_SHIFT; bm->mod->mod_end +=3D bm->headroom; - bm->mod->reserved =3D 1; + bm->relocated =3D true; } } =20 @@ -1537,7 +1536,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) #endif } =20 - if ( bi->mods[0].headroom && !bi->mods[0].mod->reserved ) + if ( bi->mods[0].headroom && !bi->mods[0].relocated ) panic("Not enough memory to relocate the dom0 kernel image\n"); for ( i =3D 0; i < bi->nr_modules; ++i ) { --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729472268; cv=pass; d=zohomail.com; s=zohoarc; b=hwIsPsJaeR9fS7gK0uHnoVkAaw/QgxdIS3E7EIxBLjjUV9Zq+E/etrrC60f1pIoFjG6nRZJ9wMzk4/1uRpqOA3UuHElvpyrFkuN8K3mK3Rdf9bNy5MNuKN+3r3h5byrTnLlTA2WXxsJTizZe6Rk0/B7xJzGiBFY8uBBYo8JGlAs= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729472268; 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=Vt87AgI0m9lK6tCp4TANNpG9kFhWx6vDUngb9zKNYKY=; b=QHPRv7TimafjtRkVpuu6vnE0T8qaT7kFwgV2BIjpr2hSMurod5VfUNfXUxs4QM7EBVHb7z7dQgho5XYE/TFhewO9MbbTrxVNrfmYB/7P52UkqykFq/RXAvu7EGDpC1ofRa65oQ7svxFeNl606BAh+1qyubi2h93U0u5Awqd0mNg= 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 172947226894386.15046549285671; Sun, 20 Oct 2024 17:57:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.823030.1237091 (Exim 4.92) (envelope-from ) id 1t2gjY-0008Kr-HR; Mon, 21 Oct 2024 00:57:20 +0000 Received: by outflank-mailman (output) from mailman id 823030.1237091; Mon, 21 Oct 2024 00:57:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gjY-0008Ka-Cr; Mon, 21 Oct 2024 00:57:20 +0000 Received: by outflank-mailman (input) for mailman id 823030; Mon, 21 Oct 2024 00:57:19 +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 1t2gZs-000738-RL for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:47:20 +0000 Received: from sender3-of-o58.zoho.com (sender3-of-o58.zoho.com [136.143.184.58]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 060d6c93-8f46-11ef-a0be-8be0dac302b0; Mon, 21 Oct 2024 02:47:19 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471591822568.8599150587428; Sun, 20 Oct 2024 17:46:31 -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: 060d6c93-8f46-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729471593; cv=none; d=zohomail.com; s=zohoarc; b=D6oyLCDD5DJpBPsrlA/M7BmHu9FXfhAZnT8g4rcfuK85qAjfgfl0Iv/dvtjK9L5aQqG/bNuf9kdoVLKr3Tu8nEBvkZv25i9EpTwCUEy06w5v4NHzZi/kcHdWsECJUCCzfvzuuCqAYMcTC6Rz+A1RK2+mBY49KSd0qw3PIU3oikk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471593; 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=Vt87AgI0m9lK6tCp4TANNpG9kFhWx6vDUngb9zKNYKY=; b=FqSpP7+5QHeyC4Y6qtlVlUjNmculkc7LL+uFS/yubXnpSYHcuNaGUd+L6vvzLDTGvZw+v57KViPnlJdAW/6utgw1SE3Ugod6l5xn7GTFpnUZufHPl/iFYa1Tw5Df7oYR+0GvYj1Fn/5i+eVMA/1cYiKtpiD8vb6/P3NeMIoZsGo= 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=1729471593; 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=Vt87AgI0m9lK6tCp4TANNpG9kFhWx6vDUngb9zKNYKY=; b=KYpeI6fo1rWP+ZYhGVQP6arHGsxz9sKtVBFWwJUQi29+UH4ISJ9cHtWN76g0FS42 ViNDWGkaY9Zk4NYxWhadBX4NeRW9KC9TYY3ZE0Lax6OzAGTInRYMAsSPPVeEvrLCvhP v7TuncPjDhlwlCzm3Vka9RUumOpd5lJ1eol887ls= 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 v7 07/38] x86/boot: add start and size fields to struct boot_module Date: Sun, 20 Oct 2024 20:45:42 -0400 Message-Id: <20241021004613.18793-8-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729472269681116600 Content-Type: text/plain; charset="utf-8" This commit introduces the start and size fields to struct boot_module and assigns their value during boot_info construction. The EFI entry point is a special case, as the EFI file loading boot service= may load a file beyond the 4G barrier. As a result, to make the address fit in = the 32bit integer used by the MB1 module_t structure, the frame number is store= d in mod_start and size in mod_end. Until the EFI entry point is enlightened to = work with boot_info and boot_module, multiboot_fill_boot_info will handle the alternate values in mod_start and mod_end when EFI is detected. Signed-off-by: Daniel P. Smith --- Changes since v6: - put the efi conversion for mod_start and mod_end back along with check - dropped unnecessary cast - updated the population of start and size fields to take into account efi Changes since v5: - switched EFI population of mod_start/mod_end to addresses --- xen/arch/x86/include/asm/bootinfo.h | 3 +++ xen/arch/x86/setup.c | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index e8fba66eedc5..dbd22db3d063 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -46,6 +46,9 @@ struct boot_module { * relocated: indicates module has been relocated in memory. */ bool relocated:1; + + paddr_t start; + size_t size; }; =20 /* diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 17f74384b5c1..2e87aa314389 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -315,10 +315,25 @@ static struct boot_info *__init multiboot_fill_boot_i= nfo(unsigned long mbi_p) * reserved for Xen. */ for ( i =3D 0; i < MAX_NR_BOOTMODS && i < bi->nr_modules; i++ ) + { bi->mods[i].mod =3D &mods[i]; =20 + if ( !efi_enabled(EFI_LOADER) ) + { + bi->mods[i].start =3D mods[i].mod_start; + bi->mods[i].size =3D mods[i].mod_end - mods[i].mod_start; + } + else + { + bi->mods[i].start =3D pfn_to_paddr(mods[i].mod_start); + bi->mods[i].size =3D mods[i].mod_end; + } + } + /* Variable 'i' should be one entry past the last module. */ bi->mods[i].mod =3D &mods[bi->nr_modules]; + bi->mods[i].start =3D mods[i].mod_start; + bi->mods[i].size =3D mods[i].mod_end - mods[i].mod_start; bi->mods[i].type =3D BOOTMOD_XEN; =20 return bi; --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729472223; cv=pass; d=zohomail.com; s=zohoarc; b=RSwzrcuSItHE3UIP9DH7Zm7JhBeZ4aHKiet0LI8dZgoU+o16o56Kq/nLWQHcXe+JACJhcczrt/AcM/OrRDopaIVZWhoYLux27+MdOAuxMWJnQAbHnG6GmULTmyQjtSvOT/26ewsXbLhnj0Rt4ipWXyAdqb/2M8p6L/A8SoVr4Tc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729472223; 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=Zg0/zrG8nOgRHoZJidNwfeDdFu4m0rBe5upUUFqNRlI=; b=aCt0k7n7UtjnPTY+HgbF81LifNF5KXCdjWPBiP+pC2SIufKg81636TECUVp8wVZt2igZAguIYWOJDd16KzKV4hI3ZjiP4Fdr53FcwTKH8Ms7XfV8g0ou77BAx6NNGonTFFb2yJYnNd+uSbQ33bgkEZ2jgSxSiwJX/K8VWTqgr90= 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 1729472223488501.772755529092; Sun, 20 Oct 2024 17:57:03 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822980.1236982 (Exim 4.92) (envelope-from ) id 1t2giv-0001vR-21; Mon, 21 Oct 2024 00:56:41 +0000 Received: by outflank-mailman (output) from mailman id 822980.1236982; Mon, 21 Oct 2024 00:56:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2giu-0001vC-UC; Mon, 21 Oct 2024 00:56:40 +0000 Received: by outflank-mailman (input) for mailman id 822980; Mon, 21 Oct 2024 00:56:39 +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 1t2gZz-000738-Uj for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:47:27 +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 0a69954d-8f46-11ef-a0be-8be0dac302b0; Mon, 21 Oct 2024 02:47:27 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471592962507.4627630240867; Sun, 20 Oct 2024 17:46:32 -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: 0a69954d-8f46-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729471594; cv=none; d=zohomail.com; s=zohoarc; b=mK3dy+ROetQibWDQkE2abbPJkr6Vvawn07z/3r4l9R6/eOQdmUtCtmVcoAp/UHYYPRI/J2a+LyrVZqkBsuABYmjX67AwkCKsJi6uXyiOwVlLhRNHz4sfIMts+nwJM8XJvoVRYziFGeR5u1s9pdIpQ2k/npu8kkFpFQbvMzkdxUE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471594; 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=Zg0/zrG8nOgRHoZJidNwfeDdFu4m0rBe5upUUFqNRlI=; b=EdBwnOe0sw8iK8jWcyW0mtp8RxiKfJuLsSUDXW5Viny8SY8BMGO3x8LRmPf3WD69I5Xn9udTkI7JKdbmZ0QIDkrTvqptn78YawwKsta4HOEfx8G/SmtZoGvJoQj6HC1ZS9I4Wo9XNNMySd1Gb94oyHEmSgrWM9tEZ1OoSj9jBlw= 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=1729471594; 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=Zg0/zrG8nOgRHoZJidNwfeDdFu4m0rBe5upUUFqNRlI=; b=Pv63iucLy2BAnqn+7M1Igu9pyL7cClzAcYZ5im4cNdjPK+wit+lVgb7o1XfducfZ XjOQFUN3Mxmf8Pf8SvxO3chfoAm5HMkdkceeTNWvGZcAqB6OniqO5PqH3GjZfLLLPFN j7bWdVFNQ4pC7pOh6+GwXgxHEjF6xpY4an0aHJBI= 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 v7 08/38] x86/boot: populate boot module for xen entry Date: Sun, 20 Oct 2024 20:45:43 -0400 Message-Id: <20241021004613.18793-9-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729472225506116600 Content-Type: text/plain; charset="utf-8" Populate the start and size fields for the Xen entry when populating them in the reserved module_t entry. Signed-off-by: Daniel P. Smith --- Changes since v6: - apply correct conversion of assignment to mod_start - rewrite commit message to reflect code change Changes since v5: - corrected conversion function for a missed switch from mfn to maddr/paddr --- xen/arch/x86/setup.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 2e87aa314389..4e5d4055e7dd 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1411,8 +1411,11 @@ void asmlinkage __init noreturn __start_xen(unsigned= long mbi_p) * respective reserve_e820_ram() invocation below. No need to * query efi_boot_mem_unused() here, though. */ - bi->mods[xen].mod->mod_start =3D virt_to_mfn(_stext); - bi->mods[xen].mod->mod_end =3D __2M_rwdata_end - _stext; + bi->mods[xen].start =3D virt_to_maddr(_stext); + bi->mods[xen].size =3D __2M_rwdata_end - _stext; + + bi->mods[xen].mod->mod_start =3D paddr_to_pfn(bi->mods[xen].start); + bi->mods[xen].mod->mod_end =3D bi->mods[xen].size; } =20 bi->mods[0].headroom =3D --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729472268; cv=pass; d=zohomail.com; s=zohoarc; b=OUHtU4aytVSEQNp117+y6JGT4cXDuwSVLGGAJztZOerJXWlcpP/egTYvEKL1UCpMMsDF0x5zZa89cvBiVN/VwYNGhVJ/vLYJTpPrb/698lNO2FTT9eQADqFrR3DPiC+oFYbDZ/+WMnskc/sahcsmpqYZ0F10r28imRnX8pxovP0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729472268; 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=gBcmVTmdjlVx1YSjoPePx3/LQoLpGu8yyKS5g8B8j3Q=; b=DkbWXYcU9j19Cw3nwYH3LtvII26RkCPIJju5eEAh2nfHsafHWx5YOVxyw0Z4445orNs8B0UHbgbRdghwHg72kZO4puCKqS83nb7W3+aWUdLJLDHgsDgCIaA2+keBR6VvoIF32YCfJyb3EF6RX1rrjWcjNPYuh2u/DJw+FPH1IPQ= 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 1729472268935721.3406355277515; Sun, 20 Oct 2024 17:57:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.823043.1237137 (Exim 4.92) (envelope-from ) id 1t2gji-0001wP-UK; Mon, 21 Oct 2024 00:57:30 +0000 Received: by outflank-mailman (output) from mailman id 823043.1237137; Mon, 21 Oct 2024 00:57:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gji-0001vF-Lr; Mon, 21 Oct 2024 00:57:30 +0000 Received: by outflank-mailman (input) for mailman id 823043; Mon, 21 Oct 2024 00:57:28 +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 1t2ga6-000738-Ow for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:47:34 +0000 Received: from sender3-of-o59.zoho.com (sender3-of-o59.zoho.com [136.143.184.59]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0e7738f3-8f46-11ef-a0be-8be0dac302b0; Mon, 21 Oct 2024 02:47:33 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471594102634.8207739049702; Sun, 20 Oct 2024 17:46:34 -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: 0e7738f3-8f46-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729471595; cv=none; d=zohomail.com; s=zohoarc; b=DwBCWLzNDovqZO5A9SXMghcH2KD50zs29+J6GUIcLtpoCvmPaS1zrNs85gIQEX9BiTBElkSayoF3xl7ABzdrskKCHsDOCsc/6Hy4N6VRSCIuWkrJo+xJRfVsla12uuB7MTseHX4p+T7kCV5uGK4t4I7pxLN5zmJ4N9hcgvHNyrg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471595; 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=gBcmVTmdjlVx1YSjoPePx3/LQoLpGu8yyKS5g8B8j3Q=; b=jyX2LyLDGO46yhvd0aPQxMj7fyBiJRf57HKzlL1nylqHBcBixsG49NhgY9e4Y1X4osqdJWicA7BrekyH4+DE5YsSilXZQJ4ECwX5DpV195SLKte3nMwRoD4SnhDeNfnyVipe+VDr2Bps9KD7pQ4zZ/e5ceYqnADpJd88sMSBiRk= 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=1729471595; 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=gBcmVTmdjlVx1YSjoPePx3/LQoLpGu8yyKS5g8B8j3Q=; b=HRxnN92+I8POhxf1RYKBqGlJk64RR2HEYD1BDj4K2x44SzNZObo6HwVYTIrH6VGy IzcsEDOiqKtQ2S33Z7eNRDIAf+mapElmYN4c1E4FXL+IfOVWdMsVuiCQv3JU29CuhMC QalrGqlJUQZRb293r7/mGRMUioJXCAiGQdzd88ko= 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 v7 09/38] x86/boot: transition relocation calculations to struct boot_module Date: Sun, 20 Oct 2024 20:45:44 -0400 Message-Id: <20241021004613.18793-10-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729472269698116600 Content-Type: text/plain; charset="utf-8" Use struct boot_module fields, start and size, when calculating the relocat= ion address and size. It also ensures that early_mod references are kept in syn= c. Signed-off-by: Daniel P. Smith --- Changes since v6: - introduce local s and l refs for start and size, shortening the lines whi= le correcting the indentation style Changes since v5: - removed unnecessary paddr_to_pfn, allowing condition to collapse to one l= ine - correct a missed conversion from .mod->mod_start to .start --- xen/arch/x86/setup.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 4e5d4055e7dd..b02391b887b1 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1507,7 +1507,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) * move mod[0], we incorporate this as extra space at the star= t. */ struct boot_module *bm =3D &bi->mods[j]; - unsigned long size =3D PAGE_ALIGN(bm->headroom + bm->mod->mod_= end); + unsigned long size =3D PAGE_ALIGN(bm->headroom + bm->size); =20 if ( bm->relocated ) continue; @@ -1519,15 +1519,13 @@ void asmlinkage __init noreturn __start_xen(unsigne= d long mbi_p) if ( highmem_start && end > highmem_start ) continue; =20 - if ( s < end && - (bm->headroom || - ((end - size) >> PAGE_SHIFT) > bm->mod->mod_start) ) + if ( s < end && (bm->headroom || (end - size) > bm->start) ) { - move_memory(end - size + bm->headroom, - (uint64_t)bm->mod->mod_start << PAGE_SHIFT, - bm->mod->mod_end); - bm->mod->mod_start =3D (end - size) >> PAGE_SHIFT; - bm->mod->mod_end +=3D bm->headroom; + move_memory(end - size + bm->headroom, bm->start, bm->size= ); + bm->start =3D (end - size); + bm->mod->mod_start =3D paddr_to_pfn(bm->start); + bm->size +=3D bm->headroom; + bm->mod->mod_end =3D bm->size; bm->relocated =3D true; } } @@ -1558,10 +1556,9 @@ void asmlinkage __init noreturn __start_xen(unsigned= long mbi_p) panic("Not enough memory to relocate the dom0 kernel image\n"); for ( i =3D 0; i < bi->nr_modules; ++i ) { - uint64_t s =3D (uint64_t)bi->mods[i].mod->mod_start << PAGE_SHIFT; + uint64_t s =3D bi->mods[i].start; =20 - reserve_e820_ram(&boot_e820, s, - s + PAGE_ALIGN(bi->mods[i].mod->mod_end)); + reserve_e820_ram(&boot_e820, s, s + PAGE_ALIGN(bi->mods[i].size)); } =20 if ( !xen_phys_start ) @@ -1639,8 +1636,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) map_e =3D boot_e820.map[j].addr + boot_e820.map[j].size; for ( j =3D 0; j < bi->nr_modules; ++j ) { - uint64_t end =3D pfn_to_paddr(bi->mods[j].mod->mod_sta= rt) + - bi->mods[j].mod->mod_end; + uint64_t end =3D bi->mods[j].start + bi->mods[j].size; =20 if ( map_e < end ) map_e =3D end; @@ -1714,12 +1710,10 @@ void asmlinkage __init noreturn __start_xen(unsigne= d long mbi_p) =20 for ( i =3D 0; i < bi->nr_modules; ++i ) { - set_pdx_range(bi->mods[i].mod->mod_start, - bi->mods[i].mod->mod_start + - PFN_UP(bi->mods[i].mod->mod_end)); - map_pages_to_xen((unsigned long)mfn_to_virt(bi->mods[i].mod->mod_s= tart), - _mfn(bi->mods[i].mod->mod_start), - PFN_UP(bi->mods[i].mod->mod_end), PAGE_HYPERVISOR= ); + unsigned long s =3D bi->mods[i].start, l =3D bi->mods[i].size; + set_pdx_range(paddr_to_pfn(s), paddr_to_pfn(s) + PFN_UP(l)); + map_pages_to_xen((unsigned long)maddr_to_virt(s), maddr_to_mfn(s), + PFN_UP(l), PAGE_HYPERVISOR); } =20 #ifdef CONFIG_KEXEC --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729472268; cv=pass; d=zohomail.com; s=zohoarc; b=VNmByQad297HPc5VqcdnUCze5HCH3k3v90QZisR6AeadVW/Xt80HB/9gYBNIyWEU5cbUUNgjUKGCmnOSbjSO+sLKLK0+AsH5AotrpN1eGWT4bPavzIkc+9kTq2S5Zzhp/oNOZ7NbYg/qGau6NrBhd82M7gZCOVReyIBFWUDIj50= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729472268; 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=YvJ2m/YsYOZLoEyM2p3qJT9+gJiHXjraaWi+kBWIksU=; b=bgWZHEp5IbQDV+zcE4ziQqOK5PjZLsXIOke7R8LPD9hWHNZpLOrRZrh3i3KLRx+lKQuHpvohHqvP3zEp2pEezYXJ92GZsEQXOZaCduCSdcLgMpEXRQutp4fK3D4C+eILxgGlseZTOTOnEym6ZhFYB/AsQ9dFXbP2JD8/tnWVLcY= 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 1729472268941265.40437201459565; Sun, 20 Oct 2024 17:57:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.823024.1237062 (Exim 4.92) (envelope-from ) id 1t2gjR-000744-B5; Mon, 21 Oct 2024 00:57:13 +0000 Received: by outflank-mailman (output) from mailman id 823024.1237062; Mon, 21 Oct 2024 00:57:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gjR-00073K-6y; Mon, 21 Oct 2024 00:57:13 +0000 Received: by outflank-mailman (input) for mailman id 823024; Mon, 21 Oct 2024 00:57:12 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gaF-0000Dk-3N for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:47:43 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1280206b-8f46-11ef-99a3-01e77a169b0f; Mon, 21 Oct 2024 02:47:40 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471595370855.1759275725335; Sun, 20 Oct 2024 17:46:35 -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: 1280206b-8f46-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729471597; cv=none; d=zohomail.com; s=zohoarc; b=gbTJwubuLjGLXIHRQ/v0sQ4sKwXEXkxqBfrsPp1jvJhZptzb8RFMpfMyZIUj7q8mtwRlMDPURn4xa/J/zyPhbAhvl3fEEAdDO6Zhdl2enuFsVYsN7aSPY02HX8Fqr+1ifwzL3TKspy1J/y4H1CBgguS0CihiDM1EV2vFOMC+OSY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471597; 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=YvJ2m/YsYOZLoEyM2p3qJT9+gJiHXjraaWi+kBWIksU=; b=gt0hBNrw1cMHJe7/URFosCDFGhah22QoJYaj+ufVmKPMIiBgu4n6SCJLqliVZQL3YTu/Rq0eyl/VdWvtADiNsUCJG6mv+h1i5G+yomkM7pX8AXC3JK+WuzY9TFTHhNhFKDZuQz+WYwYCucypXZ10xq8PGxHEau5eRBqIjdOhBX0= 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=1729471597; 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=YvJ2m/YsYOZLoEyM2p3qJT9+gJiHXjraaWi+kBWIksU=; b=npQB6TzqdDny8vKAgaIGczrXeIrX9nRV2oiiN7jZgbOrLzHYT2SNZc7jVV6ADErc cU9Yyt9vFu+QLm1U03yfj3Gyiibh+vIlVJ15tjtoAp2Hc12vjQmeSGcmiB3P2BPPZBd fQQXj0ANashdkWTbSFurktRqRzyoeZQBy78Tpoz4= 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 v7 10/38] x86/boot: introduce consumed flag for struct boot_module Date: Sun, 20 Oct 2024 20:45:45 -0400 Message-Id: <20241021004613.18793-11-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729472269676116600 Content-Type: text/plain; charset="utf-8" Allow the tracking of when a boot module has been consumed by a handler in = the hypervisor independent of when it is claimed. The instances where the hypervisor does nothing beyond claiming, the dom0 kernel, dom0 ramdisk, and= a placeholder for itself, are updated as being consumed at the time of being claimed. Signed-off-by: Daniel P. Smith --- Changes since v6: - changed flag from bitmap to bitfield. Changes since v5: - first flag assignment can be =3D instead of |=3D --- xen/arch/x86/include/asm/bootinfo.h | 3 +++ xen/arch/x86/setup.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index dbd22db3d063..3eb9930904c0 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -44,8 +44,11 @@ struct boot_module { /* * Module State Flags: * relocated: indicates module has been relocated in memory. + * consumed: indicates that the subystem that claimed the module has + * finished with it. */ bool relocated:1; + bool consumed:1; =20 paddr_t start; size_t size; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index b02391b887b1..a623f9cd9df9 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -335,6 +335,7 @@ static struct boot_info *__init multiboot_fill_boot_inf= o(unsigned long mbi_p) bi->mods[i].start =3D mods[i].mod_start; bi->mods[i].size =3D mods[i].mod_end - mods[i].mod_start; bi->mods[i].type =3D BOOTMOD_XEN; + bi->mods[i].consumed =3D true; =20 return bi; } @@ -1211,6 +1212,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) bitmap_fill(module_map, bi->nr_modules); __clear_bit(0, module_map); /* Dom0 kernel is always first */ bi->mods[0].type =3D BOOTMOD_KERNEL; + bi->mods[0].consumed =3D true; =20 if ( pvh_boot ) { @@ -2094,7 +2096,10 @@ void asmlinkage __init noreturn __start_xen(unsigned= long mbi_p) =20 initrdidx =3D find_first_bit(module_map, bi->nr_modules); if ( initrdidx < bi->nr_modules ) + { bi->mods[initrdidx].type =3D BOOTMOD_RAMDISK; + bi->mods[initrdidx].consumed =3D true; + } if ( bitmap_weight(module_map, bi->nr_modules) > 1 ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729472269; cv=pass; d=zohomail.com; s=zohoarc; b=nO1/2RvoYPSnDmXUBgVENZtmiaK0CDEdpHNV5cKtt/LZ5dWhlAfT4YHSaie0gdPJ+0K/sU06NKo++LtJqhJTlEaqITECJ6QuUoE9RZAsEj/M5QsWz6KG2RPjKDOpU5CHknAEcS/PrbqsIoPvBZwpqD/YlHbI2FhR94XxEg147+E= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729472269; 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=7htI5l3h8JWhW9QL/lD8LlUYIubTfk49/4+QzqSxcrQ=; b=amdCvQxA+Mu0o4Iej7avSDZa03fCQE5IM/p0bW9MYjWclnPj9CtYnWwB6Ucc+sjDEhqA6aCh2wSFyx2QfQjTOutoh9rGgbLDG1YxRhP6RvemFJERBHViY+/pIDdr7Hqol8c8wwbdBH3zSTgUI9rROt810RUXm62zH9nytvFZJKk= 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 1729472269578261.8646638148433; Sun, 20 Oct 2024 17:57:49 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.823026.1237082 (Exim 4.92) (envelope-from ) id 1t2gjV-0007qc-0X; Mon, 21 Oct 2024 00:57:17 +0000 Received: by outflank-mailman (output) from mailman id 823026.1237082; Mon, 21 Oct 2024 00:57:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gjU-0007qT-R8; Mon, 21 Oct 2024 00:57:16 +0000 Received: by outflank-mailman (input) for mailman id 823026; Mon, 21 Oct 2024 00:57:15 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gaM-0000Dk-GX for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:47:50 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 173a9453-8f46-11ef-99a3-01e77a169b0f; Mon, 21 Oct 2024 02:47:48 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471596570279.0068470318946; Sun, 20 Oct 2024 17:46:36 -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: 173a9453-8f46-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729471598; cv=none; d=zohomail.com; s=zohoarc; b=agHxrAwa/gwzl0lF5c5hip/jZgdb1dhKrC1ik3YA170glJuri75yKhD9UI67dwapoHyA9EjKvz/WXRos8xcugos7BEmfcTMQGQ6LO7gTsqyIia8uW3Y/B8ZT8EofVAwhUNlMsZNnbXEpifwh+RYSf2cOWkexOWjiIHZyqQK6M+E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471598; 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=7htI5l3h8JWhW9QL/lD8LlUYIubTfk49/4+QzqSxcrQ=; b=krd8hze8VMzYJtvT2OSd6aAWsm/sPOqLdBc2RqSKe/HKcnEW/0Mg/Du6r2FwwK9N1TM+BxxQVGLVyWwWltiHbAt8NjP59wgw39Nu9j8W9cnlQWsALVcGzyS+mY8aCgrLbwG4uQo5NokcYCywfdbmtEuucS8Pb2Mo53ur6Si1TwQ= 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=1729471598; 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=7htI5l3h8JWhW9QL/lD8LlUYIubTfk49/4+QzqSxcrQ=; b=bv47YzelbM1dTZhrhRFsvaBP0z7QgwF8k3fOdDYcVDZe2XE5Op9/ATadSWjWYUNJ 3orK/xI63WsWFuC/jdx7wcEhco1O6xUKzhIv6PRnhKCKcsh6zprhr+Um/PXSei0f+R7 JxaMfcS9mNjvckgxQloywrc8H4/mVBzrZRs/UQV8= 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 v7 11/38] x86/boot: convert microcode loading to consume struct boot_info Date: Sun, 20 Oct 2024 20:45:46 -0400 Message-Id: <20241021004613.18793-12-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729472271668116600 Content-Type: text/plain; charset="utf-8" Convert the microcode loading functions to take struct boot_info, and then using struct boot_module to map and check for microcode. To keep the changes focused, continue using the struct mod to hold the reference to the microco= de that is used by the late microcode logic. To support loading the microcode boot module in to the bootstrap map, intro= duce bootstrap_map_bm() for mapping struct boot_module. Signed-off-by: Daniel P. Smith --- Changes since v6: - introduce helpers for_each_boot_module and boot_module_index - drop const due to object use changes done by helpers - converted boot module search to use for each helper - make bootstrap unmap call match bootstrap map Changes since v5: - moved bootstrap_map_bm definition to this commit --- xen/arch/x86/cpu/microcode/core.c | 46 ++++++++++++---------------- xen/arch/x86/include/asm/bootinfo.h | 25 +++++++++++++++ xen/arch/x86/include/asm/microcode.h | 14 +++++---- xen/arch/x86/include/asm/setup.h | 2 ++ xen/arch/x86/setup.c | 12 ++++++-- 5 files changed, 65 insertions(+), 34 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index 8564e4d2c94c..11a0ba978a33 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -35,6 +35,7 @@ #include =20 #include +#include #include #include #include @@ -153,16 +154,14 @@ static int __init cf_check parse_ucode(const char *s) custom_param("ucode", parse_ucode); =20 static void __init microcode_scan_module( - unsigned long *module_map, - const multiboot_info_t *mbi) + unsigned long *module_map, struct boot_info *bi) { - module_t *mod =3D (module_t *)__va(mbi->mods_addr); uint64_t *_blob_start; unsigned long _blob_size; struct cpio_data cd; long offset; const char *p =3D NULL; - int i; + struct boot_module *bm; =20 ucode_blob.size =3D 0; if ( !ucode_scan ) @@ -178,17 +177,14 @@ static void __init microcode_scan_module( /* * Try all modules and see whichever could be the microcode blob. */ - for ( i =3D 1 /* Ignore dom0 kernel */; i < mbi->mods_count; i++ ) + for_each_boot_module(bi, bm, BOOTMOD_UNKNOWN) { - if ( !test_bit(i, module_map) ) - continue; - - _blob_start =3D bootstrap_map(&mod[i]); - _blob_size =3D mod[i].mod_end; + _blob_start =3D bootstrap_map_bm(bm); + _blob_size =3D bm->size; if ( !_blob_start ) { - printk("Could not map multiboot module #%d (size: %ld)\n", - i, _blob_size); + printk("Could not map boot module #%d (size: %ld)\n", + boot_module_index(bi, bm), _blob_size); continue; } cd.data =3D NULL; @@ -200,25 +196,23 @@ static void __init microcode_scan_module( ucode_blob.data =3D cd.data; break; } - bootstrap_map(NULL); + bootstrap_map_bm(NULL); } } =20 static void __init microcode_grab_module( - unsigned long *module_map, - const multiboot_info_t *mbi) + unsigned long *module_map, struct boot_info *bi) { - module_t *mod =3D (module_t *)__va(mbi->mods_addr); - if ( ucode_mod_idx < 0 ) - ucode_mod_idx +=3D mbi->mods_count; - if ( ucode_mod_idx <=3D 0 || ucode_mod_idx >=3D mbi->mods_count || + ucode_mod_idx +=3D bi->nr_modules; + if ( ucode_mod_idx <=3D 0 || ucode_mod_idx >=3D bi->nr_modules || !__test_and_clear_bit(ucode_mod_idx, module_map) ) goto scan; - ucode_mod =3D mod[ucode_mod_idx]; + bi->mods[ucode_mod_idx].type =3D BOOTMOD_MICROCODE; + ucode_mod =3D *bi->mods[ucode_mod_idx].mod; scan: if ( ucode_scan ) - microcode_scan_module(module_map, mbi); + microcode_scan_module(module_map, bi); } =20 static struct microcode_ops __ro_after_init ucode_ops; @@ -822,8 +816,8 @@ static int __init early_update_cache(const void *data, = size_t len) return rc; } =20 -int __init microcode_init_cache(unsigned long *module_map, - const struct multiboot_info *mbi) +int __init microcode_init_cache( + unsigned long *module_map, struct boot_info *bi) { int rc =3D 0; =20 @@ -832,7 +826,7 @@ int __init microcode_init_cache(unsigned long *module_m= ap, =20 if ( ucode_scan ) /* Need to rescan the modules because they might have been relocat= ed */ - microcode_scan_module(module_map, mbi); + microcode_scan_module(module_map, bi); =20 if ( ucode_mod.mod_end ) rc =3D early_update_cache(bootstrap_map(&ucode_mod), @@ -879,7 +873,7 @@ static int __init early_microcode_update_cpu(void) } =20 int __init early_microcode_init(unsigned long *module_map, - const struct multiboot_info *mbi) + struct boot_info *bi) { const struct cpuinfo_x86 *c =3D &boot_cpu_data; int rc =3D 0; @@ -922,7 +916,7 @@ int __init early_microcode_init(unsigned long *module_m= ap, return -ENODEV; } =20 - microcode_grab_module(module_map, mbi); + microcode_grab_module(module_map, bi); =20 if ( ucode_mod.mod_end || ucode_blob.size ) rc =3D early_microcode_update_cpu(); diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index 3eb9930904c0..e470df48700d 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -20,6 +20,7 @@ enum bootmod_type { BOOTMOD_XEN, BOOTMOD_KERNEL, BOOTMOD_RAMDISK, + BOOTMOD_MICROCODE, }; =20 struct boot_module { @@ -69,6 +70,30 @@ struct boot_info { struct boot_module mods[MAX_NR_BOOTMODS + 1]; }; =20 +static inline struct boot_module *__init next_boot_module_by_type( + struct boot_info *bi, struct boot_module *bm, enum bootmod_type t) +{ + if ( bm =3D=3D NULL ) + bm =3D &bi->mods[0]; + else + bm++; + + for ( ; bm <=3D &bi->mods[bi->nr_modules]; bm++ ) + { + if ( bm->type =3D=3D t ) + return bm; + } + + return NULL; +} + +#define for_each_boot_module(bi, bm, t) = \ + for ( bm =3D &bi->mods[0]; bm !=3D NULL && bm <=3D &bi->mods[bi->nr_mo= dules]; \ + bm =3D next_boot_module_by_type(bi, bm, t) ) + +#define boot_module_index(bi, bm) \ + (unsigned int)(bm - &bi->mods[0]) + #endif /* X86_BOOTINFO_H */ =20 /* diff --git a/xen/arch/x86/include/asm/microcode.h b/xen/arch/x86/include/as= m/microcode.h index 57c08205d475..9e7c7ab004ed 100644 --- a/xen/arch/x86/include/asm/microcode.h +++ b/xen/arch/x86/include/asm/microcode.h @@ -4,6 +4,8 @@ #include #include =20 +#include + #include =20 struct multiboot_info; @@ -22,12 +24,12 @@ struct cpu_signature { DECLARE_PER_CPU(struct cpu_signature, cpu_sig); =20 void microcode_set_module(unsigned int idx); -int microcode_update(XEN_GUEST_HANDLE(const_void) buf, - unsigned long len, unsigned int flags); -int early_microcode_init(unsigned long *module_map, - const struct multiboot_info *mbi); -int microcode_init_cache(unsigned long *module_map, - const struct multiboot_info *mbi); +int microcode_update( + XEN_GUEST_HANDLE(const_void) buf, unsigned long len, unsigned int flag= s); +int early_microcode_init( + unsigned long *module_map, struct boot_info *bi); +int microcode_init_cache( + unsigned long *module_map, struct boot_info *bi); int microcode_update_one(void); =20 #endif /* ASM_X86__MICROCODE_H */ diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/se= tup.h index 3d189521189d..729f68ca23b8 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -2,6 +2,7 @@ #define __X86_SETUP_H_ =20 #include +#include #include =20 extern const char __2M_text_start[], __2M_text_end[]; @@ -37,6 +38,7 @@ extern struct boot_info xen_boot_info; unsigned long initial_images_nrpages(nodeid_t node); void discard_initial_images(void); void *bootstrap_map(const module_t *mod); +void *bootstrap_map_bm(const struct boot_module *bm); =20 int remove_xen_ranges(struct rangeset *r); =20 diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index a623f9cd9df9..272d5a725c54 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -499,6 +499,14 @@ void *__init bootstrap_map(const module_t *mod) pfn_to_paddr(mod->mod_start) + mod->mod_end); } =20 +void *__init bootstrap_map_bm(const struct boot_module *bm) +{ + if ( !bm ) + return bootstrap_map_addr(0, 0); + + return bootstrap_map_addr(bm->start, bm->start + bm->size); +} + static void __init move_memory( uint64_t dst, uint64_t src, unsigned int size) { @@ -1401,7 +1409,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) * TODO: load ucode earlier once multiboot modules become accessible * at an earlier stage. */ - early_microcode_init(module_map, mbi); + early_microcode_init(module_map, bi); =20 if ( xen_phys_start ) { @@ -1948,7 +1956,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) =20 timer_init(); =20 - microcode_init_cache(module_map, mbi); /* Needs xmalloc() */ + microcode_init_cache(module_map, bi); /* Needs xmalloc() */ =20 tsx_init(); /* Needs microcode. May change HLE/RTM feature bits. */ =20 --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729472229; cv=pass; d=zohomail.com; s=zohoarc; b=d3kOCQkHLo7oFUuHyPvZksiDZ4A9bXwyrRQwV9/ba/n34D/tbyo8OkxfIgfbLwvErC39C0a0nwwFJ4IiDUmVO+qYgOSMrFgJFMcUmfYS/DTgd/juoTdOE2PS9IRJTUPgEGVWLTru2a5YM2nSlWW+JXXMxuxeIyxNoT6y+yqTU5s= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729472229; 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=bzqdIFigmmAvQphctRGkKTNha+8Q/o+Qc2uZk2PQ5ls=; b=aTDw1jMoFV1WFez4OSPApk1FraRiHYjQ0ZdQTNfQjHUpVeK8XrKTAgOgjjEIUj5kMlvYRhQXmjCDagVI1C2/omAEBoaAgqjPp+yE8XpG8w8aPuRHyQ3Oz+5SX6Xw3STsgWeqxu2TZXfWyydsInfGf67HUFdXx05RaQ8kJ1B9QS0= 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 1729472229154996.8645628938641; Sun, 20 Oct 2024 17:57:09 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822986.1237007 (Exim 4.92) (envelope-from ) id 1t2gj1-0002vD-DL; Mon, 21 Oct 2024 00:56:47 +0000 Received: by outflank-mailman (output) from mailman id 822986.1237007; Mon, 21 Oct 2024 00:56:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gj1-0002u2-7D; Mon, 21 Oct 2024 00:56:47 +0000 Received: by outflank-mailman (input) for mailman id 822986; Mon, 21 Oct 2024 00:56:45 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gaU-0000Dk-AN for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:47:58 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1bf5744c-8f46-11ef-99a3-01e77a169b0f; Mon, 21 Oct 2024 02:47:56 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471597726785.8559370322578; Sun, 20 Oct 2024 17:46:37 -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: 1bf5744c-8f46-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729471599; cv=none; d=zohomail.com; s=zohoarc; b=X+3TCbeo8SmNMU9UwPqg1IKuN36QkJXjUTY3gA2tC3JG7Xkb0Qmi7cbhb7hWOuFPzrLpaoIQQ0F+0pm0X/OeNjLrmQodiXopAkI+yy+wAzByhcUcB3cqTEktyZjwgSiPsXKmwaQjMhdhFzvuDTqqr1sMh9gdPVHYlGNdDTYL5zI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471599; 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=bzqdIFigmmAvQphctRGkKTNha+8Q/o+Qc2uZk2PQ5ls=; b=ZaulxndFMT2r5ys1DpEMqUHNNS+nEGVjApZiM/atcMP3q35mP35jFvfeiqDL8ozWyahsLgHnsQ18VsFA1C1d7C9ZCt4MK6iwKnLWF3m1W/CNqzEmyuVQc2xzHcRc9433VAznwfO4lpxaiLQPG+pSFtqtTlX7UHvrykhmav9tzLg= 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=1729471599; 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=bzqdIFigmmAvQphctRGkKTNha+8Q/o+Qc2uZk2PQ5ls=; b=KiIBgvELDEgCKkFTWgXnf/yo3oaM8JBS6dgzQkvEICbVszn+n9T7GzmPgOv7GCr5 iMrkQI4uA5kWfBQfZaug8q0eP8ELmz0ij1lsbVy3GuzkzfAWME3CS9vg+HLbGC7WiEy j90hVy5AHWa241UZW16OlULSYQskT30UpJQsVt0w= 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 v7 12/38] x86/boot: convert late microcode loading to struct boot_module Date: Sun, 20 Oct 2024 20:45:47 -0400 Message-Id: <20241021004613.18793-13-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729472229568116600 Content-Type: text/plain; charset="utf-8" Remove the use of struct mod to hold the reference for the microcode, converting the code to work with a struct boot_module. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- xen/arch/x86/cpu/microcode/core.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index 11a0ba978a33..b6badd9afdb2 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -59,7 +58,7 @@ */ #define MICROCODE_UPDATE_TIMEOUT_US 1000000 =20 -static module_t __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; @@ -98,7 +97,7 @@ struct patch_with_flags { =20 static struct ucode_mod_blob __initdata ucode_blob; /* - * By default we will NOT parse the multiboot modules to see if there is + * By default we will NOT parse the boot modules to see if there is * cpio image with the microcode images. */ static bool __initdata ucode_scan; @@ -209,7 +208,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].mod; + ucode_mod =3D bi->mods[ucode_mod_idx]; scan: if ( ucode_scan ) microcode_scan_module(module_map, bi); @@ -763,14 +762,14 @@ static int __init cf_check microcode_init(void) */ if ( ucode_blob.size ) { - bootstrap_map(NULL); + bootstrap_map_bm(NULL); ucode_blob.size =3D 0; ucode_blob.data =3D NULL; } - else if ( ucode_mod.mod_end ) + else if ( ucode_mod.size ) { - bootstrap_map(NULL); - ucode_mod.mod_end =3D 0; + bootstrap_map_bm(NULL); + ucode_mod.size =3D 0; } =20 return 0; @@ -828,9 +827,9 @@ int __init microcode_init_cache( /* Need to rescan the modules because they might have been relocat= ed */ microcode_scan_module(module_map, bi); =20 - if ( ucode_mod.mod_end ) - rc =3D early_update_cache(bootstrap_map(&ucode_mod), - ucode_mod.mod_end); + if ( ucode_mod.size ) + rc =3D early_update_cache(bootstrap_map_bm(&ucode_mod), + ucode_mod.size); else if ( ucode_blob.size ) rc =3D early_update_cache(ucode_blob.data, ucode_blob.size); =20 @@ -849,10 +848,10 @@ static int __init early_microcode_update_cpu(void) len =3D ucode_blob.size; data =3D ucode_blob.data; } - else if ( ucode_mod.mod_end ) + else if ( ucode_mod.size ) { - len =3D ucode_mod.mod_end; - data =3D bootstrap_map(&ucode_mod); + len =3D ucode_mod.size; + data =3D bootstrap_map_bm(&ucode_mod); } =20 if ( !data ) @@ -918,7 +917,7 @@ int __init early_microcode_init(unsigned long *module_m= ap, =20 microcode_grab_module(module_map, bi); =20 - if ( ucode_mod.mod_end || ucode_blob.size ) + if ( ucode_mod.size || ucode_blob.size ) rc =3D early_microcode_update_cpu(); =20 /* --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729472229; cv=pass; d=zohomail.com; s=zohoarc; b=MvaGrhV0/dB2xYRIUhVoe9lvhm+jY5/tSdp+YF8ufgVK6pMYRGrPwe9yQbE/P3yxW2N5KHAYM0NVoIFNvIUIFnMZdN9LlEYUNT/7DPMPlvvNQxI3qsWiSs7KhkDvzlU0vIRZhHZA5zDsd1P5ygilPFZkW3pOYR01gu2myPbGpBg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729472229; 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=iJYAb243RSTcsTIRrMAmS03Q6YE6d276D7BTcoq1ZCs=; b=eKswks7Ax1kqCMLV57IS790KZxf2Wb/JuKiqk2o+6QiXBCQQZt8JP/i/wtbn2ApeBAGsvsZXOQZmyWzbRfuL9Av313H3sZkQYaeZT1C0Lscxlaxqqrm7PRjUvUfr6x16/vgGQxfxM8j01I7ByzHFRvNwOR7MU6+vL2xL0jEPuyE= 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 1729472229154103.09197156459925; Sun, 20 Oct 2024 17:57:09 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822984.1236992 (Exim 4.92) (envelope-from ) id 1t2giy-0002Q8-AF; Mon, 21 Oct 2024 00:56:44 +0000 Received: by outflank-mailman (output) from mailman id 822984.1236992; Mon, 21 Oct 2024 00:56:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2giy-0002Px-6O; Mon, 21 Oct 2024 00:56:44 +0000 Received: by outflank-mailman (input) for mailman id 822984; Mon, 21 Oct 2024 00:56:43 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gad-0000Dk-MG for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:48:07 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 210e2bd8-8f46-11ef-99a3-01e77a169b0f; Mon, 21 Oct 2024 02:48:05 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471598854865.3394944103438; Sun, 20 Oct 2024 17:46:38 -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: 210e2bd8-8f46-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729471600; cv=none; d=zohomail.com; s=zohoarc; b=HKsQ+Zjc8MHAZ9nbxHOQxCY2PCzIFFbWhfNagWs5LlGQst96aMMpOka9UCGu7jv82KF6qsk+Rhbyo9rXF6znIFMHWkJMFnk/iwn5n71hgNw+5X0uUyLIQyNLyeXPro0G+pZ+oUFtWfuWhOJJ81o0GAxsBn0u+KR/LcsIIXX0K4c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471600; 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=iJYAb243RSTcsTIRrMAmS03Q6YE6d276D7BTcoq1ZCs=; b=K3fNOycSd7lD+iBLFIiHKDgbwMEF/AoUhruFNoxHxLElYjJhusdvZV3XLVOkSwxGEfvEpW/DxZ1vZOyoC3v0pbSMiyPRJ3JbYkf2NXbzEJx8cNLAU2yDAqn5/3WrAYry8aE4LuoorKTYG9nIpHR3wPp7UVj89l0F3CHP+8+meC0= 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=1729471600; 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=iJYAb243RSTcsTIRrMAmS03Q6YE6d276D7BTcoq1ZCs=; b=C1f/HYbThMei6aNxR4f+zW5r+znqk5ySicMDC6HNothbMqcr1bXAB1d0PObo/MuZ tjf44f+RFmHGSEEF595OxYbQVN0nxo/dxGWg9yImIsAuOb0RObq1qcxG+O3YhHrIzsu Cdl0Kc/Nc51+I2WdiOYtjtlFUGxPeNIq4R+9XREg= 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 v7 13/38] x86/boot: use consumed boot module flag for microcode Date: Sun, 20 Oct 2024 20:45:48 -0400 Message-Id: <20241021004613.18793-14-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729472229546116600 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 --- Changes since v6: - adjust logic to the change of consumed flag to being a bitfield --- 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 b6badd9afdb2..8ea789dceec2 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; @@ -208,7 +208,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); @@ -766,10 +766,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->consumed ) { bootstrap_map_bm(NULL); - ucode_mod.size =3D 0; + ucode_mod->consumed =3D true; } =20 return 0; @@ -823,14 +823,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->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; @@ -848,10 +848,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->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 ) @@ -917,7 +917,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 From nobody Wed Dec 4 09:14:19 2024 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=1729471715; cv=pass; d=zohomail.com; s=zohoarc; b=YLyLQikRb89MtwtbtvEE4KcS/nOZhb53HaJXSKYBPPwJKq8wnLtd9mtAWkK0S1c208U3H2mve19AxUzbGg1Q375hirc21QhKZrM6YypH4zBM95FKfoM+dQj/JFnoLtY9c1TSuomK6a5DjeMd+//vF1k5QXKmqMwPXEoN+tgSJco= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471715; 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=rCqjXfRhQzYVNQ0/zCmbI25PcWcrpjQT5dqAU64Gu4k=; b=lixrpWzg6ESiQ7LAvAung2tGsKsD7g9K9isLstCFBtOimsvwhh+eLcWfTTwXbJ8YYHa977Jkr4CqmQm9tAL4gtUwiU/10gdkag6tp7Ud6wh4/jnSHEIjAwn8b18G8+d00wnLd2Nmm49NLdhzLxWVfRZ1rZz41EwCJG+8exQdCtk= 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 1729471715095779.62115068965; Sun, 20 Oct 2024 17:48:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822902.1236822 (Exim 4.92) (envelope-from ) id 1t2gam-0001iG-7X; Mon, 21 Oct 2024 00:48:16 +0000 Received: by outflank-mailman (output) from mailman id 822902.1236822; Mon, 21 Oct 2024 00:48:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gam-0001i9-46; Mon, 21 Oct 2024 00:48:16 +0000 Received: by outflank-mailman (input) for mailman id 822902; Mon, 21 Oct 2024 00:48:15 +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 1t2gal-0001i1-5z for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:48:15 +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 265c702e-8f46-11ef-a0be-8be0dac302b0; Mon, 21 Oct 2024 02:48:14 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471600038731.5465299032828; Sun, 20 Oct 2024 17:46:40 -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: 265c702e-8f46-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729471602; cv=none; d=zohomail.com; s=zohoarc; b=R5C/6c72qx+Pv8oreNCXC4DXvp/5JJnmlv/xclSb5BsT0ZdTpN3y4h2M4kFMirySA5JTOFHKNFUEiqU4feYkIjr6+Jv3yU731SSWY6rZRItFchQFW7nv1XxJzyx04RhbxJM6LM70y8a2KbRz6lJWsTBXm1/T6aQXEK0jNGFOGB0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471602; 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=rCqjXfRhQzYVNQ0/zCmbI25PcWcrpjQT5dqAU64Gu4k=; b=lPzVPPQ3chk7ME56/x00Apav5fW5vjhbd9aysGtiPFmTQQQgCmw4zRHqbh3/aK3TFRSt8oDJaAI2WleAUMcdEpsLrAPljTUkARA9g8vQJ2jIK4384oOfiZarTWy9X2O+D1sGY0CJ3BO+FD98oUj7QobgJ6LPfFhp0/+t87tVwCU= 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=1729471602; 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=rCqjXfRhQzYVNQ0/zCmbI25PcWcrpjQT5dqAU64Gu4k=; b=bf4RE0epFdDbi2YeS7igOMlUsKCKEolaFHUl/BiUULa0RFPS60biKwgRqtVSnA5H YYniQlmasSFzxiSb40XP/+DNeUn1nK/feS03dbKzNI+6lMbefbF+oWG/37nvQBrukCw td96MHar5aOqNCcxHU5R3FRLQd9A4tdidC5JQiP8= 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 v7 14/38] x86/boot: convert xsm policy loading to struct boot_module Date: Sun, 20 Oct 2024 20:45:49 -0400 Message-Id: <20241021004613.18793-15-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729471715605116600 Content-Type: text/plain; charset="utf-8" Iterate through the unclaimed boot modules to see if any are an XSM FLASK policy. If one is located, mark it as an xsm policy. To assist with looking up the index of the xsm policy in the boot module ar= ray, an iterator is provided. Signed-off-by: Daniel P. Smith --- Changes since v6: - converted boot module walk over to for each helper - slight reword of commit message - merged the interator patch with its first usage by XSM - corrected the short-circuit return value for Xen in the interator - dropped R-b due to merging with patch not approved. Changes since v5: - replaced bootstrap_map with bootstrap_map_bm - make init function definitions consistent in dropping const on *bi --- xen/arch/x86/include/asm/bootinfo.h | 30 ++++++++++++++++++++++++++++- xen/arch/x86/setup.c | 2 +- xen/include/xsm/xsm.h | 11 +++++++---- xen/xsm/xsm_core.c | 17 ++++++++++++---- xen/xsm/xsm_policy.c | 20 +++++++++---------- 5 files changed, 59 insertions(+), 21 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index e470df48700d..3ca56454c4d7 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -21,6 +21,7 @@ enum bootmod_type { BOOTMOD_KERNEL, BOOTMOD_RAMDISK, BOOTMOD_MICROCODE, + BOOTMOD_XSM_POLICY, }; =20 struct boot_module { @@ -94,8 +95,35 @@ static inline struct boot_module *__init next_boot_modul= e_by_type( #define boot_module_index(bi, bm) \ (unsigned int)(bm - &bi->mods[0]) =20 -#endif /* X86_BOOTINFO_H */ +/* + * next_boot_module_index: + * Finds the next boot module of type t, starting at array index start. + * + * Returns: + * Success - index in boot_module array + * Failure - a value greater than MAX_NR_BOOTMODS + */ +static inline unsigned int __init next_boot_module_index( + const struct boot_info *bi, enum bootmod_type t, unsigned int start) +{ + unsigned int i; + + if ( t =3D=3D BOOTMOD_XEN ) + return bi->nr_modules; + + for ( i =3D start; i < bi->nr_modules; i++ ) + { + if ( bi->mods[i].type =3D=3D t ) + return i; + } + + return MAX_NR_BOOTMODS + 1; +} + +#define first_boot_module_index(bi, t) \ + next_boot_module_index(bi, t, 0) =20 +#endif /* X86_BOOTINFO_H */ /* * Local variables: * mode: C diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 272d5a725c54..ed1d89ad4bb4 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1882,7 +1882,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) mmio_ro_ranges =3D rangeset_new(NULL, "r/o mmio ranges", RANGESETF_prettyprint_hex); =20 - xsm_multiboot_init(module_map, mbi); + xsm_multiboot_init(module_map, bi); =20 /* * IOMMU-related ACPI table parsing may require some of the system dom= ains diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index 627c0d2731af..f155d10e718c 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -17,7 +17,10 @@ =20 #include #include -#include + +#ifdef CONFIG_MULTIBOOT +#include +#endif =20 /* policy magic number (defined by XSM_MAGIC) */ typedef uint32_t xsm_magic_t; @@ -779,9 +782,9 @@ static inline int xsm_argo_send(const struct domain *d,= const struct domain *t) =20 #ifdef CONFIG_MULTIBOOT int xsm_multiboot_init( - unsigned long *module_map, const multiboot_info_t *mbi); + unsigned long *module_map, struct boot_info *bi); int xsm_multiboot_policy_init( - unsigned long *module_map, const multiboot_info_t *mbi, + unsigned long *module_map, struct boot_info *bi, void **policy_buffer, size_t *policy_size); #endif =20 @@ -829,7 +832,7 @@ static const inline struct xsm_ops *silo_init(void) =20 #ifdef CONFIG_MULTIBOOT static inline int xsm_multiboot_init ( - unsigned long *module_map, const multiboot_info_t *mbi) + unsigned long *module_map, struct boot_info *bi) { return 0; } diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c index eaa028109bde..234b39de7a1d 100644 --- a/xen/xsm/xsm_core.c +++ b/xen/xsm/xsm_core.c @@ -21,6 +21,7 @@ #ifdef CONFIG_XSM =20 #ifdef CONFIG_MULTIBOOT +#include #include #endif =20 @@ -140,7 +141,7 @@ static int __init xsm_core_init(const void *policy_buff= er, size_t policy_size) =20 #ifdef CONFIG_MULTIBOOT int __init xsm_multiboot_init( - unsigned long *module_map, const multiboot_info_t *mbi) + unsigned long *module_map, struct boot_info *bi) { int ret =3D 0; void *policy_buffer =3D NULL; @@ -150,18 +151,26 @@ int __init xsm_multiboot_init( =20 if ( XSM_MAGIC ) { - ret =3D xsm_multiboot_policy_init(module_map, mbi, &policy_buffer, + ret =3D xsm_multiboot_policy_init(module_map, bi, &policy_buffer, &policy_size); if ( ret ) { - bootstrap_map(NULL); + bootstrap_map_bm(NULL); printk(XENLOG_ERR "Error %d initializing XSM policy\n", ret); return -EINVAL; } } =20 ret =3D xsm_core_init(policy_buffer, policy_size); - bootstrap_map(NULL); + if ( ret =3D=3D 0 ) + { + int idx =3D first_boot_module_index(bi, BOOTMOD_XSM_POLICY); + + /* If the policy was loaded from a boot module, mark it consumed */ + if ( idx >=3D 0 ) + bi->mods[idx].consumed =3D true; + } + bootstrap_map_bm(NULL); =20 return 0; } diff --git a/xen/xsm/xsm_policy.c b/xen/xsm/xsm_policy.c index 8dafbc93810f..9fb8563eb571 100644 --- a/xen/xsm/xsm_policy.c +++ b/xen/xsm/xsm_policy.c @@ -21,6 +21,7 @@ #include #ifdef CONFIG_MULTIBOOT #include +#include #include #endif #include @@ -31,26 +32,22 @@ =20 #ifdef CONFIG_MULTIBOOT int __init xsm_multiboot_policy_init( - unsigned long *module_map, const multiboot_info_t *mbi, + unsigned long *module_map, struct boot_info *bi, void **policy_buffer, size_t *policy_size) { - int i; - module_t *mod =3D (module_t *)__va(mbi->mods_addr); int rc =3D 0; u32 *_policy_start; unsigned long _policy_len; + struct boot_module *bm; =20 /* * Try all modules and see whichever could be the binary policy. * Adjust module_map for the module that is the binary policy. */ - for ( i =3D mbi->mods_count-1; i >=3D 1; i-- ) + for_each_boot_module(bi, bm, BOOTMOD_UNKNOWN) { - if ( !test_bit(i, module_map) ) - continue; - - _policy_start =3D bootstrap_map(mod + i); - _policy_len =3D mod[i].mod_end; + _policy_start =3D bootstrap_map_bm(bm); + _policy_len =3D bm->size; =20 if ( (xsm_magic_t)(*_policy_start) =3D=3D XSM_MAGIC ) { @@ -60,12 +57,13 @@ int __init xsm_multiboot_policy_init( printk("Policy len %#lx, start at %p.\n", _policy_len,_policy_start); =20 - __clear_bit(i, module_map); + __clear_bit(boot_module_index(bi, bm), module_map); + bm->type =3D BOOTMOD_XSM_POLICY; break; =20 } =20 - bootstrap_map(NULL); + bootstrap_map_bm(NULL); } =20 return rc; --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729471715; cv=pass; d=zohomail.com; s=zohoarc; b=dKp8/pzcNEfgamEe8Hoa0cNzcNqUnrBTjdzzvGxuYjpL8G2qIf1VaAcxbmTXzxDgYGfUnXKJrma6b/ayYoaaS0hYZePdyKqz5si+Pf49Nat6p9D0ibHfLDxJ0+8dtBTY6grC0TWddB+RB7jlqY9Vc30NmcURIAlLg4YgSHX6NrA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471715; 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=JxNA2AykQl5CnA7b5uvq1Eui/yHAxLJ9Nq2owH5nUvw=; b=lX2H+P9MKa2mxH4gmS6Ear1TKDcaZv4sImoWj2VDH9DQ9jMY9EMVIGZOd+Z93k14wHLV7TWZ7RFGkpbd/4SstEsRXkHG8LSKX2G/e3Fjum2jVOK/jVKuQCmWG1Xth3WD5lq+oOzYALdco+dwFjZPCPslPYwGqJY5GJxHzLlVo+k= 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 172947171554343.6207250832457; Sun, 20 Oct 2024 17:48:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822903.1236833 (Exim 4.92) (envelope-from ) id 1t2gat-0001zg-FX; Mon, 21 Oct 2024 00:48:23 +0000 Received: by outflank-mailman (output) from mailman id 822903.1236833; Mon, 21 Oct 2024 00:48:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gat-0001zX-Al; Mon, 21 Oct 2024 00:48:23 +0000 Received: by outflank-mailman (input) for mailman id 822903; Mon, 21 Oct 2024 00:48:21 +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 1t2gar-0001i1-Tc for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:48:21 +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 2a91c9af-8f46-11ef-a0be-8be0dac302b0; Mon, 21 Oct 2024 02:48:21 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471601162568.064054440376; Sun, 20 Oct 2024 17:46:41 -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: 2a91c9af-8f46-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729471603; cv=none; d=zohomail.com; s=zohoarc; b=GKyqfDqbEeKuQwWQLYdew4J4KatT5pV9ciu2/Ss2y8YRrWd87Ypz7quKGsMRZShfUHNDGKHl1DAFF+b5wELtn+IDAMjSuwkYQqQtNreS9fqJWm1+2VKBGw5gqycSOJR8PuQy4/kElkpbUbxQKWBvEfolPTxozjpxIN3rZ090kUI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471603; 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=JxNA2AykQl5CnA7b5uvq1Eui/yHAxLJ9Nq2owH5nUvw=; b=mepFKoE+xjEfcmC40Mv0inMPwwP9gHxtl5NXwixspgFXXfh+I+G6Oga4UEHTZjOI/Oz+rDDI7EoMfGd4QrPc+/NFu7HBFbhYAVZPp0pOkHdoNmVYDwLmgJuerZVqohN8QmMsbQH6MpojLpiZL+KyJfQTSmnmA3SEOrSw6b3g/Uk= 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=1729471602; 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=JxNA2AykQl5CnA7b5uvq1Eui/yHAxLJ9Nq2owH5nUvw=; b=SvSOd9o818hytF1kasZynjnxEMsP8mqfkLNEGAAbVV7eVDAdhRfHs43MzXkkrKEm q4Re16DD/BKV+s7VH/XiPX6IMceIDOv4OVS2iIGjCR4QcxnZ6fGCCQAvpMm/EVgTHi3 G9IinW38hIP9aGbMAAWrkX2rg0fqjlQQ8GgGXJK0= 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 v7 15/38] x86/boot: convert ramdisk locating to struct boot_module Date: Sun, 20 Oct 2024 20:45:50 -0400 Message-Id: <20241021004613.18793-16-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729471717546116600 Content-Type: text/plain; charset="utf-8" Locate the first unclaimed struct boot_module and mark it as ramdisk. If th= ere are any remaining unclaimed struct boot_module instances, report to the console. In the change, the new boot module iterator is used to find the initrd index, which returns a signed int. Switch initrdidx from unsigned to signed. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v5: - adjusted initrdidx check for prior changes to boot module search function --- xen/arch/x86/setup.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index ed1d89ad4bb4..153d361793c1 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -2102,16 +2102,23 @@ void asmlinkage __init noreturn __start_xen(unsigne= d long mbi_p) cpu_has_nx ? XENLOG_INFO : XENLOG_WARNING "Warning: ", cpu_has_nx ? "" : "not "); =20 - initrdidx =3D find_first_bit(module_map, bi->nr_modules); - if ( initrdidx < bi->nr_modules ) + /* + * At this point all capabilities that consume boot modules should have + * claimed their boot modules. Find the first unclaimed boot module and + * claim it as the initrd ramdisk. Do a second search to see if there = are + * any remaining unclaimed boot modules, and report them as unusued in= itrd + * candidates. + */ + initrdidx =3D first_boot_module_index(bi, BOOTMOD_UNKNOWN); + if ( initrdidx < MAX_NR_BOOTMODS ) { bi->mods[initrdidx].type =3D BOOTMOD_RAMDISK; bi->mods[initrdidx].consumed =3D true; + if ( first_boot_module_index(bi, BOOTMOD_UNKNOWN) < MAX_NR_BOOTMOD= S ) + printk(XENLOG_WARNING + "Multiple initrd candidates, picking module #%u\n", + initrdidx); } - if ( bitmap_weight(module_map, bi->nr_modules) > 1 ) - printk(XENLOG_WARNING - "Multiple initrd candidates, picking module #%u\n", - initrdidx); =20 /* * We're going to setup domain0 using the module(s) that we stashed sa= fely --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729471730; cv=pass; d=zohomail.com; s=zohoarc; b=CZdtBFAvoyGeIVi2IEOF0BfjZ5UMGAw48lenmYAvTK+De44bST/1R8cIEju2gsm3bCVl945RZaF9AwafSOLchx3nZ/XibYni5FViSqDjRg2jnPUxZRnwVh5GHWKs91J2NqqlVpmN1CcAYA/MIPKwPaJoOhjzgJGv8TeAq+R0cMw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471730; 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=1DlKXsrl8Pt4Zb3FNGx3fPisFvIcfKzE2I6khDAdJVU=; b=FZL6ETFj2fug+RkU0R7MznIBc0M3R4sw93bhFh17whiysPh2i6vf1I0qcJLY3XMVQ0+fxDPM0lNUMILVyCkFWa0R78jH+Q1BlJLv3/PvMBSNfKdn9VxHaYMdZ4mg5nT0r8E9Rp6qCUC1pwrdwvNt+152W/v/yi9+Rw8wmSHov8Q= 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 1729471730303978.7319475275992; Sun, 20 Oct 2024 17:48:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822904.1236842 (Exim 4.92) (envelope-from ) id 1t2gb0-0002OW-Mf; Mon, 21 Oct 2024 00:48:30 +0000 Received: by outflank-mailman (output) from mailman id 822904.1236842; Mon, 21 Oct 2024 00:48:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gb0-0002ON-JZ; Mon, 21 Oct 2024 00:48:30 +0000 Received: by outflank-mailman (input) for mailman id 822904; Mon, 21 Oct 2024 00:48:29 +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 1t2gaz-0001i1-DR for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:48:29 +0000 Received: from sender3-of-o58.zoho.com (sender3-of-o58.zoho.com [136.143.184.58]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2f295301-8f46-11ef-a0be-8be0dac302b0; Mon, 21 Oct 2024 02:48:28 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471602382953.3963286856804; Sun, 20 Oct 2024 17:46:42 -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: 2f295301-8f46-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729471603; cv=none; d=zohomail.com; s=zohoarc; b=ffjeDt3vlGThPv2nGih5zq6NopZoxBvcvG5nslxFWuPr28L4i22uCe1sQvZwCIX85CDHqMwW2Va9QgGRPL6r/ZVd+7rlPTudkLu28MSyu4u89o7JfPL7Id/i0/737PxbZvx7LKlJtIfy/Fh4SSMGuVIyA0fSMnazdMEv+0wzIe8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471603; 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=1DlKXsrl8Pt4Zb3FNGx3fPisFvIcfKzE2I6khDAdJVU=; b=WOeS81PAEGUyIUJI1hRr+RA1Tvfhc4b2EIs7lKgj9qeQVn3a4rSco0Kqz1tfAwvy2OmScMW1dKXwTKDbtwHZfzzE3nc0/CWPp908gXgl5/ueA5/cA+F7UCBwGVsecxb5mGBLT4tEIPSYCJlzxgURm9z4oD1OZSVaxg5nwn/3Ft8= 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=1729471603; 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=1DlKXsrl8Pt4Zb3FNGx3fPisFvIcfKzE2I6khDAdJVU=; b=R7IMpvaeD/MFXuaEPG7e7FHgRQiQbruUh3NpNGB7hrDym0oPyPmRKUNKc6ZtQpdC jECE4biceXaQiMp5JX7W3btUEhC56nSa56dUj73Z0b83ioMSZdJyf/0OzwleT4mz2l+ VEDNn8buWZwMISXBVU/rl6jMrUCbVCcDaAjnDGXA= 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 v7 16/38] x86/boot: remove module_map usage from microcode loading Date: Sun, 20 Oct 2024 20:45:51 -0400 Message-Id: <20241021004613.18793-17-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729471731844116600 Content-Type: text/plain; charset="utf-8" With all consumers of module_map converted, remove usage of it by the microcode loading logic. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v5: - dropped unnecessary parens --- xen/arch/x86/cpu/microcode/core.c | 20 ++++++++------------ xen/arch/x86/include/asm/microcode.h | 6 ++---- xen/arch/x86/setup.c | 4 ++-- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index 8ea789dceec2..938dfd74a9f1 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -152,8 +152,7 @@ static int __init cf_check parse_ucode(const char *s) } custom_param("ucode", parse_ucode); =20 -static void __init microcode_scan_module( - unsigned long *module_map, struct boot_info *bi) +static void __init microcode_scan_module(struct boot_info *bi) { uint64_t *_blob_start; unsigned long _blob_size; @@ -199,19 +198,18 @@ static void __init microcode_scan_module( } } =20 -static void __init microcode_grab_module( - unsigned long *module_map, struct boot_info *bi) +static void __init microcode_grab_module(struct boot_info *bi) { if ( ucode_mod_idx < 0 ) ucode_mod_idx +=3D bi->nr_modules; if ( ucode_mod_idx <=3D 0 || ucode_mod_idx >=3D bi->nr_modules || - !__test_and_clear_bit(ucode_mod_idx, module_map) ) + bi->mods[ucode_mod_idx].type !=3D BOOTMOD_UNKNOWN ) goto scan; bi->mods[ucode_mod_idx].type =3D BOOTMOD_MICROCODE; ucode_mod =3D &bi->mods[ucode_mod_idx]; scan: if ( ucode_scan ) - microcode_scan_module(module_map, bi); + microcode_scan_module(bi); } =20 static struct microcode_ops __ro_after_init ucode_ops; @@ -815,8 +813,7 @@ static int __init early_update_cache(const void *data, = size_t len) return rc; } =20 -int __init microcode_init_cache( - unsigned long *module_map, struct boot_info *bi) +int __init microcode_init_cache(struct boot_info *bi) { int rc =3D 0; =20 @@ -825,7 +822,7 @@ int __init microcode_init_cache( =20 /* Scan if microcode was not detected earlier */ if ( !ucode_mod ) - microcode_scan_module(module_map, bi); + microcode_scan_module(bi); =20 if ( ucode_mod && !ucode_mod->consumed ) rc =3D early_update_cache(bootstrap_map_bm(ucode_mod), @@ -871,8 +868,7 @@ static int __init early_microcode_update_cpu(void) return microcode_update_cpu(patch, 0); } =20 -int __init early_microcode_init(unsigned long *module_map, - struct boot_info *bi) +int __init early_microcode_init(struct boot_info *bi) { const struct cpuinfo_x86 *c =3D &boot_cpu_data; int rc =3D 0; @@ -915,7 +911,7 @@ int __init early_microcode_init(unsigned long *module_m= ap, return -ENODEV; } =20 - microcode_grab_module(module_map, bi); + microcode_grab_module(bi); =20 if ( ucode_mod || ucode_blob.size ) rc =3D early_microcode_update_cpu(); diff --git a/xen/arch/x86/include/asm/microcode.h b/xen/arch/x86/include/as= m/microcode.h index 9e7c7ab004ed..917a861fd8f7 100644 --- a/xen/arch/x86/include/asm/microcode.h +++ b/xen/arch/x86/include/asm/microcode.h @@ -26,10 +26,8 @@ DECLARE_PER_CPU(struct cpu_signature, cpu_sig); void microcode_set_module(unsigned int idx); int microcode_update( XEN_GUEST_HANDLE(const_void) buf, unsigned long len, unsigned int flag= s); -int early_microcode_init( - unsigned long *module_map, struct boot_info *bi); -int microcode_init_cache( - unsigned long *module_map, struct boot_info *bi); +int early_microcode_init(struct boot_info *bi); +int microcode_init_cache(struct boot_info *bi); int microcode_update_one(void); =20 #endif /* ASM_X86__MICROCODE_H */ diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 153d361793c1..7fdbe57ca1c3 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1409,7 +1409,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) * TODO: load ucode earlier once multiboot modules become accessible * at an earlier stage. */ - early_microcode_init(module_map, bi); + early_microcode_init(bi); =20 if ( xen_phys_start ) { @@ -1956,7 +1956,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) =20 timer_init(); =20 - microcode_init_cache(module_map, bi); /* Needs xmalloc() */ + microcode_init_cache(bi); /* Needs xmalloc() */ =20 tsx_init(); /* Needs microcode. May change HLE/RTM feature bits. */ =20 --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729471734; cv=pass; d=zohomail.com; s=zohoarc; b=B2cBeKHEI/nex5hz2eZAQPJyChCnOsPGYLIJLfGmOu+LgIM+s+a0JsFPDqei0x8AJlre807f4t321oHhzHQtYR9q26m/u4MwJ8wFSP5bTkQgxW8L9kEIBQ10+IFLjnBz+0Vygphgi8NQ+g8EM0IK/mP15+XYKWvrmJyAYPW0Ez8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471734; 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=yhLw3VJzc36B+i3/OvCwWtKAEdp06v39PF++zo/ehfw=; b=RIa0SavmaL8co/ZkQ0Ldh14RuJQ6lnhsETTz4wMV+85vyHNDD6McuxAvhb+zNO+xsnKZsfrVObgWTt1hQNiu/P/EWI4oWCP2pIcVy1bvBigi7A8iIoz1xJrkhfGE8A/zmwTkltYHnq8FkL50F6gB+eoMeeez3soDqkBNUzV91cE= 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 1729471734804953.125844435679; Sun, 20 Oct 2024 17:48:54 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822908.1236852 (Exim 4.92) (envelope-from ) id 1t2gb8-0002rI-2U; Mon, 21 Oct 2024 00:48:38 +0000 Received: by outflank-mailman (output) from mailman id 822908.1236852; Mon, 21 Oct 2024 00:48:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gb7-0002rB-VV; Mon, 21 Oct 2024 00:48:37 +0000 Received: by outflank-mailman (input) for mailman id 822908; Mon, 21 Oct 2024 00:48:36 +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 1t2gb6-0001i1-JM for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:48:36 +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 3353eecb-8f46-11ef-a0be-8be0dac302b0; Mon, 21 Oct 2024 02:48:35 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471603538750.0207690703996; Sun, 20 Oct 2024 17:46:43 -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: 3353eecb-8f46-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729471606; cv=none; d=zohomail.com; s=zohoarc; b=X4s3eIQ14tZWKHqkKLPMrGe3CIVkwuXN4KvYLbrgervkjM3mcQH/HYkgGTnNVovltcXzbN5fZb1yu2knYvzvSEPzc6rEWDz5my1pWEX/n2JdzZrnMqcHWimuaCBCEgBSzIXaN4uwSEjNPXVeaGLp+K+5jPcgeAkZ5Y1czBOnWeA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471606; 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=yhLw3VJzc36B+i3/OvCwWtKAEdp06v39PF++zo/ehfw=; b=Xf46jjNQrPvREwCQYthNg3zmsjbrIFGOko19Y0ng6aUd/Ez9iFvm9VX0C2kiS3dPKagfAvkb0FkLWh62JfOt2ePQY6UZvUnhfqhTKG2Py5r9qbXHFVSeqDHXsh3jcyZlshODibl+IfN88UbAlPjZIl6Dli3vne5+VOvRyZfdolQ= 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=1729471606; 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=yhLw3VJzc36B+i3/OvCwWtKAEdp06v39PF++zo/ehfw=; b=n9QYn8gCMsKqiePXlsaqdnDbpcy+na+8vvwFTe1IrpXYDS63W4CfZuW558Pm2hH9 njZcUjN8/V5+T1fZsFWtm7w2ALp4b9uPdRBY0jg20J99bacE33InNQL/yTKMs5Cqjax N0ZOs4VD7G79iuvqX+siyEoEGAPMvXn3+b4I1kEw= 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 v7 17/38] x86/boot: remove module_map usage from xsm policy loading Date: Sun, 20 Oct 2024 20:45:52 -0400 Message-Id: <20241021004613.18793-18-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729471735630116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v5: - adjust comment to coding style --- xen/arch/x86/setup.c | 2 +- xen/include/xsm/xsm.h | 9 +++------ xen/xsm/xsm_core.c | 6 ++---- xen/xsm/xsm_policy.c | 4 +--- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 7fdbe57ca1c3..84d6981f4e77 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1882,7 +1882,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) mmio_ro_ranges =3D rangeset_new(NULL, "r/o mmio ranges", RANGESETF_prettyprint_hex); =20 - xsm_multiboot_init(module_map, bi); + xsm_multiboot_init(bi); =20 /* * IOMMU-related ACPI table parsing may require some of the system dom= ains diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index f155d10e718c..791936e5285b 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -781,11 +781,9 @@ static inline int xsm_argo_send(const struct domain *d= , const struct domain *t) #endif /* XSM_NO_WRAPPERS */ =20 #ifdef CONFIG_MULTIBOOT -int xsm_multiboot_init( - unsigned long *module_map, struct boot_info *bi); +int xsm_multiboot_init(struct boot_info *bi); int xsm_multiboot_policy_init( - unsigned long *module_map, struct boot_info *bi, - void **policy_buffer, size_t *policy_size); + struct boot_info *bi, void **policy_buffer, size_t *policy_size); #endif =20 #ifdef CONFIG_HAS_DEVICE_TREE @@ -831,8 +829,7 @@ static const inline struct xsm_ops *silo_init(void) #include =20 #ifdef CONFIG_MULTIBOOT -static inline int xsm_multiboot_init ( - unsigned long *module_map, struct boot_info *bi) +static inline int xsm_multiboot_init(struct boot_info *bi) { return 0; } diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c index 234b39de7a1d..d58042a1fa4a 100644 --- a/xen/xsm/xsm_core.c +++ b/xen/xsm/xsm_core.c @@ -140,8 +140,7 @@ static int __init xsm_core_init(const void *policy_buff= er, size_t policy_size) } =20 #ifdef CONFIG_MULTIBOOT -int __init xsm_multiboot_init( - unsigned long *module_map, struct boot_info *bi) +int __init xsm_multiboot_init(struct boot_info *bi) { int ret =3D 0; void *policy_buffer =3D NULL; @@ -151,8 +150,7 @@ int __init xsm_multiboot_init( =20 if ( XSM_MAGIC ) { - ret =3D xsm_multiboot_policy_init(module_map, bi, &policy_buffer, - &policy_size); + ret =3D xsm_multiboot_policy_init(bi, &policy_buffer, &policy_size= ); if ( ret ) { bootstrap_map_bm(NULL); diff --git a/xen/xsm/xsm_policy.c b/xen/xsm/xsm_policy.c index 9fb8563eb571..f1c94702f6e0 100644 --- a/xen/xsm/xsm_policy.c +++ b/xen/xsm/xsm_policy.c @@ -32,8 +32,7 @@ =20 #ifdef CONFIG_MULTIBOOT int __init xsm_multiboot_policy_init( - unsigned long *module_map, struct boot_info *bi, - void **policy_buffer, size_t *policy_size) + struct boot_info *bi, void **policy_buffer, size_t *policy_size) { int rc =3D 0; u32 *_policy_start; @@ -57,7 +56,6 @@ int __init xsm_multiboot_policy_init( printk("Policy len %#lx, start at %p.\n", _policy_len,_policy_start); =20 - __clear_bit(boot_module_index(bi, bm), module_map); bm->type =3D BOOTMOD_XSM_POLICY; break; =20 --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729471738; cv=pass; d=zohomail.com; s=zohoarc; b=Ay8lftu4C4NB602Sj53UephMgfsSyEx3gOec+PHV4GdYGlyW6aXXrMCzoPxzaaWs3sHNCZDjY2IO5HZ3OFm1GDj+b4QRK4tGSl0Km2ppRWy/G7Js/7H6rYZeNxICaxnk9yZtKqgSRdlmjBafFBWVhN6yrcxUAGkAGqjn72HI5QU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471738; 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=yVwODdnV8WxSfmxxfPtGY+cCMyrPgV0sY5P16JCBxdM=; b=a6aoKRjnRy387aeVMUmUH0T9u8am+GF/Z14BJZc9awisZwjrdmgKapchwAjOTvXJkJmTj1UeQ7dUrdXTjH6xE402VA/MoCXtN4LyLK10YFntxSqxzgZdgAdnK5yrXj98CPINS0YMxI/pwQmMjTmeiU8GpN3f5KXl3o3EBsKAk1A= 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 1729471738252514.8799802767961; Sun, 20 Oct 2024 17:48:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822913.1236861 (Exim 4.92) (envelope-from ) id 1t2gbG-0003N5-91; Mon, 21 Oct 2024 00:48:46 +0000 Received: by outflank-mailman (output) from mailman id 822913.1236861; Mon, 21 Oct 2024 00:48:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gbG-0003Mv-6H; Mon, 21 Oct 2024 00:48:46 +0000 Received: by outflank-mailman (input) for mailman id 822913; Mon, 21 Oct 2024 00:48:44 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gbE-0003Iq-Ri for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:48:44 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 37813caf-8f46-11ef-99a3-01e77a169b0f; Mon, 21 Oct 2024 02:48:42 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471604782239.07506705249955; Sun, 20 Oct 2024 17:46:44 -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: 37813caf-8f46-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729471606; cv=none; d=zohomail.com; s=zohoarc; b=Qw2RrvII95qAkQzNoyV01MYL7i48DXV/rPwAYiEaCXvz3hozLRlt6jH2BhSsNJHUVEeNpxT3z8JoMrxsOnb/ozL3oBsXG1VaRN49roTx8x3k8u6cb7d+T8jKSt5ucp0dCb3MIQ96clok3ocHjMis0dnb/4ZmGFJ0hOS6CIfZWfI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471606; 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=yVwODdnV8WxSfmxxfPtGY+cCMyrPgV0sY5P16JCBxdM=; b=ejLfnlxz6GXAuT7pi1SNDZKKuHFJ/odObHb97X52dcdzbpVhWSscl2GsFR1k8LDn/SjzEwSNIBMyq3uXqOfnwoxaYmCHVQqqQdrT+5tEyVQlkzENsuaPny8JAACSrjciz08n4MVxgaOcLvEk08qRqPi6AcfKtI+4jXprWK5TGKs= 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=1729471606; 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=yVwODdnV8WxSfmxxfPtGY+cCMyrPgV0sY5P16JCBxdM=; b=FhnZS4DxhLJshSVTG+L9H3TzX0lo4g/BAM/BfsZWtXN/NfeS2kFZIFDhYHVx0esa cx1fzYs5CRwOm2z0EQhN+6S98lIiIDDG5fMK8VnCplJlkYeeso2i2wj+eE5DqJeGlgG 3XxiBliI9JbU/bwid4dsQVCc4hM/rJnvTvQjLAs4= 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 v7 18/38] x86/boot: remove module_map usage by ramdisk loading Date: Sun, 20 Oct 2024 20:45:53 -0400 Message-Id: <20241021004613.18793-19-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729471739752116600 Content-Type: text/plain; charset="utf-8" The ramdisk loading is the last user of module_map, remove its usage and any remaining remnants of module_map. Signed-off-by: Daniel P. Smith --- Changes since v5: - set excessive module check down to MAX_NR_BOOTMODS --- xen/arch/x86/setup.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 84d6981f4e77..4a482c8aefa4 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1053,7 +1053,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) struct boot_info *bi; multiboot_info_t *mbi; module_t *mod; - unsigned long nr_pages, raw_max_page, module_map[1]; + unsigned long nr_pages, raw_max_page; int i, j, e820_warn =3D 0, bytes =3D 0; unsigned long eb_start, eb_end; bool acpi_boot_table_init_done =3D false, relocated =3D false; @@ -1217,8 +1217,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) bi->nr_modules); } =20 - bitmap_fill(module_map, bi->nr_modules); - __clear_bit(0, module_map); /* Dom0 kernel is always first */ + /* Dom0 kernel is always first */ bi->mods[0].type =3D BOOTMOD_KERNEL; bi->mods[0].consumed =3D true; =20 --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729471752; cv=pass; d=zohomail.com; s=zohoarc; b=DmN52AOnjqEgNGW1bD1DTMduZmjPvt6gUs12tQJcV/rOLRaMrOyZjw+i58eTDnM9rsJIw5LdV+GvIHX0sSdXD4elRV2N7KHvzTXwRqaRjFiQ17Md2fs6XuYAFyse1yMaL91koSon/eKMjppNN+8yKtbRnFcB8D6R6SGM/yhOMV8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471752; 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=ZZjD4AlskBmTFJGQxv1B5HnCBYZoGhPGwEpU4WRgfog=; b=h9R+e5sGOximZzsriOt4LjCkp/F+xR93fqOwFSeEKpvPTBkn7ERQIjkFkIqZRMCqWWWYv5FhHmzNsrBTasbhhIa915aHMegY2UA4GFf7zjcvmGYvbqQs2F7PkuEE2UGGTN+gSLXk70T9cuON4i+HQhmggRujGh2l2q4giViCTNU= 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 1729471752542661.8352289186669; Sun, 20 Oct 2024 17:49:12 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822921.1236872 (Exim 4.92) (envelope-from ) id 1t2gbN-0003tJ-HR; Mon, 21 Oct 2024 00:48:53 +0000 Received: by outflank-mailman (output) from mailman id 822921.1236872; Mon, 21 Oct 2024 00:48:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gbN-0003t9-Ed; Mon, 21 Oct 2024 00:48:53 +0000 Received: by outflank-mailman (input) for mailman id 822921; Mon, 21 Oct 2024 00:48:52 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gbM-0003Iq-IA for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:48:52 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3c3ef1cb-8f46-11ef-99a3-01e77a169b0f; Mon, 21 Oct 2024 02:48:50 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471605922769.1616730146538; Sun, 20 Oct 2024 17:46:45 -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: 3c3ef1cb-8f46-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729471608; cv=none; d=zohomail.com; s=zohoarc; b=BhUoykAv0QlunbmRcqPYtKySMSy9xrRdYPBOvgw+GZZoRmHyK+RxdEaVSNZulXOvG8GWJnzZfbxicwxeQrimZxXInJj5/IjX+j7O4u3q2zrFxqI7tFFY1v+4qLZX3fJzrTXPGTNaabmNcBBgkiDRbW0MHPOlu7/qQ9pYxDt8n04= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471608; 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=ZZjD4AlskBmTFJGQxv1B5HnCBYZoGhPGwEpU4WRgfog=; b=J4BdJMqbiXxa8CxKKbS0+qX2U82cCngXxAn/5huTQX5nIdswpSqg6v39DWkEl3ZDSDVnkQq2Dzm0pLycnG58dopQYIkbolxn6P2SYmoK1uLM16yZsBiNZIWx4iQtr1p5UFNxo7wt5R3mfm67MnH8EJeam4abPptQCKh7afAlj58= 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=1729471608; 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=ZZjD4AlskBmTFJGQxv1B5HnCBYZoGhPGwEpU4WRgfog=; b=pu8QZfI1ARA9IDzbkIbj6C4cE6Dfp4G1OSyvl9bi6+qcrVINLMqRMxlDc9B6GPIn cpPQgjVrSyn43aq07GYq9WlaMpPh4Q3rwrB9Ryx6ziu7nCA6R5PGsiSiNhXGfg8DTkF +2MvNfe/0Spzvwe6MFUGO8IfXc5r+PS86SAHH+cM= 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 v7 19/38] x86/boot: convert create_dom0 to use boot info Date: Sun, 20 Oct 2024 20:45:54 -0400 Message-Id: <20241021004613.18793-20-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729471753665116600 Content-Type: text/plain; charset="utf-8" This commit changes create_dom0 to no longer take the individual components= and take struct boot_info instead. Internally, it is changed to locate the kern= el and ramdisk details from struct boot_info. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v5: - change headroom back to unsigned long - make mod_idx unsigned int --- xen/arch/x86/setup.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 4a482c8aefa4..347b27ad7c6c 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -962,10 +962,8 @@ static unsigned int __init copy_bios_e820(struct e820e= ntry *map, unsigned int li return n; } =20 -static struct domain *__init create_dom0(const module_t *image, - unsigned long headroom, - module_t *initrd, const char *kex= tra, - const char *loader) +static struct domain *__init create_dom0(const struct boot_info *bi, + const char *kextra) { static char __initdata cmdline[MAX_GUEST_CMDLINE]; =20 @@ -980,9 +978,22 @@ static struct domain *__init create_dom0(const module_= t *image, .misc_flags =3D opt_dom0_msr_relaxed ? XEN_X86_MSR_RELAXED : 0, }, }; + unsigned long headroom; + unsigned int mod_idx =3D first_boot_module_index(bi, BOOTMOD_RAMDISK); + module_t *image, *initrd; struct domain *d; domid_t domid; =20 + /* Map boot_module to mb1 module for dom0 */ + image =3D bi->mods[0].mod; + headroom =3D bi->mods[0].headroom; + + /* Map boot_module to mb1 module for initrd */ + if ( mod_idx < 0 ) + initrd =3D NULL; + else + initrd =3D bi->mods[mod_idx].mod; + if ( opt_dom0_pvh ) { dom0_cfg.flags |=3D (XEN_DOMCTL_CDF_hvm | @@ -1011,7 +1022,7 @@ static struct domain *__init create_dom0(const module= _t *image, if ( image->string || kextra ) { if ( image->string ) - safe_strcpy(cmdline, cmdline_cook(__va(image->string), loader)= ); + safe_strcpy(cmdline, cmdline_cook(__va(image->string), bi->loa= der)); =20 if ( kextra ) /* kextra always includes exactly one leading space. */ @@ -2123,10 +2134,7 @@ void asmlinkage __init noreturn __start_xen(unsigned= long mbi_p) * We're going to setup domain0 using the module(s) that we stashed sa= fely * above our heap. The second module, if present, is an initrd ramdisk. */ - dom0 =3D create_dom0(bi->mods[0].mod, bi->mods[0].headroom, - initrdidx < bi->nr_modules ? bi->mods[initrdidx].mod - : NULL, - kextra, bi->loader); + dom0 =3D create_dom0(bi, kextra); if ( !dom0 ) panic("Could not set up DOM0 guest OS\n"); =20 --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729471758; cv=pass; d=zohomail.com; s=zohoarc; b=gfXytxkekQQVdEB+ofKum/cX3Y6NQtuSUOjgO6BwioniqGWxUFtimT5HCKvn8n+A2khgppkJ0r2aGX8hIWKl9JmV6O1aO78dlIlIY7lC7vTOPw/iIpcWuQws9qp2MIPrOyBHGzzAFViViRHQBuRK8R3I2j0Gvvu9bYb5z+lq/f0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471758; 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=cBjn8qpPRBCnRHHQipv24ZKBHCd3uNn+xt1GGGTjo4k=; b=Ob04xnPeHtqQ9SUAfiFx+tjiCZooJzZ1szLsjw3K5YWLiVuW3C93xWVEoiZwd2cjbNJffIdlDtr7ZqHuL8l/qKGcQwcPxx+n9DkR6Z+0vZX/JmhGNjH4qVGl13qi6wb1rayQuTwIrTEjgCEu7CpR5OX6Zc6/1UAtAwocrY54gWs= 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 1729471758839923.4177707889346; Sun, 20 Oct 2024 17:49:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822924.1236882 (Exim 4.92) (envelope-from ) id 1t2gbV-0004OR-Q2; Mon, 21 Oct 2024 00:49:01 +0000 Received: by outflank-mailman (output) from mailman id 822924.1236882; Mon, 21 Oct 2024 00:49:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gbV-0004OH-LC; Mon, 21 Oct 2024 00:49:01 +0000 Received: by outflank-mailman (input) for mailman id 822924; Mon, 21 Oct 2024 00:49:00 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gbU-0003Iq-F1 for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:49:00 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 40ed903a-8f46-11ef-99a3-01e77a169b0f; Mon, 21 Oct 2024 02:48:58 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471607102166.0182824509185; Sun, 20 Oct 2024 17:46:47 -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: 40ed903a-8f46-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729471608; cv=none; d=zohomail.com; s=zohoarc; b=WO5Zr6CPBrBo9daYaNRGckB7hkc6SsWurLIp5gvxptdINyH8EjibF1Qtim1vnD+rBedp6vUTndyACF0A2qAvVY2rs5Z+ZpEyl4OGmqbc8GiUp2G/dWy/lvZjsueVWj/JgdX0y912qQOWKdHyPReO3qsj189ZdqveYZ9JE9C1I40= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471608; 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=cBjn8qpPRBCnRHHQipv24ZKBHCd3uNn+xt1GGGTjo4k=; b=NSbS3/reyYsemBUu+p9rK7RlHY2gQwziWRUnJzzYuLw2kpAKZzxth8vpMVkvWor9Kfaipess1v2P1OUaRrGc1BbQoFPKOGvzktO4nAjJiUE4QI400fTmXh6r/BxrlYWelWB/jCgJLKQvw98v5j7Bm16f2SbJeU1wf6IphzVaAV4= 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=1729471608; 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=cBjn8qpPRBCnRHHQipv24ZKBHCd3uNn+xt1GGGTjo4k=; b=I/OxuYEX0ItDD1mTenXEOPO3Yc/g//LoyeRo3O3ZbOn05UT6yh/ZD8npdItO9WQI U/vFyEIBRDUU1k2kPtZPAGjEqOH2460Pen30jZ5zTJi7Vdd5Vumln7rt3dowp8ZMfrA nLqJ6fBONBYP95Im4t7Fadbp7yBtx4Xh5b8UGI8I= 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 v7 20/38] x86/boot: convert construct_dom0 to use struct boot_module Date: Sun, 20 Oct 2024 20:45:55 -0400 Message-Id: <20241021004613.18793-21-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729471759707116600 Content-Type: text/plain; charset="utf-8" The construct_dom0 function is converted to consume struct boot_module instances for the kernel and ramdisk. With this change, it is no longer necessary for the internal use of struct mod by create_dom0, so they are changed to struct boot_module. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- xen/arch/x86/dom0_build.c | 12 +++++++----- xen/arch/x86/include/asm/setup.h | 6 ++---- xen/arch/x86/setup.c | 19 +++++++++---------- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 8d56705a0861..1eff3192f72d 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -13,6 +13,7 @@ #include =20 #include +#include #include #include #include @@ -596,9 +597,8 @@ int __init dom0_setup_permissions(struct domain *d) return rc; } =20 -int __init construct_dom0(struct domain *d, const module_t *image, - unsigned long image_headroom, module_t *initrd, - const char *cmdline) +int __init construct_dom0(struct domain *d, const struct boot_module *imag= e, + struct boot_module *initrd, const char *cmdline) { int rc; =20 @@ -610,9 +610,11 @@ int __init construct_dom0(struct domain *d, const modu= le_t *image, process_pending_softirqs(); =20 if ( is_hvm_domain(d) ) - rc =3D dom0_construct_pvh(d, image, image_headroom, initrd, cmdlin= e); + rc =3D dom0_construct_pvh(d, image->mod, image->headroom, initrd->= mod, + cmdline); else if ( is_pv_domain(d) ) - rc =3D dom0_construct_pv(d, image, image_headroom, initrd, cmdline= ); + rc =3D dom0_construct_pv(d, image->mod, image->headroom, initrd->m= od, + cmdline); else panic("Cannot construct Dom0. No guest interface available\n"); =20 diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/se= tup.h index 729f68ca23b8..72d183e8a4de 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -27,10 +27,8 @@ void subarch_init_memory(void); void init_IRQ(void); =20 int construct_dom0( - struct domain *d, - const module_t *image, unsigned long image_headroom, - module_t *initrd, - const char *cmdline); + struct domain *d, const struct boot_module *image, + struct boot_module *initrd, const char *cmdline); void setup_io_bitmap(struct domain *d); =20 extern struct boot_info xen_boot_info; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 347b27ad7c6c..d7f03225bd5a 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -962,7 +962,7 @@ static unsigned int __init copy_bios_e820(struct e820en= try *map, unsigned int li return n; } =20 -static struct domain *__init create_dom0(const struct boot_info *bi, +static struct domain *__init create_dom0(struct boot_info *bi, const char *kextra) { static char __initdata cmdline[MAX_GUEST_CMDLINE]; @@ -978,21 +978,19 @@ static struct domain *__init create_dom0(const struct= boot_info *bi, .misc_flags =3D opt_dom0_msr_relaxed ? XEN_X86_MSR_RELAXED : 0, }, }; - unsigned long headroom; unsigned int mod_idx =3D first_boot_module_index(bi, BOOTMOD_RAMDISK); - module_t *image, *initrd; + struct boot_module *image, *initrd; struct domain *d; domid_t domid; =20 /* Map boot_module to mb1 module for dom0 */ - image =3D bi->mods[0].mod; - headroom =3D bi->mods[0].headroom; + image =3D &bi->mods[0]; =20 /* Map boot_module to mb1 module for initrd */ if ( mod_idx < 0 ) initrd =3D NULL; else - initrd =3D bi->mods[mod_idx].mod; + initrd =3D &bi->mods[mod_idx]; =20 if ( opt_dom0_pvh ) { @@ -1019,10 +1017,11 @@ static struct domain *__init create_dom0(const stru= ct boot_info *bi, panic("Error creating d%uv0\n", domid); =20 /* Grab the DOM0 command line. */ - if ( image->string || kextra ) + if ( image->mod->string || kextra ) { - if ( image->string ) - safe_strcpy(cmdline, cmdline_cook(__va(image->string), bi->loa= der)); + if ( image->mod->string ) + safe_strcpy(cmdline, cmdline_cook(__va(image->mod->string), + bi->loader)); =20 if ( kextra ) /* kextra always includes exactly one leading space. */ @@ -1045,7 +1044,7 @@ static struct domain *__init create_dom0(const struct= boot_info *bi, } } =20 - if ( construct_dom0(d, image, headroom, initrd, cmdline) !=3D 0 ) + if ( construct_dom0(d, image, initrd, cmdline) !=3D 0 ) panic("Could not construct domain 0\n"); =20 return d; --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729472229; cv=pass; d=zohomail.com; s=zohoarc; b=CVr7l8U/SM4dnv0fVU+bvohI+4xC1rKGo7IMGVpVA6Kh6pzgPmdIiKlkYxVSWzyTB3lWlWgkkrENYAbKjPadJCKiUVbISeTTNH3by/Cs9r1oKVUXdXb3O7C7dwf2xJBgaN1ULPzxFGb50QiSgWlbZO26B3RJ+lXBF4xrTVoUzi4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729472229; 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=uzzoAQRXv4hKDmaKTHKSRZqXTQp1Xcv7fYKLtSvFAac=; b=T2a0X58b9ANIBsxeH/fcdnOlxlummB0/l2YK6usNCW+dnj2UDMy7o8ywZCCgfGfKW34u0Pg128ZTRduYtwdnzmWtOEj1lR2EHHdvcfIyK61odV1myfHtnU3crWU9t1nMibz6T4h+3YXYOuE2egjvW/KFgraUp+gv0xgeXCh6/rs= 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 1729472229160707.3009932247598; Sun, 20 Oct 2024 17:57:09 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822976.1236972 (Exim 4.92) (envelope-from ) id 1t2git-0001ef-TA; Mon, 21 Oct 2024 00:56:39 +0000 Received: by outflank-mailman (output) from mailman id 822976.1236972; Mon, 21 Oct 2024 00:56:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2git-0001eU-MN; Mon, 21 Oct 2024 00:56:39 +0000 Received: by outflank-mailman (input) for mailman id 822976; Mon, 21 Oct 2024 00:56:38 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gbd-0003Iq-Ha for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:49:09 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 458ada27-8f46-11ef-99a3-01e77a169b0f; Mon, 21 Oct 2024 02:49:06 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471608242129.3516752909568; Sun, 20 Oct 2024 17:46:48 -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: 458ada27-8f46-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729471610; cv=none; d=zohomail.com; s=zohoarc; b=TT+LCxtpTpaxwA4CjDxX6dIo1aDWZEc6eRSY+ov/NFY8IK0awNGO2R3SnmEX9PaFcfrUMfmTyLgZY6QEj4Yh7hZhiimvLbNIis9uiiKNNSMgdm88Sd/h0v6iN6ZXHSAWJmPQJEK20WZjDcOOpgdnhZH9x/5MhhGbad3Eek7ooOs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471610; 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=uzzoAQRXv4hKDmaKTHKSRZqXTQp1Xcv7fYKLtSvFAac=; b=Isnqm0WXmGSjcVq7mIMjkjMNw8IAS9ZdKYHSc1ORQYJuTYlL50T3sg8l/0Ryd3qAAlx6tsR7/WjWFFq+mvdS2fmVfNxzKSzEZCi0JxVeFPaDWE0n4Cz4tX8S4qwQ/Zq1CepE//svlNQcFIchUCyS3Y1BEB53j4WlXtIHODYXHgA= 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=1729471610; 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=uzzoAQRXv4hKDmaKTHKSRZqXTQp1Xcv7fYKLtSvFAac=; b=kn14O1BQxrWNU5Cv6zh1/xBPtB0vpXcSzhe+ei/1s125KGtvD+JCMn8oamgQ9aZZ VWMiSttqUXUkrJEW15JR1dZ+EKFWBpd/wl1lmE/S7GXRqRDU1LcdbjRwFLn0jnua5uQ EYhzBiAK4hIjtlzmLyPUDN7hvKBiV3aVfaAeAQNU= 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 v7 21/38] x86/boot: relocate kextra into boot info Date: Sun, 20 Oct 2024 20:45:56 -0400 Message-Id: <20241021004613.18793-22-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729472229567116600 Content-Type: text/plain; charset="utf-8" Move kextra into struct boot_info, thus no longer needed to be passed as a parameter to create_dom0. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- xen/arch/x86/include/asm/bootinfo.h | 1 + xen/arch/x86/setup.c | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index 3ca56454c4d7..9bd0e6336b4a 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -63,6 +63,7 @@ struct boot_module { struct boot_info { const char *loader; const char *cmdline; + const char *kextra; =20 paddr_t memmap_addr; size_t memmap_length; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index d7f03225bd5a..6f953edd7521 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -962,8 +962,7 @@ static unsigned int __init copy_bios_e820(struct e820en= try *map, unsigned int li return n; } =20 -static struct domain *__init create_dom0(struct boot_info *bi, - const char *kextra) +static struct domain *__init create_dom0(struct boot_info *bi) { static char __initdata cmdline[MAX_GUEST_CMDLINE]; =20 @@ -1017,15 +1016,15 @@ static struct domain *__init create_dom0(struct boo= t_info *bi, panic("Error creating d%uv0\n", domid); =20 /* Grab the DOM0 command line. */ - if ( image->mod->string || kextra ) + if ( image->mod->string || bi->kextra ) { if ( image->mod->string ) safe_strcpy(cmdline, cmdline_cook(__va(image->mod->string), bi->loader)); =20 - if ( kextra ) + if ( bi->kextra ) /* kextra always includes exactly one leading space. */ - safe_strcat(cmdline, kextra); + safe_strcat(cmdline, bi->kextra); =20 /* Append any extra parameters. */ if ( skip_ioapic_setup && !strstr(cmdline, "noapic") ) @@ -1121,6 +1120,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) *kextra =3D '\0'; kextra +=3D 3; while ( kextra[1] =3D=3D ' ' ) kextra++; + bi->kextra =3D kextra; } cmdline_parse(bi->cmdline); =20 @@ -2133,7 +2133,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) * We're going to setup domain0 using the module(s) that we stashed sa= fely * above our heap. The second module, if present, is an initrd ramdisk. */ - dom0 =3D create_dom0(bi, kextra); + dom0 =3D create_dom0(bi); if ( !dom0 ) panic("Could not set up DOM0 guest OS\n"); =20 --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729472217; cv=pass; d=zohomail.com; s=zohoarc; b=gWMInTyP79XHTGSVIigVBBmWFo2VThXPFpBvjXu3TFc4Z6xVvAcHqyEfpW2ZwFjXi1iokmcx2vALBe349euosOIcSCea8cNLPdqDm4Mco9cmxuxtkuIGU9xLjoc1wWZ/HFD2OZrsN/N/yAeNlu5WPdUkpuLKysFx4fyR/DYXRJQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729472217; 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=StSbCrB+Dkpm/0KxKKmbp9r7lXihj1wwfuzXw0D2zII=; b=LZrM+EjixewKMVUr84YQJQYyaXkycj65FAYcmTf24GQ7Dm5iJ3CprSn7OE5fmUHJnVlPqjj1lV+lS7QrHTpV4TFAS87R/VEBmOD2h+jyCC/vSxEi9tWExgShkf+Ad82kUEwSZxSZNgTA197A62zBkhqy2sxBPlT2LB55rpUjxrQ= 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 1729472217799101.49487961907448; Sun, 20 Oct 2024 17:56:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822970.1236954 (Exim 4.92) (envelope-from ) id 1t2giq-0000yI-Fu; Mon, 21 Oct 2024 00:56:36 +0000 Received: by outflank-mailman (output) from mailman id 822970.1236954; Mon, 21 Oct 2024 00:56:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2giq-0000wW-AJ; Mon, 21 Oct 2024 00:56:36 +0000 Received: by outflank-mailman (input) for mailman id 822970; Mon, 21 Oct 2024 00:56:34 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gbl-0003Iq-2H for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:49:17 +0000 Received: from sender3-of-o57.zoho.com (sender3-of-o57.zoho.com [136.143.184.57]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4ab63ad6-8f46-11ef-99a3-01e77a169b0f; Mon, 21 Oct 2024 02:49:15 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471609370815.6656070423512; Sun, 20 Oct 2024 17:46:49 -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: 4ab63ad6-8f46-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729471611; cv=none; d=zohomail.com; s=zohoarc; b=VOOV58aeXXstEaea5PEYY5hCNM5Cf2DbWfz2W9JspozDw/+uuMHZvc84UM+6/zOQJngg17ateZEawbZzi8ThwznVn0yhXIpVL3hoif0xQSgA5EZbnRUKg4cdalq2h+4CQMI6Poi9ZUeGjHXMYeRSU3CWB0AR6QGFuY8fYIBTllU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471611; 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=StSbCrB+Dkpm/0KxKKmbp9r7lXihj1wwfuzXw0D2zII=; b=DzdLNigp2vxkFU15ypRPfOMbmQkmJKfIrGQQQOqOX7BC6HcCkDG81j3sQVFeSixvbaKEK0yO5T9cwCC0ltJ4q0m+xleIOt0C9nnmkpwSJJgb0X1ary9aZiSQ9up0vNpwcJfzUPpVYulqrA3GhUo3cK4SXmkwWAMowI7i/mCyzCA= 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=1729471611; 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=StSbCrB+Dkpm/0KxKKmbp9r7lXihj1wwfuzXw0D2zII=; b=dXJQ+gs63Q0A8BdYYVq/jGFJDNiM0vKokc2EhktgXDOQvCoAaYHdsS5ZZJj++YUF 6mWDgRdSzh+tsmMKCryvQRCm1qbyuzI0aSgEtAu9msVEq4zRKcCZNztegQAbqz6Iycg tVLwP8p+VKalsQDZqo0aScT54knUo9z9eldrG9Mo= 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 v7 22/38] x86/boot: add cmdline to struct boot_module Date: Sun, 20 Oct 2024 20:45:57 -0400 Message-Id: <20241021004613.18793-23-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729472219582116600 Content-Type: text/plain; charset="utf-8" Add a char pointer field, cmdline, to struct boot_module to hold the address pointed to by the string field of struct mod. This removes the need to use = the early_mod field to get to the dom0 kernel command line. Signed-off-by: Daniel P. Smith --- Changes since v5: - changed boot_module element cmdline to paddr_t --- xen/arch/x86/include/asm/bootinfo.h | 2 ++ xen/arch/x86/setup.c | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index 9bd0e6336b4a..941363601db7 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -52,6 +52,8 @@ struct boot_module { bool relocated:1; bool consumed:1; =20 + paddr_t cmdline; + paddr_t start; size_t size; }; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 6f953edd7521..254aeb0c5e1b 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -318,6 +318,8 @@ static struct boot_info *__init multiboot_fill_boot_inf= o(unsigned long mbi_p) { bi->mods[i].mod =3D &mods[i]; =20 + bi->mods[i].cmdline =3D (paddr_t)mods[i].string; + if ( !efi_enabled(EFI_LOADER) ) { bi->mods[i].start =3D mods[i].mod_start; @@ -1016,10 +1018,11 @@ static struct domain *__init create_dom0(struct boo= t_info *bi) panic("Error creating d%uv0\n", domid); =20 /* Grab the DOM0 command line. */ - if ( image->mod->string || bi->kextra ) + if ( image->cmdline || bi->kextra ) { - if ( image->mod->string ) - safe_strcpy(cmdline, cmdline_cook(__va(image->mod->string), + if ( image->cmdline ) + safe_strcpy(cmdline, + cmdline_cook(__va(image->cmdline), bi->loader)); =20 if ( bi->kextra ) --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729472267; cv=pass; d=zohomail.com; s=zohoarc; b=mxwN/1eaZdjmrmeo18zaY9foe2V77c66cgq+CCnmvV6jR+/6Tnp08ah27RMslRCqnYDS9N6FyY+JdZ55OiWjXdzQpi4Q+Crr7fMHJjpcSmhc6kwB7qUw+dKN9UrCBN2WJIEVkcTjvLHpwyYfis4eG3WDs9HqUkBIvJM8RjjP6UU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729472267; 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=6EFYFOIpJeJaM58GR4EodZUTDNutkt83UE7kPDWs5iU=; b=gpzXNdLS6qNSDudWWS6qy1rVaKuNR8OYYxpf4g8ShsN6qA4Hd3SS6wYx5bMGduuehwacQRymfX4PRMzIR+laSKkJKtKXH8aqlizU0VGxSsTIc+OJ2+wQtDPngpKXdG636b/VqVfkivqPALdJzPnsBmfgfRFVC6i/cAp0WDuUCe4= 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 172947226762762.71040768682735; Sun, 20 Oct 2024 17:57:47 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.823032.1237110 (Exim 4.92) (envelope-from ) id 1t2gja-0000Q4-Fd; Mon, 21 Oct 2024 00:57:22 +0000 Received: by outflank-mailman (output) from mailman id 823032.1237110; Mon, 21 Oct 2024 00:57:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gja-0000PI-9T; Mon, 21 Oct 2024 00:57:22 +0000 Received: by outflank-mailman (input) for mailman id 823032; Mon, 21 Oct 2024 00:57:20 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gbt-0003Iq-Cz for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:49:25 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4f617d7b-8f46-11ef-99a3-01e77a169b0f; Mon, 21 Oct 2024 02:49:22 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471610646436.30794011322234; Sun, 20 Oct 2024 17:46:50 -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: 4f617d7b-8f46-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729471612; cv=none; d=zohomail.com; s=zohoarc; b=i+Fo7mE2l6lnDvHSkdzMXcIc0cXnGZAOArVr2J9rW9rvUEMLkdwRQBqObaK9lHCNNOtaJ9raWFdMjyxPOM6par5wpYQg8fB7WnH06ov6lo4fXOwDP7OeVFij+/zcE7bO7kEGjl9+rtDUhAmFlCe3oxRGJa495acNoLm9hZ1k4p8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471612; 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=6EFYFOIpJeJaM58GR4EodZUTDNutkt83UE7kPDWs5iU=; b=Hr+zKuiK73+LfVVlD2yDJZZlbQY1vLy1x66B8tC3/pE1k5dsLyC6/RA1HWeJ155h6fbbrZO/7SQW7iihIMCjWQNaOoZz4h6cwfcnwkXO3TnjHmYS+AKL4954mhNmAmsy1JFFhRElQWaq6wDZKCJwTjkMJcMx2aVDoz2p02ISIt8= 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=1729471612; 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=6EFYFOIpJeJaM58GR4EodZUTDNutkt83UE7kPDWs5iU=; b=ebI5JlVoik3O/my+I8RYupFUUSvnlk9k8w8a3pcPdmlAdnvY5vTng6VOfc/6dCfB fdAsny2LWWRRCOswBs5/oN4Pcgmtm9NgbGzElq9DRR6BWsebL9Lro68vwrINBeLoSAo W32Rzrvo8NrIE2RuEEsBSZXgS2EvZcY/LbG/uWS8= 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 v7 23/38] x86/boot: convert dom0_construct_pv image param to struct boot_module Date: Sun, 20 Oct 2024 20:45:58 -0400 Message-Id: <20241021004613.18793-24-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729472269688116600 Content-Type: text/plain; charset="utf-8" This changes the type for the image parameter of dom0_construct_pv to be st= ruct boot_module. Removing the usage of early_mod field for kernel module. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v6: - removed unnecessary indentation changes Changes since v5: - replaced bootstrap_map(NULL) with bootstrap_map_bm --- xen/arch/x86/dom0_build.c | 3 +-- xen/arch/x86/include/asm/dom0_build.h | 3 +-- xen/arch/x86/pv/dom0_build.c | 16 +++++++--------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 1eff3192f72d..54db578dd29f 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -613,8 +613,7 @@ int __init construct_dom0(struct domain *d, const struc= t boot_module *image, rc =3D dom0_construct_pvh(d, image->mod, image->headroom, initrd->= mod, cmdline); else if ( is_pv_domain(d) ) - rc =3D dom0_construct_pv(d, image->mod, image->headroom, initrd->m= od, - cmdline); + rc =3D dom0_construct_pv(d, image, initrd->mod, cmdline); else panic("Cannot construct Dom0. No guest interface available\n"); =20 diff --git a/xen/arch/x86/include/asm/dom0_build.h b/xen/arch/x86/include/a= sm/dom0_build.h index 107c1ff98367..66ea70869c49 100644 --- a/xen/arch/x86/include/asm/dom0_build.h +++ b/xen/arch/x86/include/asm/dom0_build.h @@ -13,8 +13,7 @@ unsigned long dom0_compute_nr_pages(struct domain *d, unsigned long initrd_len); int dom0_setup_permissions(struct domain *d); =20 -int dom0_construct_pv(struct domain *d, const module_t *image, - unsigned long image_headroom, +int dom0_construct_pv(struct domain *d, const struct boot_module *image, module_t *initrd, const char *cmdline); =20 diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index ee9ecdc2abbf..db4c066e626b 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -355,8 +355,7 @@ static struct page_info * __init alloc_chunk(struct dom= ain *d, } =20 static int __init dom0_construct(struct domain *d, - const module_t *image, - unsigned long image_headroom, + const struct boot_module *image, module_t *initrd, const char *cmdline) { @@ -374,9 +373,9 @@ static int __init dom0_construct(struct domain *d, unsigned int flush_flags =3D 0; start_info_t *si; struct vcpu *v =3D d->vcpu[0]; - void *image_base =3D bootstrap_map(image); - unsigned long image_len =3D image->mod_end; - void *image_start =3D image_base + image_headroom; + void *image_base =3D bootstrap_map_bm(image); + unsigned long image_len =3D image->size; + void *image_start =3D image_base + image->headroom; unsigned long initrd_len =3D initrd ? initrd->mod_end : 0; l4_pgentry_t *l4tab =3D NULL, *l4start =3D NULL; l3_pgentry_t *l3tab =3D NULL, *l3start =3D NULL; @@ -830,7 +829,7 @@ static int __init dom0_construct(struct domain *d, printk("Failed to load the kernel binary\n"); goto out; } - bootstrap_map(NULL); + bootstrap_map_bm(NULL); =20 if ( UNSET_ADDR !=3D parms.virt_hypercall ) { @@ -1052,8 +1051,7 @@ out: } =20 int __init dom0_construct_pv(struct domain *d, - const module_t *image, - unsigned long image_headroom, + const struct boot_module *image, module_t *initrd, const char *cmdline) { @@ -1073,7 +1071,7 @@ int __init dom0_construct_pv(struct domain *d, write_cr4(cr4 & ~X86_CR4_SMAP); } =20 - rc =3D dom0_construct(d, image, image_headroom, initrd, cmdline); + rc =3D dom0_construct(d, image, initrd, cmdline); =20 if ( cr4 & X86_CR4_SMAP ) { --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729472272; cv=pass; d=zohomail.com; s=zohoarc; b=ODhwW7bqRzQUsoMpoEqwrJXDgO2svsolIJtwHmAMcMRCG1yAkIiaL8/N8/NWN3PXk7L1YxsRao3M6UAFqUfyKypacxSU9dTD5L/uro3IPItuTTdtocUtLxTfBRPy1JPSvqb+iOEe1ZiKUOXL22kaTj0FGajpof2A1D9FhkuHRhw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729472272; 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=G3ehmCO8bT8qPw3YmQxCtvKfHyAgzuybCULbUdCF2DY=; b=hpcMfXIzk0e7NzXGzL6bj0lZh3HEKBzfNdLh+rCEOGI6/Sy02fQ8mfJQgbi2rgTvCrEtA9Znu69LL/AziSp6Eymf+4cwdcpPP1OUd/mJ46YVBEfYkvEUxkYuZx1i1JvoXEBKzknThYOdrKAXGwy8TzaJT3agkRf4k93xlDJd/jU= 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 172947227266553.12896591437732; Sun, 20 Oct 2024 17:57:52 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.823031.1237098 (Exim 4.92) (envelope-from ) id 1t2gjZ-0008RC-4u; Mon, 21 Oct 2024 00:57:21 +0000 Received: by outflank-mailman (output) from mailman id 823031.1237098; Mon, 21 Oct 2024 00:57:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gjY-0008QK-Rs; Mon, 21 Oct 2024 00:57:20 +0000 Received: by outflank-mailman (input) for mailman id 823031; Mon, 21 Oct 2024 00:57:19 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gc0-0003Iq-6Z for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:49:32 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 53f4a1d0-8f46-11ef-99a3-01e77a169b0f; Mon, 21 Oct 2024 02:49:30 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471611802555.2471817938753; Sun, 20 Oct 2024 17:46:51 -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: 53f4a1d0-8f46-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729471614; cv=none; d=zohomail.com; s=zohoarc; b=bqkjdy6BkatGSN0bWrlE45r4aQgQTmOVWieYxEtX1BbU/u8kFB6AUuR+bT7MTd1cAUlIR87oa3qnXe8zyEEjJQ+x55D3cwnACdK7PJJFWOhLQq2gY00SZ6R222QOSJEqzeXXNCLb2NgsU40ygT9KAUuKroPwSehxgzyhkBn0v5k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471614; 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=G3ehmCO8bT8qPw3YmQxCtvKfHyAgzuybCULbUdCF2DY=; b=BmZrndyqsacMN/x144p/nW5gC+mOYlCVlawDXPhJg/64ecfRj+W15sDNblN5h2o+8n+r3miCrt3x69fPHrAUCp4y1PV3q7mEOIWX4zCWYSBDNaOuTQg+DEdl1Z4rFyd3EEKj9USVM2qYgtpAEmjHsoXFGLxVlvcUgBDwn/yEl+Y= 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=1729471614; 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=G3ehmCO8bT8qPw3YmQxCtvKfHyAgzuybCULbUdCF2DY=; b=egMyPoqRN6xRPi9spUmX+V8+xuhVOH4kfrXmOJwU+P5tOeDLjfmbXYra/NnxKvaF VFRkle4K21A/OuORaxOvX9+ceNZAke+rjmlNIYqXIOquvdujRymlIO0SgtOOe3TF13a zTv4lrk4h8yvb/cb/mKn0KQWyLv9uH1ODhlXEJaU= 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 v7 24/38] x86/boot: convert dom0_construct_pv initrd param to struct boot_module Date: Sun, 20 Oct 2024 20:45:59 -0400 Message-Id: <20241021004613.18793-25-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729472273720116600 Content-Type: text/plain; charset="utf-8" This changes the type for the initrd parameter of dom0_construct_pv to be s= truct boot_module. This conversion requires several adjustments throughout dom0_c= onstruct_pv to account for the type change. Removes the usage of early_mod field for ra= mdisk module. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v6: - removed unnecessary indentation changes Changes since v5: - changed initrd_mfn initialization to _mfn(0) --- xen/arch/x86/dom0_build.c | 2 +- xen/arch/x86/include/asm/dom0_build.h | 2 +- xen/arch/x86/pv/dom0_build.c | 29 +++++++++++++++------------ 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 54db578dd29f..1d05ee53a6d8 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -613,7 +613,7 @@ int __init construct_dom0(struct domain *d, const struc= t boot_module *image, rc =3D dom0_construct_pvh(d, image->mod, image->headroom, initrd->= mod, cmdline); else if ( is_pv_domain(d) ) - rc =3D dom0_construct_pv(d, image, initrd->mod, cmdline); + rc =3D dom0_construct_pv(d, image, initrd, cmdline); else panic("Cannot construct Dom0. No guest interface available\n"); =20 diff --git a/xen/arch/x86/include/asm/dom0_build.h b/xen/arch/x86/include/a= sm/dom0_build.h index 66ea70869c49..3ddd22fad2ba 100644 --- a/xen/arch/x86/include/asm/dom0_build.h +++ b/xen/arch/x86/include/asm/dom0_build.h @@ -14,7 +14,7 @@ unsigned long dom0_compute_nr_pages(struct domain *d, int dom0_setup_permissions(struct domain *d); =20 int dom0_construct_pv(struct domain *d, const struct boot_module *image, - module_t *initrd, + struct boot_module *initrd, const char *cmdline); =20 int dom0_construct_pvh(struct domain *d, const module_t *image, diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index db4c066e626b..45a386aa81f0 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -356,7 +356,7 @@ static struct page_info * __init alloc_chunk(struct dom= ain *d, =20 static int __init dom0_construct(struct domain *d, const struct boot_module *image, - module_t *initrd, + struct boot_module *initrd, const char *cmdline) { int i, rc, order, machine; @@ -367,7 +367,8 @@ static int __init dom0_construct(struct domain *d, unsigned long nr_pt_pages; unsigned long alloc_spfn; unsigned long alloc_epfn; - unsigned long initrd_pfn =3D -1, initrd_mfn =3D 0; + unsigned long initrd_pfn =3D -1; + mfn_t initrd_mfn =3D _mfn(0); unsigned long count; struct page_info *page =3D NULL; unsigned int flush_flags =3D 0; @@ -376,7 +377,7 @@ static int __init dom0_construct(struct domain *d, void *image_base =3D bootstrap_map_bm(image); unsigned long image_len =3D image->size; void *image_start =3D image_base + image->headroom; - unsigned long initrd_len =3D initrd ? initrd->mod_end : 0; + unsigned long initrd_len =3D initrd ? initrd->size : 0; l4_pgentry_t *l4tab =3D NULL, *l4start =3D NULL; l3_pgentry_t *l3tab =3D NULL, *l3start =3D NULL; l2_pgentry_t *l2tab =3D NULL, *l2start =3D NULL; @@ -612,7 +613,8 @@ static int __init dom0_construct(struct domain *d, initrd_pfn =3D vinitrd_start ? (vinitrd_start - v_start) >> PAGE_SHIFT : domain_tot_pages(d); - initrd_mfn =3D mfn =3D initrd->mod_start; + initrd_mfn =3D maddr_to_mfn(initrd->start); + mfn =3D mfn_x(initrd_mfn); count =3D PFN_UP(initrd_len); if ( d->arch.physaddr_bitsize && ((mfn + count - 1) >> (d->arch.physaddr_bitsize - PAGE_SHIFT)= ) ) @@ -627,12 +629,13 @@ static int __init dom0_construct(struct domain *d, free_domheap_pages(page, order); page +=3D 1UL << order; } - memcpy(page_to_virt(page), mfn_to_virt(initrd->mod_start), + memcpy(page_to_virt(page), maddr_to_virt(initrd->start), initrd_len); - mpt_alloc =3D (paddr_t)initrd->mod_start << PAGE_SHIFT; + mpt_alloc =3D initrd->start; init_domheap_pages(mpt_alloc, mpt_alloc + PAGE_ALIGN(initrd_len)); - initrd->mod_start =3D initrd_mfn =3D mfn_x(page_to_mfn(page)); + initrd_mfn =3D page_to_mfn(page); + initrd->start =3D mfn_to_maddr(initrd_mfn); } else { @@ -640,9 +643,9 @@ static int __init dom0_construct(struct domain *d, if ( assign_pages(mfn_to_page(_mfn(mfn++)), 1, d, 0) ) BUG(); } - initrd->mod_end =3D 0; + initrd->size =3D 0; =20 - iommu_memory_setup(d, "initrd", mfn_to_page(_mfn(initrd_mfn)), + iommu_memory_setup(d, "initrd", mfn_to_page(initrd_mfn), PFN_UP(initrd_len), &flush_flags); } =20 @@ -654,7 +657,7 @@ static int __init dom0_construct(struct domain *d, nr_pages - domain_tot_pages(d)); if ( initrd ) { - mpt_alloc =3D (paddr_t)initrd->mod_start << PAGE_SHIFT; + mpt_alloc =3D initrd->start; printk("\n Init. ramdisk: %"PRIpaddr"->%"PRIpaddr, mpt_alloc, mpt_alloc + initrd_len); } @@ -763,7 +766,7 @@ static int __init dom0_construct(struct domain *d, if ( count < initrd_pfn || count >=3D initrd_pfn + PFN_UP(initrd_l= en) ) mfn =3D pfn++; else - mfn =3D initrd_mfn++; + mfn =3D mfn_x(initrd_mfn) + 1; *l1tab =3D l1e_from_pfn(mfn, compat ? COMPAT_L1_PROT : L1_PROT); l1tab++; =20 @@ -882,7 +885,7 @@ static int __init dom0_construct(struct domain *d, if ( pfn >=3D initrd_pfn ) { if ( pfn < initrd_pfn + PFN_UP(initrd_len) ) - mfn =3D initrd->mod_start + (pfn - initrd_pfn); + mfn =3D paddr_to_pfn(initrd->start) + (pfn - initrd_pfn); else mfn -=3D PFN_UP(initrd_len); } @@ -1052,7 +1055,7 @@ out: =20 int __init dom0_construct_pv(struct domain *d, const struct boot_module *image, - module_t *initrd, + struct boot_module *initrd, const char *cmdline) { unsigned long cr4 =3D read_cr4(); --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729472220; cv=pass; d=zohomail.com; s=zohoarc; b=OFzAS31uOgWXoVqpp9INOHqmRo9IdEd+5YblmoaZnBelF4Cv3/tfgjG/Xk9FVRADa7QwhfK8bOtO7q1tsRRx+otSfRDDavBe15dvjzdZYuDEckozuZkgM+cZ+oFcrBKFJgALAwqSEaKoBUmhlhiPicGEAa+aqv8vNY9dd/OJP2E= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729472220; 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=ebv6FBQmIywtxA6+m9LZfpSXV7xXQCPLvSbFsF4UzmI=; b=jeUUd4YrVod3pdFati8AW2R5NXoyMfWYg8xWw0MPzhB9z9sxdnJbXzHuwduvZ0RLM+1jAU9tQDhdov6XBmF3z8KahBYGKhVVbpa2TVM/lHPuceJhegHkkvNsi2378duNYhSMXdV4QzObhYO3EdwO7ZXKyqGq+ZiNLEPbu1zrqkY= 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 1729472220219520.9592232124884; Sun, 20 Oct 2024 17:57:00 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822961.1236932 (Exim 4.92) (envelope-from ) id 1t2gio-0000W4-Ex; Mon, 21 Oct 2024 00:56:34 +0000 Received: by outflank-mailman (output) from mailman id 822961.1236932; Mon, 21 Oct 2024 00:56:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gio-0000Vx-C5; Mon, 21 Oct 2024 00:56:34 +0000 Received: by outflank-mailman (input) for mailman id 822961; Mon, 21 Oct 2024 00:56:32 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gc8-0003Iq-8g for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:49:40 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 58ae11b6-8f46-11ef-99a3-01e77a169b0f; Mon, 21 Oct 2024 02:49:38 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471612942225.76711816814077; Sun, 20 Oct 2024 17:46:52 -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: 58ae11b6-8f46-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729471615; cv=none; d=zohomail.com; s=zohoarc; b=cpzfKsLPJDHZ+wGCTOoC4bv0ZMt6IHACr0seNBS4v9uf4XTP6KX6QHm61USy5AeXPoIFV9Y6J+Wmt5DjVV3h+HM1gzIUy0c1gLdnbG81p7hHfT+ndnmWODVJRWCmFnMai9kh0DHq7lETG0j5kQWYDPHIUIChVfPmrVOJasdTgfQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471615; 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=ebv6FBQmIywtxA6+m9LZfpSXV7xXQCPLvSbFsF4UzmI=; b=VhWSYOZNCvOHiJi9zujPVBL2n676Dp1remqwkSmdT+2zCOmqZPyLnDEqqI+jnV9pxeXhoUjsIdtToneRN8WQs4Fc9OrAoOcs8t5FWk0V0pF46gJPhEOivECy8RxNPwIDvdZ2Vr/ijuzXCgOuac9VYNYB8Ugo6RIEgJprk1RIJzw= 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=1729471615; 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=ebv6FBQmIywtxA6+m9LZfpSXV7xXQCPLvSbFsF4UzmI=; b=KNBDWPXWwZLAphtk14ZshhKlW6khKiP8V1bdBALppv0vUNtNe5etp8JwGRJ9aXYN jO0CKtH355qst6GQJhbCU0Az8Q8Ds2X4i0RMqKxH6Ds0b4qGxcBFc7sIavUueTJN2ZA Oeyt/WjBrJQ3MyFxmCcI6BQ2oIkwJ/5F9OLHliJ8= 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 v7 25/38] x86/boot: convert dom0_construct_pvh to struct boot_module Date: Sun, 20 Oct 2024 20:46:00 -0400 Message-Id: <20241021004613.18793-26-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729472221495116600 Content-Type: text/plain; charset="utf-8" This changes both the kernel and ramdisk parameters over to struct boot_module. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v6: - removed unnecessary indentation changes --- xen/arch/x86/dom0_build.c | 3 +-- xen/arch/x86/hvm/dom0_build.c | 9 ++++----- xen/arch/x86/include/asm/dom0_build.h | 5 ++--- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 1d05ee53a6d8..71b2e3afc1a1 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -610,8 +610,7 @@ int __init construct_dom0(struct domain *d, const struc= t boot_module *image, process_pending_softirqs(); =20 if ( is_hvm_domain(d) ) - rc =3D dom0_construct_pvh(d, image->mod, image->headroom, initrd->= mod, - cmdline); + rc =3D dom0_construct_pvh(d, image, initrd, cmdline); else if ( is_pv_domain(d) ) rc =3D dom0_construct_pv(d, image, initrd, cmdline); else diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index 3dd913bdb029..0fe63f040936 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -1300,9 +1300,8 @@ static void __hwdom_init pvh_setup_mmcfg(struct domai= n *d) } } =20 -int __init dom0_construct_pvh(struct domain *d, const module_t *image, - unsigned long image_headroom, - module_t *initrd, +int __init dom0_construct_pvh(struct domain *d, const struct boot_module *= image, + struct boot_module *initrd, const char *cmdline) { paddr_t entry, start_info; @@ -1347,8 +1346,8 @@ int __init dom0_construct_pvh(struct domain *d, const= module_t *image, return rc; } =20 - rc =3D pvh_load_kernel(d, image, image_headroom, initrd, bootstrap_map= (image), - cmdline, &entry, &start_info); + rc =3D pvh_load_kernel(d, image->mod, image->headroom, initrd->mod, + bootstrap_map_bm(image), cmdline, &entry, &start_= info); if ( rc ) { printk("Failed to load Dom0 kernel\n"); diff --git a/xen/arch/x86/include/asm/dom0_build.h b/xen/arch/x86/include/a= sm/dom0_build.h index 3ddd22fad2ba..5d0c4fd2639a 100644 --- a/xen/arch/x86/include/asm/dom0_build.h +++ b/xen/arch/x86/include/asm/dom0_build.h @@ -17,9 +17,8 @@ int dom0_construct_pv(struct domain *d, const struct boot= _module *image, struct boot_module *initrd, const char *cmdline); =20 -int dom0_construct_pvh(struct domain *d, const module_t *image, - unsigned long image_headroom, - module_t *initrd, +int dom0_construct_pvh(struct domain *d, const struct boot_module *image, + struct boot_module *initrd, const char *cmdline); =20 unsigned long dom0_paging_pages(const struct domain *d, --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729472255; cv=pass; d=zohomail.com; s=zohoarc; b=HyihRPF2fOQEDWTRDOfX0Shv0/Agg5sYuyM2nbmAWgQ+VIpe6PdHYDm+yEX2+1UEc9Zs+X3sVvkbbkYt4OO/iKuR0P/MPTtitFomjPRx/zI6ddu2FGpRueV4i244bn1Tv6b418FROS0biiSCqW+HpdlT8PXfwCXYJTGR6lH1ph0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729472255; 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=8l/A5uTX2SajRrK9csx9oFSHA7WUVR/YgCRfUTZ06cw=; b=fpWaJ5ZMoqDNiUjS6Os1iOLlW0t70qVCBnQL95YzToZG4riERDgDXpvyvmN6yCLh34NFjr1cX7Iqxu2fdmBZ2R22KzSDHa5fT+Z8Pjat6zwfCU0Lrojpvbil9N/QRgojez5jkXnIYBjxiDmRHhn7YpR02sBWegnVv7i8+fRQVfA= 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 1729472255933768.9601092124749; Sun, 20 Oct 2024 17:57:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.823025.1237066 (Exim 4.92) (envelope-from ) id 1t2gjR-00077K-Kh; Mon, 21 Oct 2024 00:57:13 +0000 Received: by outflank-mailman (output) from mailman id 823025.1237066; Mon, 21 Oct 2024 00:57:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gjR-00076r-G8; Mon, 21 Oct 2024 00:57:13 +0000 Received: by outflank-mailman (input) for mailman id 823025; Mon, 21 Oct 2024 00:57:12 +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 1t2gcF-0001i1-1E for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:49:47 +0000 Received: from sender3-of-o58.zoho.com (sender3-of-o58.zoho.com [136.143.184.58]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 5d3c98f9-8f46-11ef-a0be-8be0dac302b0; Mon, 21 Oct 2024 02:49:46 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471614074580.9912900787891; Sun, 20 Oct 2024 17:46:54 -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: 5d3c98f9-8f46-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729471616; cv=none; d=zohomail.com; s=zohoarc; b=Rh1pfFOh/ZaLbVfmXmkN8JvQ1BP/bKVNJPhIe+6B6jfb2wMticdqY1bNxcoaABWgCK+3xujsR72yzXeo5tOM31oGk9962xxdSnkgvNG7ye3p0jlQELzRdXXnvU236Bk25EIw9ZFVQWoq+fgspjPDauSbvvJ/vR1OLeoEMmtjA9w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471616; 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=8l/A5uTX2SajRrK9csx9oFSHA7WUVR/YgCRfUTZ06cw=; b=l2bMvlqYqkBzD7ur+Bwz+73Kqdz/Bbn7GZhuOTfNlDkV+ruazlWjeml58PCeRH0GSmq0AJ28j/geGbeZ0ppa6aTmJ8Ek1szaQL4X6S/5KXvKO1JTpUCTYQ1U6SYbH3Ay+h3eG9lK/Z3uYeLbQNgUu+5XjQAW0Hm4OQ0hiB30BT8= 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=1729471616; 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=8l/A5uTX2SajRrK9csx9oFSHA7WUVR/YgCRfUTZ06cw=; b=By/WpDgqmji2sfwMOYkHAH2S/rjv1GqBVDprm5hLT69o0VmYCmm0fPy/Bt1aNwJu 69ViJFj+c5kuZUA7beejUnL9BpLhIRub+Enh5Mp+7mIEPUjvUgrgqYye476NSHgNUnO AhH9ZUT9fpZBb3aepolJ9mqExTJBcTEZsGztZZqg= 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 v7 26/38] x86/boot: convert pvh_load_kernel to struct boot_module Date: Sun, 20 Oct 2024 20:46:01 -0400 Message-Id: <20241021004613.18793-27-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729472257619116600 Content-Type: text/plain; charset="utf-8" This changes both the kernel and ramdisk parameters over to struct boot_mod= ule. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- xen/arch/x86/hvm/dom0_build.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index 0fe63f040936..211f4e3e772e 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -642,15 +642,14 @@ static bool __init check_and_adjust_load_address( return true; } =20 -static int __init pvh_load_kernel(struct domain *d, const module_t *image, - unsigned long image_headroom, - module_t *initrd, void *image_base, - const char *cmdline, paddr_t *entry, - paddr_t *start_info_addr) +static int __init pvh_load_kernel( + struct domain *d, const struct boot_module *image, + struct boot_module *initrd, void *image_base, + const char *cmdline, paddr_t *entry, paddr_t *start_info_addr) { - void *image_start =3D image_base + image_headroom; - unsigned long image_len =3D image->mod_end; - unsigned long initrd_len =3D initrd ? initrd->mod_end : 0; + void *image_start =3D image_base + image->headroom; + unsigned long image_len =3D image->size; + unsigned long initrd_len =3D initrd ? initrd->size : 0; struct elf_binary elf; struct elf_dom_parms parms; paddr_t last_addr; @@ -725,7 +724,7 @@ static int __init pvh_load_kernel(struct domain *d, con= st module_t *image, =20 if ( initrd !=3D NULL ) { - rc =3D hvm_copy_to_guest_phys(last_addr, mfn_to_virt(initrd->mod_s= tart), + rc =3D hvm_copy_to_guest_phys(last_addr, maddr_to_virt(initrd->sta= rt), initrd_len, v); if ( rc ) { @@ -736,9 +735,9 @@ static int __init pvh_load_kernel(struct domain *d, con= st module_t *image, mod.paddr =3D last_addr; mod.size =3D initrd_len; last_addr +=3D ROUNDUP(initrd_len, elf_64bit(&elf) ? 8 : 4); - if ( initrd->string ) + if ( initrd->cmdline ) { - char *str =3D __va(initrd->string); + char *str =3D __va((unsigned long)initrd->cmdline); size_t len =3D strlen(str) + 1; =20 rc =3D hvm_copy_to_guest_phys(last_addr, str, len, v); @@ -1346,8 +1345,8 @@ int __init dom0_construct_pvh(struct domain *d, const= struct boot_module *image, return rc; } =20 - rc =3D pvh_load_kernel(d, image->mod, image->headroom, initrd->mod, - bootstrap_map_bm(image), cmdline, &entry, &start_= info); + rc =3D pvh_load_kernel(d, image, initrd, bootstrap_map_bm(image), cmdl= ine, + &entry, &start_info); if ( rc ) { printk("Failed to load Dom0 kernel\n"); --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729472267; cv=pass; d=zohomail.com; s=zohoarc; b=DWviSCWxCgziDTuBPwHcwRBsRyyG7mKLXuNoKOo3iAxnNX/qCMu9Vmg0rOhEjiyTJsyFBJHXFATasvEeSdnsOkc87T7+8rFRim01I//rIpqNE713mirRxSEfpT/J1fSMY7NCFo+i1ADy49WtbVknrZ9UhdkEv3Kt7JHP+UwPIi8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729472267; 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=g0NVk64TuKi2tR5OnvtS4NnU7f+YLD8Wq1acHX9UIbs=; b=fJFoZlPOEugWOyZ/vT2pdTGVx3onCIT/pBCx/mKdh5Vg2gP6kgtvm6mUNZm3ezWicoIOMlFK9zneoJIKfwOFlv8BGG5wSUM97YMgKI0kU2ExBES1LyQ5as5FyNjzY6/ImAku+sNDZ6hbF/kp1Dpuy0h+cgCHh0ogOBF4SgDA2jw= 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 1729472267066314.3838456583321; Sun, 20 Oct 2024 17:57:47 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.823021.1237048 (Exim 4.92) (envelope-from ) id 1t2gjP-0006ZF-S1; Mon, 21 Oct 2024 00:57:11 +0000 Received: by outflank-mailman (output) from mailman id 823021.1237048; Mon, 21 Oct 2024 00:57:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gjP-0006Yo-KR; Mon, 21 Oct 2024 00:57:11 +0000 Received: by outflank-mailman (input) for mailman id 823021; Mon, 21 Oct 2024 00:57:10 +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 1t2gcL-0001i1-G9 for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:49:53 +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 610f676a-8f46-11ef-a0be-8be0dac302b0; Mon, 21 Oct 2024 02:49:52 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471615202442.76370585557197; Sun, 20 Oct 2024 17:46:55 -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: 610f676a-8f46-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729471617; cv=none; d=zohomail.com; s=zohoarc; b=CIv9MEArRivr4cwIqGVq5EVSB2bEstnzqvi1WfqcQrGsUejgrvj6f7uAWik6A8hRzzJw1FWtVGXlJOAJBpTNf9wm2OPzc96LeE6n9BpGqZkLngmycDb1gXvcM6Q5lc2n4x1NaNgVHLn6R57qCJnmXWgoy+TCdWRKLt1s8iO5eSY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471617; 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=g0NVk64TuKi2tR5OnvtS4NnU7f+YLD8Wq1acHX9UIbs=; b=APaGUFCQVJVZ2glPYSsw687cau06o+/I8GDzrNNm8eebuSRMaKu5emPgvNaE9I9lB64nNJCoMJWs5wY+1LdGQTIK3eEi84OunSjtSqu9rYqpU3GQSrdYQBk903iqaFn5A7MClNmKKY/YBqjra0tECpc57ymP50ZtyLmJcYomuHA= 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=1729471617; 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=g0NVk64TuKi2tR5OnvtS4NnU7f+YLD8Wq1acHX9UIbs=; b=S4Bnj9nRgJCK1jSlWbAhpSGz6bZZlkvl5zO23KEK6qpHPCC5Lfn8/LC23k+8pnm8 yHbFZfcSaDvy+oOcNXpyNwwMnCGuUh1a50nRwDhOKuizpUROumKPYbl8YKqCeFg7IeE l4LueC69upfXsG1Ah/4QracetxKxQiazHrJJ4DgE= 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 v7 27/38] x86/boot: convert initial_images to struct boot_module Date: Sun, 20 Oct 2024 20:46:02 -0400 Message-Id: <20241021004613.18793-28-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729472267655116600 Content-Type: text/plain; charset="utf-8" The variable initial_images is used for tracking the boot modules passed in= by the boot loader. Convert to a struct boot_module and adjust the code that u= ses it accordingly. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v5: - coding style changes --- xen/arch/x86/setup.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 254aeb0c5e1b..0f8fb3c572c6 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -276,7 +276,7 @@ custom_param("acpi", parse_acpi_param); =20 static const char *cmdline_cook(const char *p, const char *loader_name); =20 -static const module_t *__initdata initial_images; +static const struct boot_module *__initdata initial_images; =20 struct boot_info __initdata xen_boot_info =3D { .loader =3D "unknown", @@ -352,8 +352,8 @@ unsigned long __init initial_images_nrpages(nodeid_t no= de) =20 for ( nr =3D i =3D 0; i < bi->nr_modules; ++i ) { - unsigned long start =3D initial_images[i].mod_start; - unsigned long end =3D start + PFN_UP(initial_images[i].mod_end); + unsigned long start =3D initial_images[i].mod->mod_start; + unsigned long end =3D start + PFN_UP(initial_images[i].mod->mod_en= d); =20 if ( end > node_start && node_end > start ) nr +=3D min(node_end, end) - max(node_start, start); @@ -369,10 +369,11 @@ void __init discard_initial_images(void) =20 for ( i =3D 0; i < bi->nr_modules; ++i ) { - uint64_t start =3D (uint64_t)initial_images[i].mod_start << PAGE_S= HIFT; + uint64_t start =3D + (uint64_t)initial_images[i].mod->mod_start << PAGE_SHIFT; =20 init_domheap_pages(start, - start + PAGE_ALIGN(initial_images[i].mod_end)); + start + PAGE_ALIGN(initial_images[i].mod->mod_e= nd)); } =20 bi->nr_modules =3D 0; @@ -1403,11 +1404,7 @@ void asmlinkage __init noreturn __start_xen(unsigned= long mbi_p) set_kexec_crash_area_size((u64)nr_pages << PAGE_SHIFT); kexec_reserve_area(); =20 - /* - * The field bi->mods[0].mod points to the first element of the module= _t - * array. - */ - initial_images =3D bi->mods[0].mod; + initial_images =3D bi->mods; =20 for ( i =3D 0; !efi_enabled(EFI_LOADER) && i < bi->nr_modules; i++ ) { --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729472281; cv=pass; d=zohomail.com; s=zohoarc; b=ZDwtokUvZ8Hv1/dMwHsRyVCdOD5es2GMhXanD44jhrG+4B96MF1//Dko0aShfYePBNtXqpNVhmv9jY2Q/wXZr5ibIqlqoZChXjBgvrsqdH6myENhUIq3WlEwGkzlchnU0ltsRGjaP6xUyjRrclPGgQp+Q7ROu241F8s12mArMyY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729472281; 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=4ag7BDYJg0dD1MtHECzU1bM5RUJR5RzORSBjMhAVv1w=; b=KPsM5UvXtX0xHP/q0D94oBL9WjxqiLu6GemP5kWXMTrBBpsudGCEGa2EKdJveS4YXx6mhPejLy/UIBl3QkCIzHn2DBpKXW2lFxT3ndKpQUA8hRpomjEiVA71cBIo5u1uwmLgOfJ0gHmLqspEeJ+g2H1s89ZWswLVFIh/xj+5sLU= 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 1729472281128920.5001384150967; Sun, 20 Oct 2024 17:58:01 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.823041.1237132 (Exim 4.92) (envelope-from ) id 1t2gji-0001qD-EC; Mon, 21 Oct 2024 00:57:30 +0000 Received: by outflank-mailman (output) from mailman id 823041.1237132; Mon, 21 Oct 2024 00:57:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gji-0001pu-9B; Mon, 21 Oct 2024 00:57:30 +0000 Received: by outflank-mailman (input) for mailman id 823041; Mon, 21 Oct 2024 00:57:28 +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 1t2gcS-0001i1-9C for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:50:00 +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 6522d4f6-8f46-11ef-a0be-8be0dac302b0; Mon, 21 Oct 2024 02:49:59 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471616342247.8943247367; Sun, 20 Oct 2024 17:46:56 -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: 6522d4f6-8f46-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729471618; cv=none; d=zohomail.com; s=zohoarc; b=Fv1tyRxEi/bmv8ISik3CGJTEMws3IwYpieAIPAehIm0qomzABxCtPLyzWKp35V22ptyguIXFyU1nY4DId8tge14euLcyLM/sNkYS+eTShnQbtDPlYsnBu9mXkP7AKgHOz82hEJ2h9DSRzNmsQeDEJEXX++5BFmbQY1hF5vVkwRA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471618; 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=4ag7BDYJg0dD1MtHECzU1bM5RUJR5RzORSBjMhAVv1w=; b=ZuSiiyzG3fdtSHntSZ2ZXQ0JCKmEmjkcNfSWAn866GehqOYwbFKcguMzqadb67+r2qRoft9lRfMTdpw6u7NchdcEPq8z2n+xZYgyvTA/rExfH7bmDcY/IkGGaH5YHShIdFtALq+l8/vZdV3gXBmppRpn92KGhEYcxkFM8C1h04E= 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=1729471618; 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=4ag7BDYJg0dD1MtHECzU1bM5RUJR5RzORSBjMhAVv1w=; b=qrosCpFNUEl73UQKhT5m7P6zLtUVfdIaDflloSBb0piuDWi1qcBtURdNJAm5A1vd ErsfO4PakwSy0IIiGN4a9B8fUT3amFzhGIIXhrsuztkjqd7N8uTeiUhgLmdQ3+dIv+R xysEpEr37/EdW/QUGzPxiYAip0kc9yWR+trlWo9U= 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 v7 28/38] x86/boot: drop the use of initial_images unit global Date: Sun, 20 Oct 2024 20:46:03 -0400 Message-Id: <20241021004613.18793-29-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729472281709116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v5: - coding style changes --- xen/arch/x86/setup.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 0f8fb3c572c6..87b118cdcf1e 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -276,8 +276,6 @@ custom_param("acpi", parse_acpi_param); =20 static const char *cmdline_cook(const char *p, const char *loader_name); =20 -static const struct boot_module *__initdata initial_images; - struct boot_info __initdata xen_boot_info =3D { .loader =3D "unknown", .cmdline =3D "", @@ -352,8 +350,8 @@ unsigned long __init initial_images_nrpages(nodeid_t no= de) =20 for ( nr =3D i =3D 0; i < bi->nr_modules; ++i ) { - unsigned long start =3D initial_images[i].mod->mod_start; - unsigned long end =3D start + PFN_UP(initial_images[i].mod->mod_en= d); + unsigned long start =3D bi->mods[i].mod->mod_start; + unsigned long end =3D start + PFN_UP(bi->mods[i].mod->mod_end); =20 if ( end > node_start && node_end > start ) nr +=3D min(node_end, end) - max(node_start, start); @@ -370,14 +368,12 @@ void __init discard_initial_images(void) for ( i =3D 0; i < bi->nr_modules; ++i ) { uint64_t start =3D - (uint64_t)initial_images[i].mod->mod_start << PAGE_SHIFT; + (uint64_t)bi->mods[i].mod->mod_start << PAGE_SHIFT; =20 - init_domheap_pages(start, - start + PAGE_ALIGN(initial_images[i].mod->mod_e= nd)); + init_domheap_pages(start, start + PAGE_ALIGN(bi->mods[i].mod->mod_= end)); } =20 bi->nr_modules =3D 0; - initial_images =3D NULL; } =20 static void __init init_idle_domain(void) @@ -1404,8 +1400,6 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) set_kexec_crash_area_size((u64)nr_pages << PAGE_SHIFT); kexec_reserve_area(); =20 - initial_images =3D bi->mods; - for ( i =3D 0; !efi_enabled(EFI_LOADER) && i < bi->nr_modules; i++ ) { if ( bi->mods[i].mod->mod_start & (PAGE_SIZE - 1) ) --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729472247; cv=pass; d=zohomail.com; s=zohoarc; b=BLnoloUnwcH4nG8ksF/FH98ZSl0iDy/Ln6TYy569xu0lomR157qFj0A2RZIVL++xuyeWBOF5YYnEQQBjE5SaC82yaTOKafYs5LrfepwHenAKLJPDAY//KpzChBC/rkr4K3W9QsulLCc9xcXflRaGi+3MAP6LahBB0D2jK2pztyI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729472247; 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=2hHosgMYwG/qh3KyF6wBYzUNZ0LC3cPr+j0rK/PGAiY=; b=M8R1HDeS1xYpjZd6BEf6dTHRz5CzYROpVfQ9v2jrSm9G6AYjTMq4EWmaNtkhgF3wRE8QBDYCaBi2CbqCdqhq+7p/9lNKAJwxFMPwTp1+t4uLs89l2SMjiIub0JfFrAbhzRvavjBt4ioZXDf3jPCcVESbPhRUGe7kwj83IEFAR28= 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 1729472247474863.8888315753406; Sun, 20 Oct 2024 17:57:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822998.1237032 (Exim 4.92) (envelope-from ) id 1t2gj9-0004dQ-32; Mon, 21 Oct 2024 00:56:55 +0000 Received: by outflank-mailman (output) from mailman id 822998.1237032; Mon, 21 Oct 2024 00:56:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gj8-0004d1-UY; Mon, 21 Oct 2024 00:56:54 +0000 Received: by outflank-mailman (input) for mailman id 822998; Mon, 21 Oct 2024 00:56:53 +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 1t2gcY-0001i1-Qq for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:50:06 +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 6938c053-8f46-11ef-a0be-8be0dac302b0; Mon, 21 Oct 2024 02:50:06 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471617465839.8166672698667; Sun, 20 Oct 2024 17:46:57 -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: 6938c053-8f46-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729471619; cv=none; d=zohomail.com; s=zohoarc; b=J31Wi4UxyzqAXeN9DVb/u9MYZSPtC/vYa3QRHJPuV9+Wmrt7PPaBNqCOJB3/kPg/jWgzB6Zxq/lc2f7Ed+tqAC8xYBhuRg5zk2ESkoxWitAfXOAQgHsqhdGw9jaw+wDpOHNRxx8jhZFgtn3KAWZg+oOI0D6hCWUg9Mhq66frSIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471619; 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=2hHosgMYwG/qh3KyF6wBYzUNZ0LC3cPr+j0rK/PGAiY=; b=HxqUZ+g+sSGAeGTjPNSmFdMQCEKEc1MGQ1QNOxpZ1+pSHgyzwAiwkPPMXLFiFJC5uadz5aV0w+YcK4oJ4l4iCWwolMCdFSH+wv8mFTbVKJSywSYW5E8q0jASJTxOnCawvvM0lg9W4fV/OBKPghhyhakKCWhF9Cq/BkSLQ9ayYI0= 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=1729471619; 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=2hHosgMYwG/qh3KyF6wBYzUNZ0LC3cPr+j0rK/PGAiY=; b=SUw+1gLzRkcVfTFOdXvLHoCerTY2wmLKmFd46xXdn9wH1xr1np/F+iRoKvwiBA5P Eo4z01n/Cbv1vDdUq4Rpcj/37kpNwBp+8Q1SvjKekzVKnw0QUtPDA6ZkP7F7ruGSEpd MDJj/9WBTSkeKzAqaj+JY2hOgwCvqEDGcLDfwTbQ= 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 v7 29/38] x86/boot: remove usage of mod_end by discard_initial_images Date: Sun, 20 Oct 2024 20:46:04 -0400 Message-Id: <20241021004613.18793-30-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729472249773116600 Content-Type: text/plain; charset="utf-8" This eliminates usage of early_mod by discard_initial_images Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- xen/arch/x86/setup.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 87b118cdcf1e..67e72459170a 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -367,10 +367,9 @@ void __init discard_initial_images(void) =20 for ( i =3D 0; i < bi->nr_modules; ++i ) { - uint64_t start =3D - (uint64_t)bi->mods[i].mod->mod_start << PAGE_SHIFT; + uint64_t start =3D bi->mods[i].start; =20 - init_domheap_pages(start, start + PAGE_ALIGN(bi->mods[i].mod->mod_= end)); + init_domheap_pages(start, start + PAGE_ALIGN(bi->mods[i].size)); } =20 bi->nr_modules =3D 0; --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729472273; cv=pass; d=zohomail.com; s=zohoarc; b=Dv1OI/dBxMTwWI6w/+cGN9TdsVi2prBkrY2yn+UIOTJqpuXqOz+QuUTwwd+t/VqllEJKFCveqX+vHptsNfUBFnWajgJ7rzYrvoR+YcoF+qkBqJTffSI6rXgXwJmjefahmb9eLSayO6FI8dq7vjwgqkK3EQEGx6/4dTYMgiZii4o= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729472273; 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=GK3STJ5aZqEuHy+kekMK2JZrWAG/l3wNbP6L7AEea2o=; b=h55D0YtKCKucOoXFNvTFo5G9OkGuKaJE+aBvSsU7ZejtfO4CuBMvTUp8dTBQGrJ6Q4vHqaF+y0+Uo1ehLCCrpNKmmdmYwKk+vuc9SF9gV213kgr8VqapXUchh+KDPxUBvFkAd331UkrJPDFHQT8oUAiIJqAcd+yyCL0LosPT31A= 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 1729472273956763.2386441879218; Sun, 20 Oct 2024 17:57:53 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.823038.1237122 (Exim 4.92) (envelope-from ) id 1t2gjd-00011W-Ry; Mon, 21 Oct 2024 00:57:25 +0000 Received: by outflank-mailman (output) from mailman id 823038.1237122; Mon, 21 Oct 2024 00:57:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gjd-0000zk-Ky; Mon, 21 Oct 2024 00:57:25 +0000 Received: by outflank-mailman (input) for mailman id 823038; Mon, 21 Oct 2024 00:57:24 +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 1t2gcg-0001i1-8a for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:50:14 +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 6d7b8930-8f46-11ef-a0be-8be0dac302b0; Mon, 21 Oct 2024 02:50:13 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471618610716.8532469184576; Sun, 20 Oct 2024 17:46:58 -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: 6d7b8930-8f46-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729471620; cv=none; d=zohomail.com; s=zohoarc; b=FbmgV0ezgOaZfoTNAr14nsADmTTI4W2l6IfmMrxqv7fZZKXzsUEzOl5yMjdawq9lc4ARJ6RxXFMC0W0ivtfppHqoG0rhWa0h3p9WIB0tXVf9COnD/uo+1HbfLQMS+Gq+jlHlT3OvUvcOKKtNKYIEl8Ish+/BwgTJ06kIyhsMeWk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471620; 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=GK3STJ5aZqEuHy+kekMK2JZrWAG/l3wNbP6L7AEea2o=; b=WOIp4AnExr9s0FuhE8pQQyfzHxS42zDXg8ARsNhYfFsoMl792+QVpMjiHt4qgpJybCjPcL4yfR9fTeivhMgqOso8/sOYBg4zflKTUzScbTCLGHjofQKkGAIlmmtAhfsdzJAa0/CA6hHWlg3qKGUfTLmsI2iI7tP9BIXzicnviNo= 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=1729471620; 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=GK3STJ5aZqEuHy+kekMK2JZrWAG/l3wNbP6L7AEea2o=; b=oE3W/Ky24xtuIXw4iJhxF7Lfi3zRKAbUkmzBs3n+VBuhi9yfoQ3CqIhY2ly+GI83 +0C0omcIB7u9zFNNXXB4Urw+q1hWTo7fREWQr1snuTlHTak6KuAynDvyK60He+/Uwcd qrW0A0K6V2Gv+WYKrn5tzUgqe5NF8T/7MQQfFREE= 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 v7 30/38] x86/boot: remove remaining module_t references Date: Sun, 20 Oct 2024 20:46:05 -0400 Message-Id: <20241021004613.18793-31-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729472275706116600 Content-Type: text/plain; charset="utf-8" Any direct usages of module_t have been transitioned, remove the remaining references to the mod field. This also removes any external use of bootstrap_map(), dropping from setup.h and making it static. Signed-off-by: Daniel P. Smith --- Changes since v6: - drop efi exclusion check for module memory alignment validation Changes since v5: - commit message rewrite - coding style change - remove export of bootstrap_map() --- xen/arch/x86/include/asm/setup.h | 1 - xen/arch/x86/setup.c | 29 ++++++++++------------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/se= tup.h index 72d183e8a4de..f7958b56eab6 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -35,7 +35,6 @@ extern struct boot_info xen_boot_info; =20 unsigned long initial_images_nrpages(nodeid_t node); void discard_initial_images(void); -void *bootstrap_map(const module_t *mod); void *bootstrap_map_bm(const struct boot_module *bm); =20 int remove_xen_ranges(struct rangeset *r); diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 67e72459170a..2102923cd510 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -350,8 +350,8 @@ unsigned long __init initial_images_nrpages(nodeid_t no= de) =20 for ( nr =3D i =3D 0; i < bi->nr_modules; ++i ) { - unsigned long start =3D bi->mods[i].mod->mod_start; - unsigned long end =3D start + PFN_UP(bi->mods[i].mod->mod_end); + unsigned long start =3D bi->mods[i].start; + unsigned long end =3D start + PFN_UP(bi->mods[i].size); =20 if ( end > node_start && node_end > start ) nr +=3D min(node_end, end) - max(node_start, start); @@ -488,7 +488,7 @@ static void *__init bootstrap_map_addr(paddr_t start, p= addr_t end) return ret; } =20 -void *__init bootstrap_map(const module_t *mod) +static void *__init bootstrap_map(const module_t *mod) { if ( !mod ) return bootstrap_map_addr(0, 0); @@ -678,8 +678,8 @@ static uint64_t __init consider_modules( =20 for ( i =3D 0; i < nr_mods ; ++i ) { - uint64_t start =3D pfn_to_paddr(mods[i].mod->mod_start); - uint64_t end =3D start + PAGE_ALIGN(mods[i].mod->mod_end); + uint64_t start =3D (uint64_t)mods[i].start; + uint64_t end =3D start + PAGE_ALIGN(mods[i].size); =20 if ( i =3D=3D this_mod ) continue; @@ -1399,12 +1399,10 @@ void asmlinkage __init noreturn __start_xen(unsigne= d long mbi_p) set_kexec_crash_area_size((u64)nr_pages << PAGE_SHIFT); kexec_reserve_area(); =20 - for ( i =3D 0; !efi_enabled(EFI_LOADER) && i < bi->nr_modules; i++ ) + for ( i =3D 0; i < bi->nr_modules; i++ ) { - if ( bi->mods[i].mod->mod_start & (PAGE_SIZE - 1) ) + if ( bi->mods[i].start & (PAGE_SIZE - 1) ) panic("Bootloader didn't honor module alignment request\n"); - bi->mods[i].mod->mod_end -=3D bi->mods[i].mod->mod_start; - bi->mods[i].mod->mod_start >>=3D PAGE_SHIFT; } =20 /* @@ -1425,16 +1423,11 @@ void asmlinkage __init noreturn __start_xen(unsigne= d long mbi_p) */ bi->mods[xen].start =3D virt_to_maddr(_stext); bi->mods[xen].size =3D __2M_rwdata_end - _stext; - - bi->mods[xen].mod->mod_start =3D paddr_to_pfn(bi->mods[xen].start); - bi->mods[xen].mod->mod_end =3D bi->mods[xen].size; } =20 - bi->mods[0].headroom =3D - bzimage_headroom(bootstrap_map(bi->mods[0].mod), - bi->mods[0].mod->mod_end); - - bootstrap_map(NULL); + bi->mods[0].headroom =3D bzimage_headroom( + bootstrap_map_bm(&bi->mods[0]), bi->mods[0].size); + bootstrap_map_bm(NULL); =20 #ifndef highmem_start /* Don't allow split below 4Gb. */ @@ -1535,9 +1528,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) { move_memory(end - size + bm->headroom, bm->start, bm->size= ); bm->start =3D (end - size); - bm->mod->mod_start =3D paddr_to_pfn(bm->start); bm->size +=3D bm->headroom; - bm->mod->mod_end =3D bm->size; bm->relocated =3D true; } } --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729471838; cv=pass; d=zohomail.com; s=zohoarc; b=kPixRUcusi5F0E+PValxKO1BUZx8KIoo0hITh5epMaFWOPCQhmXOLmrzmuA8LPZDNRIMWN5m+vMp/3NoHG3r74uedetlnGoiq8x/O298BX4YHAeTf9HE1MaHKSNRZQcjGj0IQZIbGP+pJcfnBWhkHi7AwkS7D3FLsvSdB9IGYJw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471838; 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=Jx51Zf1zwygUUllbZAd+b9gYxFDST6JrxccGSqHc+vc=; b=ltzWcytgpw1g6LZ+UoKCfl9LlT5SnPTDbCVph2EFU39KvqJ4uJqtPUkprsEzd/FMaxbK95nPtYF/VVS6LJgFiW6KtxFvXcajkzRHjx0Z1RGg3v9rhacKeIuY5MXEPxHGZrjxoVw6PUYWAHh+8pU5bNjqrLsPlpQV0YduvtCIDYo= 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 1729471838275968.8842560348334; Sun, 20 Oct 2024 17:50:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822930.1236892 (Exim 4.92) (envelope-from ) id 1t2gcr-0006Ss-2D; Mon, 21 Oct 2024 00:50:25 +0000 Received: by outflank-mailman (output) from mailman id 822930.1236892; Mon, 21 Oct 2024 00:50:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gcq-0006Sl-Vh; Mon, 21 Oct 2024 00:50:24 +0000 Received: by outflank-mailman (input) for mailman id 822930; Mon, 21 Oct 2024 00:50:24 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gcq-0006SZ-8Y for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:50:24 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 72bfce43-8f46-11ef-99a3-01e77a169b0f; Mon, 21 Oct 2024 02:50:22 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471619758245.98953686943776; Sun, 20 Oct 2024 17:46:59 -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: 72bfce43-8f46-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729471622; cv=none; d=zohomail.com; s=zohoarc; b=IRqZaQ4+kh/HRypaOU5C5US+K0CJvsmhAIFWyD4SbQ8osnR2ivVgxks1gf52rW3J2X0mJo2rMgB2BGKmwXXv2L5/BS73P9i/kGlW1NwFIu75IrEFeObVnwUlJ3pYuvAmjswTJb3XLfBrO0j0ih+YdavyQ6rwLusYmr1qrzpIyJw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471622; 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=Jx51Zf1zwygUUllbZAd+b9gYxFDST6JrxccGSqHc+vc=; b=HUbtKCinlxiyjKm2U/HqD/m266ijeF9U5/81vdsyTWqjHOqgbkAx/LAmHW1dZCOpBAdliHhYUZlqy4lFa4ggk+3AZZ5soxbVzrQdpi5EcYIudxSTlzj/mvDOZ1l5UpjfCZ80pz0fABAOtkP59VRcR01UVyvRYyxA5avq25Aj8kI= 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=1729471622; 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=Jx51Zf1zwygUUllbZAd+b9gYxFDST6JrxccGSqHc+vc=; b=IHCOGVlafenqtX/hDFMkmGm89FkiB7nolG3pT236cn0cBDr3plYLAuXefKNoLmkA 24ZAizCLX6VUoFKVKdblOYxo/YUNTRHjRs0moa23Ueoch/K9FoyVVvwAzBCavaBF1qK TagzaIh3wBeZES4/3Iz2BoHDZEQHEcTRf884iBpI= 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 v7 31/38] x86/boot: remove mod from struct boot_module Date: Sun, 20 Oct 2024 20:46:06 -0400 Message-Id: <20241021004613.18793-32-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729471839984116600 Content-Type: text/plain; charset="utf-8" With all references to mod field removed, remove the mod field from struct boot_module. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- xen/arch/x86/include/asm/bootinfo.h | 4 ---- xen/arch/x86/setup.c | 3 --- 2 files changed, 7 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index 941363601db7..eaed99b64e57 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -8,7 +8,6 @@ #ifndef X86_BOOTINFO_H #define X86_BOOTINFO_H =20 -#include #include =20 /* Max number of boot modules a bootloader can provide in addition to Xen = */ @@ -25,9 +24,6 @@ enum bootmod_type { }; =20 struct boot_module { - /* Transitionary only */ - module_t *mod; - /* * A boot module may contain a compressed kernel that will require * additional space, before the module data, into which the kernel wil= l be diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 2102923cd510..1fda462ba1d0 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -314,8 +314,6 @@ static struct boot_info *__init multiboot_fill_boot_inf= o(unsigned long mbi_p) */ for ( i =3D 0; i < MAX_NR_BOOTMODS && i < bi->nr_modules; i++ ) { - bi->mods[i].mod =3D &mods[i]; - bi->mods[i].cmdline =3D (paddr_t)mods[i].string; =20 if ( !efi_enabled(EFI_LOADER) ) @@ -331,7 +329,6 @@ static struct boot_info *__init multiboot_fill_boot_inf= o(unsigned long mbi_p) } =20 /* Variable 'i' should be one entry past the last module. */ - bi->mods[i].mod =3D &mods[bi->nr_modules]; bi->mods[i].start =3D mods[i].mod_start; bi->mods[i].size =3D mods[i].mod_end - mods[i].mod_start; bi->mods[i].type =3D BOOTMOD_XEN; --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729471851; cv=pass; d=zohomail.com; s=zohoarc; b=GtpG6Dxw4PO4jXcdtxnGJSK6t+BoQJqmECf7/auiculHgaeWqPoWw6xpcdUFq8Y1XkrJVSjqZVnZ/wl1rjLM3U/Afe0Aeio/Sko9/lYIapTh/83FAXReOVymm+8Qvyf5YMhsQvj8ttP0EgIO601cVgxcL5G7M2T9VsPJwrZctV8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471851; 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=Oopo77OjyZyLSeSBhv9zVkD0fLALdVYLRGVHW2cBbWA=; b=LdjuVCM2jNtkVIAXhUAf1csrouyHAfxcAkd5LsW4eLC3Rd6b+I9AvX9zLLuADNNrJqQkXEd2bX/hh6gfR2b2WsGULviNIpCORFdNRPdQSZt1wDmh7yNymQa65zC0CIAbyG4h4vTALkNoX7xR4SNr1ZWTzL4zd2exR5LZ+7YrhG0= 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 172947185100666.77117788923647; Sun, 20 Oct 2024 17:50:51 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822931.1236902 (Exim 4.92) (envelope-from ) id 1t2gcz-0006mK-CX; Mon, 21 Oct 2024 00:50:33 +0000 Received: by outflank-mailman (output) from mailman id 822931.1236902; Mon, 21 Oct 2024 00:50:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gcz-0006mB-9g; Mon, 21 Oct 2024 00:50:33 +0000 Received: by outflank-mailman (input) for mailman id 822931; Mon, 21 Oct 2024 00:50:32 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gcy-0006SZ-Ek for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:50:32 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 77c4f1ae-8f46-11ef-99a3-01e77a169b0f; Mon, 21 Oct 2024 02:50:30 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471620910870.5614994718397; Sun, 20 Oct 2024 17:47:00 -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: 77c4f1ae-8f46-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729471623; cv=none; d=zohomail.com; s=zohoarc; b=DuBhDV9LR43EjSEDrWxffmCR7i6UHowBWr7l+kg6XwSINeRtJOd86N/zKlBiTw6oKnTRsFsHyDMwXYVn8UkTFjCtfaC2eL7ftbeYf+1H1U7dkixblKhFPQ+Pkj6P8a/B00wHAeB9pLlhHO1uNEjq+IAgZjD1Xs9+fc3sCH76i0I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471623; 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=Oopo77OjyZyLSeSBhv9zVkD0fLALdVYLRGVHW2cBbWA=; b=bCNVar2zNjEBdjfjwPaH/BnBHAqljrdLZgyXO9wfANN245/I36u7c+600KnPRklNsWYEZ5O6Mgw3O1NOrNwIdNS1XVRmWHDgYzdgi4G8HC6PnjVveLP1+v5GlLIEdZxiIakAABDAVisSwV2fHttpXGsuAmo+0h9+cyeBCizSyMY= 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=1729471623; 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=Oopo77OjyZyLSeSBhv9zVkD0fLALdVYLRGVHW2cBbWA=; b=UQhe8Ua9gqNAY8peiLoAJNH5hlB8ScDqnGV6yIMJVUg48TBWhzqY8jcyxykrEQyU p6doLUX1OO2C3fYyPHOAMC9lUyrbrbcVHAr/7neHRHqsUjd+F5FDnS7JKSAlM0cPaJd v/CMUXFMwAA8qI04KEdtE4t8/zfqowB5xct30V2k= 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 v7 32/38] x86/boot: introduce boot domain Date: Sun, 20 Oct 2024 20:46:07 -0400 Message-Id: <20241021004613.18793-33-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729471852065116600 Content-Type: text/plain; charset="utf-8" To begin moving toward allowing the hypervisor to construct more than one domain at boot, a container is needed for a domain's build information. Introduce a new header, , that contains the initial struct boot_domain that encapsulate the build information for a domain. No functional change intended. Signed-off-by: Daniel P. Smith --- xen/arch/x86/include/asm/bootdomain.h | 28 +++++++++++++++++++++++++++ xen/arch/x86/include/asm/bootinfo.h | 5 +++++ xen/arch/x86/setup.c | 23 +++++++--------------- 3 files changed, 40 insertions(+), 16 deletions(-) create mode 100644 xen/arch/x86/include/asm/bootdomain.h diff --git a/xen/arch/x86/include/asm/bootdomain.h b/xen/arch/x86/include/a= sm/bootdomain.h new file mode 100644 index 000000000000..4285223ac5ab --- /dev/null +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (c) 2024 Apertus Solutions, LLC + * Author: Daniel P. Smith + * Copyright (c) 2024 Christopher Clark + */ + +#ifndef __XEN_X86_BOOTDOMAIN_H__ +#define __XEN_X86_BOOTDOMAIN_H__ + +struct boot_module; + +struct boot_domain { + struct boot_module *kernel; + struct boot_module *ramdisk; +}; + +#endif + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index eaed99b64e57..3fb23e90d712 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -9,10 +9,14 @@ #define X86_BOOTINFO_H =20 #include +#include =20 /* Max number of boot modules a bootloader can provide in addition to Xen = */ #define MAX_NR_BOOTMODS 63 =20 +/* Max number of boot domains that Xen can construct */ +#define MAX_NR_BOOTDOMS 1 + /* Boot module binary type / purpose */ enum bootmod_type { BOOTMOD_UNKNOWN, @@ -68,6 +72,7 @@ struct boot_info { =20 unsigned int nr_modules; struct boot_module mods[MAX_NR_BOOTMODS + 1]; + struct boot_domain domains[MAX_NR_BOOTDOMS]; }; =20 static inline struct boot_module *__init next_boot_module_by_type( diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 1fda462ba1d0..9b2a16863eae 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -972,20 +972,10 @@ static struct domain *__init create_dom0(struct boot_= info *bi) .misc_flags =3D opt_dom0_msr_relaxed ? XEN_X86_MSR_RELAXED : 0, }, }; - unsigned int mod_idx =3D first_boot_module_index(bi, BOOTMOD_RAMDISK); - struct boot_module *image, *initrd; + struct boot_domain *bd =3D &bi->domains[0]; struct domain *d; domid_t domid; =20 - /* Map boot_module to mb1 module for dom0 */ - image =3D &bi->mods[0]; - - /* Map boot_module to mb1 module for initrd */ - if ( mod_idx < 0 ) - initrd =3D NULL; - else - initrd =3D &bi->mods[mod_idx]; - if ( opt_dom0_pvh ) { dom0_cfg.flags |=3D (XEN_DOMCTL_CDF_hvm | @@ -1011,11 +1001,10 @@ static struct domain *__init create_dom0(struct boo= t_info *bi) panic("Error creating d%uv0\n", domid); =20 /* Grab the DOM0 command line. */ - if ( image->cmdline || bi->kextra ) + if ( bd->kernel->cmdline || bi->kextra ) { - if ( image->cmdline ) - safe_strcpy(cmdline, - cmdline_cook(__va(image->cmdline), + if ( bd->kernel->cmdline ) + safe_strcpy(cmdline, cmdline_cook(__va(bd->kernel->cmdline), bi->loader)); =20 if ( bi->kextra ) @@ -1039,7 +1028,7 @@ static struct domain *__init create_dom0(struct boot_= info *bi) } } =20 - if ( construct_dom0(d, image, initrd, cmdline) !=3D 0 ) + if ( construct_dom0(d, bd->kernel, bd->ramdisk, cmdline) !=3D 0 ) panic("Could not construct domain 0\n"); =20 return d; @@ -1226,6 +1215,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) /* Dom0 kernel is always first */ bi->mods[0].type =3D BOOTMOD_KERNEL; bi->mods[0].consumed =3D true; + bi->domains[0].kernel =3D &bi->mods[0]; =20 if ( pvh_boot ) { @@ -2104,6 +2094,7 @@ void asmlinkage __init noreturn __start_xen(unsigned = long mbi_p) { bi->mods[initrdidx].type =3D BOOTMOD_RAMDISK; bi->mods[initrdidx].consumed =3D true; + bi->domains[0].ramdisk =3D &bi->mods[initrdidx]; if ( first_boot_module_index(bi, BOOTMOD_UNKNOWN) < MAX_NR_BOOTMOD= S ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729471858; cv=pass; d=zohomail.com; s=zohoarc; b=BqFBVxI5+oSIIGTfMspHi5X244Ehd9iY3h9jCB1vcTOozcd2aA5CdDzjembXWlpYz6F3fSoiueYrIW3QEagWT08vvnGrA9oYBEKq05fgJ6OJjcQHgFMrGHVOdJg7hu9Immb1gTkwh3002v2RuJjQkORVbh6XZh1w+UkLhyFZz9Y= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471858; 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=W9SYyOcjZouRlsw2CUmEqIi1nilT6Qy3TrY52aUXeMg=; b=fnZaVdWUwLEa+L4h2NsOaQ4yQrrOoat0YvcXk9seA/vAUFThp+/0sXmQUfaRynLc+0ajYvWPIStYty9TOoh2CLoKYxiSvDeo+dTMZsaLVFg2djsJRDKGLEQAz6AQLXXN+q+6l3O1ndgaGecfwhsDgjKGzze0Cyl3BVw8Zz3gTSs= 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 1729471858468927.9857240991763; Sun, 20 Oct 2024 17:50:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822932.1236912 (Exim 4.92) (envelope-from ) id 1t2gd7-0007Ah-K3; Mon, 21 Oct 2024 00:50:41 +0000 Received: by outflank-mailman (output) from mailman id 822932.1236912; Mon, 21 Oct 2024 00:50:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gd7-0007Aa-HN; Mon, 21 Oct 2024 00:50:41 +0000 Received: by outflank-mailman (input) for mailman id 822932; Mon, 21 Oct 2024 00:50:40 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gd6-0006SZ-C7 for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:50:40 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7c837f0d-8f46-11ef-99a3-01e77a169b0f; Mon, 21 Oct 2024 02:50:38 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471622046365.3421362328204; Sun, 20 Oct 2024 17:47:02 -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: 7c837f0d-8f46-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729471624; cv=none; d=zohomail.com; s=zohoarc; b=FBnTCKciI1qXLSfvCylWHRkTkplR4ELrfIQI8nyH/1X7lmHPI/SbwYrFzyLX36A5yd3lS+JIeruVSDZEn5rteH+C3P3tyJscSdsRGxnd6HLNh4SCtypNmWqaTyuFWddxm1teOKlglF4cBK9OHkv08bVpfruVShtJS0183J/YHHs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471624; 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=W9SYyOcjZouRlsw2CUmEqIi1nilT6Qy3TrY52aUXeMg=; b=DLRUpmCqKFm+g+ScIYzX5BvoR3b7nyJ9li+oSezQqi+g0tsmxHScsB0hWsaiacP/yqG7xWVuywGJO2QXmuF6xjW7PYZ24XFt+gM8OH7HmjGv/MdDa/on9VVqQQ5KPPqLmEtzzS0uAInRacfwtZlUE011k6NAnXtTlf3cszxoVNo= 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=1729471624; 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=W9SYyOcjZouRlsw2CUmEqIi1nilT6Qy3TrY52aUXeMg=; b=oVYj5Zm+wV2+cD1qWNmVcSId/gJNWioLepmtZGnBaw0V6oLDVuJsYqeMP2GnQFr+ Ej+asYIbKQ2Ziiz/+oCqkhLwkIX9ucD4hLb6e4pvywvATHsc2izb1Jf8WUuAqFLiLK2 mH9SseOHWCA2ve8xNhkJXgTkc9qMumruEitPfV4w= 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 v7 33/38] x86/boot: introduce domid field to struct boot_domain Date: Sun, 20 Oct 2024 20:46:08 -0400 Message-Id: <20241021004613.18793-34-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729471860113116600 Content-Type: text/plain; charset="utf-8" Add a domid field to struct boot_domain to hold the assigned domain id for = the domain. During initialization, ensure all instances of struct boot_domain h= ave the invalid domid to ensure that the domid must be set either by convention= or configuration. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- xen/arch/x86/include/asm/bootdomain.h | 2 ++ xen/arch/x86/setup.c | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/include/asm/bootdomain.h b/xen/arch/x86/include/a= sm/bootdomain.h index 4285223ac5ab..d6264d554dba 100644 --- a/xen/arch/x86/include/asm/bootdomain.h +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -11,6 +11,8 @@ struct boot_module; =20 struct boot_domain { + domid_t domid; + struct boot_module *kernel; struct boot_module *ramdisk; }; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 9b2a16863eae..e6756d0ad18d 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -334,6 +334,9 @@ static struct boot_info *__init multiboot_fill_boot_inf= o(unsigned long mbi_p) bi->mods[i].type =3D BOOTMOD_XEN; bi->mods[i].consumed =3D true; =20 + for ( i =3D 0; i < MAX_NR_BOOTDOMS; i++ ) + bi->domains[i].domid =3D DOMID_INVALID; + return bi; } =20 @@ -974,7 +977,6 @@ static struct domain *__init create_dom0(struct boot_in= fo *bi) }; struct boot_domain *bd =3D &bi->domains[0]; struct domain *d; - domid_t domid; =20 if ( opt_dom0_pvh ) { @@ -990,15 +992,15 @@ static struct domain *__init create_dom0(struct boot_= info *bi) dom0_cfg.flags |=3D XEN_DOMCTL_CDF_iommu; =20 /* Create initial domain. Not d0 for pvshim. */ - domid =3D get_initial_domain_id(); - d =3D domain_create(domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged); + bd->domid =3D get_initial_domain_id(); + d =3D domain_create(bd->domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged= ); if ( IS_ERR(d) ) - panic("Error creating d%u: %ld\n", domid, PTR_ERR(d)); + panic("Error creating d%u: %ld\n", bd->domid, PTR_ERR(d)); =20 init_dom0_cpuid_policy(d); =20 if ( alloc_dom0_vcpu0(d) =3D=3D NULL ) - panic("Error creating d%uv0\n", domid); + panic("Error creating d%uv0\n", bd->domid); =20 /* Grab the DOM0 command line. */ if ( bd->kernel->cmdline || bi->kextra ) --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729471862; cv=pass; d=zohomail.com; s=zohoarc; b=jh+4iORQJuH+DFJSlcZOFXGnL5+9ViVznNeGXY6qZauaJlrKO7CgvIgUUDW1WfSWKGS0oWd/nMlRbw0D2sqydtU/2RuifIYcgGkJTaZR7nlzDdaZtZGujqET9Ht55o7tmuMrufrTN2wrQv+JwvcCoUkqd6Mv9AwwilX5o4s+UC8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471862; 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=UX88o1+TSwX0OSFHrl/WAKdIoJCte8538NgcDozE6gA=; b=fu+NpBPaRc0VpFr7ncwn6ozalmGwbEVDwDbfx2Q+rHzNg8oN61YKN4SAszrWmFNLUPorTL1jz+bBTKtFsyRCvxMHFET2i9Vd1tEQSRflmu+EpRushnfQwZjW6XkQ5laFbrDpHrgxM/p53Zr9Wa6KB6CYEjFWzD0zJyyWX04+aVM= 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 1729471862154807.2310020165854; Sun, 20 Oct 2024 17:51:02 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822937.1236922 (Exim 4.92) (envelope-from ) id 1t2gdF-0007fY-SA; Mon, 21 Oct 2024 00:50:49 +0000 Received: by outflank-mailman (output) from mailman id 822937.1236922; Mon, 21 Oct 2024 00:50:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gdF-0007fP-OT; Mon, 21 Oct 2024 00:50:49 +0000 Received: by outflank-mailman (input) for mailman id 822937; Mon, 21 Oct 2024 00:50:48 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gdE-0006SZ-EW for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:50:48 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 813cac43-8f46-11ef-99a3-01e77a169b0f; Mon, 21 Oct 2024 02:50:46 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471623186522.1233549769001; Sun, 20 Oct 2024 17:47:03 -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: 813cac43-8f46-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1729471625; cv=none; d=zohomail.com; s=zohoarc; b=HqxM3dqdeB0km8RbD03cNlgcNFhccTKsB3/cwgbgufplgTrAjeFLwM7zuLG7IwHraDZRbTpAG7qCrP5LEU0m6uxyiNRL1QKyQmNncwkN+V+Y1BniHqMeoCuGlR5urTxiKmZezHgQH/00B7GnHBlq14lhqiPVc/BT0EBNgvJMdcg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471625; 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=UX88o1+TSwX0OSFHrl/WAKdIoJCte8538NgcDozE6gA=; b=TyFlmEAIJGaeMFUxU+j1jKotorVNlZm8Bi0WySImX/t3XgX9VAdjoUEcjHwI+5jt2o6Rt6a20r+oSt5ZPCd4LtrPn+FvhoC4aXDp25XVq8lctsl8++XZIJKLfRoYdA/6HDt8wOzpSkQzA/biTwA73h5lKyDMoU2E1x6h1eRULgY= 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=1729471625; 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=UX88o1+TSwX0OSFHrl/WAKdIoJCte8538NgcDozE6gA=; b=IKzMOY38vu0RPRknNzhv2Ov7+2JGcL0+KdOkbx69xbdhgs2IrXZtSy8XL4qzfN9A DxmmheJFF9EKTrTPXItg3PBjFbJKGeyYXa3nacO7bHIhaIBl2EP0HEZB/JfkD2wUSFh 7eXcKMW+czxF2vwm6UlVC2iPIXPyazeGDHPGPg4E= 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 v7 34/38] x86/boot: add cmdline to struct boot_domain Date: Sun, 20 Oct 2024 20:46:09 -0400 Message-Id: <20241021004613.18793-35-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729471864083116600 Content-Type: text/plain; charset="utf-8" Add a container for the "cooked" command line for a domain. Signed-off-by: Daniel P. Smith --- xen/arch/x86/include/asm/bootdomain.h | 4 ++++ xen/arch/x86/setup.c | 18 ++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/xen/arch/x86/include/asm/bootdomain.h b/xen/arch/x86/include/a= sm/bootdomain.h index d6264d554dba..00f7d9267965 100644 --- a/xen/arch/x86/include/asm/bootdomain.h +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -8,9 +8,13 @@ #ifndef __XEN_X86_BOOTDOMAIN_H__ #define __XEN_X86_BOOTDOMAIN_H__ =20 +#include + struct boot_module; =20 struct boot_domain { + char cmdline[MAX_GUEST_CMDLINE]; + domid_t domid; =20 struct boot_module *kernel; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index e6756d0ad18d..47b705097dd3 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -962,8 +962,6 @@ static unsigned int __init copy_bios_e820(struct e820en= try *map, unsigned int li =20 static struct domain *__init create_dom0(struct boot_info *bi) { - static char __initdata cmdline[MAX_GUEST_CMDLINE]; - struct xen_domctl_createdomain dom0_cfg =3D { .flags =3D IS_ENABLED(CONFIG_TBOOT) ? XEN_DOMCTL_CDF_s3_integrity = : 0, .max_evtchn_port =3D -1, @@ -1006,16 +1004,16 @@ static struct domain *__init create_dom0(struct boo= t_info *bi) if ( bd->kernel->cmdline || bi->kextra ) { if ( bd->kernel->cmdline ) - safe_strcpy(cmdline, cmdline_cook(__va(bd->kernel->cmdline), + safe_strcpy(bd->cmdline, cmdline_cook(__va(bd->kernel->cmdline= ), bi->loader)); =20 if ( bi->kextra ) /* kextra always includes exactly one leading space. */ - safe_strcat(cmdline, bi->kextra); + safe_strcat(bd->cmdline, bi->kextra); =20 /* Append any extra parameters. */ - if ( skip_ioapic_setup && !strstr(cmdline, "noapic") ) - safe_strcat(cmdline, " noapic"); + if ( skip_ioapic_setup && !strstr(bd->cmdline, "noapic") ) + safe_strcat(bd->cmdline, " noapic"); =20 if ( (strlen(acpi_param) =3D=3D 0) && acpi_disabled ) { @@ -1023,14 +1021,14 @@ static struct domain *__init create_dom0(struct boo= t_info *bi) safe_strcpy(acpi_param, "off"); } =20 - if ( (strlen(acpi_param) !=3D 0) && !strstr(cmdline, "acpi=3D") ) + if ( (strlen(acpi_param) !=3D 0) && !strstr(bd->cmdline, "acpi=3D"= ) ) { - safe_strcat(cmdline, " acpi=3D"); - safe_strcat(cmdline, acpi_param); + safe_strcat(bd->cmdline, " acpi=3D"); + safe_strcat(bd->cmdline, acpi_param); } } =20 - if ( construct_dom0(d, bd->kernel, bd->ramdisk, cmdline) !=3D 0 ) + if ( construct_dom0(d, bd->kernel, bd->ramdisk, bd->cmdline) !=3D 0 ) panic("Could not construct domain 0\n"); =20 return d; --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729472228; cv=pass; d=zohomail.com; s=zohoarc; b=hPzFlo7u6dSjdbHClfbB9tGHbT1Is0yCbSZcY5uRmCogsaG80tr11c3HMr2cRhbarH12klsskKErBKqQaImQ2t36dQsKrA17iqHSQQGXMI72JFSdyquK4Em9qK2h8D/jM8JfiB9gOfOCQB8gvTd/8hgQfIsLuWUi54PYnfmBpeQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729472228; 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=SP/LZEnrjEkSEMtxaAJe6x6uyzbbJYUTQUInZxcjnQE=; b=b/w7oBNvUl32504bI3l5dYTw94NcHL2mp83+hvupn3M6579CC4fSuLnWFaII4F6aFlx8C5RqEKKZfqQw58xXUS0Kj2CGUy8vHfhQSu8T2KMXPPRO60AZBpFl43BBGJvzoWsMwVUhfNBueICwBXUriymi7iQn7c7SSJFrjzjP/d8= 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 1729472228609248.41304377181496; Sun, 20 Oct 2024 17:57:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822963.1236942 (Exim 4.92) (envelope-from ) id 1t2gip-0000lm-MK; Mon, 21 Oct 2024 00:56:35 +0000 Received: by outflank-mailman (output) from mailman id 822963.1236942; Mon, 21 Oct 2024 00:56:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gip-0000lf-J8; Mon, 21 Oct 2024 00:56:35 +0000 Received: by outflank-mailman (input) for mailman id 822963; Mon, 21 Oct 2024 00:56:33 +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 1t2gdL-0001i1-5T for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:50:55 +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 85e2359c-8f46-11ef-a0be-8be0dac302b0; Mon, 21 Oct 2024 02:50:54 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471624314615.4554817379054; Sun, 20 Oct 2024 17:47:04 -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: 85e2359c-8f46-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729471626; cv=none; d=zohomail.com; s=zohoarc; b=i30lf8G+k/jQfGtNSeGKOCqI68IMmUoWwWcBaXzwK2jtXy6qKxgotbJp8GcH3YILB/znM2CpC5fhWAIOCjWix0yGhDC1nn3SDjBJL9NoK6mPS4tODrn1oaORhYFNLOr+Wbf/jKC/xOxQFick1LEOx8jQw4iBHuAb4agLj/m4Ctg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471626; 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=SP/LZEnrjEkSEMtxaAJe6x6uyzbbJYUTQUInZxcjnQE=; b=ZC/Ja/iy4CecbkMHRdrE8sPL2DerYU8qTnccbOlu7f7mF06+0lOUqrGpBgt71Z4u3qNoS4iD5GDIaXe5D6RNkmd6ZGHrX68yGtglO2Lo5hS/SAN9Z8XNVhLud5tDzpYiJEjP3EqTcsH8vNK3zSb18kT7b5nJLRiLGS9PDG+iTd4= 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=1729471626; 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=SP/LZEnrjEkSEMtxaAJe6x6uyzbbJYUTQUInZxcjnQE=; b=Ei/E3zLwLQ1W4eaCfIMHpufN0xqQlLOUE3IfHKrSjpMlhI6khcNG9WzPWNjUuQ/4 HMPli8dtCpuEGWGqmVU41onFqoAGtaGLCetK8MM3E6JU9147deMT11PxZEI1ZBEVcb1 kPE6GRBVlEb9wKoC95KKdVTQQvKKOJpl2B7LsIdw= 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 v7 35/38] x86/boot: add struct domain to struct boot_domain Date: Sun, 20 Oct 2024 20:46:10 -0400 Message-Id: <20241021004613.18793-36-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729472229527116600 Content-Type: text/plain; charset="utf-8" Store a reference to the created domain in struct boot_domain. Signed-off-by: Daniel P. Smith --- Changes since v5: - moved back to using variable *d to hold domain reference locally --- xen/arch/x86/include/asm/bootdomain.h | 3 +++ xen/arch/x86/setup.c | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/include/asm/bootdomain.h b/xen/arch/x86/include/a= sm/bootdomain.h index 00f7d9267965..2322c459e36a 100644 --- a/xen/arch/x86/include/asm/bootdomain.h +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -10,6 +10,7 @@ =20 #include =20 +struct domain; struct boot_module; =20 struct boot_domain { @@ -19,6 +20,8 @@ struct boot_domain { =20 struct boot_module *kernel; struct boot_module *ramdisk; + + struct domain *d; }; =20 #endif diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 47b705097dd3..9423e999990a 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1028,10 +1028,12 @@ static struct domain *__init create_dom0(struct boo= t_info *bi) } } =20 + bd->d =3D d; + if ( construct_dom0(d, bd->kernel, bd->ramdisk, bd->cmdline) !=3D 0 ) panic("Could not construct domain 0\n"); =20 - return d; + return bd->d; } =20 /* How much of the directmap is prebuilt at compile time. */ --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729472233; cv=pass; d=zohomail.com; s=zohoarc; b=YzFC/Vtf88OqYm0dpmaMGn6oxEBmksqlpFiSbBx9235fg5QEYOrfLbRTTwGxRA6zuIYvb2SneaEcxMznTOm+CX33lkEbMkQSDt7mM1rDlg3hP9SX32q+f0s31yo+xQ0MIxnv620ObC/iRjXEgzyZD8MoYGfCw4sxmXQzvrDxKOs= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729472233; 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=Bmio29Z/US+aVmz65/fnIfDiOrUjnKKY2s1SIs0oHx0=; b=H/Nlg3vaUpZ8TYlVlTQ55pdcgu0sdnGAc6bcbZaCRaaxLilrENenOeVQ49/wWx1fbKYIWXGbiPRvIiY2QhbIYeYqbdPE+M1udTfB3/zo0pbWjYq7nuedXxPspRAbSotq9Dd2kCzcCjjBBt8H0O1lgGLdE7iuXYv3X881BtZ84Oc= 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 1729472233883898.0771670965792; Sun, 20 Oct 2024 17:57:13 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822985.1237002 (Exim 4.92) (envelope-from ) id 1t2gj0-0002pa-Ux; Mon, 21 Oct 2024 00:56:46 +0000 Received: by outflank-mailman (output) from mailman id 822985.1237002; Mon, 21 Oct 2024 00:56:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gj0-0002pM-Ps; Mon, 21 Oct 2024 00:56:46 +0000 Received: by outflank-mailman (input) for mailman id 822985; Mon, 21 Oct 2024 00:56: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 1t2gdT-0001i1-8Z for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:51:03 +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 89e10626-8f46-11ef-a0be-8be0dac302b0; Mon, 21 Oct 2024 02:51:01 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471625461841.4722904899356; Sun, 20 Oct 2024 17:47:05 -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: 89e10626-8f46-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729471627; cv=none; d=zohomail.com; s=zohoarc; b=eMa1HRJ1pAyi+naSie41rXJ4ul0tWIH6Mf4h5eXWiaMGb1WtszHSh0FRIeIfbYUSrSAUmnpdGvtXa06ctW+iYcPYSBCXeUAxUozuCXoMRDYY/q65I8iYpPnFPGfvhBUb/XIzO0oCRto+U2R5PAmk7HjPgErldu9D/bPhVv9fI1k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471627; 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=Bmio29Z/US+aVmz65/fnIfDiOrUjnKKY2s1SIs0oHx0=; b=FtcGzU9OdEGgDi8JtV8esFwJZdDdYc3FwToszELgJYCKjLI10GiASnswuPw0hk7hEq7e8nvSC+WZq7R2jdAPvn09nqy52EHLCBvJdA/bAUM2iyQ0wmoRHEDTs/yCBAjHRfyLVzmIpic9hO24x6gBpZZRbMCro5Qm/fuBSa+h3EM= 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=1729471627; 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=Bmio29Z/US+aVmz65/fnIfDiOrUjnKKY2s1SIs0oHx0=; b=Uq+pgaMtepxBpvUbdDz5+mnmmL609SPvaVha7e1ZNQ2Ybm2UqTMUuEx8ZNQI4Qm/ fpUDozbuGyV0n46vcwpX27e8ym2e/3waNyoO5UGlhRMvLrbQ6mPdj+XZ+u6btWdMDoF TQ9Nf0W8C6FMXY6E+BPtiWkrmgvUniB6ptze7JSI= 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 v7 36/38] x86/boot: convert construct_dom0 to struct boot_domain Date: Sun, 20 Oct 2024 20:46:11 -0400 Message-Id: <20241021004613.18793-37-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729472235555116600 Content-Type: text/plain; charset="utf-8" A struct boot_domain now encapsulates the domain reference, kernel, ramdisk, and command line for the domain being constructed. As a result of this encapsulation, construct_dom0 can now take a single struct boot_domain inst= ead of these four parameters. Signed-off-by: Daniel P. Smith --- Changes since v5: - moved back to using variable *d to hold domain reference locally --- xen/arch/x86/dom0_build.c | 8 ++++---- xen/arch/x86/include/asm/setup.h | 4 +--- xen/arch/x86/setup.c | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 71b2e3afc1a1..34b4943de3b1 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -597,10 +597,10 @@ int __init dom0_setup_permissions(struct domain *d) return rc; } =20 -int __init construct_dom0(struct domain *d, const struct boot_module *imag= e, - struct boot_module *initrd, const char *cmdline) +int __init construct_dom0(struct boot_domain *bd) { int rc; + struct domain *d =3D bd->d; =20 /* Sanity! */ BUG_ON(!pv_shim && d->domain_id !=3D 0); @@ -610,9 +610,9 @@ int __init construct_dom0(struct domain *d, const struc= t boot_module *image, process_pending_softirqs(); =20 if ( is_hvm_domain(d) ) - rc =3D dom0_construct_pvh(d, image, initrd, cmdline); + rc =3D dom0_construct_pvh(bd->d, bd->kernel, bd->ramdisk, bd->cmdl= ine); else if ( is_pv_domain(d) ) - rc =3D dom0_construct_pv(d, image, initrd, cmdline); + rc =3D dom0_construct_pv(bd->d, bd->kernel, bd->ramdisk, bd->cmdli= ne); else panic("Cannot construct Dom0. No guest interface available\n"); =20 diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/se= tup.h index f7958b56eab6..b049dc5ee17e 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -26,9 +26,7 @@ void subarch_init_memory(void); =20 void init_IRQ(void); =20 -int construct_dom0( - struct domain *d, const struct boot_module *image, - struct boot_module *initrd, const char *cmdline); +int construct_dom0(struct boot_domain *d); void setup_io_bitmap(struct domain *d); =20 extern struct boot_info xen_boot_info; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 9423e999990a..ed4bf3d2b62b 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1030,7 +1030,7 @@ static struct domain *__init create_dom0(struct boot_= info *bi) =20 bd->d =3D d; =20 - if ( construct_dom0(d, bd->kernel, bd->ramdisk, bd->cmdline) !=3D 0 ) + if ( construct_dom0(bd) !=3D 0 ) panic("Could not construct domain 0\n"); =20 return bd->d; --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729472253; cv=pass; d=zohomail.com; s=zohoarc; b=B1faVcLgN/Gsx5z7SRT/HO+/wwFLkuFNLhSp75JBPjQnp8SLjSLmwHQIVUkBtxoB6G6e9LfvHi7m84x7TmuiOrDzYRVgwreumsqSoi6Rw0j0yz2Z/RXsaJW5dRdzcSTVeRFQ/CuGnKuMtsPoJQcKi//P54t4RWGVUNZjWVbShhg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729472253; 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=7rvH6WBzxQb9IRNi1YOifSatMNkaZHAsSaJgeiL+WGk=; b=K9txsviGbXvHlWba4SvkaPkS1QUF4hvoT4FhotijTApP+pM3vPUDf898YErQNfTdJ7rebsX5WaB4659NrkKVjqvXtyEAzvtBZ4qtILjgl8b8s7O89Y7Hx6xdpyFhX/vCagEEjNOexG0uX0RJPDOvIw7HH1roSDXeaCMPQIL1mak= 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 1729472253233773.3231546542956; Sun, 20 Oct 2024 17:57:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.823019.1237041 (Exim 4.92) (envelope-from ) id 1t2gjP-0006Sz-BB; Mon, 21 Oct 2024 00:57:11 +0000 Received: by outflank-mailman (output) from mailman id 823019.1237041; Mon, 21 Oct 2024 00:57:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2gjP-0006ST-81; Mon, 21 Oct 2024 00:57:11 +0000 Received: by outflank-mailman (input) for mailman id 823019; Mon, 21 Oct 2024 00:57:10 +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 1t2gda-0001i1-1z for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:51:10 +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 8e57dc13-8f46-11ef-a0be-8be0dac302b0; Mon, 21 Oct 2024 02:51:08 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471626606907.5806199234472; Sun, 20 Oct 2024 17:47:06 -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: 8e57dc13-8f46-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729471628; cv=none; d=zohomail.com; s=zohoarc; b=UGl4CcdPM4nKzyzRg8g2MZsMS0SHNlqa1Ngq87fUNUy9l0ZIg0feoNz44a07z5NbfbLsUzCLF7nwBpbwXJjc+//Y2x5SePEbYcpNTQB+SwZcwXYgMFf3sM1ZSi/F+xfFPdWJITxhbaw3Emuii4TCu8CvZ4GaM8eiijUAWs7BOrc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471628; 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=7rvH6WBzxQb9IRNi1YOifSatMNkaZHAsSaJgeiL+WGk=; b=fUMoFVEl22M+HotU5VGt1vYC22FqJMImju+zWCj7peCRnOaGX6z+jE++gBX3iPbwaydr/lNLRcCBb9As3j/morUe8xCjvYL6OGL+5XAdDgdWP46AlCOBCNOZr8vOw7Zkk9AiviQGF+GNIQ5qbpNd36eHSQhlWIhWl+En7Twm9xY= 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=1729471628; 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=7rvH6WBzxQb9IRNi1YOifSatMNkaZHAsSaJgeiL+WGk=; b=H+A0Rxi/Q7hfCBuQ3mu860Sh6YZFaKMlU/2bSEysxZWH+XUhwkL9QRcGGC9MtBFs FlUj0CzVdsrMzHFMbtS2IZgGusPgUz3Vhel/BLpeD0caC7Q2FgJk0ANDhERD1y3MKoh scQnMc8HRMljirszyGZscBl51eSw72cnDzGuJMSg= 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 v7 37/38] x86/boot: convert dom0_construct_pv to struct boot_domain Date: Sun, 20 Oct 2024 20:46:12 -0400 Message-Id: <20241021004613.18793-38-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729472253689116600 Content-Type: text/plain; charset="utf-8" With construct_dom0 consuming struct boot_domain, continue passing the structure down to dom0_construct_pv. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v5: - reverted back *v d->vcpu[0] --- xen/arch/x86/dom0_build.c | 2 +- xen/arch/x86/include/asm/dom0_build.h | 5 ++-- xen/arch/x86/pv/dom0_build.c | 41 ++++++++++++--------------- 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 34b4943de3b1..96cd1154b037 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -612,7 +612,7 @@ int __init construct_dom0(struct boot_domain *bd) if ( is_hvm_domain(d) ) rc =3D dom0_construct_pvh(bd->d, bd->kernel, bd->ramdisk, bd->cmdl= ine); else if ( is_pv_domain(d) ) - rc =3D dom0_construct_pv(bd->d, bd->kernel, bd->ramdisk, bd->cmdli= ne); + rc =3D dom0_construct_pv(bd); else panic("Cannot construct Dom0. No guest interface available\n"); =20 diff --git a/xen/arch/x86/include/asm/dom0_build.h b/xen/arch/x86/include/a= sm/dom0_build.h index 5d0c4fd2639a..eafa741db16f 100644 --- a/xen/arch/x86/include/asm/dom0_build.h +++ b/xen/arch/x86/include/asm/dom0_build.h @@ -4,6 +4,7 @@ #include #include =20 +#include #include =20 extern unsigned int dom0_memflags; @@ -13,9 +14,7 @@ unsigned long dom0_compute_nr_pages(struct domain *d, unsigned long initrd_len); int dom0_setup_permissions(struct domain *d); =20 -int dom0_construct_pv(struct domain *d, const struct boot_module *image, - struct boot_module *initrd, - const char *cmdline); +int dom0_construct_pv(struct boot_domain *bd); =20 int dom0_construct_pvh(struct domain *d, const struct boot_module *image, struct boot_module *initrd, diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 45a386aa81f0..d9efef4f0599 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -354,10 +354,7 @@ static struct page_info * __init alloc_chunk(struct do= main *d, return page; } =20 -static int __init dom0_construct(struct domain *d, - const struct boot_module *image, - struct boot_module *initrd, - const char *cmdline) +static int __init dom0_construct(struct boot_domain *bd) { int i, rc, order, machine; bool compatible, compat; @@ -373,11 +370,12 @@ static int __init dom0_construct(struct domain *d, struct page_info *page =3D NULL; unsigned int flush_flags =3D 0; start_info_t *si; + struct domain *d =3D bd->d; struct vcpu *v =3D d->vcpu[0]; - void *image_base =3D bootstrap_map_bm(image); - unsigned long image_len =3D image->size; - void *image_start =3D image_base + image->headroom; - unsigned long initrd_len =3D initrd ? initrd->size : 0; + void *image_base =3D bootstrap_map_bm(bd->kernel); + unsigned long image_len =3D bd->kernel->size; + void *image_start =3D image_base + bd->kernel->headroom; + unsigned long initrd_len =3D bd->ramdisk ? bd->ramdisk->size : 0; l4_pgentry_t *l4tab =3D NULL, *l4start =3D NULL; l3_pgentry_t *l3tab =3D NULL, *l3start =3D NULL; l2_pgentry_t *l2tab =3D NULL, *l2start =3D NULL; @@ -613,7 +611,7 @@ static int __init dom0_construct(struct domain *d, initrd_pfn =3D vinitrd_start ? (vinitrd_start - v_start) >> PAGE_SHIFT : domain_tot_pages(d); - initrd_mfn =3D maddr_to_mfn(initrd->start); + initrd_mfn =3D maddr_to_mfn(bd->ramdisk->start); mfn =3D mfn_x(initrd_mfn); count =3D PFN_UP(initrd_len); if ( d->arch.physaddr_bitsize && @@ -629,13 +627,13 @@ static int __init dom0_construct(struct domain *d, free_domheap_pages(page, order); page +=3D 1UL << order; } - memcpy(page_to_virt(page), maddr_to_virt(initrd->start), + memcpy(page_to_virt(page), maddr_to_virt(bd->ramdisk->start), initrd_len); - mpt_alloc =3D initrd->start; + mpt_alloc =3D bd->ramdisk->start; init_domheap_pages(mpt_alloc, mpt_alloc + PAGE_ALIGN(initrd_len)); initrd_mfn =3D page_to_mfn(page); - initrd->start =3D mfn_to_maddr(initrd_mfn); + bd->ramdisk->start =3D mfn_to_maddr(initrd_mfn); } else { @@ -643,7 +641,7 @@ static int __init dom0_construct(struct domain *d, if ( assign_pages(mfn_to_page(_mfn(mfn++)), 1, d, 0) ) BUG(); } - initrd->size =3D 0; + bd->ramdisk->size =3D 0; =20 iommu_memory_setup(d, "initrd", mfn_to_page(initrd_mfn), PFN_UP(initrd_len), &flush_flags); @@ -655,9 +653,9 @@ static int __init dom0_construct(struct domain *d, if ( domain_tot_pages(d) < nr_pages ) printk(" (%lu pages to be allocated)", nr_pages - domain_tot_pages(d)); - if ( initrd ) + if ( bd->ramdisk ) { - mpt_alloc =3D initrd->start; + mpt_alloc =3D bd->ramdisk->start; printk("\n Init. ramdisk: %"PRIpaddr"->%"PRIpaddr, mpt_alloc, mpt_alloc + initrd_len); } @@ -885,7 +883,7 @@ static int __init dom0_construct(struct domain *d, if ( pfn >=3D initrd_pfn ) { if ( pfn < initrd_pfn + PFN_UP(initrd_len) ) - mfn =3D paddr_to_pfn(initrd->start) + (pfn - initrd_pfn); + mfn =3D paddr_to_pfn(bd->ramdisk->start) + (pfn - initrd_p= fn); else mfn -=3D PFN_UP(initrd_len); } @@ -955,8 +953,8 @@ static int __init dom0_construct(struct domain *d, } =20 memset(si->cmd_line, 0, sizeof(si->cmd_line)); - if ( cmdline !=3D NULL ) - strlcpy((char *)si->cmd_line, cmdline, sizeof(si->cmd_line)); + if ( bd->cmdline[0] !=3D '\0' ) + strlcpy((char *)si->cmd_line, bd->cmdline, sizeof(si->cmd_line)); =20 #ifdef CONFIG_VIDEO if ( !pv_shim && fill_console_start_info((void *)(si + 1)) ) @@ -1053,10 +1051,7 @@ out: return rc; } =20 -int __init dom0_construct_pv(struct domain *d, - const struct boot_module *image, - struct boot_module *initrd, - const char *cmdline) +int __init dom0_construct_pv(struct boot_domain *bd) { unsigned long cr4 =3D read_cr4(); int rc; @@ -1074,7 +1069,7 @@ int __init dom0_construct_pv(struct domain *d, write_cr4(cr4 & ~X86_CR4_SMAP); } =20 - rc =3D dom0_construct(d, image, initrd, cmdline); + rc =3D dom0_construct(bd); =20 if ( cr4 & X86_CR4_SMAP ) { --=20 2.30.2 From nobody Wed Dec 4 09:14:19 2024 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=1729472215; cv=pass; d=zohomail.com; s=zohoarc; b=Jk5yyqh8QsXmmsd76HN9teBwTGnDqSC0PUlQAdTrR3dtWvBpplw2sBAQl5c+9OHq/ugrsAKGobmCrrb2VrRnntwQ+YJo3yWtTSkc6GDwK5E9BpFHG1AqfAL8HfXxHS+GaP6GPZyt73FxWWhc0cw1jxIvIXnidOvdWb/kXNhXSgc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729472215; 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=aNiN7YZD1SazmqTlmBUizZzq3LQ/OZULOiAYxfKrfPs=; b=VRPvPNpYLqfb/GPuxIL1zC76bxsv07W0hO+V/OxuwLdw+E+6oElm7qbEhqWRT16Tb5QCApkSXH6VtAOMZfAxrRk/fllXc+YoMXXSjIfU8sRyB3DKqVh3J4EKehsCHtU+Zb/9lOQ+PnkU5gPBfoEEJ2KJYLUZWvIFANxGsJL6d9I= 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 1729472215019438.8001736904506; Sun, 20 Oct 2024 17:56:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.822968.1236948 (Exim 4.92) (envelope-from ) id 1t2giq-0000ts-6Q; Mon, 21 Oct 2024 00:56:36 +0000 Received: by outflank-mailman (output) from mailman id 822968.1236948; Mon, 21 Oct 2024 00:56:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2giq-0000rm-1H; Mon, 21 Oct 2024 00:56:36 +0000 Received: by outflank-mailman (input) for mailman id 822968; Mon, 21 Oct 2024 00:56:34 +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 1t2gdg-0001i1-E6 for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 00:51:16 +0000 Received: from sender3-of-o57.zoho.com (sender3-of-o57.zoho.com [136.143.184.57]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 92784cff-8f46-11ef-a0be-8be0dac302b0; Mon, 21 Oct 2024 02:51:15 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1729471627762341.13633961756796; Sun, 20 Oct 2024 17:47:07 -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: 92784cff-8f46-11ef-a0be-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1729471630; cv=none; d=zohomail.com; s=zohoarc; b=DBpP/etX40b9X02XsY3EwrRHnOnn1TQzVdf233CEGfo6hf/HkjM+08haoVCXvTxSkuVdjQMRUZhChx3xDGieYgOFJv3ue5fD4iDRIda1e31w9597CFrmqsUGvxOtI1+1/YQ6p/zKf1Fg4tXEj6k2wRzVGVhGbPp4qorLmAEUlY4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729471630; 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=aNiN7YZD1SazmqTlmBUizZzq3LQ/OZULOiAYxfKrfPs=; b=cClLXdwR2izAtMgWydaL8WXbRd943bZGgq1Jubtuoog+ln9tjiBEltcE6tDNXiHTgJpNlr0OJwog8b/N8qOHYGB3I15wAr+O+xl7Wr2cC1LseSyTzruRKdMxP+a0/N1SXVANs8YwlinIgAUEn2WWohdwChRo0RAMtqcJ+Za7dyU= 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=1729471630; 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=aNiN7YZD1SazmqTlmBUizZzq3LQ/OZULOiAYxfKrfPs=; b=BtM3NsMWsvvFPWD62qTZVIfeXRwvA6uhNs8WbuskbHBWsdvBGGzG1JoNAtIVYCEW ZeyeCK1tD24lOc8v//7bNaoXHA7HH7jfZgnnII7AYU30YR+4srXjq4nCOlRulIUOSSP BOX9qzU2r+YyoVGGOJ72ZlpriyVa/5CtdRtsu75s= 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 v7 38/38] x86/boot: convert dom0_construct_pvh to struct boot_domain Date: Sun, 20 Oct 2024 20:46:13 -0400 Message-Id: <20241021004613.18793-39-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241021004613.18793-1-dpsmith@apertussolutions.com> References: <20241021004613.18793-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: 1729472215546116600 Content-Type: text/plain; charset="utf-8" With construct_dom0 consuming struct boot_domain, continue passing the structure down to dom0_construct_pvh. Signed-off-by: Daniel P. Smith --- Changes since v5: - revert back to using *d as local reference for struct domain --- xen/arch/x86/dom0_build.c | 2 +- xen/arch/x86/hvm/dom0_build.c | 8 ++++---- xen/arch/x86/include/asm/dom0_build.h | 4 +--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 96cd1154b037..f0d2c349095b 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -610,7 +610,7 @@ int __init construct_dom0(struct boot_domain *bd) process_pending_softirqs(); =20 if ( is_hvm_domain(d) ) - rc =3D dom0_construct_pvh(bd->d, bd->kernel, bd->ramdisk, bd->cmdl= ine); + rc =3D dom0_construct_pvh(bd); else if ( is_pv_domain(d) ) rc =3D dom0_construct_pv(bd); else diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index 211f4e3e772e..720e08f9346f 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -1299,10 +1299,9 @@ static void __hwdom_init pvh_setup_mmcfg(struct doma= in *d) } } =20 -int __init dom0_construct_pvh(struct domain *d, const struct boot_module *= image, - struct boot_module *initrd, - const char *cmdline) +int __init dom0_construct_pvh(const struct boot_domain *bd) { + struct domain *d =3D bd->d; paddr_t entry, start_info; int rc; =20 @@ -1345,7 +1344,8 @@ int __init dom0_construct_pvh(struct domain *d, const= struct boot_module *image, return rc; } =20 - rc =3D pvh_load_kernel(d, image, initrd, bootstrap_map_bm(image), cmdl= ine, + rc =3D pvh_load_kernel(d, bd->kernel, bd->ramdisk, + bootstrap_map_bm(bd->kernel), bd->cmdline, &entry, &start_info); if ( rc ) { diff --git a/xen/arch/x86/include/asm/dom0_build.h b/xen/arch/x86/include/a= sm/dom0_build.h index eafa741db16f..adbe90bfd034 100644 --- a/xen/arch/x86/include/asm/dom0_build.h +++ b/xen/arch/x86/include/asm/dom0_build.h @@ -16,9 +16,7 @@ int dom0_setup_permissions(struct domain *d); =20 int dom0_construct_pv(struct boot_domain *bd); =20 -int dom0_construct_pvh(struct domain *d, const struct boot_module *image, - struct boot_module *initrd, - const char *cmdline); +int dom0_construct_pvh(const struct boot_domain *bd); =20 unsigned long dom0_paging_pages(const struct domain *d, unsigned long nr_pages); --=20 2.30.2