From patchwork Mon Oct 21 00:45:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843413 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E8C5CD3C937 for ; Mon, 21 Oct 2024 00:46:58 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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. Once the transition is complete, the parameter will be dropped from the structure. 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 +#include #include +/* 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; unsigned int nr_modules; + struct boot_module mods[MAX_NR_BOOTMODS + 1]; }; #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_info(unsigned long mbi_p) { struct boot_info *bi = &xen_boot_info; const multiboot_info_t *mbi = __va(mbi_p); + module_t *mods = __va(mbi->mods_addr); + unsigned int i; if ( mbi->flags & MBI_MODULES ) bi->nr_modules = mbi->mods_count; @@ -303,6 +305,21 @@ static struct boot_info *__init multiboot_fill_boot_info(unsigned long mbi_p) bi->memmap_length = mbi->mmap_length; } + /* + * The multiboot entry point will reserve mods_count + 1 instances of + * module_t, with the last one being for Xen. First iterate over nr_modules + * module_t entries, or MAX_NR_BOOTMODS if more than the max was passed. + * + * 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 point + * reserved for Xen. + */ + for ( i = 0; i < MAX_NR_BOOTMODS && i < bi->nr_modules; i++ ) + bi->mods[i].mod = &mods[i]; + + /* Variable 'i' should be one entry past the last module. */ + bi->mods[i].mod = &mods[bi->nr_modules]; + return bi; } @@ -1163,9 +1180,14 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) panic("dom0 kernel not specified. Check bootloader configuration\n"); /* 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 = sizeof(module_map) * 8; + /* + * Only MAX_NR_BOOTMODS were populated in bootinfo, truncate nr_modules + * now that it can be report that an excess number of modules were + * passed. + */ + bi->nr_modules = MAX_NR_BOOTMODS; printk("Excessive boot modules - using the first %u only\n", bi->nr_modules); } From patchwork Mon Oct 21 00:45:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843415 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9D4A6D3C935 for ; Mon, 21 Oct 2024 00:47:01 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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 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( for ( i = 0; i < nr_mods ; ++i ) { - uint64_t start = (uint64_t)mod[i].mod_start << PAGE_SHIFT; - uint64_t end = start + PAGE_ALIGN(mod[i].mod_end); + uint64_t start = pfn_to_paddr(mods[i].mod->mod_start); + uint64_t end = start + PAGE_ALIGN(mods[i].mod->mod_end); if ( i == this_mod ) continue; if ( s < end && start < e ) { - end = consider_modules(end, e, size, mod + i + 1, + end = consider_modules(end, e, size, &mods[i + 1], nr_mods - i - 1, this_mod - i - 1); if ( end ) return end; - 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 = consider_modules(s, e, reloc_size + mask, - mod, bi->nr_modules, -1); + bi->mods, bi->nr_modules, -1); end &= ~mask; } else @@ -1486,7 +1486,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) continue; /* Don't overlap with other modules (or Xen itself). */ - end = consider_modules(s, e, size, mod, + end = consider_modules(s, e, size, bi->mods, bi->nr_modules + relocated, j); 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 = consider_modules(s, e, PAGE_ALIGN(kexec_crash_area.size), mod, + e = consider_modules(s, e, PAGE_ALIGN(kexec_crash_area.size), bi->mods, bi->nr_modules + relocated, -1); if ( s >= e ) break; From patchwork Mon Oct 21 00:45:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843416 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A8034D3C937 for ; Mon, 21 Oct 2024 00:47:02 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External The purpose of struct boot_module is to encapsulate the state of boot module as it is processed by Xen. Locating boot module state struct boot_module reduces 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-domain construction, where multiple instances of state variables like headroom will 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 will 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; }; /* 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 = 0, bytes = 0; unsigned long eb_start, eb_end; bool acpi_boot_table_init_done = false, relocated = false; @@ -1394,7 +1394,10 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) mod[bi->nr_modules].mod_end = __2M_rwdata_end - _stext; } - modules_headroom = bzimage_headroom(bootstrap_map(mod), mod->mod_end); + bi->mods[0].headroom = + bzimage_headroom(bootstrap_map(bi->mods[0].mod), + bi->mods[0].mod->mod_end); + bootstrap_map(NULL); #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 start. */ - unsigned long headroom = j ? 0 : modules_headroom; - unsigned long size = PAGE_ALIGN(headroom + mod[j].mod_end); + struct boot_module *bm = &bi->mods[j]; + unsigned long size = PAGE_ALIGN(bm->headroom + mod[j].mod_end); if ( mod[j].reserved ) continue; @@ -1493,14 +1496,14 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) continue; 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 = (end - size) >> PAGE_SHIFT; - mod[j].mod_end += headroom; + mod[j].mod_end += bm->headroom; mod[j].reserved = 1; } } @@ -1527,7 +1530,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) #endif } - 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 = 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 safely * above our heap. The second module, if present, is an initrd ramdisk. */ - dom0 = create_dom0(mod, modules_headroom, + dom0 = create_dom0(mod, bi->mods[0].headroom, initrdidx < bi->nr_modules ? mod + initrdidx : NULL, kextra, bi->loader); if ( !dom0 ) From patchwork Mon Oct 21 00:45:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843417 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4E313D3C935 for ; Mon, 21 Oct 2024 00:47:15 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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 element 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 parameters 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(unsigned long mbi_p) set_kexec_crash_area_size((u64)nr_pages << PAGE_SHIFT); kexec_reserve_area(); - initial_images = mod; + /* + * The field bi->mods[0].mod points to the first element of the module_t + * array. + */ + initial_images = bi->mods[0].mod; for ( i = 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 -= mod[i].mod_start; - mod[i].mod_start >>= PAGE_SHIFT; - mod[i].reserved = 0; + bi->mods[i].mod->mod_end -= bi->mods[i].mod->mod_start; + bi->mods[i].mod->mod_start >>= PAGE_SHIFT; + bi->mods[i].mod->reserved = 0; } /* @@ -1383,6 +1387,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) if ( xen_phys_start ) { + unsigned int xen = bi->nr_modules; relocated = true; /* @@ -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 = virt_to_mfn(_stext); - mod[bi->nr_modules].mod_end = __2M_rwdata_end - _stext; + bi->mods[xen].mod->mod_start = virt_to_mfn(_stext); + bi->mods[xen].mod->mod_end = __2M_rwdata_end - _stext; } bi->mods[0].headroom = @@ -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 start. */ struct boot_module *bm = &bi->mods[j]; - unsigned long size = PAGE_ALIGN(bm->headroom + mod[j].mod_end); + unsigned long size = PAGE_ALIGN(bm->headroom + bm->mod->mod_end); - if ( mod[j].reserved ) + if ( bm->mod->reserved ) continue; /* Don't overlap with other modules (or Xen itself). */ @@ -1497,14 +1502,14 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) 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 = (end - size) >> PAGE_SHIFT; - mod[j].mod_end += bm->headroom; - mod[j].reserved = 1; + (uint64_t)bm->mod->mod_start << PAGE_SHIFT, + bm->mod->mod_end); + bm->mod->mod_start = (end - size) >> PAGE_SHIFT; + bm->mod->mod_end += bm->headroom; + bm->mod->reserved = 1; } } @@ -1530,13 +1535,14 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) #endif } - 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 = 0; i < bi->nr_modules; ++i ) { - uint64_t s = (uint64_t)mod[i].mod_start << PAGE_SHIFT; + uint64_t s = (uint64_t)bi->mods[i].mod->mod_start << PAGE_SHIFT; - 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)); } if ( !xen_phys_start ) @@ -1614,8 +1620,8 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) map_e = boot_e820.map[j].addr + boot_e820.map[j].size; for ( j = 0; j < bi->nr_modules; ++j ) { - uint64_t end = pfn_to_paddr(mod[j].mod_start) + - mod[j].mod_end; + uint64_t end = pfn_to_paddr(bi->mods[j].mod->mod_start) + + bi->mods[j].mod->mod_end; if ( map_e < end ) map_e = end; @@ -1689,11 +1695,12 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) for ( i = 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_start), + _mfn(bi->mods[i].mod->mod_start), + PFN_UP(bi->mods[i].mod->mod_end), PAGE_HYPERVISOR); } #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 safely * above our heap. The second module, if present, is an initrd ramdisk. */ - dom0 = create_dom0(mod, bi->mods[0].headroom, - initrdidx < bi->nr_modules ? mod + initrdidx : NULL, + dom0 = 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"); From patchwork Mon Oct 21 00:45:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843418 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8492FD3C935 for ; Mon, 21 Oct 2024 00:47:21 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External This commit introduces module types of xen, kernel, and ramdisk to allow boot module detect code to tag the purpose of a boot module. This reduces the need for hard coded order assumptions and global variables to be used by consumers 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 +/* 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; }; /* 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_info(unsigned long mbi_p) /* Variable 'i' should be one entry past the last module. */ bi->mods[i].mod = &mods[bi->nr_modules]; + bi->mods[i].type = BOOTMOD_XEN; return bi; } @@ -1194,6 +1195,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 = BOOTMOD_KERNEL; if ( pvh_boot ) { @@ -2080,6 +2082,8 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) cpu_has_nx ? "" : "not "); initrdidx = find_first_bit(module_map, bi->nr_modules); + if ( initrdidx < bi->nr_modules ) + bi->mods[initrdidx].type = BOOTMOD_RAMDISK; if ( bitmap_weight(module_map, bi->nr_modules) > 1 ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", From patchwork Mon Oct 21 00:45:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843451 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E8C06D3C927 for ; Mon, 21 Oct 2024 00:57:07 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External The existing startup code employs various ad-hoc state tracking about certain 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; }; /* 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 -= bi->mods[i].mod->mod_start; bi->mods[i].mod->mod_start >>= PAGE_SHIFT; - bi->mods[i].mod->reserved = 0; } /* @@ -1492,7 +1491,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) struct boot_module *bm = &bi->mods[j]; unsigned long size = PAGE_ALIGN(bm->headroom + bm->mod->mod_end); - if ( bm->mod->reserved ) + if ( bm->relocated ) continue; /* 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 = (end - size) >> PAGE_SHIFT; bm->mod->mod_end += bm->headroom; - bm->mod->reserved = 1; + bm->relocated = true; } } @@ -1537,7 +1536,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) #endif } - 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 = 0; i < bi->nr_modules; ++i ) { From patchwork Mon Oct 21 00:45:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843463 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 01605D3C927 for ; Mon, 21 Oct 2024 00:57:36 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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 stored 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; }; /* 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_info(unsigned long mbi_p) * reserved for Xen. */ for ( i = 0; i < MAX_NR_BOOTMODS && i < bi->nr_modules; i++ ) + { bi->mods[i].mod = &mods[i]; + if ( !efi_enabled(EFI_LOADER) ) + { + bi->mods[i].start = mods[i].mod_start; + bi->mods[i].size = mods[i].mod_end - mods[i].mod_start; + } + else + { + bi->mods[i].start = pfn_to_paddr(mods[i].mod_start); + bi->mods[i].size = mods[i].mod_end; + } + } + /* Variable 'i' should be one entry past the last module. */ bi->mods[i].mod = &mods[bi->nr_modules]; + bi->mods[i].start = mods[i].mod_start; + bi->mods[i].size = mods[i].mod_end - mods[i].mod_start; bi->mods[i].type = BOOTMOD_XEN; return bi; From patchwork Mon Oct 21 00:45:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843443 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D6263D3C927 for ; Mon, 21 Oct 2024 00:56:50 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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 = virt_to_mfn(_stext); - bi->mods[xen].mod->mod_end = __2M_rwdata_end - _stext; + bi->mods[xen].start = virt_to_maddr(_stext); + bi->mods[xen].size = __2M_rwdata_end - _stext; + + bi->mods[xen].mod->mod_start = paddr_to_pfn(bi->mods[xen].start); + bi->mods[xen].mod->mod_end = bi->mods[xen].size; } bi->mods[0].headroom = From patchwork Mon Oct 21 00:45:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843464 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1DF7DD3C935 for ; Mon, 21 Oct 2024 00:57:39 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External Use struct boot_module fields, start and size, when calculating the relocation address and size. It also ensures that early_mod references are kept in sync. Signed-off-by: Daniel P. Smith --- Changes since v6: - introduce local s and l refs for start and size, shortening the lines while correcting the indentation style Changes since v5: - removed unnecessary paddr_to_pfn, allowing condition to collapse to one line - 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 start. */ struct boot_module *bm = &bi->mods[j]; - unsigned long size = PAGE_ALIGN(bm->headroom + bm->mod->mod_end); + unsigned long size = PAGE_ALIGN(bm->headroom + bm->size); if ( bm->relocated ) continue; @@ -1519,15 +1519,13 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) if ( highmem_start && end > highmem_start ) continue; - 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 = (end - size) >> PAGE_SHIFT; - bm->mod->mod_end += bm->headroom; + move_memory(end - size + bm->headroom, bm->start, bm->size); + bm->start = (end - size); + bm->mod->mod_start = paddr_to_pfn(bm->start); + bm->size += bm->headroom; + bm->mod->mod_end = bm->size; bm->relocated = 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 = 0; i < bi->nr_modules; ++i ) { - uint64_t s = (uint64_t)bi->mods[i].mod->mod_start << PAGE_SHIFT; + uint64_t s = bi->mods[i].start; - 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)); } if ( !xen_phys_start ) @@ -1639,8 +1636,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) map_e = boot_e820.map[j].addr + boot_e820.map[j].size; for ( j = 0; j < bi->nr_modules; ++j ) { - uint64_t end = pfn_to_paddr(bi->mods[j].mod->mod_start) + - bi->mods[j].mod->mod_end; + uint64_t end = bi->mods[j].start + bi->mods[j].size; if ( map_e < end ) map_e = end; @@ -1714,12 +1710,10 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) for ( i = 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_start), - _mfn(bi->mods[i].mod->mod_start), - PFN_UP(bi->mods[i].mod->mod_end), PAGE_HYPERVISOR); + unsigned long s = bi->mods[i].start, l = 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); } #ifdef CONFIG_KEXEC From patchwork Mon Oct 21 00:45:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843461 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 79497D3C937 for ; Mon, 21 Oct 2024 00:57:35 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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 = instead of |= --- 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; 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_info(unsigned long mbi_p) bi->mods[i].start = mods[i].mod_start; bi->mods[i].size = mods[i].mod_end - mods[i].mod_start; bi->mods[i].type = BOOTMOD_XEN; + bi->mods[i].consumed = true; 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 = BOOTMOD_KERNEL; + bi->mods[0].consumed = true; if ( pvh_boot ) { @@ -2094,7 +2096,10 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) initrdidx = find_first_bit(module_map, bi->nr_modules); if ( initrdidx < bi->nr_modules ) + { bi->mods[initrdidx].type = BOOTMOD_RAMDISK; + bi->mods[initrdidx].consumed = true; + } if ( bitmap_weight(module_map, bi->nr_modules) > 1 ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", From patchwork Mon Oct 21 00:45:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843462 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2B4D5D3C935 for ; Mon, 21 Oct 2024 00:57:36 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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 microcode that is used by the late microcode logic. To support loading the microcode boot module in to the bootstrap map, introduce 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 #include +#include #include #include #include @@ -153,16 +154,14 @@ static int __init cf_check parse_ucode(const char *s) custom_param("ucode", parse_ucode); 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 = (module_t *)__va(mbi->mods_addr); uint64_t *_blob_start; unsigned long _blob_size; struct cpio_data cd; long offset; const char *p = NULL; - int i; + struct boot_module *bm; ucode_blob.size = 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 = 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 = bootstrap_map(&mod[i]); - _blob_size = mod[i].mod_end; + _blob_start = bootstrap_map_bm(bm); + _blob_size = 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 = NULL; @@ -200,25 +196,23 @@ static void __init microcode_scan_module( ucode_blob.data = cd.data; break; } - bootstrap_map(NULL); + bootstrap_map_bm(NULL); } } 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 = (module_t *)__va(mbi->mods_addr); - if ( ucode_mod_idx < 0 ) - ucode_mod_idx += mbi->mods_count; - if ( ucode_mod_idx <= 0 || ucode_mod_idx >= mbi->mods_count || + ucode_mod_idx += bi->nr_modules; + if ( ucode_mod_idx <= 0 || ucode_mod_idx >= bi->nr_modules || !__test_and_clear_bit(ucode_mod_idx, module_map) ) goto scan; - ucode_mod = mod[ucode_mod_idx]; + bi->mods[ucode_mod_idx].type = BOOTMOD_MICROCODE; + ucode_mod = *bi->mods[ucode_mod_idx].mod; scan: if ( ucode_scan ) - microcode_scan_module(module_map, mbi); + microcode_scan_module(module_map, bi); } 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; } -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 = 0; @@ -832,7 +826,7 @@ int __init microcode_init_cache(unsigned long *module_map, if ( ucode_scan ) /* Need to rescan the modules because they might have been relocated */ - microcode_scan_module(module_map, mbi); + microcode_scan_module(module_map, bi); if ( ucode_mod.mod_end ) rc = early_update_cache(bootstrap_map(&ucode_mod), @@ -879,7 +873,7 @@ static int __init early_microcode_update_cpu(void) } int __init early_microcode_init(unsigned long *module_map, - const struct multiboot_info *mbi) + struct boot_info *bi) { const struct cpuinfo_x86 *c = &boot_cpu_data; int rc = 0; @@ -922,7 +916,7 @@ int __init early_microcode_init(unsigned long *module_map, return -ENODEV; } - microcode_grab_module(module_map, mbi); + microcode_grab_module(module_map, bi); if ( ucode_mod.mod_end || ucode_blob.size ) rc = 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, }; struct boot_module { @@ -69,6 +70,30 @@ struct boot_info { struct boot_module mods[MAX_NR_BOOTMODS + 1]; }; +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 == NULL ) + bm = &bi->mods[0]; + else + bm++; + + for ( ; bm <= &bi->mods[bi->nr_modules]; bm++ ) + { + if ( bm->type == t ) + return bm; + } + + return NULL; +} + +#define for_each_boot_module(bi, bm, t) \ + for ( bm = &bi->mods[0]; bm != NULL && bm <= &bi->mods[bi->nr_modules]; \ + bm = next_boot_module_by_type(bi, bm, t) ) + +#define boot_module_index(bi, bm) \ + (unsigned int)(bm - &bi->mods[0]) + #endif /* X86_BOOTINFO_H */ /* diff --git a/xen/arch/x86/include/asm/microcode.h b/xen/arch/x86/include/asm/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 +#include + #include struct multiboot_info; @@ -22,12 +24,12 @@ struct cpu_signature { 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 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 flags); +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); #endif /* ASM_X86__MICROCODE_H */ diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.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_ #include +#include #include 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); int remove_xen_ranges(struct rangeset *r); 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); } +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); if ( xen_phys_start ) { @@ -1948,7 +1956,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) timer_init(); - microcode_init_cache(module_map, mbi); /* Needs xmalloc() */ + microcode_init_cache(module_map, bi); /* Needs xmalloc() */ tsx_init(); /* Needs microcode. May change HLE/RTM feature bits. */ From patchwork Mon Oct 21 00:45:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843446 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D94BCD3C927 for ; Mon, 21 Oct 2024 00:56:54 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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 -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 { 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 = BOOTMOD_MICROCODE; - ucode_mod = *bi->mods[ucode_mod_idx].mod; + ucode_mod = 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 = 0; ucode_blob.data = NULL; } - else if ( ucode_mod.mod_end ) + else if ( ucode_mod.size ) { - bootstrap_map(NULL); - ucode_mod.mod_end = 0; + bootstrap_map_bm(NULL); + ucode_mod.size = 0; } return 0; @@ -828,9 +827,9 @@ int __init microcode_init_cache( /* Need to rescan the modules because they might have been relocated */ microcode_scan_module(module_map, bi); - if ( ucode_mod.mod_end ) - rc = early_update_cache(bootstrap_map(&ucode_mod), - ucode_mod.mod_end); + if ( ucode_mod.size ) + rc = early_update_cache(bootstrap_map_bm(&ucode_mod), + ucode_mod.size); else if ( ucode_blob.size ) rc = early_update_cache(ucode_blob.data, ucode_blob.size); @@ -849,10 +848,10 @@ static int __init early_microcode_update_cpu(void) len = ucode_blob.size; data = ucode_blob.data; } - else if ( ucode_mod.mod_end ) + else if ( ucode_mod.size ) { - len = ucode_mod.mod_end; - data = bootstrap_map(&ucode_mod); + len = ucode_mod.size; + data = bootstrap_map_bm(&ucode_mod); } if ( !data ) @@ -918,7 +917,7 @@ int __init early_microcode_init(unsigned long *module_map, microcode_grab_module(module_map, bi); - if ( ucode_mod.mod_end || ucode_blob.size ) + if ( ucode_mod.size || ucode_blob.size ) rc = early_microcode_update_cpu(); /* From patchwork Mon Oct 21 00:45:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843447 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E37BED3C937 for ; Mon, 21 Oct 2024 00:56:54 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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 rescanned 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 -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 = BOOTMOD_MICROCODE; - ucode_mod = bi->mods[ucode_mod_idx]; + ucode_mod = &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 = 0; ucode_blob.data = NULL; } - else if ( ucode_mod.size ) + else if ( ucode_mod && !ucode_mod->consumed ) { bootstrap_map_bm(NULL); - ucode_mod.size = 0; + ucode_mod->consumed = true; } return 0; @@ -823,14 +823,14 @@ int __init microcode_init_cache( if ( !ucode_ops.apply_microcode ) return -ENODEV; - if ( ucode_scan ) - /* Need to rescan the modules because they might have been relocated */ + /* Scan if microcode was not detected earlier */ + if ( !ucode_mod ) microcode_scan_module(module_map, bi); - if ( ucode_mod.size ) - rc = early_update_cache(bootstrap_map_bm(&ucode_mod), - ucode_mod.size); - else if ( ucode_blob.size ) + if ( ucode_mod && !ucode_mod->consumed ) + rc = early_update_cache(bootstrap_map_bm(ucode_mod), + ucode_mod->size); + else if ( ucode_mod && ucode_blob.size ) rc = early_update_cache(ucode_blob.data, ucode_blob.size); return rc; @@ -848,10 +848,10 @@ static int __init early_microcode_update_cpu(void) len = ucode_blob.size; data = ucode_blob.data; } - else if ( ucode_mod.size ) + else if ( ucode_mod && !ucode_mod->consumed ) { - len = ucode_mod.size; - data = bootstrap_map_bm(&ucode_mod); + len = ucode_mod->size; + data = bootstrap_map_bm(ucode_mod); } if ( !data ) @@ -917,7 +917,7 @@ int __init early_microcode_init(unsigned long *module_map, microcode_grab_module(module_map, bi); - if ( ucode_mod.size || ucode_blob.size ) + if ( ucode_mod || ucode_blob.size ) rc = early_microcode_update_cpu(); /* From patchwork Mon Oct 21 00:45:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843427 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7A74DD3C927 for ; Mon, 21 Oct 2024 00:48:29 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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 array, 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, }; struct boot_module { @@ -94,8 +95,35 @@ static inline struct boot_module *__init next_boot_module_by_type( #define boot_module_index(bi, bm) \ (unsigned int)(bm - &bi->mods[0]) -#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 == BOOTMOD_XEN ) + return bi->nr_modules; + + for ( i = start; i < bi->nr_modules; i++ ) + { + if ( bi->mods[i].type == t ) + return i; + } + + return MAX_NR_BOOTMODS + 1; +} + +#define first_boot_module_index(bi, t) \ + next_boot_module_index(bi, t, 0) +#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 = rangeset_new(NULL, "r/o mmio ranges", RANGESETF_prettyprint_hex); - xsm_multiboot_init(module_map, mbi); + xsm_multiboot_init(module_map, bi); /* * IOMMU-related ACPI table parsing may require some of the system domains 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 @@ #include #include -#include + +#ifdef CONFIG_MULTIBOOT +#include +#endif /* 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) #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 @@ -829,7 +832,7 @@ static const inline struct xsm_ops *silo_init(void) #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 #ifdef CONFIG_MULTIBOOT +#include #include #endif @@ -140,7 +141,7 @@ static int __init xsm_core_init(const void *policy_buffer, size_t policy_size) #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 = 0; void *policy_buffer = NULL; @@ -150,18 +151,26 @@ int __init xsm_multiboot_init( if ( XSM_MAGIC ) { - ret = xsm_multiboot_policy_init(module_map, mbi, &policy_buffer, + ret = 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; } } ret = xsm_core_init(policy_buffer, policy_size); - bootstrap_map(NULL); + if ( ret == 0 ) + { + int idx = first_boot_module_index(bi, BOOTMOD_XSM_POLICY); + + /* If the policy was loaded from a boot module, mark it consumed */ + if ( idx >= 0 ) + bi->mods[idx].consumed = true; + } + bootstrap_map_bm(NULL); 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 @@ #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 = (module_t *)__va(mbi->mods_addr); int rc = 0; u32 *_policy_start; unsigned long _policy_len; + struct boot_module *bm; /* * Try all modules and see whichever could be the binary policy. * Adjust module_map for the module that is the binary policy. */ - for ( i = mbi->mods_count-1; i >= 1; i-- ) + for_each_boot_module(bi, bm, BOOTMOD_UNKNOWN) { - if ( !test_bit(i, module_map) ) - continue; - - _policy_start = bootstrap_map(mod + i); - _policy_len = mod[i].mod_end; + _policy_start = bootstrap_map_bm(bm); + _policy_len = bm->size; if ( (xsm_magic_t)(*_policy_start) == XSM_MAGIC ) { @@ -60,12 +57,13 @@ int __init xsm_multiboot_policy_init( printk("Policy len %#lx, start at %p.\n", _policy_len,_policy_start); - __clear_bit(i, module_map); + __clear_bit(boot_module_index(bi, bm), module_map); + bm->type = BOOTMOD_XSM_POLICY; break; } - bootstrap_map(NULL); + bootstrap_map_bm(NULL); } return rc; From patchwork Mon Oct 21 00:45:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843428 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3EC87D3C937 for ; Mon, 21 Oct 2024 00:48:30 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External Locate the first unclaimed struct boot_module and mark it as ramdisk. If there 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(unsigned long mbi_p) cpu_has_nx ? XENLOG_INFO : XENLOG_WARNING "Warning: ", cpu_has_nx ? "" : "not "); - initrdidx = 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 initrd + * candidates. + */ + initrdidx = first_boot_module_index(bi, BOOTMOD_UNKNOWN); + if ( initrdidx < MAX_NR_BOOTMODS ) { bi->mods[initrdidx].type = BOOTMOD_RAMDISK; bi->mods[initrdidx].consumed = true; + if ( first_boot_module_index(bi, BOOTMOD_UNKNOWN) < MAX_NR_BOOTMODS ) + 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); /* * We're going to setup domain0 using the module(s) that we stashed safely From patchwork Mon Oct 21 00:45:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843429 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 67A8ED3C927 for ; Mon, 21 Oct 2024 00:48:45 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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); -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( } } -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 += bi->nr_modules; if ( ucode_mod_idx <= 0 || ucode_mod_idx >= bi->nr_modules || - !__test_and_clear_bit(ucode_mod_idx, module_map) ) + bi->mods[ucode_mod_idx].type != BOOTMOD_UNKNOWN ) goto scan; bi->mods[ucode_mod_idx].type = BOOTMOD_MICROCODE; ucode_mod = &bi->mods[ucode_mod_idx]; scan: if ( ucode_scan ) - microcode_scan_module(module_map, bi); + microcode_scan_module(bi); } 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; } -int __init microcode_init_cache( - unsigned long *module_map, struct boot_info *bi) +int __init microcode_init_cache(struct boot_info *bi) { int rc = 0; @@ -825,7 +822,7 @@ int __init microcode_init_cache( /* Scan if microcode was not detected earlier */ if ( !ucode_mod ) - microcode_scan_module(module_map, bi); + microcode_scan_module(bi); if ( ucode_mod && !ucode_mod->consumed ) rc = 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); } -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 = &boot_cpu_data; int rc = 0; @@ -915,7 +911,7 @@ int __init early_microcode_init(unsigned long *module_map, return -ENODEV; } - microcode_grab_module(module_map, bi); + microcode_grab_module(bi); if ( ucode_mod || ucode_blob.size ) rc = early_microcode_update_cpu(); diff --git a/xen/arch/x86/include/asm/microcode.h b/xen/arch/x86/include/asm/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 flags); -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); #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); if ( xen_phys_start ) { @@ -1956,7 +1956,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) timer_init(); - microcode_init_cache(module_map, bi); /* Needs xmalloc() */ + microcode_init_cache(bi); /* Needs xmalloc() */ tsx_init(); /* Needs microcode. May change HLE/RTM feature bits. */ From patchwork Mon Oct 21 00:45:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843430 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8DB90D3C935 for ; Mon, 21 Oct 2024 00:48:49 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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 = rangeset_new(NULL, "r/o mmio ranges", RANGESETF_prettyprint_hex); - xsm_multiboot_init(module_map, bi); + xsm_multiboot_init(bi); /* * IOMMU-related ACPI table parsing may require some of the system domains 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 */ #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 #ifdef CONFIG_HAS_DEVICE_TREE @@ -831,8 +829,7 @@ static const inline struct xsm_ops *silo_init(void) #include #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_buffer, size_t policy_size) } #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 = 0; void *policy_buffer = NULL; @@ -151,8 +150,7 @@ int __init xsm_multiboot_init( if ( XSM_MAGIC ) { - ret = xsm_multiboot_policy_init(module_map, bi, &policy_buffer, - &policy_size); + ret = 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 @@ #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 = 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); - __clear_bit(boot_module_index(bi, bm), module_map); bm->type = BOOTMOD_XSM_POLICY; break; From patchwork Mon Oct 21 00:45:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843431 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BD2AAD3C927 for ; Mon, 21 Oct 2024 00:48:53 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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 = 0, bytes = 0; unsigned long eb_start, eb_end; bool acpi_boot_table_init_done = false, relocated = false; @@ -1217,8 +1217,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) bi->nr_modules); } - 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 = BOOTMOD_KERNEL; bi->mods[0].consumed = true; From patchwork Mon Oct 21 00:45:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843432 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8AA11D3C927 for ; Mon, 21 Oct 2024 00:49:07 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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 kernel 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 e820entry *map, unsigned int li return n; } -static struct domain *__init create_dom0(const module_t *image, - unsigned long headroom, - module_t *initrd, const char *kextra, - const char *loader) +static struct domain *__init create_dom0(const struct boot_info *bi, + const char *kextra) { static char __initdata cmdline[MAX_GUEST_CMDLINE]; @@ -980,9 +978,22 @@ static struct domain *__init create_dom0(const module_t *image, .misc_flags = opt_dom0_msr_relaxed ? XEN_X86_MSR_RELAXED : 0, }, }; + unsigned long headroom; + unsigned int mod_idx = first_boot_module_index(bi, BOOTMOD_RAMDISK); + module_t *image, *initrd; struct domain *d; domid_t domid; + /* Map boot_module to mb1 module for dom0 */ + image = bi->mods[0].mod; + headroom = bi->mods[0].headroom; + + /* Map boot_module to mb1 module for initrd */ + if ( mod_idx < 0 ) + initrd = NULL; + else + initrd = bi->mods[mod_idx].mod; + if ( opt_dom0_pvh ) { dom0_cfg.flags |= (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->loader)); 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 safely * above our heap. The second module, if present, is an initrd ramdisk. */ - dom0 = create_dom0(bi->mods[0].mod, bi->mods[0].headroom, - initrdidx < bi->nr_modules ? bi->mods[initrdidx].mod - : NULL, - kextra, bi->loader); + dom0 = create_dom0(bi, kextra); if ( !dom0 ) panic("Could not set up DOM0 guest OS\n"); From patchwork Mon Oct 21 00:45:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843433 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AC48BD3C927 for ; Mon, 21 Oct 2024 00:49:13 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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 #include +#include #include #include #include @@ -596,9 +597,8 @@ int __init dom0_setup_permissions(struct domain *d) return rc; } -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 *image, + struct boot_module *initrd, const char *cmdline) { int rc; @@ -610,9 +610,11 @@ int __init construct_dom0(struct domain *d, const module_t *image, process_pending_softirqs(); if ( is_hvm_domain(d) ) - rc = dom0_construct_pvh(d, image, image_headroom, initrd, cmdline); + rc = dom0_construct_pvh(d, image->mod, image->headroom, initrd->mod, + cmdline); else if ( is_pv_domain(d) ) - rc = dom0_construct_pv(d, image, image_headroom, initrd, cmdline); + rc = dom0_construct_pv(d, image->mod, image->headroom, initrd->mod, + cmdline); else panic("Cannot construct Dom0. No guest interface available\n"); diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.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); 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); 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 e820entry *map, unsigned int li return n; } -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 = opt_dom0_msr_relaxed ? XEN_X86_MSR_RELAXED : 0, }, }; - unsigned long headroom; unsigned int mod_idx = first_boot_module_index(bi, BOOTMOD_RAMDISK); - module_t *image, *initrd; + struct boot_module *image, *initrd; struct domain *d; domid_t domid; /* Map boot_module to mb1 module for dom0 */ - image = bi->mods[0].mod; - headroom = bi->mods[0].headroom; + image = &bi->mods[0]; /* Map boot_module to mb1 module for initrd */ if ( mod_idx < 0 ) initrd = NULL; else - initrd = bi->mods[mod_idx].mod; + initrd = &bi->mods[mod_idx]; if ( opt_dom0_pvh ) { @@ -1019,10 +1017,11 @@ static struct domain *__init create_dom0(const struct boot_info *bi, panic("Error creating d%uv0\n", domid); /* 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->loader)); + if ( image->mod->string ) + safe_strcpy(cmdline, cmdline_cook(__va(image->mod->string), + bi->loader)); if ( kextra ) /* kextra always includes exactly one leading space. */ @@ -1045,7 +1044,7 @@ static struct domain *__init create_dom0(const struct boot_info *bi, } } - if ( construct_dom0(d, image, headroom, initrd, cmdline) != 0 ) + if ( construct_dom0(d, image, initrd, cmdline) != 0 ) panic("Could not construct domain 0\n"); return d; From patchwork Mon Oct 21 00:45:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843449 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6A095D3C938 for ; Mon, 21 Oct 2024 00:57:03 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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; 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 e820entry *map, unsigned int li return n; } -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]; @@ -1017,15 +1016,15 @@ static struct domain *__init create_dom0(struct boot_info *bi, panic("Error creating d%uv0\n", domid); /* 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)); - if ( kextra ) + if ( bi->kextra ) /* kextra always includes exactly one leading space. */ - safe_strcat(cmdline, kextra); + safe_strcat(cmdline, bi->kextra); /* 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 = '\0'; kextra += 3; while ( kextra[1] == ' ' ) kextra++; + bi->kextra = kextra; } cmdline_parse(bi->cmdline); @@ -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 safely * above our heap. The second module, if present, is an initrd ramdisk. */ - dom0 = create_dom0(bi, kextra); + dom0 = create_dom0(bi); if ( !dom0 ) panic("Could not set up DOM0 guest OS\n"); From patchwork Mon Oct 21 00:45:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843444 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2ADA9D3C935 for ; Mon, 21 Oct 2024 00:56:51 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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; + 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_info(unsigned long mbi_p) { bi->mods[i].mod = &mods[i]; + bi->mods[i].cmdline = (paddr_t)mods[i].string; + if ( !efi_enabled(EFI_LOADER) ) { bi->mods[i].start = mods[i].mod_start; @@ -1016,10 +1018,11 @@ static struct domain *__init create_dom0(struct boot_info *bi) panic("Error creating d%uv0\n", domid); /* 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)); if ( bi->kextra ) From patchwork Mon Oct 21 00:45:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843460 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A123CD3C935 for ; Mon, 21 Oct 2024 00:57:33 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External This changes the type for the image parameter of dom0_construct_pv to be struct 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 struct boot_module *image, rc = dom0_construct_pvh(d, image->mod, image->headroom, initrd->mod, cmdline); else if ( is_pv_domain(d) ) - rc = dom0_construct_pv(d, image->mod, image->headroom, initrd->mod, - cmdline); + rc = dom0_construct_pv(d, image, initrd->mod, cmdline); else panic("Cannot construct Dom0. No guest interface available\n"); diff --git a/xen/arch/x86/include/asm/dom0_build.h b/xen/arch/x86/include/asm/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); -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); 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 domain *d, } 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 = 0; start_info_t *si; struct vcpu *v = d->vcpu[0]; - void *image_base = bootstrap_map(image); - unsigned long image_len = image->mod_end; - void *image_start = image_base + image_headroom; + void *image_base = bootstrap_map_bm(image); + unsigned long image_len = image->size; + void *image_start = image_base + image->headroom; unsigned long initrd_len = initrd ? initrd->mod_end : 0; l4_pgentry_t *l4tab = NULL, *l4start = NULL; l3_pgentry_t *l3tab = NULL, *l3start = 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); if ( UNSET_ADDR != parms.virt_hypercall ) { @@ -1052,8 +1051,7 @@ out: } 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); } - rc = dom0_construct(d, image, image_headroom, initrd, cmdline); + rc = dom0_construct(d, image, initrd, cmdline); if ( cr4 & X86_CR4_SMAP ) { From patchwork Mon Oct 21 00:45:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843465 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 61E11D3C937 for ; Mon, 21 Oct 2024 00:57:39 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External This changes the type for the initrd parameter of dom0_construct_pv to be struct boot_module. This conversion requires several adjustments throughout dom0_construct_pv to account for the type change. Removes the usage of early_mod field for ramdisk 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 struct boot_module *image, rc = dom0_construct_pvh(d, image->mod, image->headroom, initrd->mod, cmdline); else if ( is_pv_domain(d) ) - rc = dom0_construct_pv(d, image, initrd->mod, cmdline); + rc = dom0_construct_pv(d, image, initrd, cmdline); else panic("Cannot construct Dom0. No guest interface available\n"); diff --git a/xen/arch/x86/include/asm/dom0_build.h b/xen/arch/x86/include/asm/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); int dom0_construct_pv(struct domain *d, const struct boot_module *image, - module_t *initrd, + struct boot_module *initrd, const char *cmdline); 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 domain *d, 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 = -1, initrd_mfn = 0; + unsigned long initrd_pfn = -1; + mfn_t initrd_mfn = _mfn(0); unsigned long count; struct page_info *page = NULL; unsigned int flush_flags = 0; @@ -376,7 +377,7 @@ static int __init dom0_construct(struct domain *d, void *image_base = bootstrap_map_bm(image); unsigned long image_len = image->size; void *image_start = image_base + image->headroom; - unsigned long initrd_len = initrd ? initrd->mod_end : 0; + unsigned long initrd_len = initrd ? initrd->size : 0; l4_pgentry_t *l4tab = NULL, *l4start = NULL; l3_pgentry_t *l3tab = NULL, *l3start = NULL; l2_pgentry_t *l2tab = NULL, *l2start = NULL; @@ -612,7 +613,8 @@ static int __init dom0_construct(struct domain *d, initrd_pfn = vinitrd_start ? (vinitrd_start - v_start) >> PAGE_SHIFT : domain_tot_pages(d); - initrd_mfn = mfn = initrd->mod_start; + initrd_mfn = maddr_to_mfn(initrd->start); + mfn = mfn_x(initrd_mfn); count = 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 += 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 = (paddr_t)initrd->mod_start << PAGE_SHIFT; + mpt_alloc = initrd->start; init_domheap_pages(mpt_alloc, mpt_alloc + PAGE_ALIGN(initrd_len)); - initrd->mod_start = initrd_mfn = mfn_x(page_to_mfn(page)); + initrd_mfn = page_to_mfn(page); + initrd->start = 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 = 0; + initrd->size = 0; - 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); } @@ -654,7 +657,7 @@ static int __init dom0_construct(struct domain *d, nr_pages - domain_tot_pages(d)); if ( initrd ) { - mpt_alloc = (paddr_t)initrd->mod_start << PAGE_SHIFT; + mpt_alloc = 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 >= initrd_pfn + PFN_UP(initrd_len) ) mfn = pfn++; else - mfn = initrd_mfn++; + mfn = mfn_x(initrd_mfn) + 1; *l1tab = l1e_from_pfn(mfn, compat ? COMPAT_L1_PROT : L1_PROT); l1tab++; @@ -882,7 +885,7 @@ static int __init dom0_construct(struct domain *d, if ( pfn >= initrd_pfn ) { if ( pfn < initrd_pfn + PFN_UP(initrd_len) ) - mfn = initrd->mod_start + (pfn - initrd_pfn); + mfn = paddr_to_pfn(initrd->start) + (pfn - initrd_pfn); else mfn -= PFN_UP(initrd_len); } @@ -1052,7 +1055,7 @@ out: 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 = read_cr4(); From patchwork Mon Oct 21 00:46:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843445 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8A829D3C938 for ; Mon, 21 Oct 2024 00:56:52 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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 struct boot_module *image, process_pending_softirqs(); if ( is_hvm_domain(d) ) - rc = dom0_construct_pvh(d, image->mod, image->headroom, initrd->mod, - cmdline); + rc = dom0_construct_pvh(d, image, initrd, cmdline); else if ( is_pv_domain(d) ) rc = 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 domain *d) } } -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; } - rc = pvh_load_kernel(d, image, image_headroom, initrd, bootstrap_map(image), - cmdline, &entry, &start_info); + rc = 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/asm/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); -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); unsigned long dom0_paging_pages(const struct domain *d, From patchwork Mon Oct 21 00:46:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843454 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 956FAD3C937 for ; Mon, 21 Oct 2024 00:57:21 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External This changes both the kernel and ramdisk parameters over to struct boot_module. 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; } -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 = image_base + image_headroom; - unsigned long image_len = image->mod_end; - unsigned long initrd_len = initrd ? initrd->mod_end : 0; + void *image_start = image_base + image->headroom; + unsigned long image_len = image->size; + unsigned long initrd_len = 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, const module_t *image, if ( initrd != NULL ) { - rc = hvm_copy_to_guest_phys(last_addr, mfn_to_virt(initrd->mod_start), + rc = hvm_copy_to_guest_phys(last_addr, maddr_to_virt(initrd->start), initrd_len, v); if ( rc ) { @@ -736,9 +735,9 @@ static int __init pvh_load_kernel(struct domain *d, const module_t *image, mod.paddr = last_addr; mod.size = initrd_len; last_addr += ROUNDUP(initrd_len, elf_64bit(&elf) ? 8 : 4); - if ( initrd->string ) + if ( initrd->cmdline ) { - char *str = __va(initrd->string); + char *str = __va((unsigned long)initrd->cmdline); size_t len = strlen(str) + 1; rc = 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; } - rc = pvh_load_kernel(d, image->mod, image->headroom, initrd->mod, - bootstrap_map_bm(image), cmdline, &entry, &start_info); + rc = pvh_load_kernel(d, image, initrd, bootstrap_map_bm(image), cmdline, + &entry, &start_info); if ( rc ) { printk("Failed to load Dom0 kernel\n"); From patchwork Mon Oct 21 00:46:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843459 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 48586D3C927 for ; Mon, 21 Oct 2024 00:57:33 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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 uses 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); static const char *cmdline_cook(const char *p, const char *loader_name); -static const module_t *__initdata initial_images; +static const struct boot_module *__initdata initial_images; struct boot_info __initdata xen_boot_info = { .loader = "unknown", @@ -352,8 +352,8 @@ unsigned long __init initial_images_nrpages(nodeid_t node) for ( nr = i = 0; i < bi->nr_modules; ++i ) { - unsigned long start = initial_images[i].mod_start; - unsigned long end = start + PFN_UP(initial_images[i].mod_end); + unsigned long start = initial_images[i].mod->mod_start; + unsigned long end = start + PFN_UP(initial_images[i].mod->mod_end); if ( end > node_start && node_end > start ) nr += min(node_end, end) - max(node_start, start); @@ -369,10 +369,11 @@ void __init discard_initial_images(void) for ( i = 0; i < bi->nr_modules; ++i ) { - uint64_t start = (uint64_t)initial_images[i].mod_start << PAGE_SHIFT; + uint64_t start = + (uint64_t)initial_images[i].mod->mod_start << PAGE_SHIFT; init_domheap_pages(start, - start + PAGE_ALIGN(initial_images[i].mod_end)); + start + PAGE_ALIGN(initial_images[i].mod->mod_end)); } bi->nr_modules = 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(); - /* - * The field bi->mods[0].mod points to the first element of the module_t - * array. - */ - initial_images = bi->mods[0].mod; + initial_images = bi->mods; for ( i = 0; !efi_enabled(EFI_LOADER) && i < bi->nr_modules; i++ ) { From patchwork Mon Oct 21 00:46:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843467 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 91362D3C935 for ; Mon, 21 Oct 2024 00:57:47 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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); static const char *cmdline_cook(const char *p, const char *loader_name); -static const struct boot_module *__initdata initial_images; - struct boot_info __initdata xen_boot_info = { .loader = "unknown", .cmdline = "", @@ -352,8 +350,8 @@ unsigned long __init initial_images_nrpages(nodeid_t node) for ( nr = i = 0; i < bi->nr_modules; ++i ) { - unsigned long start = initial_images[i].mod->mod_start; - unsigned long end = start + PFN_UP(initial_images[i].mod->mod_end); + unsigned long start = bi->mods[i].mod->mod_start; + unsigned long end = start + PFN_UP(bi->mods[i].mod->mod_end); if ( end > node_start && node_end > start ) nr += min(node_end, end) - max(node_start, start); @@ -370,14 +368,12 @@ void __init discard_initial_images(void) for ( i = 0; i < bi->nr_modules; ++i ) { uint64_t start = - (uint64_t)initial_images[i].mod->mod_start << PAGE_SHIFT; + (uint64_t)bi->mods[i].mod->mod_start << PAGE_SHIFT; - init_domheap_pages(start, - start + PAGE_ALIGN(initial_images[i].mod->mod_end)); + init_domheap_pages(start, start + PAGE_ALIGN(bi->mods[i].mod->mod_end)); } bi->nr_modules = 0; - initial_images = NULL; } 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(); - initial_images = bi->mods; - for ( i = 0; !efi_enabled(EFI_LOADER) && i < bi->nr_modules; i++ ) { if ( bi->mods[i].mod->mod_start & (PAGE_SIZE - 1) ) From patchwork Mon Oct 21 00:46:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843452 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5186DD3C927 for ; Mon, 21 Oct 2024 00:57:14 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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) for ( i = 0; i < bi->nr_modules; ++i ) { - uint64_t start = - (uint64_t)bi->mods[i].mod->mod_start << PAGE_SHIFT; + uint64_t start = bi->mods[i].start; - init_domheap_pages(start, start + PAGE_ALIGN(bi->mods[i].mod->mod_end)); + init_domheap_pages(start, start + PAGE_ALIGN(bi->mods[i].size)); } bi->nr_modules = 0; From patchwork Mon Oct 21 00:46:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843466 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5B2C3D3C935 for ; Mon, 21 Oct 2024 00:57:44 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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/setup.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; 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); 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 node) for ( nr = i = 0; i < bi->nr_modules; ++i ) { - unsigned long start = bi->mods[i].mod->mod_start; - unsigned long end = start + PFN_UP(bi->mods[i].mod->mod_end); + unsigned long start = bi->mods[i].start; + unsigned long end = start + PFN_UP(bi->mods[i].size); if ( end > node_start && node_end > start ) nr += min(node_end, end) - max(node_start, start); @@ -488,7 +488,7 @@ static void *__init bootstrap_map_addr(paddr_t start, paddr_t end) return ret; } -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( for ( i = 0; i < nr_mods ; ++i ) { - uint64_t start = pfn_to_paddr(mods[i].mod->mod_start); - uint64_t end = start + PAGE_ALIGN(mods[i].mod->mod_end); + uint64_t start = (uint64_t)mods[i].start; + uint64_t end = start + PAGE_ALIGN(mods[i].size); if ( i == this_mod ) continue; @@ -1399,12 +1399,10 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) set_kexec_crash_area_size((u64)nr_pages << PAGE_SHIFT); kexec_reserve_area(); - for ( i = 0; !efi_enabled(EFI_LOADER) && i < bi->nr_modules; i++ ) + for ( i = 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 -= bi->mods[i].mod->mod_start; - bi->mods[i].mod->mod_start >>= PAGE_SHIFT; } /* @@ -1425,16 +1423,11 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) */ bi->mods[xen].start = virt_to_maddr(_stext); bi->mods[xen].size = __2M_rwdata_end - _stext; - - bi->mods[xen].mod->mod_start = paddr_to_pfn(bi->mods[xen].start); - bi->mods[xen].mod->mod_end = bi->mods[xen].size; } - bi->mods[0].headroom = - bzimage_headroom(bootstrap_map(bi->mods[0].mod), - bi->mods[0].mod->mod_end); - - bootstrap_map(NULL); + bi->mods[0].headroom = bzimage_headroom( + bootstrap_map_bm(&bi->mods[0]), bi->mods[0].size); + bootstrap_map_bm(NULL); #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 = (end - size); - bm->mod->mod_start = paddr_to_pfn(bm->start); bm->size += bm->headroom; - bm->mod->mod_end = bm->size; bm->relocated = true; } } From patchwork Mon Oct 21 00:46:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843434 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E1173D3C935 for ; Mon, 21 Oct 2024 00:50:32 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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 -#include #include /* Max number of boot modules a bootloader can provide in addition to Xen */ @@ -25,9 +24,6 @@ enum bootmod_type { }; 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 will 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_info(unsigned long mbi_p) */ for ( i = 0; i < MAX_NR_BOOTMODS && i < bi->nr_modules; i++ ) { - bi->mods[i].mod = &mods[i]; - bi->mods[i].cmdline = (paddr_t)mods[i].string; if ( !efi_enabled(EFI_LOADER) ) @@ -331,7 +329,6 @@ static struct boot_info *__init multiboot_fill_boot_info(unsigned long mbi_p) } /* Variable 'i' should be one entry past the last module. */ - bi->mods[i].mod = &mods[bi->nr_modules]; bi->mods[i].start = mods[i].mod_start; bi->mods[i].size = mods[i].mod_end - mods[i].mod_start; bi->mods[i].type = BOOTMOD_XEN; From patchwork Mon Oct 21 00:46:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843435 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 29019D3C935 for ; Mon, 21 Oct 2024 00:50:46 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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/asm/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 #include +#include /* Max number of boot modules a bootloader can provide in addition to Xen */ #define MAX_NR_BOOTMODS 63 +/* 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 { unsigned int nr_modules; struct boot_module mods[MAX_NR_BOOTMODS + 1]; + struct boot_domain domains[MAX_NR_BOOTDOMS]; }; 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 = opt_dom0_msr_relaxed ? XEN_X86_MSR_RELAXED : 0, }, }; - unsigned int mod_idx = first_boot_module_index(bi, BOOTMOD_RAMDISK); - struct boot_module *image, *initrd; + struct boot_domain *bd = &bi->domains[0]; struct domain *d; domid_t domid; - /* Map boot_module to mb1 module for dom0 */ - image = &bi->mods[0]; - - /* Map boot_module to mb1 module for initrd */ - if ( mod_idx < 0 ) - initrd = NULL; - else - initrd = &bi->mods[mod_idx]; - if ( opt_dom0_pvh ) { dom0_cfg.flags |= (XEN_DOMCTL_CDF_hvm | @@ -1011,11 +1001,10 @@ static struct domain *__init create_dom0(struct boot_info *bi) panic("Error creating d%uv0\n", domid); /* 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)); if ( bi->kextra ) @@ -1039,7 +1028,7 @@ static struct domain *__init create_dom0(struct boot_info *bi) } } - if ( construct_dom0(d, image, initrd, cmdline) != 0 ) + if ( construct_dom0(d, bd->kernel, bd->ramdisk, cmdline) != 0 ) panic("Could not construct domain 0\n"); 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 = BOOTMOD_KERNEL; bi->mods[0].consumed = true; + bi->domains[0].kernel = &bi->mods[0]; if ( pvh_boot ) { @@ -2104,6 +2094,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p) { bi->mods[initrdidx].type = BOOTMOD_RAMDISK; bi->mods[initrdidx].consumed = true; + bi->domains[0].ramdisk = &bi->mods[initrdidx]; if ( first_boot_module_index(bi, BOOTMOD_UNKNOWN) < MAX_NR_BOOTMODS ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", From patchwork Mon Oct 21 00:46:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843436 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 826BED3C927 for ; Mon, 21 Oct 2024 00:50:53 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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 have 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/asm/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; 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_info(unsigned long mbi_p) bi->mods[i].type = BOOTMOD_XEN; bi->mods[i].consumed = true; + for ( i = 0; i < MAX_NR_BOOTDOMS; i++ ) + bi->domains[i].domid = DOMID_INVALID; + return bi; } @@ -974,7 +977,6 @@ static struct domain *__init create_dom0(struct boot_info *bi) }; struct boot_domain *bd = &bi->domains[0]; struct domain *d; - domid_t domid; if ( opt_dom0_pvh ) { @@ -990,15 +992,15 @@ static struct domain *__init create_dom0(struct boot_info *bi) dom0_cfg.flags |= XEN_DOMCTL_CDF_iommu; /* Create initial domain. Not d0 for pvshim. */ - domid = get_initial_domain_id(); - d = domain_create(domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged); + bd->domid = get_initial_domain_id(); + d = 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)); init_dom0_cpuid_policy(d); if ( alloc_dom0_vcpu0(d) == NULL ) - panic("Error creating d%uv0\n", domid); + panic("Error creating d%uv0\n", bd->domid); /* Grab the DOM0 command line. */ if ( bd->kernel->cmdline || bi->kextra ) From patchwork Mon Oct 21 00:46:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843437 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C57AED3C935 for ; Mon, 21 Oct 2024 00:50:57 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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/asm/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__ +#include + struct boot_module; struct boot_domain { + char cmdline[MAX_GUEST_CMDLINE]; + domid_t domid; 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 e820entry *map, unsigned int li static struct domain *__init create_dom0(struct boot_info *bi) { - static char __initdata cmdline[MAX_GUEST_CMDLINE]; - struct xen_domctl_createdomain dom0_cfg = { .flags = IS_ENABLED(CONFIG_TBOOT) ? XEN_DOMCTL_CDF_s3_integrity : 0, .max_evtchn_port = -1, @@ -1006,16 +1004,16 @@ static struct domain *__init create_dom0(struct boot_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)); if ( bi->kextra ) /* kextra always includes exactly one leading space. */ - safe_strcat(cmdline, bi->kextra); + safe_strcat(bd->cmdline, bi->kextra); /* 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"); if ( (strlen(acpi_param) == 0) && acpi_disabled ) { @@ -1023,14 +1021,14 @@ static struct domain *__init create_dom0(struct boot_info *bi) safe_strcpy(acpi_param, "off"); } - if ( (strlen(acpi_param) != 0) && !strstr(cmdline, "acpi=") ) + if ( (strlen(acpi_param) != 0) && !strstr(bd->cmdline, "acpi=") ) { - safe_strcat(cmdline, " acpi="); - safe_strcat(cmdline, acpi_param); + safe_strcat(bd->cmdline, " acpi="); + safe_strcat(bd->cmdline, acpi_param); } } - if ( construct_dom0(d, bd->kernel, bd->ramdisk, cmdline) != 0 ) + if ( construct_dom0(d, bd->kernel, bd->ramdisk, bd->cmdline) != 0 ) panic("Could not construct domain 0\n"); return d; From patchwork Mon Oct 21 00:46:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843448 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C6677D3C927 for ; Mon, 21 Oct 2024 00:57:01 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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/asm/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 @@ #include +struct domain; struct boot_module; struct boot_domain { @@ -19,6 +20,8 @@ struct boot_domain { struct boot_module *kernel; struct boot_module *ramdisk; + + struct domain *d; }; #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 boot_info *bi) } } + bd->d = d; + if ( construct_dom0(d, bd->kernel, bd->ramdisk, bd->cmdline) != 0 ) panic("Could not construct domain 0\n"); - return d; + return bd->d; } /* How much of the directmap is prebuilt at compile time. */ From patchwork Mon Oct 21 00:46:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843450 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B4FB4D3C935 for ; Mon, 21 Oct 2024 00:57:04 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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 instead 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; } -int __init construct_dom0(struct domain *d, const struct boot_module *image, - struct boot_module *initrd, const char *cmdline) +int __init construct_dom0(struct boot_domain *bd) { int rc; + struct domain *d = bd->d; /* Sanity! */ BUG_ON(!pv_shim && d->domain_id != 0); @@ -610,9 +610,9 @@ int __init construct_dom0(struct domain *d, const struct boot_module *image, process_pending_softirqs(); if ( is_hvm_domain(d) ) - rc = dom0_construct_pvh(d, image, initrd, cmdline); + rc = dom0_construct_pvh(bd->d, bd->kernel, bd->ramdisk, bd->cmdline); else if ( is_pv_domain(d) ) - rc = dom0_construct_pv(d, image, initrd, cmdline); + rc = dom0_construct_pv(bd->d, bd->kernel, bd->ramdisk, bd->cmdline); else panic("Cannot construct Dom0. No guest interface available\n"); diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.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); void init_IRQ(void); -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); 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) bd->d = d; - if ( construct_dom0(d, bd->kernel, bd->ramdisk, bd->cmdline) != 0 ) + if ( construct_dom0(bd) != 0 ) panic("Could not construct domain 0\n"); return bd->d; From patchwork Mon Oct 21 00:46:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843453 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 327EFD3C935 for ; Mon, 21 Oct 2024 00:57:19 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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 = dom0_construct_pvh(bd->d, bd->kernel, bd->ramdisk, bd->cmdline); else if ( is_pv_domain(d) ) - rc = dom0_construct_pv(bd->d, bd->kernel, bd->ramdisk, bd->cmdline); + rc = dom0_construct_pv(bd); else panic("Cannot construct Dom0. No guest interface available\n"); diff --git a/xen/arch/x86/include/asm/dom0_build.h b/xen/arch/x86/include/asm/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 +#include #include 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); -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); 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 domain *d, return page; } -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 = NULL; unsigned int flush_flags = 0; start_info_t *si; + struct domain *d = bd->d; struct vcpu *v = d->vcpu[0]; - void *image_base = bootstrap_map_bm(image); - unsigned long image_len = image->size; - void *image_start = image_base + image->headroom; - unsigned long initrd_len = initrd ? initrd->size : 0; + void *image_base = bootstrap_map_bm(bd->kernel); + unsigned long image_len = bd->kernel->size; + void *image_start = image_base + bd->kernel->headroom; + unsigned long initrd_len = bd->ramdisk ? bd->ramdisk->size : 0; l4_pgentry_t *l4tab = NULL, *l4start = NULL; l3_pgentry_t *l3tab = NULL, *l3start = NULL; l2_pgentry_t *l2tab = NULL, *l2start = NULL; @@ -613,7 +611,7 @@ static int __init dom0_construct(struct domain *d, initrd_pfn = vinitrd_start ? (vinitrd_start - v_start) >> PAGE_SHIFT : domain_tot_pages(d); - initrd_mfn = maddr_to_mfn(initrd->start); + initrd_mfn = maddr_to_mfn(bd->ramdisk->start); mfn = mfn_x(initrd_mfn); count = 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 += 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 = initrd->start; + mpt_alloc = bd->ramdisk->start; init_domheap_pages(mpt_alloc, mpt_alloc + PAGE_ALIGN(initrd_len)); initrd_mfn = page_to_mfn(page); - initrd->start = mfn_to_maddr(initrd_mfn); + bd->ramdisk->start = 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 = 0; + bd->ramdisk->size = 0; 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 = initrd->start; + mpt_alloc = 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 >= initrd_pfn ) { if ( pfn < initrd_pfn + PFN_UP(initrd_len) ) - mfn = paddr_to_pfn(initrd->start) + (pfn - initrd_pfn); + mfn = paddr_to_pfn(bd->ramdisk->start) + (pfn - initrd_pfn); else mfn -= PFN_UP(initrd_len); } @@ -955,8 +953,8 @@ static int __init dom0_construct(struct domain *d, } memset(si->cmd_line, 0, sizeof(si->cmd_line)); - if ( cmdline != NULL ) - strlcpy((char *)si->cmd_line, cmdline, sizeof(si->cmd_line)); + if ( bd->cmdline[0] != '\0' ) + strlcpy((char *)si->cmd_line, bd->cmdline, sizeof(si->cmd_line)); #ifdef CONFIG_VIDEO if ( !pv_shim && fill_console_start_info((void *)(si + 1)) ) @@ -1053,10 +1051,7 @@ out: return rc; } -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 = read_cr4(); int rc; @@ -1074,7 +1069,7 @@ int __init dom0_construct_pv(struct domain *d, write_cr4(cr4 & ~X86_CR4_SMAP); } - rc = dom0_construct(d, image, initrd, cmdline); + rc = dom0_construct(bd); if ( cr4 & X86_CR4_SMAP ) { From patchwork Mon Oct 21 00:46:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel P. Smith" X-Patchwork-Id: 13843442 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DE5ECD3C927 for ; Mon, 21 Oct 2024 00:56:47 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 X-ZohoMailClient: External 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(); if ( is_hvm_domain(d) ) - rc = dom0_construct_pvh(bd->d, bd->kernel, bd->ramdisk, bd->cmdline); + rc = dom0_construct_pvh(bd); else if ( is_pv_domain(d) ) rc = 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 domain *d) } } -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 = bd->d; paddr_t entry, start_info; int rc; @@ -1345,7 +1344,8 @@ int __init dom0_construct_pvh(struct domain *d, const struct boot_module *image, return rc; } - rc = pvh_load_kernel(d, image, initrd, bootstrap_map_bm(image), cmdline, + rc = 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/asm/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); int dom0_construct_pv(struct boot_domain *bd); -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); unsigned long dom0_paging_pages(const struct domain *d, unsigned long nr_pages);