From nobody Thu Nov 21 15:29:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1730568409; cv=pass; d=zohomail.com; s=zohoarc; b=WkFoHJP3kAL0Trh7+65VtMQqwnhfDMPGKxvKzeIQ/GUVuYIM8YnCK3323yBIbnHu/WlrcqqiWBOk0xLQ+xnwx1Nu+G1QoHipNx1W4LbQ9S3GG5hRdjqutdm53cs2/VK9g6z1lQzmB8F1WNR/jMHWnj+YMO87FZHXFAgmeD5fLWc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730568409; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Gr0Bo47Cp6rQWLc3HgBA4fLt5SBG4Kw79tWuOGibWjw=; b=V/ruzHVoy1H+AkCQmE5lT701ROU9HSqASxTChcXY7MrfyHI3dr9FW42RplKydNRfJtk4GSB688P1qtRDk6bbf2fbFUaUn9o6/oKGqLTthnYKfg/YvM1C9/p+uXgUpexW6koGFGzwOFUqFG+yahTmmyP8tatAYZdjRL2W9ILoHzA= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1730568409378741.46797150688; Sat, 2 Nov 2024 10:26:49 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.829559.1244554 (Exim 4.92) (envelope-from ) id 1t7HtG-0005AD-79; Sat, 02 Nov 2024 17:26:22 +0000 Received: by outflank-mailman (output) from mailman id 829559.1244554; Sat, 02 Nov 2024 17:26: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 1t7HtG-0005A0-4D; Sat, 02 Nov 2024 17:26:22 +0000 Received: by outflank-mailman (input) for mailman id 829559; Sat, 02 Nov 2024 17:26:21 +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 1t7HtF-0004r4-7a for xen-devel@lists.xenproject.org; Sat, 02 Nov 2024 17:26:21 +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 8ef6b234-993f-11ef-99a3-01e77a169b0f; Sat, 02 Nov 2024 18:26:14 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1730568360842714.6163680866581; Sat, 2 Nov 2024 10:26:00 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 8ef6b234-993f-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6IjhlZjZiMjM0LTk5M2YtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMwNTY4Mzc1LjA0MDUwMSwic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1730568367; cv=none; d=zohomail.com; s=zohoarc; b=gOXvqeIJINXmDJf/CC0P5TlgB3n0EUwvGeb85hEV3ewSRZFI1GOG1Kv0dEwF4cw3zEjQC0aO2A1bJe4YcKq7pBRlyywkOMvGNym+OwxYxllX+4fcfptq1HDgUUoL0hFhW0vc5xgwh8F6CsdLZtNoP5MEPj+OKExfrAUQjX6VDPU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730568367; 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=Gr0Bo47Cp6rQWLc3HgBA4fLt5SBG4Kw79tWuOGibWjw=; b=YEHhRXWhPRKmxq7TQtkZ+2NLoZaFumFTmmeQ137suNCGxKEPtACcFjD81jKRKwYwiwMrWuc/DIAlfmsAzMo50Gx0til4OmfzmjCFJZVCRIEzq6AoVPUhP42On9AlUbS9myf4F3ho0Q28wGN21+qMbQAPdMJ9OkNoHpwp5zHhlZg= 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=1730568367; 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=Gr0Bo47Cp6rQWLc3HgBA4fLt5SBG4Kw79tWuOGibWjw=; b=RSOHPynlurMFkn2C/yLIJc7VqCGWAZbSj0T8VUjlBC1zsODpkFSCXw4fA1BkvS5g KlAsWOBO82LVMkBk5FtJai825y1aPt9oiDzPk520On/6eE9gd/nF7OHrI8jLmIoqEc9 gT1DaT+I26byylqYUu8mQ1JaGDCURtkPG/WQGbcM= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 01/12] x86/boot: introduce boot module types Date: Sat, 2 Nov 2024 13:25:40 -0400 Message-Id: <20241102172551.17233-2-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241102172551.17233-1-dpsmith@apertussolutions.com> References: <20241102172551.17233-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1730568410528116600 Content-Type: text/plain; charset="utf-8" This commit introduces module types for the types of boot modules that may = be passed to Xen. These include xen, kernel, ramdisk, microcode, and xsm polic= y. 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: Andrew Cooper , albeit it with --- Changes since v7: - merged the addition of microcode and xsm boot mod types Changes since v5: - added guard around initrd type assignment - removed a missed rebase artifact --- xen/arch/x86/cpu/microcode/core.c | 1 + xen/arch/x86/include/asm/bootinfo.h | 12 ++++++++++++ xen/arch/x86/setup.c | 4 ++++ xen/xsm/xsm_policy.c | 1 + 4 files changed, 18 insertions(+) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index 1fa6cbf3d364..f46464241557 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -845,6 +845,7 @@ static int __init early_microcode_load(struct boot_info= *bi) printk(XENLOG_WARNING "Microcode: Chosen module %d already use= d\n", idx); return -ENODEV; } + bi->mods[idx].type =3D BOOTMOD_MICROCODE; =20 size =3D bi->mods[idx].mod->mod_end; data =3D bootstrap_map_bm(&bi->mods[idx]); diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index 6237da7e4d86..fc74e3b224e7 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -14,9 +14,21 @@ /* Max number of boot modules a bootloader can provide in addition to Xen = */ #define MAX_NR_BOOTMODS 63 =20 +/* Boot module binary type / purpose */ +enum bootmod_type { + BOOTMOD_UNKNOWN, + BOOTMOD_XEN, + BOOTMOD_KERNEL, + BOOTMOD_RAMDISK, + BOOTMOD_MICROCODE, + BOOTMOD_XSM_POLICY, +}; + struct boot_module { /* Transitionary only */ module_t *mod; + + enum bootmod_type type; }; =20 /* diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 5db57e1b1af2..fac08b6242e9 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -316,6 +316,7 @@ static struct boot_info *__init multiboot_fill_boot_inf= o( =20 /* Variable 'i' should be one entry past the last module. */ bi->mods[i].mod =3D &mods[bi->nr_modules]; + bi->mods[i].type =3D BOOTMOD_XEN; =20 return bi; } @@ -1217,6 +1218,7 @@ void asmlinkage __init noreturn __start_xen(void) =20 bitmap_fill(module_map, bi->nr_modules); __clear_bit(0, module_map); /* Dom0 kernel is always first */ + bi->mods[0].type =3D BOOTMOD_KERNEL; =20 if ( pvh_boot ) { @@ -2097,6 +2099,8 @@ void asmlinkage __init noreturn __start_xen(void) cpu_has_nx ? "" : "not "); =20 initrdidx =3D find_first_bit(module_map, bi->nr_modules); + if ( initrdidx < bi->nr_modules ) + bi->mods[initrdidx].type =3D BOOTMOD_RAMDISK; if ( bitmap_weight(module_map, bi->nr_modules) > 1 ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", diff --git a/xen/xsm/xsm_policy.c b/xen/xsm/xsm_policy.c index 35f36c6f2359..4c195411d05b 100644 --- a/xen/xsm/xsm_policy.c +++ b/xen/xsm/xsm_policy.c @@ -59,6 +59,7 @@ int __init xsm_multiboot_policy_init( _policy_len,_policy_start); =20 __clear_bit(i, bi->module_map); + bi->mods[i].type =3D BOOTMOD_XSM_POLICY; break; =20 } --=20 2.30.2 From nobody Thu Nov 21 15:29:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1730568422; cv=pass; d=zohomail.com; s=zohoarc; b=B4SSbMu0AoZVtBqOsKsoZvJEE6y82BPka3+8fcEM54fP3582ZcF3KmEuJEp3ClB79jMKl4nuulBBMW09qLUA/8Tz3p0lGypW6fDRK8gQFrQ/MDuDhAV6Dk9txZ5Iipu4idZeRsk/9VVpM/2fpf5z0qV/tyss4kui6hq4T7HzQHU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730568422; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jNx/3SoBTvToEoU/tE6YgPkXOEv7nkcy+Lso0iBfWHw=; b=gHoJ0G65EBeChrYYk4/LGfuKww5SLStikz/aIlXjw1FP5IS1ZSdF291UhR8HuWEn4UI8yAuirfo+djsvns4FH3HaedMeTlBSSTQT9xUAP04UVyWAYh9OrTTdvtDLdmAmrVuqXsSDv3oPBjnMF/OaXnC+btvTcxfowAKRAXatgyE= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 173056842263399.34297782763997; Sat, 2 Nov 2024 10:27:02 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.829561.1244564 (Exim 4.92) (envelope-from ) id 1t7HtQ-0005cb-G8; Sat, 02 Nov 2024 17:26:32 +0000 Received: by outflank-mailman (output) from mailman id 829561.1244564; Sat, 02 Nov 2024 17:26:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t7HtQ-0005cS-CN; Sat, 02 Nov 2024 17:26:32 +0000 Received: by outflank-mailman (input) for mailman id 829561; Sat, 02 Nov 2024 17:26:31 +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 1t7HtP-0004r4-6f for xen-devel@lists.xenproject.org; Sat, 02 Nov 2024 17:26:31 +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 96d410c4-993f-11ef-99a3-01e77a169b0f; Sat, 02 Nov 2024 18:26:27 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 173056836207092.5618760022054; Sat, 2 Nov 2024 10:26:02 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 96d410c4-993f-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6Ijk2ZDQxMGM0LTk5M2YtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMwNTY4Mzg4LjA1MDgxNCwic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1730568370; cv=none; d=zohomail.com; s=zohoarc; b=dUI3wqdDoph7S1XYVUqdxX/7PlP8MddaQqSm1ootBmufcxdXEaJMqVw8K34vjdI4KBqq7zLwtU7lhEcOH/pWe8Pl3rDZac4Bfc3Hranus3s4scONhAktbyEv87yZu5Az4wq/eBnyIjjKLsFC2PdaVNrexZs11cp56Gkh3xGfEdE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730568370; 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=jNx/3SoBTvToEoU/tE6YgPkXOEv7nkcy+Lso0iBfWHw=; b=UR/wiT+YM+Y65CIH865oeH3gvFR5Nitkv+sVej56QIeOq/9yNljGY1kwA6DqcHJUzLgRHllIOsRZDquPEJKiFzur66RQJkpcxDjm7fcJGWo9+TFkXCJTW5rlyaR1n/A04fEB9uhrrv+ZQLNFqH+noLTReSKnL5dRsQFz9VTGcm8= 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=1730568370; 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=jNx/3SoBTvToEoU/tE6YgPkXOEv7nkcy+Lso0iBfWHw=; b=l2cIrvL8nj8VguIribLhqPtiBZT8nVI2hnN3x49fw0YdwUYHRll3Nat6vQb3GKjp k7BoL9fuw+dFuCLdUokcD19fXNzdwmyaoHVv9iy2bjcn6kNcZP9RYaqwPWUxfkh2S9H R57L9dfAH64Cfb+OKc5fODglwxhOcFPDC0K7XDxE= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 02/12] x86/boot: eliminate module_map Date: Sat, 2 Nov 2024 13:25:41 -0400 Message-Id: <20241102172551.17233-3-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241102172551.17233-1-dpsmith@apertussolutions.com> References: <20241102172551.17233-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1730568424946116600 Content-Type: text/plain; charset="utf-8" With all boot modules now labeled by type, it is no longer necessary to track whether a boot module was identified via the module_map bitmap. Introduce a set of helpers to search the list of boot modules based on type= and the reference type, pointer or array index, desired. Then drop all uses of setting a bit in module_map and replace its use for looping with the helper= s. Signed-off-by: Daniel P. Smith --- Changes since v7: - collapse the three module_map patches into one, - x86/boot: remove module_map usage from microcode loading - x86/boot: remove module_map usage from xsm policy loading - x86/boot: remove module_map usage by ramdisk loading --- xen/arch/x86/cpu/microcode/core.c | 12 ++++----- xen/arch/x86/include/asm/bootinfo.h | 42 ++++++++++++++++++++++++++++- xen/arch/x86/setup.c | 28 +++++++++++-------- xen/xsm/xsm_policy.c | 19 +++++-------- 4 files changed, 70 insertions(+), 31 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index f46464241557..b09cf83249f6 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -790,15 +790,13 @@ static int __init early_microcode_load(struct boot_in= fo *bi) =20 if ( opt_scan ) /* Scan for a CPIO archive */ { - for ( idx =3D 1; idx < bi->nr_modules; ++idx ) + for_each_boot_module_by_type(idx, bi, BOOTMOD_UNKNOWN) { + struct boot_module *bm =3D &bi->mods[idx]; struct cpio_data cd; =20 - if ( !test_bit(idx, bi->module_map) ) - continue; - - size =3D bi->mods[idx].mod->mod_end; - data =3D bootstrap_map_bm(&bi->mods[idx]); + size =3D bm->mod->mod_end; + data =3D bootstrap_map_bm(bm); if ( !data ) { printk(XENLOG_WARNING "Microcode: Could not map module %d,= size %zu\n", @@ -840,7 +838,7 @@ static int __init early_microcode_load(struct boot_info= *bi) return -ENODEV; } =20 - if ( !__test_and_clear_bit(idx, bi->module_map) ) + if ( bi->mods[idx].type !=3D BOOTMOD_UNKNOWN ) { printk(XENLOG_WARNING "Microcode: Chosen module %d already use= d\n", idx); return -ENODEV; diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index fc74e3b224e7..37dfcc14fa7d 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -43,10 +43,50 @@ struct boot_info { size_t memmap_length; =20 unsigned int nr_modules; - unsigned long *module_map; /* Temporary */ struct boot_module mods[MAX_NR_BOOTMODS + 1]; }; =20 +/* + * next_boot_module_index: + * Finds the next boot module of type t, starting at array index start. + * + * Returns: + * Success - index in boot_module array + * Failure - a value greater than MAX_NR_BOOTMODS + */ +static inline unsigned int __init next_boot_module_index( + const struct boot_info *bi, enum bootmod_type t, unsigned int start) +{ + unsigned int i; + + if ( t =3D=3D BOOTMOD_XEN ) + return bi->nr_modules; + + for ( i =3D start; i < bi->nr_modules; i++ ) + { + if ( bi->mods[i].type =3D=3D t ) + return i; + } + + return MAX_NR_BOOTMODS + 1; +} + +/* + * first_boot_module_index: + * Finds the first boot module of type t. + * + * Returns: + * Success - index in boot_module array + * Failure - a value greater than MAX_NR_BOOTMODS + */ +#define first_boot_module_index(bi, t) \ + next_boot_module_index(bi, t, 0) + +#define for_each_boot_module_by_type(i, b, t) \ + for ( i =3D first_boot_module_index(b, t); \ + i <=3D (b)->nr_modules; \ + i =3D next_boot_module_index(b, t, i + 1) ) + #endif /* X86_BOOTINFO_H */ =20 /* diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index fac08b6242e9..92dbdfe12a3d 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1034,7 +1034,7 @@ void asmlinkage __init noreturn __start_xen(void) struct cpu_info *info =3D get_cpu_info(), *bsp_info; unsigned int initrdidx, num_parked =3D 0; struct boot_info *bi; - unsigned long nr_pages, raw_max_page, modules_headroom, module_map[1]; + unsigned long nr_pages, raw_max_page, modules_headroom; int i, j, e820_warn =3D 0, bytes =3D 0; unsigned long eb_start, eb_end; bool acpi_boot_table_init_done =3D false, relocated =3D false; @@ -1097,8 +1097,6 @@ void asmlinkage __init noreturn __start_xen(void) ASSERT(multiboot_ptr < MB(1) || xen_phys_start); } =20 - bi->module_map =3D module_map; /* Temporary */ - /* Parse the command-line options. */ if ( (kextra =3D strstr(bi->cmdline, " -- ")) !=3D NULL ) { @@ -1216,8 +1214,7 @@ void asmlinkage __init noreturn __start_xen(void) bi->nr_modules); } =20 - bitmap_fill(module_map, bi->nr_modules); - __clear_bit(0, module_map); /* Dom0 kernel is always first */ + /* Dom0 kernel is always first */ bi->mods[0].type =3D BOOTMOD_KERNEL; =20 if ( pvh_boot ) @@ -2098,13 +2095,22 @@ void asmlinkage __init noreturn __start_xen(void) cpu_has_nx ? XENLOG_INFO : XENLOG_WARNING "Warning: ", cpu_has_nx ? "" : "not "); =20 - initrdidx =3D find_first_bit(module_map, bi->nr_modules); - if ( initrdidx < bi->nr_modules ) + /* + * At this point all capabilities that consume boot modules should have + * claimed their boot modules. Find the first unclaimed boot module and + * claim it as the initrd ramdisk. Do a second search to see if there = are + * any remaining unclaimed boot modules, and report them as unusued in= itrd + * candidates. + */ + initrdidx =3D first_boot_module_index(bi, BOOTMOD_UNKNOWN); + if ( initrdidx < MAX_NR_BOOTMODS ) + { bi->mods[initrdidx].type =3D BOOTMOD_RAMDISK; - if ( bitmap_weight(module_map, bi->nr_modules) > 1 ) - printk(XENLOG_WARNING - "Multiple initrd candidates, picking module #%u\n", - initrdidx); + if ( first_boot_module_index(bi, BOOTMOD_UNKNOWN) < MAX_NR_BOOTMOD= S ) + printk(XENLOG_WARNING + "Multiple initrd candidates, picking module #%u\n", + initrdidx); + } =20 /* * We're going to setup domain0 using the module(s) that we stashed sa= fely diff --git a/xen/xsm/xsm_policy.c b/xen/xsm/xsm_policy.c index 4c195411d05b..12c9de5a1fbf 100644 --- a/xen/xsm/xsm_policy.c +++ b/xen/xsm/xsm_policy.c @@ -33,22 +33,18 @@ int __init xsm_multiboot_policy_init( struct boot_info *bi, void **policy_buffer, size_t *policy_size) { - int i; + unsigned int i; int rc =3D 0; u32 *_policy_start; unsigned long _policy_len; =20 - /* - * Try all modules and see whichever could be the binary policy. - * Adjust module_map for the module that is the binary policy. - */ - for ( i =3D bi->nr_modules - 1; i >=3D 1; i-- ) + /* Try all unknown modules and see whichever could be the binary polic= y. */ + for_each_boot_module_by_type(i, bi, BOOTMOD_UNKNOWN) { - if ( !test_bit(i, bi->module_map) ) - continue; + struct boot_module *bm =3D &bi->mods[i]; =20 - _policy_start =3D bootstrap_map(bi->mods[i].mod); - _policy_len =3D bi->mods[i].mod->mod_end; + _policy_start =3D bootstrap_map(bm->mod); + _policy_len =3D bm->mod->mod_end; =20 if ( (xsm_magic_t)(*_policy_start) =3D=3D XSM_MAGIC ) { @@ -58,8 +54,7 @@ int __init xsm_multiboot_policy_init( printk("Policy len %#lx, start at %p.\n", _policy_len,_policy_start); =20 - __clear_bit(i, bi->module_map); - bi->mods[i].type =3D BOOTMOD_XSM_POLICY; + bm->type =3D BOOTMOD_XSM_POLICY; break; =20 } --=20 2.30.2 From nobody Thu Nov 21 15:29:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1730568415; cv=pass; d=zohomail.com; s=zohoarc; b=RjXx3M+640itcTWydc2WYT24FWW3Aw1NicyuDApONsH4eYVNLFQ1seBxrJ/QX2pWc+XHtcTkoCmZNEXQYFTKi6jf3bo0GqqfZefdhe5NfNJjpDuV/Xe9k7jnEvB87n0HsmDT3aYTz51w+ClehIiIJ4Lbg+ekAkTHq74IH7m0Wgc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730568415; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cldlTjNG2X0IEi+ADcYbrRHkM0Zd7pCxKFfx6gZwAx4=; b=nbsUH403hLIh+Dv+sBTmoqSYpVQiOg359ORNrrOgG8o6IE4poUHIouMqVfnk3JcmUAPNtn+I/ZnGf/B4KJbWRdiPSgNr5BCRYDMCfvEnPJNfbAr6AeTQNulxCROh4GYV7W8AAJcsZ/RSgF+a4Tf2zXHY3WHQ+Zmwee5KY5lDYTg= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1730568415089634.337296417857; Sat, 2 Nov 2024 10:26:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.829570.1244574 (Exim 4.92) (envelope-from ) id 1t7Hta-0006Ck-O5; Sat, 02 Nov 2024 17:26:42 +0000 Received: by outflank-mailman (output) from mailman id 829570.1244574; Sat, 02 Nov 2024 17:26:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t7Hta-0006CY-Ki; Sat, 02 Nov 2024 17:26:42 +0000 Received: by outflank-mailman (input) for mailman id 829570; Sat, 02 Nov 2024 17:26:41 +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 1t7HtZ-0005zO-H2 for xen-devel@lists.xenproject.org; Sat, 02 Nov 2024 17:26:41 +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 9d21230b-993f-11ef-a0c5-8be0dac302b0; Sat, 02 Nov 2024 18:26:38 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1730568363326833.7879973254649; Sat, 2 Nov 2024 10:26:03 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 9d21230b-993f-11ef-a0c5-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6IjlkMjEyMzBiLTk5M2YtMTFlZi1hMGM1LThiZTBkYWMzMDJiMCIsInRzIjoxNzMwNTY4Mzk5LjA2MDI4Mywic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1730568371; cv=none; d=zohomail.com; s=zohoarc; b=HFi/r/GDxbDE0VePkjwtbYsGJYlfYuTWJfm4B/wZotDKLu0nJs12lIsd+8QHmpHE/QogUi0ekV54vPIoyL9tkYPRHXuTtvxEZP3749r7uu4uk5mTbBMnZ07J6uALm/GkbKgxMRuR+OFV/XbbTvGqPAhKRJ0Tlk3YHQa3ntZa170= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730568371; 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=cldlTjNG2X0IEi+ADcYbrRHkM0Zd7pCxKFfx6gZwAx4=; b=iNk/IFq2UuGeGuMTxhzenE6No3ZT50h/u5jJwhMSESw3bzVnApGuoQhHS9HKu3jNwTt0pAfRFqEmLc3gT82Qs3xlLdoWqOSqgXFwUEC7O4Q2zQA9hmmIT1o/qd92HULNqWOOIrD1N9AaL0HTXlOh9jY/F9OZgWEWGPztLJ0OYJ4= 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=1730568371; 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=cldlTjNG2X0IEi+ADcYbrRHkM0Zd7pCxKFfx6gZwAx4=; b=IqvHUs8veLwEkrbCuInEwuyCIKtdaL/waH4FGQWUz0NYvmSGXPfnK1v/hhvFREn6 0xk0qiMfTGKFUhBT3052KdVw7tWOtC/rqeqfJ+gZtRfMZ3yRODYMx+xr/3Gmh4ectZ8 G/hxksDmuROJNr7jnTP/LPw3B/G0pISSVSwyeAFI= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 03/12] x86/boot: introduce boot module flags Date: Sat, 2 Nov 2024 13:25:42 -0400 Message-Id: <20241102172551.17233-4-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241102172551.17233-1-dpsmith@apertussolutions.com> References: <20241102172551.17233-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1730568416577116600 Content-Type: text/plain; charset="utf-8" The existing startup code employs various ad-hoc state tracking about certa= in boot module types by each area of the code. A boot module flags bitfield is added to enable tracking these different states. The first state to be transition by this commit is module relocation. Signed-off-by: Daniel P. Smith Reviewed-by: Andrew Cooper --- 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 37dfcc14fa7d..0fbf36739782 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -29,6 +29,12 @@ struct boot_module { module_t *mod; =20 enum bootmod_type type; + + /* + * Module State Flags: + * relocated: indicates module has been relocated in memory. + */ + bool relocated:1; }; =20 /* diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 92dbdfe12a3d..d061ece0541f 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1392,7 +1392,6 @@ void asmlinkage __init noreturn __start_xen(void) panic("Bootloader didn't honor module alignment request\n"); bi->mods[i].mod->mod_end -=3D bi->mods[i].mod->mod_start; bi->mods[i].mod->mod_start >>=3D PAGE_SHIFT; - bi->mods[i].mod->reserved =3D 0; } =20 /* @@ -1508,7 +1507,7 @@ void asmlinkage __init noreturn __start_xen(void) unsigned long headroom =3D j ? 0 : modules_headroom; unsigned long size =3D PAGE_ALIGN(headroom + bm->mod->mod_end); =20 - if ( bm->mod->reserved ) + if ( bm->relocated ) continue; =20 /* Don't overlap with other modules (or Xen itself). */ @@ -1526,7 +1525,7 @@ void asmlinkage __init noreturn __start_xen(void) pfn_to_paddr(bm->mod->mod_start), bm->mod->mod= _end); bm->mod->mod_start =3D (end - size) >> PAGE_SHIFT; bm->mod->mod_end +=3D headroom; - bm->mod->reserved =3D 1; + bm->relocated =3D true; } } =20 @@ -1552,7 +1551,7 @@ void asmlinkage __init noreturn __start_xen(void) #endif } =20 - if ( modules_headroom && !bi->mods[0].mod->reserved ) + if ( modules_headroom && !bi->mods[0].relocated ) panic("Not enough memory to relocate the dom0 kernel image\n"); for ( i =3D 0; i < bi->nr_modules; ++i ) { --=20 2.30.2 From nobody Thu Nov 21 15:29:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1730568428; cv=pass; d=zohomail.com; s=zohoarc; b=Or1AwhNbH8Y/Yn0KMO7FuxahjYGn21/htNXxogEco6nTBKJLK7QKFnsiIrQQkNBKjCOqqucGwTYbH/kEB/QHQb2hy27lCldcLobCluUE515+4YJPZlyydic/COQSeVvjU1mZhWw7Ay4jfXEnO5JN/9J4WuS5PXUgzZKuftv+F/Y= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730568428; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hUGH3RDsDf1IJruHP2Kvrv3CdfGhOfh0xY63XM5AYas=; b=dlqhn1+/G7m+v/r5BEqIB43FyNGtY8yxu0o7rIxg9t6aAzOD7gGef6qsfxMtc86U1ZO6+xnReUIMPgM16XwX2lnkhqBq3oe5RoUArATPN73A95MJhVjbU+SvQxIq/FSpmaaZ1qU9gKJVnrrfxprlepJVUoCBlTM5RHwCn/n9gNQ= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 173056842865915.594922439743755; Sat, 2 Nov 2024 10:27:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.829575.1244584 (Exim 4.92) (envelope-from ) id 1t7Htl-0006nI-Vl; Sat, 02 Nov 2024 17:26:53 +0000 Received: by outflank-mailman (output) from mailman id 829575.1244584; Sat, 02 Nov 2024 17:26: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 1t7Htl-0006n9-Su; Sat, 02 Nov 2024 17:26:53 +0000 Received: by outflank-mailman (input) for mailman id 829575; Sat, 02 Nov 2024 17:26: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 1t7Htk-0005zO-8V for xen-devel@lists.xenproject.org; Sat, 02 Nov 2024 17:26:52 +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 a396f37c-993f-11ef-a0c5-8be0dac302b0; Sat, 02 Nov 2024 18:26:49 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1730568365486995.6070687004028; Sat, 2 Nov 2024 10:26:05 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a396f37c-993f-11ef-a0c5-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg0LjU3IiwiaGVsbyI6InNlbmRlcjMtb2YtbzU3LnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6ImEzOTZmMzdjLTk5M2YtMTFlZi1hMGM1LThiZTBkYWMzMDJiMCIsInRzIjoxNzMwNTY4NDA5LjYyODEzLCJzZW5kZXIiOiJkcHNtaXRoQGFwZXJ0dXNzb2x1dGlvbnMuY29tIiwicmVjaXBpZW50IjoieGVuLWRldmVsQGxpc3RzLnhlbnByb2plY3Qub3JnIn0= ARC-Seal: i=1; a=rsa-sha256; t=1730568372; cv=none; d=zohomail.com; s=zohoarc; b=h/d0e3JJo5w/7SvCKkTsi3kCw1xMIg8Phnq0Njv6Wl0Q/9BrhL158pOX3T7pZQ+0H2UUPYcYfMZgc2gc268WkKjjkWpxUQXxNoJX2cTzijobcWKoMbeMDSTVGUxNue9K9j4GRWgdCfieDnfbhSfohV9gL4QyA2IKDHFIGg2b2lE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730568372; 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=hUGH3RDsDf1IJruHP2Kvrv3CdfGhOfh0xY63XM5AYas=; b=gZZtJEuxMXMNrVyxcAP6O2chvCiJfrc7gsDUVuXG9MI1lPLJndg5ATz/qck2kl3CaQiS3cK4WX5enpk/8nwFN2cIFk/9kVcqr6z+uGKMSDMJtMpdPBOiBquLCGRSaKmzY9qMdcm9bPurx42zCODzr59yZeghm6ZP+YAE1NTMAcM= 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=1730568372; 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=hUGH3RDsDf1IJruHP2Kvrv3CdfGhOfh0xY63XM5AYas=; b=MckSqtGkfpRDMv8MtYbE5UcHK+4ijbl57rLme/js6NhApym2d9OrnAlDLbdpVFZQ dD4mis2Fi5VWLQ/WNfERxuLCVoL+F0mNMPeG4MT1Vt8R+WCefZlrgzeIvGrh2jHQdnd ctZ7oZ9a4DOzO7S4dxVNcJXI2FK513pmX3PTqLsE= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 04/12] x86/boot: introduce module release Date: Sat, 2 Nov 2024 13:25:43 -0400 Message-Id: <20241102172551.17233-5-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241102172551.17233-1-dpsmith@apertussolutions.com> References: <20241102172551.17233-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1730568430728116600 Content-Type: text/plain; charset="utf-8" A precarious approach was used to release the pages used to hold a boot mod= ule. The precariousness stemmed from the fact that in the case of PV dom0, the initrd module pages may be either mapped or explicitly copied into the dom0 address space. So to handle this situation, the PV dom0 construction code w= ill set the size of the module to zero, relying on discard_initial_images() to = skip any modules with a size of zero. A function is introduced to release a module when it is no longer needed th= at accepts a boolean parameter, free_mem, to indicate if the corresponding pag= es can be freed. To track that a module has been released, the boot module flag `released` is introduced. The previous release model was a free all at once except those of size zero= s, which would handle any unused modules passed. The new model is one of, free consumed module after usage is complete, thus unconsumed modules do not hav= e a consumer to free them. To address this, the discard_uknown_boot_modules() is introduced and called after the last module identification occurs, initrd, = to free the pages of any boot modules that are identified as not being release= d. After domain construction completes, all modules should be freed. A walk of= the boot modules is added after domain construction to validate and notify if a module is found not to have been released. Signed-off-by: Daniel P. Smith --- Changes since v7: - This is a new approach as an alternative to the `consumed` flag. --- xen/arch/x86/cpu/microcode/core.c | 4 ++ xen/arch/x86/hvm/dom0_build.c | 7 ++-- xen/arch/x86/include/asm/bootinfo.h | 2 + xen/arch/x86/include/asm/setup.h | 3 +- xen/arch/x86/pv/dom0_build.c | 20 ++-------- xen/arch/x86/setup.c | 57 +++++++++++++++++++++++------ xen/xsm/xsm_core.c | 5 +++ 7 files changed, 67 insertions(+), 31 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index b09cf83249f6..349e857f539a 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -756,6 +756,10 @@ static int __init cf_check microcode_init_cache(void) return rc; } =20 + /* If raw module, we can free it now */ + if ( !opt_scan ) + release_boot_module(&bi->mods[early_mod_idx], true); + if ( !patch ) return -ENOENT; =20 diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index 3dd913bdb029..a4ac262db463 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -704,6 +704,8 @@ static int __init pvh_load_kernel(struct domain *d, con= st module_t *image, return rc; } =20 + release_module(image, true); + /* * Find a RAM region big enough (and that doesn't overlap with the loa= ded * kernel) in order to load the initrd and the metadata. Note it could= be @@ -751,10 +753,9 @@ static int __init pvh_load_kernel(struct domain *d, co= nst module_t *image, last_addr +=3D len; } last_addr =3D ROUNDUP(last_addr, PAGE_SIZE); - } =20 - /* Free temporary buffers. */ - discard_initial_images(); + release_module(initrd, true); + } =20 if ( cmdline !=3D NULL ) { diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index 0fbf36739782..b1549d8c8f93 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -33,8 +33,10 @@ struct boot_module { /* * Module State Flags: * relocated: indicates module has been relocated in memory. + * released: indicates module's pages have been freed. */ bool relocated:1; + bool released:1; }; =20 /* diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/se= tup.h index d7ed4f40024c..d68d37a5293b 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -36,12 +36,13 @@ void setup_io_bitmap(struct domain *d); extern struct boot_info xen_boot_info; =20 unsigned long initial_images_nrpages(nodeid_t node); -void discard_initial_images(void); +void release_module(const module_t *m, bool mapped); =20 struct boot_module; void *bootstrap_map_bm(const struct boot_module *bm); void *bootstrap_map(const module_t *mod); void bootstrap_unmap(void); +void release_boot_module(struct boot_module *bm, bool mapped); =20 struct rangeset; int remove_xen_ranges(struct rangeset *r); diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index cc882bee61c3..c1f44502a1ac 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -630,9 +630,7 @@ static int __init dom0_construct(struct domain *d, } memcpy(page_to_virt(page), mfn_to_virt(initrd->mod_start), initrd_len); - mpt_alloc =3D (paddr_t)initrd->mod_start << PAGE_SHIFT; - init_domheap_pages(mpt_alloc, - mpt_alloc + PAGE_ALIGN(initrd_len)); + release_module(initrd, true); initrd->mod_start =3D initrd_mfn =3D mfn_x(page_to_mfn(page)); } else @@ -640,18 +638,9 @@ static int __init dom0_construct(struct domain *d, while ( count-- ) if ( assign_pages(mfn_to_page(_mfn(mfn++)), 1, d, 0) ) BUG(); + release_module(initrd, false); } =20 - /* - * We have either: - * - Mapped the initrd directly into dom0, or - * - Copied it and freed the module. - * - * Either way, tell discard_initial_images() to not free it a seco= nd - * time. - */ - initrd->mod_end =3D 0; - iommu_memory_setup(d, "initrd", mfn_to_page(_mfn(initrd_mfn)), PFN_UP(initrd_len), &flush_flags); } @@ -839,7 +828,9 @@ static int __init dom0_construct(struct domain *d, printk("Failed to load the kernel binary\n"); goto out; } + /* All done with kernel, release the module pages */ bootstrap_unmap(); + release_module(image, true); =20 if ( UNSET_ADDR !=3D parms.virt_hypercall ) { @@ -854,9 +845,6 @@ static int __init dom0_construct(struct domain *d, init_hypercall_page(d, _p(parms.virt_hypercall)); } =20 - /* Free temporary buffers. */ - discard_initial_images(); - /* Set up start info area. */ si =3D (start_info_t *)vstartinfo_start; clear_page(si); diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index d061ece0541f..e6d2d25fd038 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -341,27 +341,55 @@ unsigned long __init initial_images_nrpages(nodeid_t = node) return nr; } =20 -void __init discard_initial_images(void) /* a.k.a. Free boot modules */ +void __init release_boot_module(struct boot_module *bm, bool free_mem) +{ + uint64_t start =3D pfn_to_paddr(bm->mod->mod_start); + uint64_t size =3D bm->mod->mod_end; + + if ( bm->released ) + { + printk(XENLOG_WARNING "Attempt second release boot module of type = %d\n", + bm->type); + return; + } + + if ( free_mem ) + init_domheap_pages(start, start + PAGE_ALIGN(size)); + + bm->released =3D true; +} + +void __init release_module(const module_t *m, bool free_mem) { struct boot_info *bi =3D &xen_boot_info; unsigned int i; =20 - for ( i =3D 0; i < bi->nr_modules; ++i ) + for ( i =3D 0; i < bi->nr_modules; i++ ) { - uint64_t start =3D pfn_to_paddr(bi->mods[i].mod->mod_start); - uint64_t size =3D bi->mods[i].mod->mod_end; + if ( bi->mods[i].mod =3D=3D m ) + release_boot_module(&bi->mods[i], free_mem); + } +} =20 - /* - * Sometimes the initrd is mapped, rather than copied, into dom0. - * Size being 0 is how we're instructed to leave the module alone. - */ - if ( size =3D=3D 0 ) +static void __init discard_unknown_boot_modules(void) +{ + struct boot_info *bi =3D &xen_boot_info; + unsigned int i, count =3D 0; + + for_each_boot_module_by_type(i, bi, BOOTMOD_UNKNOWN) + { + struct boot_module *bm =3D &bi->mods[i]; + + if ( bm =3D=3D NULL || bm->released ) continue; =20 - init_domheap_pages(start, start + PAGE_ALIGN(size)); + release_boot_module(bm, true); + count++; } =20 - bi->nr_modules =3D 0; + if ( count ) + printk(XENLOG_DEBUG "Releasing pages for uknown boot module %d\n", + count); } =20 static void __init init_idle_domain(void) @@ -2111,6 +2139,8 @@ void asmlinkage __init noreturn __start_xen(void) initrdidx); } =20 + discard_unknown_boot_modules(); + /* * We're going to setup domain0 using the module(s) that we stashed sa= fely * above our heap. The second module, if present, is an initrd ramdisk. @@ -2122,6 +2152,11 @@ void asmlinkage __init noreturn __start_xen(void) if ( !dom0 ) panic("Could not set up DOM0 guest OS\n"); =20 + /* Check and warn if any modules did not get released */ + for ( i =3D 0; i < bi->nr_modules; i++ ) + if ( !bi->mods[i].released ) + printk(XENLOG_ERR "Boot module %d not released, memory leaked"= , i); + heap_init_late(); =20 init_trace_bufs(); diff --git a/xen/xsm/xsm_core.c b/xen/xsm/xsm_core.c index f255fb63bf6f..d5875599b63a 100644 --- a/xen/xsm/xsm_core.c +++ b/xen/xsm/xsm_core.c @@ -162,6 +162,11 @@ int __init xsm_multiboot_init(struct boot_info *bi) ret =3D xsm_core_init(policy_buffer, policy_size); bootstrap_unmap(); =20 + /* If the policy was loaded from a boot module, release it's memory */ + ret =3D first_boot_module_index(bi, BOOTMOD_XSM_POLICY); + if ( ret >=3D 0 && ret < bi->nr_modules ) + release_boot_module(&bi->mods[ret], true); + return 0; } #endif --=20 2.30.2 From nobody Thu Nov 21 15:29:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1730568438; cv=pass; d=zohomail.com; s=zohoarc; b=cjS5SMSCPg5URBHf+ZrK5cLxJdLJ1Dty8R80rmrFaAopTk7k5Yl2K33I9JXTBm3DZ1uh9SiK1SxpKATJJlMqLCT5CMzMOkt4va9rtE24BPLQWXATezxfhNOx/gyXee8xwuRo/AzKRRW33duDFe38CusnZH60QHwstV2QepMPY2I= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730568438; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IkU4V9zheGmMbE9F1wh08/Ap7m7WOTpvdQ1/oa+ZpD8=; b=Zr7oQoqBR2je3JTeq81JDXM0Wk+aDav9hHeqqA/ardmfGaAFg5vXST9m6wkthmE2sG69Rc3O+xfRBlRKeFVLFeFFTsKeinMbpmvuq9uvEQhBXBpOdah/Vmsd1uRwjAmmPY28p1bXhqaLu3P/EM6GNKhUc4naJbRl4FCgfeybOdE= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1730568437858557.9096943407961; Sat, 2 Nov 2024 10:27:17 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.829582.1244594 (Exim 4.92) (envelope-from ) id 1t7Htv-0007N3-CH; Sat, 02 Nov 2024 17:27:03 +0000 Received: by outflank-mailman (output) from mailman id 829582.1244594; Sat, 02 Nov 2024 17:27:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t7Htv-0007Mu-9Z; Sat, 02 Nov 2024 17:27:03 +0000 Received: by outflank-mailman (input) for mailman id 829582; Sat, 02 Nov 2024 17:27:02 +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 1t7Htu-0005zO-3A for xen-devel@lists.xenproject.org; Sat, 02 Nov 2024 17:27:02 +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 a999790a-993f-11ef-a0c5-8be0dac302b0; Sat, 02 Nov 2024 18:26:59 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1730568366662651.7865909718565; Sat, 2 Nov 2024 10:26:06 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a999790a-993f-11ef-a0c5-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6ImE5OTk3OTBhLTk5M2YtMTFlZi1hMGM1LThiZTBkYWMzMDJiMCIsInRzIjoxNzMwNTY4NDE5Ljk1MTM0Nywic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1730568379; cv=none; d=zohomail.com; s=zohoarc; b=MDs4UQlt+6cs2MV/bWPoLf5yewGv93jWyeHDuTpMW6SgVw2/JVod3CnrXWklN+pLDNKziIrJb9KVATzKRFkUxkZuokVak1GIfmKZI8C6K8lL4qVUVKMQvzDVcxyKnTcW8d8bizs3lctc4ihG6PjNksGe4w3eCDaSWz0e9tKJjfA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730568379; 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=IkU4V9zheGmMbE9F1wh08/Ap7m7WOTpvdQ1/oa+ZpD8=; b=NYUw0b5xZJxFu0ddjhlUI0/2WD7p6PD+ndizVHfUaKOUjDxTg6o37hSHMrVklqUupX1pb8ndpRoyshKCX3LozvxiX9tuIkFeW98JQlrstT6VeeOjEWD3E05Ze6bKbb1OvZ1oVbclB4EBK45mjibU9ChedPKOPJc7+66XjfI9NVY= 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=1730568379; 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=IkU4V9zheGmMbE9F1wh08/Ap7m7WOTpvdQ1/oa+ZpD8=; b=dY/uCFEpDm5b3izFTvNScs7KUuXIQXWi+S3qUfNUXqYyvWtVqtXq5U4KZBgoYpWm 7yu8yXnXIPkgY+3iIqTr8+eMc42UmqB7W/nMPpmqS60p3qKtUgOwx3JxaQOFQC9yqTE J7hmKJGntWDgOtQuwd956fZieo6gAi52IyUFQocc= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 05/12] x86/boot: move headroom to boot modules Date: Sat, 2 Nov 2024 13:25:44 -0400 Message-Id: <20241102172551.17233-6-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241102172551.17233-1-dpsmith@apertussolutions.com> References: <20241102172551.17233-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1730568438648116600 Content-Type: text/plain; charset="utf-8" The purpose of struct boot_module is to encapsulate the state of boot modul= e as it is processed by Xen. Locating boot module state struct boot_module reduc= es the number of global variables as well as the number of state variables that must be passed around. It also lays the groundwork for hyperlaunch mult-dom= ain construction, where multiple instances of state variables like headroom wil= l be needed. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v7: - adopted headroom comment from Andy Cooper 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 | 22 ++++++++++++++++++++++ xen/arch/x86/setup.c | 23 ++++++++--------------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index b1549d8c8f93..e337baa905f0 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -30,6 +30,28 @@ struct boot_module { =20 enum bootmod_type type; =20 + /* + * A boot module may need decompressing by Xen. Headroom is an estima= te of + * the additional space required to decompress the module. + * + * Headroom is accounted for at the start of the module. Decompressin= g is + * done in-place with input=3Dstart, output=3Dstart-headroom, expectin= g the + * pointers to become equal (give or take some rounding) when decompre= ssion + * is complete. + * + * Memory layout at boot: + * + * start ----+ + * v + * |<-----headroom------>|<------size------->| + * +-------------------+ + * | Compressed Module | + * +---------------------+-------------------+ + * | Decompressed Module | + * +-----------------------------------------+ + */ + unsigned long headroom; + /* * Module State Flags: * relocated: indicates module has been relocated in memory. diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index e6d2d25fd038..633319d39d80 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1062,7 +1062,7 @@ void asmlinkage __init noreturn __start_xen(void) struct cpu_info *info =3D get_cpu_info(), *bsp_info; unsigned int initrdidx, num_parked =3D 0; struct boot_info *bi; - unsigned long nr_pages, raw_max_page, modules_headroom; + unsigned long nr_pages, raw_max_page; int i, j, e820_warn =3D 0, bytes =3D 0; unsigned long eb_start, eb_end; bool acpi_boot_table_init_done =3D false, relocated =3D false; @@ -1443,7 +1443,7 @@ void asmlinkage __init noreturn __start_xen(void) xen->mod->mod_end =3D __2M_rwdata_end - _stext; } =20 - modules_headroom =3D + bi->mods[0].headroom =3D bzimage_headroom(bootstrap_map_bm(&bi->mods[0]), bi->mods[0].mod->mod_end); bootstrap_unmap(); @@ -1526,14 +1526,7 @@ void asmlinkage __init noreturn __start_xen(void) for ( j =3D bi->nr_modules - 1; j >=3D 0; j-- ) { struct boot_module *bm =3D &bi->mods[j]; - - /* - * 'headroom' is a guess for the decompressed size and - * decompressor overheads of mod[0] (the dom0 kernel). When we - * move mod[0], we incorporate this as extra space at the star= t. - */ - unsigned long headroom =3D j ? 0 : modules_headroom; - unsigned long size =3D PAGE_ALIGN(headroom + bm->mod->mod_end); + unsigned long size =3D PAGE_ALIGN(bm->headroom + bm->mod->mod_= end); =20 if ( bm->relocated ) continue; @@ -1546,13 +1539,13 @@ void asmlinkage __init noreturn __start_xen(void) continue; =20 if ( s < end && - (headroom || + (bm->headroom || ((end - size) >> PAGE_SHIFT) > bm->mod->mod_start) ) { - move_memory(end - size + headroom, + move_memory(end - size + bm->headroom, pfn_to_paddr(bm->mod->mod_start), bm->mod->mod= _end); bm->mod->mod_start =3D (end - size) >> PAGE_SHIFT; - bm->mod->mod_end +=3D headroom; + bm->mod->mod_end +=3D bm->headroom; bm->relocated =3D true; } } @@ -1579,7 +1572,7 @@ void asmlinkage __init noreturn __start_xen(void) #endif } =20 - if ( modules_headroom && !bi->mods[0].relocated ) + if ( bi->mods[0].headroom && !bi->mods[0].relocated ) panic("Not enough memory to relocate the dom0 kernel image\n"); for ( i =3D 0; i < bi->nr_modules; ++i ) { @@ -2145,7 +2138,7 @@ void asmlinkage __init noreturn __start_xen(void) * We're going to setup domain0 using the module(s) that we stashed sa= fely * above our heap. The second module, if present, is an initrd ramdisk. */ - dom0 =3D create_dom0(bi->mods[0].mod, modules_headroom, + dom0 =3D create_dom0(bi->mods[0].mod, bi->mods[0].headroom, initrdidx < bi->nr_modules ? bi->mods[initrdidx].mod : NULL, kextra, bi->loader); --=20 2.30.2 From nobody Thu Nov 21 15:29:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1730569074; cv=pass; d=zohomail.com; s=zohoarc; b=kqcJm8A/2VVjzKn86ddjM6YuiKj4wUDuVfV+wHQv6H2Lu8X1nS8yAxQtyC9fFk7BjRrbtja2jpRT2mb0UQrPltVET9OvsnzxVje701HPtgVCZU+ozp7K3L/qcMpmY0mUm64SX0K46xSwcWcB8CUUjRq7Vju2dtiEBZMaCydSMjw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730569074; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9OF7jr3+XP9qd3JfzPB9uF0lHAJIr0GJpZTZwT478GE=; b=hQs6UPQh+dKixSpZHEHfcW0ncDb2oujvAblH3bbEz/eSAJjDIGZ+6rTpjcoCTBRal38AOUo8FSX1UUYVxlyyB/7zZfSnCUWUagCGUTAQEAgfu8+N3xFdQqesADv4vBimrHBwu4EPeHgdl4nNW6/li2bcDvFxhjeT6puSO2bCiOA= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1730569074299568.2727617601863; Sat, 2 Nov 2024 10:37:54 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.829614.1244624 (Exim 4.92) (envelope-from ) id 1t7I49-0002a7-Rb; Sat, 02 Nov 2024 17:37:37 +0000 Received: by outflank-mailman (output) from mailman id 829614.1244624; Sat, 02 Nov 2024 17:37:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t7I49-0002a0-Oo; Sat, 02 Nov 2024 17:37:37 +0000 Received: by outflank-mailman (input) for mailman id 829614; Sat, 02 Nov 2024 17:37: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 1t7Hu3-0005zO-Ly for xen-devel@lists.xenproject.org; Sat, 02 Nov 2024 17:27:11 +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 aef35b32-993f-11ef-a0c5-8be0dac302b0; Sat, 02 Nov 2024 18:27:08 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1730568368262930.5138048817796; Sat, 2 Nov 2024 10:26:08 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: aef35b32-993f-11ef-a0c5-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6ImFlZjM1YjMyLTk5M2YtMTFlZi1hMGM1LThiZTBkYWMzMDJiMCIsInRzIjoxNzMwNTY4NDI4Ljk0MTQxMSwic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1730568380; cv=none; d=zohomail.com; s=zohoarc; b=eseagGIWxSDS05FvDZ1vaX8iLM4KFZPv5hQwSOpgiaW1krIObSkWnLUcPHkjQjtNkpPznvEmBW8576Sips77kyH7RVKF65oOJFw7GAZlappArKt8pdu4LMM5f4CvwsBg8RQS9uVlFSdH3fHI/udJKiH9lcYhewpCvhyoBykff28= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730568380; 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=9OF7jr3+XP9qd3JfzPB9uF0lHAJIr0GJpZTZwT478GE=; b=l2nApuwB+FebU4gSAE8VsY+yHxacx1YWedZy26toqYRn2/JHxE1A32b5SaMYwjpXlE9n+8d5eFAz9+FA+w2iXhRFILFzuqQvsLk9wsTAcoqQ1xlT1YcSL5Vep/z92+9NWAWvuzDrPQHl6Bx0izxgzMT2KxHtdcUiZvgJAVevE6k= 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=1730568380; 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=9OF7jr3+XP9qd3JfzPB9uF0lHAJIr0GJpZTZwT478GE=; b=RhvDDm3GI4rx4r3df+BhgoYdgln8UhlBBLXT0tZUOPxOw1cq/6osnOdYt1NjTB4U XNJZtLi9KnCkU2AWv3TR6pscoLvbpkPDofcfFEMC4bphO4j27vQUH4eqwMbL2kaD8Vi n7IENw/XiWaBp7HQdvlI9czN/h1r640bDLZcYhVA= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 06/12] x86/boot: relocate kextra into boot info Date: Sat, 2 Nov 2024 13:25:45 -0400 Message-Id: <20241102172551.17233-7-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241102172551.17233-1-dpsmith@apertussolutions.com> References: <20241102172551.17233-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1730569075181116600 Content-Type: text/plain; charset="utf-8" Move kextra into struct boot_info, thus no longer needed to be passed as a parameter to create_dom0. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- xen/arch/x86/include/asm/bootinfo.h | 1 + xen/arch/x86/setup.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index e337baa905f0..6638da597073 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -68,6 +68,7 @@ struct boot_module { struct boot_info { const char *loader; const char *cmdline; + const char *kextra; =20 paddr_t memmap_addr; size_t memmap_length; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 633319d39d80..425467a0d977 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1136,6 +1136,7 @@ void asmlinkage __init noreturn __start_xen(void) *kextra =3D '\0'; kextra +=3D 3; while ( kextra[1] =3D=3D ' ' ) kextra++; + bi->kextra =3D kextra; } cmdline_parse(bi->cmdline); =20 @@ -2141,7 +2142,7 @@ void asmlinkage __init noreturn __start_xen(void) dom0 =3D create_dom0(bi->mods[0].mod, bi->mods[0].headroom, initrdidx < bi->nr_modules ? bi->mods[initrdidx].mod : NULL, - kextra, bi->loader); + bi->kextra, bi->loader); if ( !dom0 ) panic("Could not set up DOM0 guest OS\n"); =20 --=20 2.30.2 From nobody Thu Nov 21 15:29:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1730569091; cv=pass; d=zohomail.com; s=zohoarc; b=BAs/rp2uFl41aa5Q+5tnXGNx/uqVJaKiyVp4GpNRGeB5PnlDr1u/G6OA5D6SE9AITgXIbDSo6tJ1HataDpTGtthy1bAlJ9U6LTMdfBcYks9pB9dJDyDUcwblRNNuupbIUDqmkPjU+2hbWeTnVXtact5tb+qVA26Ao+fzCmEQoME= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730569091; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EoeU2cNTcSm145aYChZTxXF4zyu19NL3WvcyiomLUIo=; b=JSjSGJr2XkquQBgSyJ83K4himxWV9DeDIuwMn5Pgbg/iwOhB6GSHemIAL82oRvSxyijue+SQq5JqXVP5sIr+JqQtcxmF74Fdx89Nd2zSj3FhJkjNSi7fiJU2NBoEB34Amc1YvbIJtxNeQQaxoZB0CGda/YvGROX+hCRVRITTBmQ= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1730569091294972.3154570746473; Sat, 2 Nov 2024 10:38:11 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.829623.1244654 (Exim 4.92) (envelope-from ) id 1t7I4R-0003wk-Na; Sat, 02 Nov 2024 17:37:55 +0000 Received: by outflank-mailman (output) from mailman id 829623.1244654; Sat, 02 Nov 2024 17:37: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 1t7I4R-0003w6-Jw; Sat, 02 Nov 2024 17:37:55 +0000 Received: by outflank-mailman (input) for mailman id 829623; Sat, 02 Nov 2024 17:37: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 1t7HuB-0005zO-5n for xen-devel@lists.xenproject.org; Sat, 02 Nov 2024 17:27:19 +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 b41bade3-993f-11ef-a0c5-8be0dac302b0; Sat, 02 Nov 2024 18:27:17 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1730568370382770.7062276164702; Sat, 2 Nov 2024 10:26:10 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b41bade3-993f-11ef-a0c5-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6ImI0MWJhZGUzLTk5M2YtMTFlZi1hMGM1LThiZTBkYWMzMDJiMCIsInRzIjoxNzMwNTY4NDM3LjQxNjQzMiwic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1730568381; cv=none; d=zohomail.com; s=zohoarc; b=Pv3kCvtoVTibz+u51wsTPJ5JitINxwAOpevWtkWjGtA+JWT3fCFys7qKisjDpRspKF8cE6Na4u4P4sAYgIvXnib8ogDHD7qa917MB6/CKAkrP9LxqenNtAEhstgVWQeMv9GFHykAYSXCk45kqYNj+YV3iKZ79QN/5kMnAkvkMVM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730568381; 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=EoeU2cNTcSm145aYChZTxXF4zyu19NL3WvcyiomLUIo=; b=VmD2X8mPFmLcbOXuactLxKobkuST/Ivf/owiVPogZTbNDA3U5hp6bXL1jUgkZu6svuNJ7CgpT12T7bvzAHC7dOzDsvQgoyVZr5UkGhPnu5jfqd9ZaXpnoMeb7xvcETzJ4QJxzBCwaUVA+W98zWzUN+JqxTTBeZNNCJcISAWeGxg= 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=1730568381; 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=EoeU2cNTcSm145aYChZTxXF4zyu19NL3WvcyiomLUIo=; b=ZZPR73ighyafEVqyrtsLosPv4w8AMkNG1vIMUwR2wEX8gS0HeRb6MWv+rm27fc02 IJSeCj0PKuKslzoyprxSm0jNIFoT0D+RsLnQUKgXmx649F5vHK55RlKrj6XbThwT6kO iMW89A6SL33oOQ6BczXIstFLxYVy1kgZZBPlfw6c= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 07/12] x86/boot: add cmdline_pa to struct boot_module Date: Sat, 2 Nov 2024 13:25:46 -0400 Message-Id: <20241102172551.17233-8-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241102172551.17233-1-dpsmith@apertussolutions.com> References: <20241102172551.17233-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1730569093288116600 Content-Type: text/plain; charset="utf-8" Add an address field, cmdline_pa, to struct boot_module to hold the address= of the string field from struct mod. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v7: - renamed cmdline to cmdline_pa - reword commit message for field rename Changes since v5: - changed boot_module element cmdline to paddr_t --- xen/arch/x86/include/asm/bootinfo.h | 2 ++ xen/arch/x86/setup.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index 6638da597073..819c8224d715 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -59,6 +59,8 @@ struct boot_module { */ bool relocated:1; bool released:1; + + paddr_t cmdline_pa; }; =20 /* diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 425467a0d977..aba9df8620ef 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -312,8 +312,12 @@ static struct boot_info *__init multiboot_fill_boot_in= fo( * reserved for Xen. */ for ( i =3D 0; i < MAX_NR_BOOTMODS && i < bi->nr_modules; i++ ) + { bi->mods[i].mod =3D &mods[i]; =20 + bi->mods[i].cmdline_pa =3D mods[i].string; + } + /* Variable 'i' should be one entry past the last module. */ bi->mods[i].mod =3D &mods[bi->nr_modules]; bi->mods[i].type =3D BOOTMOD_XEN; --=20 2.30.2 From nobody Thu Nov 21 15:29:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1730569016; cv=pass; d=zohomail.com; s=zohoarc; b=VOZJJYwEulpR/yPhxfh5d9bcSfjEccmUoIlw7SKDnnu4QR2UlD3Fx3A0uPYbv6NcDxx+fslBN8AeK/TbmuGLIjEpVeJpXEDxEiFVKZZ/Kefxa6NacFQxaCSVYQtOuZVfGhnjrbd9Y+uzMf4TOCbR/Z4hRKgy3RUqviJiYUhua28= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730569016; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Lqch7F1xargZBo/VkvL/BtzwFfKefeZoUmZw1HodarM=; b=Z6w/HVuMnAiTuFqrOaOn2FfCRUi2W0eKQstfnRx9StUy9X02WFzNBnbghPQ5wV4ns5vPffPiaXuN2wZ1ViV+2X4RkZ3vg39rpKrheEqYMCfwgDyxqvwCtAQNYkYIwA2GeofRMF2IGvGA9sXw8YFoEki57czC3kIQ5fNUpKacs88= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1730569016053955.2480090528184; Sat, 2 Nov 2024 10:36:56 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.829598.1244604 (Exim 4.92) (envelope-from ) id 1t7I31-00019U-8X; Sat, 02 Nov 2024 17:36:27 +0000 Received: by outflank-mailman (output) from mailman id 829598.1244604; Sat, 02 Nov 2024 17:36:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t7I31-00019N-5s; Sat, 02 Nov 2024 17:36:27 +0000 Received: by outflank-mailman (input) for mailman id 829598; Sat, 02 Nov 2024 17:36:26 +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 1t7HuK-0005zO-6m for xen-devel@lists.xenproject.org; Sat, 02 Nov 2024 17:27:28 +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 b9042e17-993f-11ef-a0c5-8be0dac302b0; Sat, 02 Nov 2024 18:27:25 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1730568371686592.9410739240645; Sat, 2 Nov 2024 10:26:11 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b9042e17-993f-11ef-a0c5-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6ImI5MDQyZTE3LTk5M2YtMTFlZi1hMGM1LThiZTBkYWMzMDJiMCIsInRzIjoxNzMwNTY4NDQ1LjYwOTg4OCwic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1730568382; cv=none; d=zohomail.com; s=zohoarc; b=mTxocaw2aTmmjbtNyLxeZlPAg6zz7wgDZuCq2P1ZmgTQ318SnYwvsHxs++ub8gBGADVllyy8TIp0jNLmAPUnVxrxqbAsG1jWeEOWQef07ePN2dmsbPYYcnKzYh3Gtptlfr7VPy2AiZvbG8jaEJ4MBL3tzWvkGS/VgyMx9VDjE3U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730568382; 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=Lqch7F1xargZBo/VkvL/BtzwFfKefeZoUmZw1HodarM=; b=QTwU7SPpLluNGZbz96hnXDrB1BK94BqPuCfkrHryY5Vf5qq5eUThL9vib1sGfIIH18tMkvh4M4RSvzCWYbxbLQGi2U6VhorARbRR1HcNsPFv73KKHewL0HqnLizN0rJLfznKZE9YuxoXaGMfNG1MoTNx/VffnszhOk0ahOyvwqI= 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=1730568382; 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=Lqch7F1xargZBo/VkvL/BtzwFfKefeZoUmZw1HodarM=; b=GyszozVMlcznzwc55Q8draW6XhURdi9eZotdbZmL4ZVrD/Rq4qmnsP81psy67uFb IV2Jjy26eexd9JM/W1IcwlHx4PP29dmLiBKHRpjtJ4JJujhNyNto7Q4A95fus7N/3yg X93HiWdGd9yUAn4CuFyqS2pd0w5T4BahotUszOHk= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 08/12] x86/boot: convert domain construction to use boot info Date: Sat, 2 Nov 2024 13:25:47 -0400 Message-Id: <20241102172551.17233-9-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241102172551.17233-1-dpsmith@apertussolutions.com> References: <20241102172551.17233-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1730569017238116600 Content-Type: text/plain; charset="utf-8" With all the components used to construct dom0 encapsulated in struct boot_= info and struct boot_module, it is no longer necessary to pass all them as parameters down the domain construction call chain. Change the parameter li= st to pass the struct boot_info instance and the struct domain reference. Signed-off-by: Daniel P. Smith --- Changes since v5: - renamed from "x86/boot: convert create_dom0 to use boot info" Changes since v5: - change headroom back to unsigned long - make mod_idx unsigned int --- xen/arch/x86/dom0_build.c | 9 ++-- xen/arch/x86/hvm/dom0_build.c | 49 +++++++++++++--------- xen/arch/x86/include/asm/dom0_build.h | 13 ++---- xen/arch/x86/include/asm/setup.h | 7 ++-- xen/arch/x86/pv/dom0_build.c | 59 ++++++++++++++++----------- xen/arch/x86/setup.c | 33 ++++++++------- 6 files changed, 95 insertions(+), 75 deletions(-) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 8d56705a0861..2276965c02bd 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -13,6 +13,7 @@ #include =20 #include +#include #include #include #include @@ -596,9 +597,7 @@ int __init dom0_setup_permissions(struct domain *d) return rc; } =20 -int __init construct_dom0(struct domain *d, const module_t *image, - unsigned long image_headroom, module_t *initrd, - const char *cmdline) +int __init construct_dom0(struct boot_info *bi, struct domain *d) { int rc; =20 @@ -610,9 +609,9 @@ int __init construct_dom0(struct domain *d, const modul= e_t *image, process_pending_softirqs(); =20 if ( is_hvm_domain(d) ) - rc =3D dom0_construct_pvh(d, image, image_headroom, initrd, cmdlin= e); + rc =3D dom0_construct_pvh(bi, d); else if ( is_pv_domain(d) ) - rc =3D dom0_construct_pv(d, image, image_headroom, initrd, cmdline= ); + rc =3D dom0_construct_pv(bi, d); else panic("Cannot construct Dom0. No guest interface available\n"); =20 diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index a4ac262db463..cd97f94a168a 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -16,6 +16,7 @@ =20 #include =20 +#include #include #include #include @@ -642,15 +643,15 @@ static bool __init check_and_adjust_load_address( return true; } =20 -static int __init pvh_load_kernel(struct domain *d, const module_t *image, - unsigned long image_headroom, - module_t *initrd, void *image_base, - const char *cmdline, paddr_t *entry, - paddr_t *start_info_addr) +static int __init pvh_load_kernel( + struct domain *d, struct boot_module *image, struct boot_module *initr= d, + paddr_t *entry, paddr_t *start_info_addr) { - void *image_start =3D image_base + image_headroom; - unsigned long image_len =3D image->mod_end; - unsigned long initrd_len =3D initrd ? initrd->mod_end : 0; + void *image_base =3D bootstrap_map_bm(image); + void *image_start =3D image_base + image->headroom; + unsigned long image_len =3D image->mod->mod_end; + unsigned long initrd_len =3D initrd ? initrd->mod->mod_end : 0; + const char *cmdline =3D __va(image->cmdline_pa); struct elf_binary elf; struct elf_dom_parms parms; paddr_t last_addr; @@ -704,7 +705,7 @@ static int __init pvh_load_kernel(struct domain *d, con= st module_t *image, return rc; } =20 - release_module(image, true); + release_boot_module(image, true); =20 /* * Find a RAM region big enough (and that doesn't overlap with the loa= ded @@ -727,8 +728,8 @@ static int __init pvh_load_kernel(struct domain *d, con= st module_t *image, =20 if ( initrd !=3D NULL ) { - rc =3D hvm_copy_to_guest_phys(last_addr, mfn_to_virt(initrd->mod_s= tart), - initrd_len, v); + rc =3D hvm_copy_to_guest_phys( + last_addr, mfn_to_virt(initrd->mod->mod_start), initrd_len, v); if ( rc ) { printk("Unable to copy initrd to guest\n"); @@ -738,9 +739,9 @@ static int __init pvh_load_kernel(struct domain *d, con= st module_t *image, mod.paddr =3D last_addr; mod.size =3D initrd_len; last_addr +=3D ROUNDUP(initrd_len, elf_64bit(&elf) ? 8 : 4); - if ( initrd->string ) + if ( initrd->cmdline_pa ) { - char *str =3D __va(initrd->string); + char *str =3D __va(initrd->cmdline_pa); size_t len =3D strlen(str) + 1; =20 rc =3D hvm_copy_to_guest_phys(last_addr, str, len, v); @@ -754,7 +755,7 @@ static int __init pvh_load_kernel(struct domain *d, con= st module_t *image, } last_addr =3D ROUNDUP(last_addr, PAGE_SIZE); =20 - release_module(initrd, true); + release_boot_module(initrd, true); } =20 if ( cmdline !=3D NULL ) @@ -1301,16 +1302,25 @@ static void __hwdom_init pvh_setup_mmcfg(struct dom= ain *d) } } =20 -int __init dom0_construct_pvh(struct domain *d, const module_t *image, - unsigned long image_headroom, - module_t *initrd, - const char *cmdline) +int __init dom0_construct_pvh(struct boot_info *bi, struct domain *d) { paddr_t entry, start_info; + struct boot_module *image; + struct boot_module *initrd =3D NULL; int rc; =20 printk(XENLOG_INFO "*** Building a PVH Dom%d ***\n", d->domain_id); =20 + rc =3D first_boot_module_index(bi, BOOTMOD_KERNEL); + if ( unlikely(rc < 0 || rc > bi->nr_modules) ) + panic("Missing kernel boot module for %pd construction\n", d); + + image =3D &bi->mods[rc]; + + rc =3D first_boot_module_index(bi, BOOTMOD_RAMDISK); + if ( rc > 0 || rc < bi->nr_modules ) + initrd =3D &bi->mods[rc]; + if ( is_hardware_domain(d) ) { /* @@ -1348,8 +1358,7 @@ int __init dom0_construct_pvh(struct domain *d, const= module_t *image, return rc; } =20 - rc =3D pvh_load_kernel(d, image, image_headroom, initrd, bootstrap_map= (image), - cmdline, &entry, &start_info); + rc =3D pvh_load_kernel(d, image, initrd, &entry, &start_info); if ( rc ) { printk("Failed to load Dom0 kernel\n"); diff --git a/xen/arch/x86/include/asm/dom0_build.h b/xen/arch/x86/include/a= sm/dom0_build.h index 107c1ff98367..4c2193c4a982 100644 --- a/xen/arch/x86/include/asm/dom0_build.h +++ b/xen/arch/x86/include/asm/dom0_build.h @@ -13,15 +13,10 @@ unsigned long dom0_compute_nr_pages(struct domain *d, unsigned long initrd_len); int dom0_setup_permissions(struct domain *d); =20 -int dom0_construct_pv(struct domain *d, const module_t *image, - unsigned long image_headroom, - module_t *initrd, - const char *cmdline); - -int dom0_construct_pvh(struct domain *d, const module_t *image, - unsigned long image_headroom, - module_t *initrd, - const char *cmdline); +struct boot_info; +int dom0_construct_pv(struct boot_info *bi, struct domain *d); + +int dom0_construct_pvh(struct boot_info *bi, struct domain *d); =20 unsigned long dom0_paging_pages(const struct domain *d, unsigned long nr_pages); diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/se= tup.h index d68d37a5293b..1e23f55be51b 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -26,11 +26,10 @@ void subarch_init_memory(void); =20 void init_IRQ(void); =20 +struct boot_info; int construct_dom0( - struct domain *d, - const module_t *image, unsigned long image_headroom, - module_t *initrd, - const char *cmdline); + struct boot_info *bi, + struct domain *d); void setup_io_bitmap(struct domain *d); =20 extern struct boot_info xen_boot_info; diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index c1f44502a1ac..594874cd8d85 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -14,6 +14,7 @@ #include #include =20 +#include #include #include #include @@ -354,11 +355,7 @@ static struct page_info * __init alloc_chunk(struct do= main *d, return page; } =20 -static int __init dom0_construct(struct domain *d, - const module_t *image, - unsigned long image_headroom, - module_t *initrd, - const char *cmdline) +static int __init dom0_construct(struct boot_info *bi, struct domain *d) { int i, rc, order, machine; bool compatible, compat; @@ -374,10 +371,13 @@ static int __init dom0_construct(struct domain *d, unsigned int flush_flags =3D 0; start_info_t *si; struct vcpu *v =3D d->vcpu[0]; - void *image_base =3D bootstrap_map(image); - unsigned long image_len =3D image->mod_end; - void *image_start =3D image_base + image_headroom; - unsigned long initrd_len =3D initrd ? initrd->mod_end : 0; + struct boot_module *image; + struct boot_module *initrd =3D NULL; + void *image_base; + unsigned long image_len; + void *image_start; + unsigned long initrd_len =3D 0; + const char *cmdline; l4_pgentry_t *l4tab =3D NULL, *l4start =3D NULL; l3_pgentry_t *l3tab =3D NULL, *l3start =3D NULL; l2_pgentry_t *l2tab =3D NULL, *l2start =3D NULL; @@ -414,6 +414,23 @@ static int __init dom0_construct(struct domain *d, =20 printk(XENLOG_INFO "*** Building a PV Dom%d ***\n", d->domain_id); =20 + i =3D first_boot_module_index(bi, BOOTMOD_KERNEL); + if ( unlikely(i < 0 || i > bi->nr_modules) ) + panic("Missing kernel boot module for %pd construction\n", d); + + image =3D &bi->mods[i]; + image_base =3D bootstrap_map_bm(image); + image_len =3D image->mod->mod_end; + image_start =3D image_base + image->headroom; + cmdline =3D __va(image->cmdline_pa); + + i =3D first_boot_module_index(bi, BOOTMOD_RAMDISK); + if ( i > 0 || i < bi->nr_modules ) + { + initrd =3D &bi->mods[i]; + initrd_len =3D initrd->mod->mod_end; + } + d->max_pages =3D ~0U; =20 if ( (rc =3D bzimage_parse(image_base, &image_start, &image_len)) !=3D= 0 ) @@ -613,7 +630,7 @@ static int __init dom0_construct(struct domain *d, initrd_pfn =3D vinitrd_start ? (vinitrd_start - v_start) >> PAGE_SHIFT : domain_tot_pages(d); - initrd_mfn =3D mfn =3D initrd->mod_start; + initrd_mfn =3D mfn =3D initrd->mod->mod_start; count =3D PFN_UP(initrd_len); if ( d->arch.physaddr_bitsize && ((mfn + count - 1) >> (d->arch.physaddr_bitsize - PAGE_SHIFT)= ) ) @@ -628,17 +645,17 @@ static int __init dom0_construct(struct domain *d, free_domheap_pages(page, order); page +=3D 1UL << order; } - memcpy(page_to_virt(page), mfn_to_virt(initrd->mod_start), + memcpy(page_to_virt(page), mfn_to_virt(initrd->mod->mod_start), initrd_len); - release_module(initrd, true); - initrd->mod_start =3D initrd_mfn =3D mfn_x(page_to_mfn(page)); + release_boot_module(initrd, true); + initrd->mod->mod_start =3D initrd_mfn =3D mfn_x(page_to_mfn(pa= ge)); } else { while ( count-- ) if ( assign_pages(mfn_to_page(_mfn(mfn++)), 1, d, 0) ) BUG(); - release_module(initrd, false); + release_boot_module(initrd, false); } =20 iommu_memory_setup(d, "initrd", mfn_to_page(_mfn(initrd_mfn)), @@ -653,7 +670,7 @@ static int __init dom0_construct(struct domain *d, nr_pages - domain_tot_pages(d)); if ( initrd ) { - mpt_alloc =3D (paddr_t)initrd->mod_start << PAGE_SHIFT; + mpt_alloc =3D (paddr_t)initrd->mod->mod_start << PAGE_SHIFT; printk("\n Init. ramdisk: %"PRIpaddr"->%"PRIpaddr, mpt_alloc, mpt_alloc + initrd_len); } @@ -830,7 +847,7 @@ static int __init dom0_construct(struct domain *d, } /* All done with kernel, release the module pages */ bootstrap_unmap(); - release_module(image, true); + release_boot_module(image, true); =20 if ( UNSET_ADDR !=3D parms.virt_hypercall ) { @@ -880,7 +897,7 @@ static int __init dom0_construct(struct domain *d, if ( pfn >=3D initrd_pfn ) { if ( pfn < initrd_pfn + PFN_UP(initrd_len) ) - mfn =3D initrd->mod_start + (pfn - initrd_pfn); + mfn =3D initrd->mod->mod_start + (pfn - initrd_pfn); else mfn -=3D PFN_UP(initrd_len); } @@ -1048,11 +1065,7 @@ out: return rc; } =20 -int __init dom0_construct_pv(struct domain *d, - const module_t *image, - unsigned long image_headroom, - module_t *initrd, - const char *cmdline) +int __init dom0_construct_pv(struct boot_info *bi, struct domain *d) { unsigned long cr4 =3D read_cr4(); int rc; @@ -1070,7 +1083,7 @@ int __init dom0_construct_pv(struct domain *d, write_cr4(cr4 & ~X86_CR4_SMAP); } =20 - rc =3D dom0_construct(d, image, image_headroom, initrd, cmdline); + rc =3D dom0_construct(bi, d); =20 if ( cr4 & X86_CR4_SMAP ) { diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index aba9df8620ef..d9785acf89b6 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -977,10 +977,7 @@ static unsigned int __init copy_bios_e820(struct e820e= ntry *map, unsigned int li return n; } =20 -static struct domain *__init create_dom0(const module_t *image, - unsigned long headroom, - module_t *initrd, const char *kex= tra, - const char *loader) +static struct domain *__init create_dom0(struct boot_info *bi) { static char __initdata cmdline[MAX_GUEST_CMDLINE]; =20 @@ -997,6 +994,14 @@ static struct domain *__init create_dom0(const module_= t *image, }; struct domain *d; domid_t domid; + struct boot_module *image; + unsigned int idx; + + idx =3D first_boot_module_index(bi, BOOTMOD_KERNEL); + if ( unlikely(idx < 0 || idx > bi->nr_modules) ) + panic("Missing kernel boot module for building Dom0\n"); + + image =3D &bi->mods[idx]; =20 if ( opt_dom0_pvh ) { @@ -1023,14 +1028,15 @@ static struct domain *__init create_dom0(const modu= le_t *image, panic("Error creating d%uv0\n", domid); =20 /* Grab the DOM0 command line. */ - if ( image->string || kextra ) + if ( image->cmdline_pa || bi->kextra ) { - if ( image->string ) - safe_strcpy(cmdline, cmdline_cook(__va(image->string), loader)= ); + if ( image->cmdline_pa ) + safe_strcpy( + cmdline, cmdline_cook(__va(image->cmdline_pa), bi->loader)= ); =20 - if ( kextra ) + if ( bi->kextra ) /* kextra always includes exactly one leading space. */ - safe_strcat(cmdline, kextra); + safe_strcat(cmdline, bi->kextra); =20 /* Append any extra parameters. */ if ( skip_ioapic_setup && !strstr(cmdline, "noapic") ) @@ -1047,9 +1053,11 @@ static struct domain *__init create_dom0(const modul= e_t *image, safe_strcat(cmdline, " acpi=3D"); safe_strcat(cmdline, acpi_param); } + + image->cmdline_pa =3D __pa(cmdline); } =20 - if ( construct_dom0(d, image, headroom, initrd, cmdline) !=3D 0 ) + if ( construct_dom0(bi, d) !=3D 0 ) panic("Could not construct domain 0\n"); =20 return d; @@ -2143,10 +2151,7 @@ void asmlinkage __init noreturn __start_xen(void) * We're going to setup domain0 using the module(s) that we stashed sa= fely * above our heap. The second module, if present, is an initrd ramdisk. */ - dom0 =3D create_dom0(bi->mods[0].mod, bi->mods[0].headroom, - initrdidx < bi->nr_modules ? bi->mods[initrdidx].mod - : NULL, - bi->kextra, bi->loader); + dom0 =3D create_dom0(bi); if ( !dom0 ) panic("Could not set up DOM0 guest OS\n"); =20 --=20 2.30.2 From nobody Thu Nov 21 15:29:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1730569072; cv=pass; d=zohomail.com; s=zohoarc; b=TeLIJ7t9iUuGcXf79/ODibCgqUqvnEXrEWpEQjYJfzmkhQAVKKInKyKQEAA8kmNlYVaijIm+M6DDNKAt5L7zL9xWRx8hbzGGE2UW2qZV2xe7rCUsanyhFkrwG0zOA4qCHE3HWdO+7EJm+imNGeuTLyJf21y+wgoNKTB5OE2RRHk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730569072; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vCeE70zl4N0GlCwS3QvCnOR8vYrFq8AHq0hy/S+7yQ0=; b=lbHM2e40QR1S6PN70bjIBil1Xu6FAKvkJnAGtNEPesopx5LEYMGKtV5Mijp/GryOamUlcIk5T4RYX8ptRDDbiiw05XgkUEqJb6JyMWTODzL1OFA0Y27Q04TdODYvgiSXRj+2uQSs6XvWGtAgQrE5bIBVV6v6tSMa8ak9OtOz+PU= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1730569072679582.2973002974783; Sat, 2 Nov 2024 10:37:52 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.829615.1244631 (Exim 4.92) (envelope-from ) id 1t7I4A-0002dM-7B; Sat, 02 Nov 2024 17:37:38 +0000 Received: by outflank-mailman (output) from mailman id 829615.1244631; Sat, 02 Nov 2024 17:37: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 1t7I49-0002cE-Vt; Sat, 02 Nov 2024 17:37:37 +0000 Received: by outflank-mailman (input) for mailman id 829615; Sat, 02 Nov 2024 17:37: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 1t7HuT-0005zO-Mk for xen-devel@lists.xenproject.org; Sat, 02 Nov 2024 17:27: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 bea09c15-993f-11ef-a0c5-8be0dac302b0; Sat, 02 Nov 2024 18:27:34 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1730568372958973.0588263222835; Sat, 2 Nov 2024 10:26:12 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: bea09c15-993f-11ef-a0c5-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6ImJlYTA5YzE1LTk5M2YtMTFlZi1hMGM1LThiZTBkYWMzMDJiMCIsInRzIjoxNzMwNTY4NDU1LjAyOTYyOSwic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1730568383; cv=none; d=zohomail.com; s=zohoarc; b=OMPoFSoueO83CWAIaqTMkpDlMSMCtn2hOusrNcYNXQl3sNtsC4QKoLbKUzNQJKFY/oUofmA2IS4rPE7/5d3LFEGx8g3MjuGq8SFEFMzjYM/duefSMXfqJ6SDUTMdjpD7Y+/VhbaKxUyp9ETOdqPkUlLI+sKy1dhXMcQ9wXT1QRs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730568383; 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=vCeE70zl4N0GlCwS3QvCnOR8vYrFq8AHq0hy/S+7yQ0=; b=oA2STv2bb9th+YTZ13EEEWc+pQFXqFd8raWxDgm1wcq3t7++2MflaXS5pmFXaXLfx/uaFAWfmkli9Nn0dVYHTADR7D129/Rzkn6DrJsn0CDgjQjgumUtov62ueWyaCOjf5nvOhXLvxOOUyvwrOkJqqafwbW2S8+v7UJCw+fstco= 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=1730568383; 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=vCeE70zl4N0GlCwS3QvCnOR8vYrFq8AHq0hy/S+7yQ0=; b=S8fnDq3uPgVq4fEhPI629C6RAwGc1s64AkEoF7lmvZc1+qoW5I6SUc7zyiDzLKlZ Ak0WkIfciMSYBgq5Z0eqsu3ViRcJkIVzQh9/x2I0rDc+PinmAhc5lKwWD3ZM1KRS6E9 J1cylnVi4OjPuEOe+UzPd+uheLos2B3NsXS9k8sw= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 09/12] x86/boot: add start and size fields to struct boot_module Date: Sat, 2 Nov 2024 13:25:48 -0400 Message-Id: <20241102172551.17233-10-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241102172551.17233-1-dpsmith@apertussolutions.com> References: <20241102172551.17233-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1730569073421116600 Content-Type: text/plain; charset="utf-8" Introduce the start and size fields to struct boot_module and assigns their value during boot_info construction. All uses of module_t to = get the address and size of a module are replaced with start and size. The EFI entry point is a special case, as the EFI file loading boot service= may load a file beyond the 4G barrier. As a result, to make the address fit in = the 32bit integer used by the MB1 module_t structure, the frame number is store= d in mod_start and size in mod_end. Until the EFI entry point is enlightened to = work with boot_info and boot_module, multiboot_fill_boot_info will handle the alternate values in mod_start and mod_end when EFI is detected. A result of the switch to start/size removes all uses of the mod field in struct boot_modules, along with the uses of bootstra_map() and release_modu= le() functions. With all usage gone, they all are dropped here. Signed-off-by: Daniel P. Smith -- Changes since v7: - add the start/size change to bootstrap_map_bm() - convert all BM start/size when introduced, consolidates: x86/boot: populate boot module for xen entry x86/boot: transition relocation calculations to struct boot_module - consolidates all the removal commits 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 a# edit 336ac1fc0019 x86/boot: introduce boot domain --- xen/arch/x86/cpu/microcode/core.c | 8 +-- xen/arch/x86/hvm/dom0_build.c | 6 +- xen/arch/x86/include/asm/bootinfo.h | 6 +- xen/arch/x86/include/asm/setup.h | 2 - xen/arch/x86/pv/dom0_build.c | 17 ++--- xen/arch/x86/setup.c | 100 ++++++++++++---------------- xen/xsm/xsm_policy.c | 4 +- 7 files changed, 64 insertions(+), 79 deletions(-) diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode= /core.c index 349e857f539a..891e6d29c7f4 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -726,8 +726,8 @@ static int __init cf_check microcode_init_cache(void) /* early_microcode_load() didn't leave us any work to do. */ return 0; =20 - size =3D bi->mods[early_mod_idx].mod->mod_end; - data =3D __mfn_to_virt(bi->mods[early_mod_idx].mod->mod_start); + size =3D bi->mods[early_mod_idx].size; + data =3D __va(bi->mods[early_mod_idx].start); =20 /* * If opt_scan is set, we're looking for a CPIO archive rather than a = raw @@ -799,7 +799,7 @@ static int __init early_microcode_load(struct boot_info= *bi) struct boot_module *bm =3D &bi->mods[idx]; struct cpio_data cd; =20 - size =3D bm->mod->mod_end; + size =3D bm->size; data =3D bootstrap_map_bm(bm); if ( !data ) { @@ -849,7 +849,7 @@ static int __init early_microcode_load(struct boot_info= *bi) } bi->mods[idx].type =3D BOOTMOD_MICROCODE; =20 - size =3D bi->mods[idx].mod->mod_end; + size =3D bi->mods[idx].size; data =3D bootstrap_map_bm(&bi->mods[idx]); if ( !data ) { diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index cd97f94a168a..e74684f10b12 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -649,8 +649,8 @@ static int __init pvh_load_kernel( { void *image_base =3D bootstrap_map_bm(image); void *image_start =3D image_base + image->headroom; - unsigned long image_len =3D image->mod->mod_end; - unsigned long initrd_len =3D initrd ? initrd->mod->mod_end : 0; + unsigned long image_len =3D image->size; + unsigned long initrd_len =3D initrd ? initrd->size : 0; const char *cmdline =3D __va(image->cmdline_pa); struct elf_binary elf; struct elf_dom_parms parms; @@ -729,7 +729,7 @@ static int __init pvh_load_kernel( if ( initrd !=3D NULL ) { rc =3D hvm_copy_to_guest_phys( - last_addr, mfn_to_virt(initrd->mod->mod_start), initrd_len, v); + last_addr, __va(initrd->start), initrd_len, v); if ( rc ) { printk("Unable to copy initrd to guest\n"); diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index 819c8224d715..a5ee90a36607 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -25,9 +25,6 @@ enum bootmod_type { }; =20 struct boot_module { - /* Transitionary only */ - module_t *mod; - enum bootmod_type type; =20 /* @@ -61,6 +58,9 @@ struct boot_module { bool released:1; =20 paddr_t cmdline_pa; + + paddr_t start; + size_t size; }; =20 /* diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/se= tup.h index 1e23f55be51b..0591847c57e6 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -35,11 +35,9 @@ void setup_io_bitmap(struct domain *d); extern struct boot_info xen_boot_info; =20 unsigned long initial_images_nrpages(nodeid_t node); -void release_module(const module_t *m, bool mapped); =20 struct boot_module; void *bootstrap_map_bm(const struct boot_module *bm); -void *bootstrap_map(const module_t *mod); void bootstrap_unmap(void); void release_boot_module(struct boot_module *bm, bool mapped); =20 diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 594874cd8d85..5efc650eeff0 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -420,7 +420,7 @@ static int __init dom0_construct(struct boot_info *bi, = struct domain *d) =20 image =3D &bi->mods[i]; image_base =3D bootstrap_map_bm(image); - image_len =3D image->mod->mod_end; + image_len =3D image->size; image_start =3D image_base + image->headroom; cmdline =3D __va(image->cmdline_pa); =20 @@ -428,7 +428,7 @@ static int __init dom0_construct(struct boot_info *bi, = struct domain *d) if ( i > 0 || i < bi->nr_modules ) { initrd =3D &bi->mods[i]; - initrd_len =3D initrd->mod->mod_end; + initrd_len =3D initrd->size; } =20 d->max_pages =3D ~0U; @@ -630,7 +630,8 @@ static int __init dom0_construct(struct boot_info *bi, = struct domain *d) initrd_pfn =3D vinitrd_start ? (vinitrd_start - v_start) >> PAGE_SHIFT : domain_tot_pages(d); - initrd_mfn =3D mfn =3D initrd->mod->mod_start; + initrd_mfn =3D paddr_to_pfn(initrd->start); + mfn =3D initrd_mfn; count =3D PFN_UP(initrd_len); if ( d->arch.physaddr_bitsize && ((mfn + count - 1) >> (d->arch.physaddr_bitsize - PAGE_SHIFT)= ) ) @@ -645,10 +646,10 @@ static int __init dom0_construct(struct boot_info *bi= , struct domain *d) free_domheap_pages(page, order); page +=3D 1UL << order; } - memcpy(page_to_virt(page), mfn_to_virt(initrd->mod->mod_start), - initrd_len); + memcpy(page_to_virt(page), __va(initrd->start), initrd_len); release_boot_module(initrd, true); - initrd->mod->mod_start =3D initrd_mfn =3D mfn_x(page_to_mfn(pa= ge)); + initrd_mfn =3D mfn_x(page_to_mfn(page)); + initrd->start =3D pfn_to_paddr(initrd_mfn); } else { @@ -670,7 +671,7 @@ static int __init dom0_construct(struct boot_info *bi, = struct domain *d) nr_pages - domain_tot_pages(d)); if ( initrd ) { - mpt_alloc =3D (paddr_t)initrd->mod->mod_start << PAGE_SHIFT; + mpt_alloc =3D initrd->start; printk("\n Init. ramdisk: %"PRIpaddr"->%"PRIpaddr, mpt_alloc, mpt_alloc + initrd_len); } @@ -897,7 +898,7 @@ static int __init dom0_construct(struct boot_info *bi, = struct domain *d) if ( pfn >=3D initrd_pfn ) { if ( pfn < initrd_pfn + PFN_UP(initrd_len) ) - mfn =3D initrd->mod->mod_start + (pfn - initrd_pfn); + mfn =3D paddr_to_pfn(initrd->start) + (pfn - initrd_pfn); else mfn -=3D PFN_UP(initrd_len); } diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index d9785acf89b6..18b93d6a272a 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -313,13 +313,29 @@ static struct boot_info *__init multiboot_fill_boot_i= nfo( */ for ( i =3D 0; i < MAX_NR_BOOTMODS && i < bi->nr_modules; i++ ) { - bi->mods[i].mod =3D &mods[i]; - bi->mods[i].cmdline_pa =3D mods[i].string; + + if ( !efi_enabled(EFI_LOADER) ) + { + /* + * The EFI loader gives us modules which are already frame/siz= e. + * Switch back to address/size. + */ + bi->mods[i].start =3D mods[i].mod_start; + bi->mods[i].size =3D mods[i].mod_end - mods[i].mod_start; + } + else + { + /* + * PVH and BIOS loaders give us modules which are start/end. + * Switch to address/size. + */ + bi->mods[i].start =3D pfn_to_paddr(mods[i].mod_start); + bi->mods[i].size =3D mods[i].mod_end; + } } =20 /* Variable 'i' should be one entry past the last module. */ - bi->mods[i].mod =3D &mods[bi->nr_modules]; bi->mods[i].type =3D BOOTMOD_XEN; =20 return bi; @@ -335,8 +351,8 @@ unsigned long __init initial_images_nrpages(nodeid_t no= de) =20 for ( nr =3D i =3D 0; i < bi->nr_modules; ++i ) { - unsigned long start =3D bi->mods[i].mod->mod_start; - unsigned long end =3D start + PFN_UP(bi->mods[i].mod->mod_end); + unsigned long start =3D bi->mods[i].start; + unsigned long end =3D start + PFN_UP(bi->mods[i].size); =20 if ( end > node_start && node_end > start ) nr +=3D min(node_end, end) - max(node_start, start); @@ -347,8 +363,8 @@ unsigned long __init initial_images_nrpages(nodeid_t no= de) =20 void __init release_boot_module(struct boot_module *bm, bool free_mem) { - uint64_t start =3D pfn_to_paddr(bm->mod->mod_start); - uint64_t size =3D bm->mod->mod_end; + uint64_t start =3D bm->start; + uint64_t size =3D bm->size; =20 if ( bm->released ) { @@ -363,18 +379,6 @@ void __init release_boot_module(struct boot_module *bm= , bool free_mem) bm->released =3D true; } =20 -void __init release_module(const module_t *m, bool free_mem) -{ - struct boot_info *bi =3D &xen_boot_info; - unsigned int i; - - for ( i =3D 0; i < bi->nr_modules; i++ ) - { - if ( bi->mods[i].mod =3D=3D m ) - release_boot_module(&bi->mods[i], free_mem); - } -} - static void __init discard_unknown_boot_modules(void) { struct boot_info *bi =3D &xen_boot_info; @@ -509,15 +513,9 @@ static void *__init bootstrap_map_addr(paddr_t start, = paddr_t end) return ret; } =20 -void *__init bootstrap_map(const module_t *mod) -{ - return bootstrap_map_addr(pfn_to_paddr(mod->mod_start), - pfn_to_paddr(mod->mod_start) + mod->mod_end); -} - void *__init bootstrap_map_bm(const struct boot_module *bm) { - return bootstrap_map(bm->mod); + return bootstrap_map_addr(bm->start, bm->start + bm->size); } =20 void __init bootstrap_unmap(void) @@ -695,8 +693,8 @@ static uint64_t __init consider_modules( =20 for ( i =3D 0; i < nr_mods ; ++i ) { - uint64_t start =3D pfn_to_paddr(mods[i].mod->mod_start); - uint64_t end =3D start + PAGE_ALIGN(mods[i].mod->mod_end); + uint64_t start =3D mods[i].start; + uint64_t end =3D start + PAGE_ALIGN(mods[i].size); =20 if ( i =3D=3D this_mod ) continue; @@ -1427,13 +1425,9 @@ void asmlinkage __init noreturn __start_xen(void) set_kexec_crash_area_size((u64)nr_pages << PAGE_SHIFT); kexec_reserve_area(); =20 - for ( i =3D 0; !efi_enabled(EFI_LOADER) && i < bi->nr_modules; i++ ) - { - if ( bi->mods[i].mod->mod_start & (PAGE_SIZE - 1) ) + for ( i =3D 0; i < bi->nr_modules; i++ ) + if ( bi->mods[i].start & (PAGE_SIZE - 1) ) panic("Bootloader didn't honor module alignment request\n"); - bi->mods[i].mod->mod_end -=3D bi->mods[i].mod->mod_start; - bi->mods[i].mod->mod_start >>=3D PAGE_SHIFT; - } =20 /* * TODO: load ucode earlier once multiboot modules become accessible @@ -1452,13 +1446,12 @@ void asmlinkage __init noreturn __start_xen(void) * respective reserve_e820_ram() invocation below. No need to * query efi_boot_mem_unused() here, though. */ - xen->mod->mod_start =3D virt_to_mfn(_stext); - xen->mod->mod_end =3D __2M_rwdata_end - _stext; + xen->start =3D virt_to_maddr(_stext); + xen->size =3D __2M_rwdata_end - _stext; } =20 bi->mods[0].headroom =3D - bzimage_headroom(bootstrap_map_bm(&bi->mods[0]), - bi->mods[0].mod->mod_end); + bzimage_headroom(bootstrap_map_bm(&bi->mods[0]), bi->mods[0].size); bootstrap_unmap(); =20 #ifndef highmem_start @@ -1539,7 +1532,7 @@ void asmlinkage __init noreturn __start_xen(void) for ( j =3D bi->nr_modules - 1; j >=3D 0; j-- ) { struct boot_module *bm =3D &bi->mods[j]; - unsigned long size =3D PAGE_ALIGN(bm->headroom + bm->mod->mod_= end); + unsigned long size =3D PAGE_ALIGN(bm->headroom + bm->size); =20 if ( bm->relocated ) continue; @@ -1551,14 +1544,11 @@ void asmlinkage __init noreturn __start_xen(void) if ( highmem_start && end > highmem_start ) continue; =20 - if ( s < end && - (bm->headroom || - ((end - size) >> PAGE_SHIFT) > bm->mod->mod_start) ) + if ( s < end && (bm->headroom || (end - size) > bm->start) ) { - move_memory(end - size + bm->headroom, - pfn_to_paddr(bm->mod->mod_start), bm->mod->mod= _end); - bm->mod->mod_start =3D (end - size) >> PAGE_SHIFT; - bm->mod->mod_end +=3D bm->headroom; + move_memory(end - size + bm->headroom, bm->start, bm->size= ); + bm->start =3D (end - size); + bm->size +=3D bm->headroom; bm->relocated =3D true; } } @@ -1589,10 +1579,9 @@ void asmlinkage __init noreturn __start_xen(void) panic("Not enough memory to relocate the dom0 kernel image\n"); for ( i =3D 0; i < bi->nr_modules; ++i ) { - const struct boot_module *bm =3D &bi->mods[i]; - uint64_t s =3D pfn_to_paddr(bm->mod->mod_start); + uint64_t s =3D bi->mods[i].start, l =3D bi->mods[i].size; =20 - reserve_e820_ram(&boot_e820, s, s + PAGE_ALIGN(bm->mod->mod_end)); + reserve_e820_ram(&boot_e820, s, s + PAGE_ALIGN(l)); } =20 if ( !xen_phys_start ) @@ -1670,8 +1659,7 @@ void asmlinkage __init noreturn __start_xen(void) map_e =3D boot_e820.map[j].addr + boot_e820.map[j].size; for ( j =3D 0; j < bi->nr_modules; ++j ) { - uint64_t end =3D pfn_to_paddr(bi->mods[j].mod->mod_sta= rt) + - bi->mods[j].mod->mod_end; + uint64_t end =3D bi->mods[j].start + bi->mods[j].size; =20 if ( map_e < end ) map_e =3D end; @@ -1745,13 +1733,11 @@ void asmlinkage __init noreturn __start_xen(void) =20 for ( i =3D 0; i < bi->nr_modules; ++i ) { - const struct boot_module *bm =3D &bi->mods[i]; + unsigned long s =3D bi->mods[i].start, l =3D bi->mods[i].size; =20 - set_pdx_range(bm->mod->mod_start, - bm->mod->mod_start + PFN_UP(bm->mod->mod_end)); - map_pages_to_xen((unsigned long)mfn_to_virt(bm->mod->mod_start), - _mfn(bm->mod->mod_start), - PFN_UP(bm->mod->mod_end), PAGE_HYPERVISOR); + set_pdx_range(paddr_to_pfn(s), paddr_to_pfn(s) + PFN_UP(l)); + map_pages_to_xen((unsigned long)maddr_to_virt(s), maddr_to_mfn(s), + PFN_UP(l), PAGE_HYPERVISOR); } =20 #ifdef CONFIG_KEXEC diff --git a/xen/xsm/xsm_policy.c b/xen/xsm/xsm_policy.c index 12c9de5a1fbf..f8836026f63b 100644 --- a/xen/xsm/xsm_policy.c +++ b/xen/xsm/xsm_policy.c @@ -43,8 +43,8 @@ int __init xsm_multiboot_policy_init( { struct boot_module *bm =3D &bi->mods[i]; =20 - _policy_start =3D bootstrap_map(bm->mod); - _policy_len =3D bm->mod->mod_end; + _policy_start =3D bootstrap_map_bm(bm); + _policy_len =3D bm->size; =20 if ( (xsm_magic_t)(*_policy_start) =3D=3D XSM_MAGIC ) { --=20 2.30.2 From nobody Thu Nov 21 15:29:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1730569017; cv=pass; d=zohomail.com; s=zohoarc; b=I9UnadDNFnEvprLBBgrbWDcgzGKn4ZHCpm/OAhvkP7pEYDmnl7X30RqBq0vnCZhgGyXDSVRwduNFo1ZeVw512upwOS0Hvu+yR7DBOBFas9qmwZlMMu/jhZkGcmum+bvPg4Yw6efga9/Gk5q6lQhwbMI4hHoCMXcL2Ca5k6qYvpk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730569017; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BanyZbKdg0T0KbDMwIGAn8rkRguFwufoO5593eI1GXs=; b=I5P3yv9+pG5TR66Y+U8bpaE1BppT0MllgdbdfIhKbT3u0aRlD1RktwZ6JdHa1T2+QXZ7F6YN0P2O2kkgvdelOgGQr6RJHkiMKHi8daKRIl/6vMrw6BQrV+f5jYW+VERpZdE1cUXI6JxiXbCRYIVEc58LfczTdAt4yo4V5kPNmp4= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1730569017910725.7487245595546; Sat, 2 Nov 2024 10:36:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.829599.1244611 (Exim 4.92) (envelope-from ) id 1t7I31-0001CL-Io; Sat, 02 Nov 2024 17:36:27 +0000 Received: by outflank-mailman (output) from mailman id 829599.1244611; Sat, 02 Nov 2024 17:36:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t7I31-0001BQ-BR; Sat, 02 Nov 2024 17:36:27 +0000 Received: by outflank-mailman (input) for mailman id 829599; Sat, 02 Nov 2024 17:36:26 +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 1t7Hud-0004r4-H4 for xen-devel@lists.xenproject.org; Sat, 02 Nov 2024 17:27:47 +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 c42a77d5-993f-11ef-99a3-01e77a169b0f; Sat, 02 Nov 2024 18:27:43 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1730568374182907.7832620165392; Sat, 2 Nov 2024 10:26:14 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: c42a77d5-993f-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6ImM0MmE3N2Q1LTk5M2YtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMwNTY4NDY0LjA5MTg2Mywic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1730568384; cv=none; d=zohomail.com; s=zohoarc; b=EbK0LHLHm1J7bAzjzo7Yq0KlmM0opYOILP4NhGcy0cwwqFRBQK2+5R0mpXzZwwzGX3lURjW1Db4ASb43mRKQ6pXMkwpSXtbhgMBGfhw+zzoQ7h1LxGFq4Fiv6CI4Kc2/Q+Tc/XEH33WPwCTfMe0iA6wXIMdONmEMRs0KJBWgIYQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730568384; 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=BanyZbKdg0T0KbDMwIGAn8rkRguFwufoO5593eI1GXs=; b=BYsMCPPaXAqIEOSH+Bxy87ZozWFsiuQMSxCDdu4CXUOdQX5/rnIAwc0rCE6dVNsFZ36uNeFXH/oSGNhVp+lC2Gk/oDAsV+XWifK18dxvKOLDNEZd5B0ejsukrw1Mvj7e/2/KUDD26OoWjhRsunSNwLR0I1WV9ZlM31OIpAGtb1I= 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=1730568384; 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=BanyZbKdg0T0KbDMwIGAn8rkRguFwufoO5593eI1GXs=; b=Bnhb55YJbsmVlMOpcw5lXSIo/drVPSpd1rV5mCpptVvnBl7DgNo78EwSsIeF0wzx iafTEied21NF7aM85DFkp+diElAhHuGfV7begn+qlntOx9/Z4pSg9ZfEgnm2wKjZOpx baPbBCu8XJvp1m0OWRB+cN/bRJ2o9BZBpOUEA+Uk= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 10/12] x86/boot: introduce boot domain Date: Sat, 2 Nov 2024 13:25:49 -0400 Message-Id: <20241102172551.17233-11-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241102172551.17233-1-dpsmith@apertussolutions.com> References: <20241102172551.17233-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1730569019204116600 Content-Type: text/plain; charset="utf-8" To begin moving toward allowing the hypervisor to construct more than one domain at boot, a container is needed for a domain's build information. Introduce a new header, , that contains the initial struct boot_domain that encapsulate the build information for a domain. Add a kernel and ramdisk boot module reference along with a struct domain reference to the new struct boot_domain. This allows a struct boot_domain reference to be the only parameter necessary to pass down through the domain construction call chain. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v7 - collapsed the incremental changes to the call chain into this commit --- xen/arch/x86/dom0_build.c | 7 +++--- xen/arch/x86/hvm/dom0_build.c | 16 +++++--------- xen/arch/x86/include/asm/bootdomain.h | 31 +++++++++++++++++++++++++++ xen/arch/x86/include/asm/bootinfo.h | 5 +++++ xen/arch/x86/include/asm/dom0_build.h | 6 +++--- xen/arch/x86/include/asm/setup.h | 6 ++---- xen/arch/x86/pv/dom0_build.c | 24 +++++++-------------- xen/arch/x86/setup.c | 24 +++++++++------------ 8 files changed, 68 insertions(+), 51 deletions(-) create mode 100644 xen/arch/x86/include/asm/bootdomain.h diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 2276965c02bd..2f71d01a03e2 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -597,9 +597,10 @@ int __init dom0_setup_permissions(struct domain *d) return rc; } =20 -int __init construct_dom0(struct boot_info *bi, struct domain *d) +int __init construct_dom0(struct boot_domain *bd) { int rc; + const struct domain *d =3D bd->d; =20 /* Sanity! */ BUG_ON(!pv_shim && d->domain_id !=3D 0); @@ -609,9 +610,9 @@ int __init construct_dom0(struct boot_info *bi, struct = domain *d) process_pending_softirqs(); =20 if ( is_hvm_domain(d) ) - rc =3D dom0_construct_pvh(bi, d); + rc =3D dom0_construct_pvh(bd); else if ( is_pv_domain(d) ) - rc =3D dom0_construct_pv(bi, d); + rc =3D dom0_construct_pv(bd); else panic("Cannot construct Dom0. No guest interface available\n"); =20 diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index e74684f10b12..5aacfeb21fcf 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -1302,25 +1302,19 @@ static void __hwdom_init pvh_setup_mmcfg(struct dom= ain *d) } } =20 -int __init dom0_construct_pvh(struct boot_info *bi, struct domain *d) +int __init dom0_construct_pvh(struct boot_domain *bd) { paddr_t entry, start_info; - struct boot_module *image; - struct boot_module *initrd =3D NULL; + struct boot_module *image =3D bd->kernel; + struct boot_module *initrd =3D bd->ramdisk; + struct domain *d =3D bd->d; int rc; =20 printk(XENLOG_INFO "*** Building a PVH Dom%d ***\n", d->domain_id); =20 - rc =3D first_boot_module_index(bi, BOOTMOD_KERNEL); - if ( unlikely(rc < 0 || rc > bi->nr_modules) ) + if ( unlikely(image =3D=3D NULL) ) panic("Missing kernel boot module for %pd construction\n", d); =20 - image =3D &bi->mods[rc]; - - rc =3D first_boot_module_index(bi, BOOTMOD_RAMDISK); - if ( rc > 0 || rc < bi->nr_modules ) - initrd =3D &bi->mods[rc]; - if ( is_hardware_domain(d) ) { /* diff --git a/xen/arch/x86/include/asm/bootdomain.h b/xen/arch/x86/include/a= sm/bootdomain.h new file mode 100644 index 000000000000..12c19ab37bd8 --- /dev/null +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -0,0 +1,31 @@ +/* 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 domain; + +struct boot_domain { + struct boot_module *kernel; + struct boot_module *ramdisk; + + struct domain *d; +}; + +#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 a5ee90a36607..7b793ca62f19 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -10,10 +10,14 @@ =20 #include #include +#include =20 /* Max number of boot modules a bootloader can provide in addition to Xen = */ #define MAX_NR_BOOTMODS 63 =20 +/* Max number of boot domains that Xen can construct */ +#define MAX_NR_BOOTDOMS 1 + /* Boot module binary type / purpose */ enum bootmod_type { BOOTMOD_UNKNOWN, @@ -77,6 +81,7 @@ struct boot_info { =20 unsigned int nr_modules; struct boot_module mods[MAX_NR_BOOTMODS + 1]; + struct boot_domain domains[MAX_NR_BOOTDOMS]; }; =20 /* diff --git a/xen/arch/x86/include/asm/dom0_build.h b/xen/arch/x86/include/a= sm/dom0_build.h index 4c2193c4a982..4a75fb25a801 100644 --- a/xen/arch/x86/include/asm/dom0_build.h +++ b/xen/arch/x86/include/asm/dom0_build.h @@ -13,10 +13,10 @@ unsigned long dom0_compute_nr_pages(struct domain *d, unsigned long initrd_len); int dom0_setup_permissions(struct domain *d); =20 -struct boot_info; -int dom0_construct_pv(struct boot_info *bi, struct domain *d); +struct boot_domain; +int dom0_construct_pv(struct boot_domain *bd); =20 -int dom0_construct_pvh(struct boot_info *bi, struct domain *d); +int dom0_construct_pvh(struct boot_domain *bd); =20 unsigned long dom0_paging_pages(const struct domain *d, unsigned long nr_pages); diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/se= tup.h index 0591847c57e6..4968ac38398b 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -26,10 +26,8 @@ void subarch_init_memory(void); =20 void init_IRQ(void); =20 -struct boot_info; -int construct_dom0( - struct boot_info *bi, - struct domain *d); +struct boot_domain; +int construct_dom0(struct boot_domain *bd); void setup_io_bitmap(struct domain *d); =20 extern struct boot_info xen_boot_info; diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 5efc650eeff0..28257bf13127 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -355,7 +355,7 @@ static struct page_info * __init alloc_chunk(struct dom= ain *d, return page; } =20 -static int __init dom0_construct(struct boot_info *bi, struct domain *d) +static int __init dom0_construct(struct boot_domain *bd) { int i, rc, order, machine; bool compatible, compat; @@ -370,13 +370,14 @@ static int __init dom0_construct(struct boot_info *bi= , struct domain *d) struct page_info *page =3D NULL; unsigned int flush_flags =3D 0; start_info_t *si; + struct domain *d =3D bd->d; struct vcpu *v =3D d->vcpu[0]; - struct boot_module *image; - struct boot_module *initrd =3D NULL; + struct boot_module *image =3D bd->kernel; + struct boot_module *initrd =3D bd->ramdisk; void *image_base; unsigned long image_len; void *image_start; - unsigned long initrd_len =3D 0; + unsigned long initrd_len =3D initrd ? initrd->size : 0; const char *cmdline; l4_pgentry_t *l4tab =3D NULL, *l4start =3D NULL; l3_pgentry_t *l3tab =3D NULL, *l3start =3D NULL; @@ -414,23 +415,14 @@ static int __init dom0_construct(struct boot_info *bi= , struct domain *d) =20 printk(XENLOG_INFO "*** Building a PV Dom%d ***\n", d->domain_id); =20 - i =3D first_boot_module_index(bi, BOOTMOD_KERNEL); - if ( unlikely(i < 0 || i > bi->nr_modules) ) + if ( unlikely(image =3D=3D NULL) ) panic("Missing kernel boot module for %pd construction\n", d); =20 - image =3D &bi->mods[i]; image_base =3D bootstrap_map_bm(image); image_len =3D image->size; image_start =3D image_base + image->headroom; cmdline =3D __va(image->cmdline_pa); =20 - i =3D first_boot_module_index(bi, BOOTMOD_RAMDISK); - if ( i > 0 || i < bi->nr_modules ) - { - initrd =3D &bi->mods[i]; - initrd_len =3D initrd->size; - } - d->max_pages =3D ~0U; =20 if ( (rc =3D bzimage_parse(image_base, &image_start, &image_len)) !=3D= 0 ) @@ -1066,7 +1058,7 @@ out: return rc; } =20 -int __init dom0_construct_pv(struct boot_info *bi, struct domain *d) +int __init dom0_construct_pv(struct boot_domain *bd) { unsigned long cr4 =3D read_cr4(); int rc; @@ -1084,7 +1076,7 @@ int __init dom0_construct_pv(struct boot_info *bi, st= ruct domain *d) write_cr4(cr4 & ~X86_CR4_SMAP); } =20 - rc =3D dom0_construct(bi, d); + rc =3D dom0_construct(bd); =20 if ( cr4 & X86_CR4_SMAP ) { diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 18b93d6a272a..6e25a9f726c7 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -990,16 +990,9 @@ static struct domain *__init create_dom0(struct boot_i= nfo *bi) .misc_flags =3D opt_dom0_msr_relaxed ? XEN_X86_MSR_RELAXED : 0, }, }; + struct boot_domain *bd =3D &bi->domains[0]; struct domain *d; domid_t domid; - struct boot_module *image; - unsigned int idx; - - idx =3D first_boot_module_index(bi, BOOTMOD_KERNEL); - if ( unlikely(idx < 0 || idx > bi->nr_modules) ) - panic("Missing kernel boot module for building Dom0\n"); - - image =3D &bi->mods[idx]; =20 if ( opt_dom0_pvh ) { @@ -1026,11 +1019,11 @@ static struct domain *__init create_dom0(struct boo= t_info *bi) panic("Error creating d%uv0\n", domid); =20 /* Grab the DOM0 command line. */ - if ( image->cmdline_pa || bi->kextra ) + if ( bd->kernel->cmdline_pa || bi->kextra ) { - if ( image->cmdline_pa ) - safe_strcpy( - cmdline, cmdline_cook(__va(image->cmdline_pa), bi->loader)= ); + if ( bd->kernel->cmdline_pa ) + safe_strcpy(cmdline, cmdline_cook(__va(bd->kernel->cmdline_pa), + bi->loader)); =20 if ( bi->kextra ) /* kextra always includes exactly one leading space. */ @@ -1052,10 +1045,11 @@ static struct domain *__init create_dom0(struct boo= t_info *bi) safe_strcat(cmdline, acpi_param); } =20 - image->cmdline_pa =3D __pa(cmdline); + bd->kernel->cmdline_pa =3D __pa(cmdline); } =20 - if ( construct_dom0(bi, d) !=3D 0 ) + bd->d =3D d; + if ( construct_dom0(bd) !=3D 0 ) panic("Could not construct domain 0\n"); =20 return d; @@ -1255,6 +1249,7 @@ void asmlinkage __init noreturn __start_xen(void) =20 /* Dom0 kernel is always first */ bi->mods[0].type =3D BOOTMOD_KERNEL; + bi->domains[0].kernel =3D &bi->mods[0]; =20 if ( pvh_boot ) { @@ -2125,6 +2120,7 @@ void asmlinkage __init noreturn __start_xen(void) if ( initrdidx < MAX_NR_BOOTMODS ) { bi->mods[initrdidx].type =3D BOOTMOD_RAMDISK; + bi->domains[0].ramdisk =3D &bi->mods[initrdidx]; if ( first_boot_module_index(bi, BOOTMOD_UNKNOWN) < MAX_NR_BOOTMOD= S ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", --=20 2.30.2 From nobody Thu Nov 21 15:29:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1730569078; cv=pass; d=zohomail.com; s=zohoarc; b=Avjq0F3iv7TLpVmHtYmfi0i1IikDs67QKNZ4xfDJQqwePIstvdXI2e7Of/6lFi3vQgVrqHHHccX3viXjbFiK3WTgC0eedU7Ia3uSmmt2n6BKx4YrPaZaChmMXwsTkQK/MGnS4OkwiYqaWMvl/krG2gO97+hKWDZsAqgq8Xi4dyE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730569078; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DlW8869YgbQ7b/dFXUZq70NRQ3QZ7VjwhbTQzGdmgBI=; b=Zlr5l8YBxsB5k0nOlDuAChwr9eBqVsDA4Dy/slgSnRbjFdq+TXhEntvm8UpWGT6LN+WA1aJTwHtnMdzPXOYh296u/1KIB7NPt7boEUyQFuXHzJTLVCxkKz+i5CeZ0cNOxO492bdfG2gzYNcqSpYppLYfnTdAYCp8mUBhHcY+RgU= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 173056907853325.97916870889958; Sat, 2 Nov 2024 10:37:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.829618.1244644 (Exim 4.92) (envelope-from ) id 1t7I4F-00039p-CD; Sat, 02 Nov 2024 17:37:43 +0000 Received: by outflank-mailman (output) from mailman id 829618.1244644; Sat, 02 Nov 2024 17:37:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t7I4F-00039i-93; Sat, 02 Nov 2024 17:37:43 +0000 Received: by outflank-mailman (input) for mailman id 829618; Sat, 02 Nov 2024 17:37:41 +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 1t7Hun-0004r4-9v for xen-devel@lists.xenproject.org; Sat, 02 Nov 2024 17:27:57 +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 ca29640c-993f-11ef-99a3-01e77a169b0f; Sat, 02 Nov 2024 18:27:53 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1730568375366826.8780724690604; Sat, 2 Nov 2024 10:26:15 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ca29640c-993f-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6ImNhMjk2NDBjLTk5M2YtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMwNTY4NDc0LjMzNzU3OSwic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1730568385; cv=none; d=zohomail.com; s=zohoarc; b=GXqqM1eguA2Hqrwqld2IRWlUOBtvX8mk9HblxiZfWXdP/aj1BP9a5wi1WfnGxKZ2tOsCAkQtzlqjToD4/DvxrcTcyE6fnSZqvLufchVowmN0iXbypL/XgzczSpDoqhiiLp8SEUX+NsxVio4QOl4yakoYWF/skV8Qvn2nGrDoIhk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730568385; 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=DlW8869YgbQ7b/dFXUZq70NRQ3QZ7VjwhbTQzGdmgBI=; b=I+2RzWb/pZzKdYO+rh73X4evInsrClFR8eSFoAeooQNTxy2IxTEu4ikeU9zssfOedLlBXEktKUA4cXhDXbz67mTFeW2Jt4twun0AalK3AEdlbLE/KqvUTvUqQf1PzB7t0rKQ2YjcGgM7EuuTCSvQuTCioSSThYBqrRwPxfQ4nhw= 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=1730568385; 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=DlW8869YgbQ7b/dFXUZq70NRQ3QZ7VjwhbTQzGdmgBI=; b=sv3Zz7Ca7Dka+jjB3+AIr+geIunMXPPzH8L9winziOCf+Sj/eAN1BeNDCzdSDOvk nYerP8gDK/GMTZpH4xNbclrpFd+8WcAscOZD/JOE5ULW54tuGiXZANtSVuX7ljKmD1J 0/sxtHVm4koGvK2vxj8vssW/vDssFhaK91W7NLn0= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 11/12] x86/boot: introduce domid field to struct boot_domain Date: Sat, 2 Nov 2024 13:25:50 -0400 Message-Id: <20241102172551.17233-12-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241102172551.17233-1-dpsmith@apertussolutions.com> References: <20241102172551.17233-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1730569079203116600 Content-Type: text/plain; charset="utf-8" Add a domid field to struct boot_domain to hold the assigned domain id for = the domain. During initialization, ensure all instances of struct boot_domain h= ave the invalid domid to ensure that the domid must be set either by convention= or configuration. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- xen/arch/x86/include/asm/bootdomain.h | 2 ++ xen/arch/x86/setup.c | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/include/asm/bootdomain.h b/xen/arch/x86/include/a= sm/bootdomain.h index 12c19ab37bd8..3873f916f854 100644 --- a/xen/arch/x86/include/asm/bootdomain.h +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -12,6 +12,8 @@ struct boot_module; struct domain; =20 struct boot_domain { + domid_t domid; + struct boot_module *kernel; struct boot_module *ramdisk; =20 diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 6e25a9f726c7..7b78bd9c7c8d 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -338,6 +338,9 @@ static struct boot_info *__init multiboot_fill_boot_inf= o( /* Variable 'i' should be one entry past the last module. */ bi->mods[i].type =3D BOOTMOD_XEN; =20 + for ( i =3D 0; i < MAX_NR_BOOTDOMS; i++ ) + bi->domains[i].domid =3D DOMID_INVALID; + return bi; } =20 @@ -992,7 +995,6 @@ static struct domain *__init create_dom0(struct boot_in= fo *bi) }; struct boot_domain *bd =3D &bi->domains[0]; struct domain *d; - domid_t domid; =20 if ( opt_dom0_pvh ) { @@ -1008,15 +1010,15 @@ static struct domain *__init create_dom0(struct boo= t_info *bi) dom0_cfg.flags |=3D XEN_DOMCTL_CDF_iommu; =20 /* Create initial domain. Not d0 for pvshim. */ - domid =3D get_initial_domain_id(); - d =3D domain_create(domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged); + bd->domid =3D get_initial_domain_id(); + d =3D domain_create(bd->domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged= ); if ( IS_ERR(d) ) - panic("Error creating d%u: %ld\n", domid, PTR_ERR(d)); + panic("Error creating d%u: %ld\n", bd->domid, PTR_ERR(d)); =20 init_dom0_cpuid_policy(d); =20 if ( alloc_dom0_vcpu0(d) =3D=3D NULL ) - panic("Error creating d%uv0\n", domid); + panic("Error creating d%uv0\n", bd->domid); =20 /* Grab the DOM0 command line. */ if ( bd->kernel->cmdline_pa || bi->kextra ) --=20 2.30.2 From nobody Thu Nov 21 15:29:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1730569092; cv=pass; d=zohomail.com; s=zohoarc; b=B4JW4sABEwIJwN2CCWvSgBk1x4CbFKbmZ1dPrrIaJr1k5bSdsNPMvxr8RPEl+ZEZw8ASjivGRO9GmcQT/tHr8JC9s3xPjU1iLuygL8sx/fYOopvI7Oa7q1d6b4QMIYV+OhISWsje3MTlblY/l4GnoCAZHB9a4G5MDmKyzVqEPXM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730569092; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=D+Ero9Cx9cs2ogNCswgWtWOJ14E6rK5H6+adO3A9JUc=; b=Oj340/FQC0kJlooAMhtVDzMHjHlmZyBXtt6d3cZphWdn9M6bxDocnGSywrn4geYetX4SfSgiXzTwgSC6mgoo1TTOsHmb7OAu2UGLAMRXOx0AN3x+w6tQFIQyjWDzoAFZj9BNwwW4njlA7FKFwu3NdM5vNDXdAiJ7bV0IEHVI8qw= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1730569092631429.09224906167776; Sat, 2 Nov 2024 10:38:12 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.829624.1244658 (Exim 4.92) (envelope-from ) id 1t7I4S-000400-0p; Sat, 02 Nov 2024 17:37:56 +0000 Received: by outflank-mailman (output) from mailman id 829624.1244658; Sat, 02 Nov 2024 17:37: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 1t7I4R-0003yy-Qw; Sat, 02 Nov 2024 17:37:55 +0000 Received: by outflank-mailman (input) for mailman id 829624; Sat, 02 Nov 2024 17:37:54 +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 1t7Hux-0004r4-No for xen-devel@lists.xenproject.org; Sat, 02 Nov 2024 17:28: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 d062b535-993f-11ef-99a3-01e77a169b0f; Sat, 02 Nov 2024 18:28:04 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1730568376554254.352253814322; Sat, 2 Nov 2024 10:26:16 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d062b535-993f-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6ImQwNjJiNTM1LTk5M2YtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMwNTY4NDg0LjgwMDUzMiwic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1730568385; cv=none; d=zohomail.com; s=zohoarc; b=DaE1msTh9OL/UMNeyEU+I+slUVIkmCcBLTOkiP4IeAh0AFi0/le5UTAY2mPxrvmSFKIax7cucpovfwpc6qUvdMAy76Ak6ZYVS3fLy/a5JmP2URQwX7pJVW65yfp0FuiGWoAfxRs3R92xHYz1/89WXYl+YRcK1pSD/cDgUyotk/I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730568385; 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=D+Ero9Cx9cs2ogNCswgWtWOJ14E6rK5H6+adO3A9JUc=; b=cz5B2xs55xJa3cNJI30LvbySktK7yR3NFJn38I5WZq+Z9irgJN+KntUaa/Bc+WxOWl2mbX+4wRLGn7JYfsI2eAGUUzfPii+t1LHFfJ0JhDqA1IXZ1luND/pYufhlxSBZB7otSUDnh2CbPuiMsbY4YRrgcijLpiUym4spH+8Z4Pg= 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=1730568385; 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=D+Ero9Cx9cs2ogNCswgWtWOJ14E6rK5H6+adO3A9JUc=; b=ebpNRVEcdLj7MAIUFRuaw3inmi9D37/O6u5vIVXXw/L86ZiXaNzV+opQt23bJGD4 yrso92wIMRz+DnfIOPyh91WTJnLqBhqk6e4yMQkBlJJ2R0KLb53dEht4VjUnerXcW+O YYZoAj58haXpOymqXpqtXjGJjVWfww7ZiayQbX3A= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 12/12] x86/boot: add cmdline to struct boot_domain Date: Sat, 2 Nov 2024 13:25:51 -0400 Message-Id: <20241102172551.17233-13-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241102172551.17233-1-dpsmith@apertussolutions.com> References: <20241102172551.17233-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1730569093423116600 Content-Type: text/plain; charset="utf-8" Add a container for the "cooked" command line for a domain. This provides f= or the backing memory to be directly associated with the domain being construc= ted. This is done in anticipation that the domain construction path may need to = be invoked multiple times, thus ensuring each instance had a distinct memory allocation. Signed-off-by: Daniel P. Smith --- Changes since v7: - updated commit message to expand on intent and purpose --- xen/arch/x86/include/asm/bootdomain.h | 4 ++++ xen/arch/x86/include/asm/dom0_build.h | 1 + xen/arch/x86/pv/dom0_build.c | 4 ++-- xen/arch/x86/setup.c | 18 ++++++++---------- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/include/asm/bootdomain.h b/xen/arch/x86/include/a= sm/bootdomain.h index 3873f916f854..bc51f04a1df6 100644 --- a/xen/arch/x86/include/asm/bootdomain.h +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -8,10 +8,14 @@ #ifndef __XEN_X86_BOOTDOMAIN_H__ #define __XEN_X86_BOOTDOMAIN_H__ =20 +#include + struct boot_module; struct domain; =20 struct boot_domain { + char cmdline[MAX_GUEST_CMDLINE]; + domid_t domid; =20 struct boot_module *kernel; diff --git a/xen/arch/x86/include/asm/dom0_build.h b/xen/arch/x86/include/a= sm/dom0_build.h index 4a75fb25a801..982bc1fa9e6b 100644 --- a/xen/arch/x86/include/asm/dom0_build.h +++ b/xen/arch/x86/include/asm/dom0_build.h @@ -4,6 +4,7 @@ #include #include =20 +#include #include =20 extern unsigned int dom0_memflags; diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index 28257bf13127..2c84af52de3e 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -960,8 +960,8 @@ static int __init dom0_construct(struct boot_domain *bd) } =20 memset(si->cmd_line, 0, sizeof(si->cmd_line)); - if ( cmdline !=3D NULL ) - strlcpy((char *)si->cmd_line, cmdline, sizeof(si->cmd_line)); + if ( cmdline[0] !=3D '\0' ) + strlcpy((char *)si->cmd_line, bd->cmdline, sizeof(si->cmd_line)); =20 #ifdef CONFIG_VIDEO if ( !pv_shim && fill_console_start_info((void *)(si + 1)) ) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 7b78bd9c7c8d..9db8a650ecc2 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -980,8 +980,6 @@ static unsigned int __init copy_bios_e820(struct e820en= try *map, unsigned int li =20 static struct domain *__init create_dom0(struct boot_info *bi) { - static char __initdata cmdline[MAX_GUEST_CMDLINE]; - struct xen_domctl_createdomain dom0_cfg =3D { .flags =3D IS_ENABLED(CONFIG_TBOOT) ? XEN_DOMCTL_CDF_s3_integrity = : 0, .max_evtchn_port =3D -1, @@ -1024,16 +1022,16 @@ static struct domain *__init create_dom0(struct boo= t_info *bi) if ( bd->kernel->cmdline_pa || bi->kextra ) { if ( bd->kernel->cmdline_pa ) - safe_strcpy(cmdline, cmdline_cook(__va(bd->kernel->cmdline_pa), + safe_strcpy(bd->cmdline, cmdline_cook(__va(bd->kernel->cmdline= _pa), bi->loader)); =20 if ( bi->kextra ) /* kextra always includes exactly one leading space. */ - safe_strcat(cmdline, bi->kextra); + safe_strcat(bd->cmdline, bi->kextra); =20 /* Append any extra parameters. */ - if ( skip_ioapic_setup && !strstr(cmdline, "noapic") ) - safe_strcat(cmdline, " noapic"); + if ( skip_ioapic_setup && !strstr(bd->cmdline, "noapic") ) + safe_strcat(bd->cmdline, " noapic"); =20 if ( (strlen(acpi_param) =3D=3D 0) && acpi_disabled ) { @@ -1041,13 +1039,13 @@ static struct domain *__init create_dom0(struct boo= t_info *bi) safe_strcpy(acpi_param, "off"); } =20 - if ( (strlen(acpi_param) !=3D 0) && !strstr(cmdline, "acpi=3D") ) + if ( (strlen(acpi_param) !=3D 0) && !strstr(bd->cmdline, "acpi=3D"= ) ) { - safe_strcat(cmdline, " acpi=3D"); - safe_strcat(cmdline, acpi_param); + safe_strcat(bd->cmdline, " acpi=3D"); + safe_strcat(bd->cmdline, acpi_param); } =20 - bd->kernel->cmdline_pa =3D __pa(cmdline); + bd->kernel->cmdline_pa =3D __pa(bd->cmdline); } =20 bd->d =3D d; --=20 2.30.2