From nobody Sat Dec 28 03:46:08 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=1735232303; cv=pass; d=zohomail.com; s=zohoarc; b=EE7/jpskIgkWM3W26p4GlU8BfBj7LDsIXjKS9/FtAxU7UqByVVjuLgN31vUAe5DpRLO8WxepT2tQutxE82Hf++n66FuydPzG70MdxQI7NpGPYvzdB16nyXTVdIPodUAuHdhvV2C5eUOVsNuu/H2FgWD/NhAwxy0Pbfd9/Q5NCJI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232303; 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=/JEBs+owbU9zKFMXeF6gl9Ekr8hZ2owuS8MfDWsoy0M=; b=fWAr1AP/1INHHjwyW3sJ0XQzwddsn4LNajJ/aywLk6+tJbKg9uuyTyY43Fwmo1Npq84XkI1dKR/mCqvlAb3fq4XaKonDd7TVuoJ6oyWkypW+sfaYVBuF80qJUkOLVSUIAmHNNj9qCJYV9iEDZnzSdGI6zZuxOp3pXpbS9gdpkHs= 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 1735232303229970.5513357207769; Thu, 26 Dec 2024 08:58:23 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.863236.1274657 (Exim 4.92) (envelope-from ) id 1tQrBU-0002LP-Ha; Thu, 26 Dec 2024 16:58:04 +0000 Received: by outflank-mailman (output) from mailman id 863236.1274657; Thu, 26 Dec 2024 16:58:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tQrBU-0002LE-Ey; Thu, 26 Dec 2024 16:58:04 +0000 Received: by outflank-mailman (input) for mailman id 863236; Thu, 26 Dec 2024 16:58:03 +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 1tQrBT-00026T-Hd for xen-devel@lists.xenproject.org; Thu, 26 Dec 2024 16:58:03 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 90cdeefc-c3aa-11ef-a0da-8be0dac302b0; Thu, 26 Dec 2024 17:58:02 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1735232271045470.01366880994726; Thu, 26 Dec 2024 08:57:51 -0800 (PST) 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: 90cdeefc-c3aa-11ef-a0da-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1735232272; cv=none; d=zohomail.com; s=zohoarc; b=NgzhDXiJG2mXhvHErwt9ZqhWeHKIomFe2B2HxnbWBp+5100uNqjMOVCHgHMk4pOJmeGarT7MJhd2hKbUw3lafh44DIgHAOd3pmkzHHhr0j6stIQW3xHLxJc8vsfQ4wQVnhzZ1+pNuRbVF5hJdAmqmKiTzissnh9porFs1YSNrZM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232272; 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=/JEBs+owbU9zKFMXeF6gl9Ekr8hZ2owuS8MfDWsoy0M=; b=UwZcSTyd04VLLQIVhZ0E5B+jUyfwUq7KN8XIRHMzsQkz4ECRK6wW2jafh4XfofAqMXsvOm4OMgaRtPMvFx0bWtHDCahUOGWvqfi21/nQ7Hv6/6a/vDUJiAfXQFI57QyvBJJ4rpudvc3z8Ir+NwkPM3L0ERjR4yM7rArgAcIWRug= 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=1735232272; 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=/JEBs+owbU9zKFMXeF6gl9Ekr8hZ2owuS8MfDWsoy0M=; b=T9LCCGVdlAVM1x1CMLBYcsUhzzdMe50AuAgWKQHWnL2aC0XYz/JVEOmP+9972XMJ Y1HGB9jXZF2v36P6pdO7G4Wiprea4ghW9XBG3RKEpQ9vzdiAg+rcj20EiC8jYkBz38u iGs6cZr1psDCAGTnrBm5mq7ID1evOXsIAi6z1qUo= 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 v2 01/15] x86/boot: introduce boot domain Date: Thu, 26 Dec 2024 11:57:26 -0500 Message-Id: <20241226165740.29812-2-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241226165740.29812-1-dpsmith@apertussolutions.com> References: <20241226165740.29812-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: 1735232304793116600 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 dom0 device tree v1: - dropped unnecessary forward declarations - moved pvh_load_kernel() changes forward to this commit Changes since boot modules v9 - dropped unlikely Changes since v8: - code style correction --- xen/arch/x86/dom0_build.c | 8 +++++--- xen/arch/x86/hvm/dom0_build.c | 23 ++++++++-------------- xen/arch/x86/include/asm/bootdomain.h | 28 +++++++++++++++++++++++++++ xen/arch/x86/include/asm/bootinfo.h | 5 +++++ xen/arch/x86/include/asm/dom0_build.h | 6 +++--- xen/arch/x86/include/asm/setup.h | 4 ++-- xen/arch/x86/pv/dom0_build.c | 24 ++++++++--------------- xen/arch/x86/setup.c | 24 ++++++++++------------- 8 files changed, 69 insertions(+), 53 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 e8f5bf5447bc..c231191faec7 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,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); @@ -608,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 ce5b5c31b318..cbc365d678d2 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -644,9 +644,11 @@ static bool __init check_and_adjust_load_address( } =20 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) + struct boot_domain *bd, paddr_t *entry, paddr_t *start_info_addr) { + struct domain *d =3D bd->d; + struct boot_module *image =3D bd->kernel; + struct boot_module *initrd =3D bd->ramdisk; void *image_base =3D bootstrap_map_bm(image); void *image_start =3D image_base + image->headroom; unsigned long image_len =3D image->size; @@ -1301,26 +1303,17 @@ 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; - unsigned int idx; + struct domain *d =3D bd->d; int rc; =20 printk(XENLOG_INFO "*** Building a PVH Dom%d ***\n", d->domain_id); =20 - idx =3D first_boot_module_index(bi, BOOTMOD_KERNEL); - if ( idx >=3D bi->nr_modules ) + if ( bd->kernel =3D=3D NULL ) panic("Missing kernel boot module for %pd construction\n", d); =20 - image =3D &bi->mods[idx]; - - idx =3D first_boot_module_index(bi, BOOTMOD_RAMDISK); - if ( idx < bi->nr_modules ) - initrd =3D &bi->mods[idx]; - if ( is_hardware_domain(d) ) { /* @@ -1358,7 +1351,7 @@ int __init dom0_construct_pvh(struct boot_info *bi, s= truct domain *d) return rc; } =20 - rc =3D pvh_load_kernel(d, image, initrd, &entry, &start_info); + rc =3D pvh_load_kernel(bd, &entry, &start_info); if ( rc ) { printk("Failed to load Dom0 kernel\n"); 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..8d0e5c78d426 --- /dev/null +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (c) 2024 Apertus Solutions, LLC + * Author: Daniel P. Smith + * Copyright (c) 2024 Christopher Clark + */ + +#ifndef __XEN_X86_BOOTDOMAIN_H__ +#define __XEN_X86_BOOTDOMAIN_H__ + +struct boot_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 f8b422913063..9f65e2c8f62d 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -11,10 +11,14 @@ #include #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, @@ -78,6 +82,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 2d67b17213dc..8c94e87dc576 100644 --- a/xen/arch/x86/include/asm/dom0_build.h +++ b/xen/arch/x86/include/asm/dom0_build.h @@ -13,9 +13,9 @@ 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); -int dom0_construct_pvh(struct boot_info *bi, struct domain *d); +struct boot_domain; +int dom0_construct_pv(struct boot_domain *bd); +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 5c2391a8684b..b517da6144de 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -26,8 +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); =20 void setup_io_bitmap(struct domain *d); =20 diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index f54d1da5c6f4..e0709a1c1a7a 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) { unsigned int i; int rc, order, machine; @@ -371,14 +371,15 @@ 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]; =20 - 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; =20 l4_pgentry_t *l4tab =3D NULL, *l4start =3D NULL; l3_pgentry_t *l3tab =3D NULL, *l3start =3D NULL; @@ -416,22 +417,13 @@ 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 ( i >=3D bi->nr_modules ) + if ( !image ) 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; =20 - i =3D first_boot_module_index(bi, BOOTMOD_RAMDISK); - if ( 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 ) @@ -1078,7 +1070,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; @@ -1096,7 +1088,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 8ebe5a9443f3..7e4529d6bfb2 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -989,16 +989,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 ( idx >=3D bi->nr_modules ) - panic("Missing kernel boot module for building domain\n"); - - image =3D &bi->mods[idx]; =20 if ( opt_dom0_pvh ) { @@ -1025,11 +1018,11 @@ static struct domain *__init create_dom0(struct boo= t_info *bi) panic("Error creating d%uv0\n", domid); =20 /* Grab the DOM0 command line. */ - if ( image->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->loa= der)); =20 if ( bi->kextra ) /* kextra always includes exactly one leading space. */ @@ -1051,10 +1044,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; @@ -1261,6 +1255,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 ) { @@ -2118,6 +2113,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 Sat Dec 28 03:46:08 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=1735232307; cv=pass; d=zohomail.com; s=zohoarc; b=ALZiAttOr0prvzjin27ozK4t93DPWlAUICWt09ovJNk/ID7lHGiHhWgUemIfLc5ElxQ5ZYQHvVd39RUd5EeWkIX881Aq9zSbEw3qI/WIUWhfiyQxHk88pOwsbbiGOntnvqgKtnPk9ymUloFd9stt2I7lGhxJcDQMsElEvZyMhNM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232307; 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=Vny6kTLP1Zgh9pS1XObMWkggVqw9oNCU0me6bh/qKT0=; b=FZzd17uqTTwWOn2VrMdwNKViKpS0n8JiWpy5l9+RrGGVr5Ssp1HF1hts3Yf7NCbRMW3w0XXTFZatQU2nVnB3fX6hKWxdtIGuWngyTH2hf+eJVaVeVDMDj1JMsRuLykXWlM/8RuMYk38FvuIcobFb2PaV4gySJ/gr7qCK+cwhppE= 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 1735232307779860.9707538256341; Thu, 26 Dec 2024 08:58:27 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.863240.1274667 (Exim 4.92) (envelope-from ) id 1tQrBc-0002g3-PL; Thu, 26 Dec 2024 16:58:12 +0000 Received: by outflank-mailman (output) from mailman id 863240.1274667; Thu, 26 Dec 2024 16:58:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tQrBc-0002fw-MB; Thu, 26 Dec 2024 16:58:12 +0000 Received: by outflank-mailman (input) for mailman id 863240; Thu, 26 Dec 2024 16:58:11 +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 1tQrBb-00026T-UU for xen-devel@lists.xenproject.org; Thu, 26 Dec 2024 16:58: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 95e1c8de-c3aa-11ef-a0da-8be0dac302b0; Thu, 26 Dec 2024 17:58:11 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1735232272298956.4716909412124; Thu, 26 Dec 2024 08:57:52 -0800 (PST) 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: 95e1c8de-c3aa-11ef-a0da-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1735232274; cv=none; d=zohomail.com; s=zohoarc; b=K/w2vq6EreekCze9dp3/gK9AfMDOPqxSLk8NTEMPVaWDFrRidtnoHkPyxzFJhB4EqZg7iaLym8Wc/wh3oQYwzt3vRHKk/VTGYYcabwdoESlrpwqSGHXL/WdEhbiBr2nFDEy0PJOjPlkxIogYb9Zk9BAoH6uxbeRaSCaX9B2H62A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232274; 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=Vny6kTLP1Zgh9pS1XObMWkggVqw9oNCU0me6bh/qKT0=; b=hs9xJUPpT3W3Ht3QPOx96+ehkJQ7DJUEdbcZOq9sEfsdQaSOFXncBapqHjcs9jOfILH+Ch2YA6NgQlV1IvnMuaBGKxmud6IDw+dMn41r4vpb2gF4I3bYqkSyhHtdRkPyOkNe2JBYbgF2wCA5CR9/tPQhxXlnneuu4X1Vxha37pk= 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=1735232274; 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=Vny6kTLP1Zgh9pS1XObMWkggVqw9oNCU0me6bh/qKT0=; b=e8s+QPuhbtWMPbLkTZbRs3RyEPdv5D7OTNFrShJvzHQTVXp7eoLHI/kCC8r4IJxy Eyl/7RtSyk4+O9k8+YvASIR4R2YDEV00ljjs0nmg9uLLCY/86nPRywXwjRyHgGyc5MG yxkzb+NxgooyN0plEGEdDZ/uDY9xq4+C9yT5ewy4= 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 v2 02/15] x86/boot: introduce domid field to struct boot_domain Date: Thu, 26 Dec 2024 11:57:27 -0500 Message-Id: <20241226165740.29812-3-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241226165740.29812-1-dpsmith@apertussolutions.com> References: <20241226165740.29812-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: 1735232308606116600 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 --- Changes since v1 dom0 device tree: - made .domid part of the static init of xen_boot_info Changes since v9 boot modules - missing include for domid_t def --- xen/arch/x86/include/asm/bootdomain.h | 4 ++++ xen/arch/x86/setup.c | 10 +++++----- 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 8d0e5c78d426..67be575fe781 100644 --- a/xen/arch/x86/include/asm/bootdomain.h +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -5,10 +5,14 @@ * Copyright (c) 2024 Christopher Clark */ =20 +#include + #ifndef __XEN_X86_BOOTDOMAIN_H__ #define __XEN_X86_BOOTDOMAIN_H__ =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 7e4529d6bfb2..27937a7f7aeb 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -292,6 +292,7 @@ static const char *cmdline_cook(const char *p, const ch= ar *loader_name); struct boot_info __initdata xen_boot_info =3D { .loader =3D "unknown", .cmdline =3D "", + .domains =3D { {.domid =3D DOMID_INVALID} }, }; =20 static struct boot_info *__init multiboot_fill_boot_info( @@ -991,7 +992,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 ) { @@ -1007,15 +1007,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 Sat Dec 28 03:46:08 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=1735232312; cv=pass; d=zohomail.com; s=zohoarc; b=KQTBUGJJyP/1EkRkFesyKtW6xY4zAqVKgMoWXcm6FPPjF4WGjxPgz60eE7o2pF/swv62eopRvY1VUB2KBErzifJJGmoDAZo+vtNDAZKuJyYY7YTF/LOLm9nCLtK5sQiUe3Y6QE2BhlHVCRgkhGfB1ySqJBbpwrlgXvD6kSwzueI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232312; 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=fG1DwHOuY1y8Qw7V1e8eHce6xg4PlNOOzNk4YL76snY=; b=T6fFWeu4G5W0u39b8CCVApWYC3KZadlb3zIY0VrezdFjHbBAePkpw6OHz5zKq8SqWG1q48Fy8A4Gk4k7RTOV2pb/S//FD40EkQCcqDigxo0x7DdtIe6ScdXQ2NASM7fgrqHGaZ0fSUxCKjedUNLvTuxhtTVARkyAvvgsDrMJocs= 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 1735232312102394.6900344280517; Thu, 26 Dec 2024 08:58:32 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.863245.1274676 (Exim 4.92) (envelope-from ) id 1tQrBl-00039X-62; Thu, 26 Dec 2024 16:58:21 +0000 Received: by outflank-mailman (output) from mailman id 863245.1274676; Thu, 26 Dec 2024 16:58:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tQrBl-00039K-3C; Thu, 26 Dec 2024 16:58:21 +0000 Received: by outflank-mailman (input) for mailman id 863245; Thu, 26 Dec 2024 16:58:19 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tQrBj-00026T-AB for xen-devel@lists.xenproject.org; Thu, 26 Dec 2024 16:58: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 9a53d519-c3aa-11ef-a0da-8be0dac302b0; Thu, 26 Dec 2024 17:58:18 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1735232273654381.53674337156747; Thu, 26 Dec 2024 08:57:53 -0800 (PST) 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: 9a53d519-c3aa-11ef-a0da-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1735232276; cv=none; d=zohomail.com; s=zohoarc; b=UqsHOLVe0cuGQXX8CRglyebO2vkr0qM81gyNDvroZvGJAhAbpnl9HB2xtS1Gr3Tw2DOwRzFA2MGIUa3H9/nUutGmUQQ1Nu9FTffwlowtu8iqFTQrwhgiJq+A/RGmbt9mungBVp3gM8yCzPtemZjJNaEjcfGf4gujxRjQ9nVO3Wo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232276; 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=fG1DwHOuY1y8Qw7V1e8eHce6xg4PlNOOzNk4YL76snY=; b=cq6IaJCpcBseYLliQ/itw048FRybGhXj8IoV/Z7Jz0AZR9O9BaORPKRtob4pkIqEAoWnJ+28a4t8U/gkW5Nqm/M4FdKh/RPRFy+dAmWoub4e4hhEclRjHTRbSBBlP1jrjGGxfY7lGB4SuTQcRjlEBVDqMpGgN07MJXa3ZOR4/1M= 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=1735232276; 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=fG1DwHOuY1y8Qw7V1e8eHce6xg4PlNOOzNk4YL76snY=; b=bZi0Q7nPT4qm7Ep7EOvW44uuj9xjEN8bb/YxnbLSzSVMcbUedatZcvWh7ZYp2GL2 uvKzw94t4Rd4LLQzFngAanRxOmVAcLJrT9rdWbULsldZHFXROBUFaoWk/eCkTS/xKnR gA+ty1z302carQqk8muwzpng78NnfWgFj3YqrxRA= 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 v2 03/15] x86/boot: add cmdline to struct boot_domain Date: Thu, 26 Dec 2024 11:57:28 -0500 Message-Id: <20241226165740.29812-4-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241226165740.29812-1-dpsmith@apertussolutions.com> References: <20241226165740.29812-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: 1735232312832116600 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 dom0 device tree v1: - switched over to bd->cmdline in pvh_load_kernel - moved cmdline processing under if, eliminating goto - zero-ed cmdline_pa for kernel module after cmdline processing Changes since v9 boot modules: - convert pvh_load_kernel to boot domain to directly use cmdline - adjustments to domain_cmdline_size - remove ASSERT and return 0 instead - use strlen() of values instead of hardcoded sizes - update cmdline parsing check to inspect multiboot string and not just poi= nter - add goto to skip cmdline processing if domain_cmdline_size returns 0 - drop updating cmdline_pa with dynamic buffer with change of its last cons= umer pvh_load_kernel Changes since v8: - switch to a dynamically allocated buffer - dropped local cmdline var in pv dom0_construct() Changes since v7: - updated commit message to expand on intent and purpose --- xen/arch/x86/hvm/dom0_build.c | 14 ++--- xen/arch/x86/include/asm/bootdomain.h | 2 + xen/arch/x86/pv/dom0_build.c | 4 +- xen/arch/x86/setup.c | 78 +++++++++++++++++++-------- 4 files changed, 66 insertions(+), 32 deletions(-) diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index cbc365d678d2..47bc3e9ce858 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -653,7 +653,6 @@ static int __init pvh_load_kernel( void *image_start =3D image_base + image->headroom; unsigned long image_len =3D image->size; unsigned long initrd_len =3D initrd ? initrd->size : 0; - const char *cmdline =3D image->cmdline_pa ? __va(image->cmdline_pa) : = NULL; struct elf_binary elf; struct elf_dom_parms parms; paddr_t last_addr; @@ -717,9 +716,9 @@ static int __init pvh_load_kernel( (initrd ? ROUNDUP(initrd_len, PAGE_SIZE) + sizeof(mod) : 0) + - (cmdline ? ROUNDUP(strlen(cmdline) + 1, - elf_64bit(&elf) ? 8 : 4) - : 0)); + (bd->cmdline ? ROUNDUP(strlen(bd->cmdline) + 1, + elf_64bit(&elf) ? 8 : 4) + : 0)); if ( last_addr =3D=3D INVALID_PADDR ) { printk("Unable to find a memory region to load initrd and metadata= \n"); @@ -759,9 +758,10 @@ static int __init pvh_load_kernel( /* Free temporary buffers. */ free_boot_modules(); =20 - if ( cmdline !=3D NULL ) + if ( bd->cmdline !=3D NULL ) { - rc =3D hvm_copy_to_guest_phys(last_addr, cmdline, strlen(cmdline) = + 1, v); + rc =3D hvm_copy_to_guest_phys( + last_addr, bd->cmdline, strlen(bd->cmdline) + 1, v); if ( rc ) { printk("Unable to copy guest command line\n"); @@ -772,7 +772,7 @@ static int __init pvh_load_kernel( * Round up to 32/64 bits (depending on the guest kernel bitness) = so * the modlist/start_info is aligned. */ - last_addr +=3D ROUNDUP(strlen(cmdline) + 1, elf_64bit(&elf) ? 8 : = 4); + last_addr +=3D ROUNDUP(strlen(bd->cmdline) + 1, elf_64bit(&elf) ? = 8 : 4); } if ( initrd !=3D NULL ) { diff --git a/xen/arch/x86/include/asm/bootdomain.h b/xen/arch/x86/include/a= sm/bootdomain.h index 67be575fe781..101a0c643d74 100644 --- a/xen/arch/x86/include/asm/bootdomain.h +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -11,6 +11,8 @@ #define __XEN_X86_BOOTDOMAIN_H__ =20 struct boot_domain { + const char *cmdline; + domid_t domid; =20 struct boot_module *kernel; diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index e0709a1c1a7a..580f2703a154 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -972,8 +972,8 @@ static int __init dom0_construct(struct boot_domain *bd) } =20 memset(si->cmd_line, 0, sizeof(si->cmd_line)); - if ( image->cmdline_pa ) - strlcpy((char *)si->cmd_line, __va(image->cmdline_pa), sizeof(si->= cmd_line)); + if ( bd->cmdline ) + 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 27937a7f7aeb..a61131365477 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -975,10 +975,29 @@ static unsigned int __init copy_bios_e820(struct e820= entry *map, unsigned int li return n; } =20 -static struct domain *__init create_dom0(struct boot_info *bi) +static size_t __init domain_cmdline_size( + struct boot_info *bi, struct boot_domain *bd) { - static char __initdata cmdline[MAX_GUEST_CMDLINE]; + size_t s =3D bi->kextra ? strlen(bi->kextra) : 0; + + s +=3D bd->kernel->cmdline_pa ? strlen(__va(bd->kernel->cmdline_pa)) := 0; + + if ( s =3D=3D 0 ) + return s; + + /* + * Certain parameters from the Xen command line may be added to the do= m0 + * command line. Add additional space for the possible cases along wit= h one + * extra char to hold \0. + */ + s +=3D strlen(" noapic") + strlen(" acpi=3D") + sizeof(acpi_param) + 1; =20 + return s; +} + +static struct domain *__init create_dom0(struct boot_info *bi) +{ + char *cmdline =3D NULL; struct xen_domctl_createdomain dom0_cfg =3D { .flags =3D IS_ENABLED(CONFIG_TBOOT) ? XEN_DOMCTL_CDF_s3_integrity = : 0, .max_evtchn_port =3D -1, @@ -1018,39 +1037,52 @@ static struct domain *__init create_dom0(struct boo= t_info *bi) panic("Error creating d%uv0\n", bd->domid); =20 /* Grab the DOM0 command line. */ - if ( bd->kernel->cmdline_pa || bi->kextra ) + if ( (bd->kernel->cmdline_pa && + ((char *)__va(bd->kernel->cmdline_pa))[0]) || + bi->kextra ) { - if ( bd->kernel->cmdline_pa ) - safe_strcpy(cmdline, - cmdline_cook(__va(bd->kernel->cmdline_pa), bi->loa= der)); + size_t cmdline_size =3D domain_cmdline_size(bi, bd); + + if ( cmdline_size ) + { + if ( !(cmdline =3D xzalloc_array(char, cmdline_size)) ) + panic("Error allocating cmdline buffer for %pd\n", d); =20 - if ( bi->kextra ) - /* kextra always includes exactly one leading space. */ - safe_strcat(cmdline, bi->kextra); + if ( bd->kernel->cmdline_pa ) + strlcpy(cmdline, + cmdline_cook(__va(bd->kernel->cmdline_pa), bi->loa= der), + cmdline_size); =20 - /* Append any extra parameters. */ - if ( skip_ioapic_setup && !strstr(cmdline, "noapic") ) - safe_strcat(cmdline, " noapic"); + if ( bi->kextra ) + /* kextra always includes exactly one leading space. */ + strlcat(cmdline, bi->kextra, cmdline_size); =20 - if ( (strlen(acpi_param) =3D=3D 0) && acpi_disabled ) - { - printk("ACPI is disabled, notifying Domain 0 (acpi=3Doff)\n"); - safe_strcpy(acpi_param, "off"); - } + /* Append any extra parameters. */ + if ( skip_ioapic_setup && !strstr(cmdline, "noapic") ) + strlcat(cmdline, " noapic", cmdline_size); =20 - if ( (strlen(acpi_param) !=3D 0) && !strstr(cmdline, "acpi=3D") ) - { - safe_strcat(cmdline, " acpi=3D"); - safe_strcat(cmdline, acpi_param); - } + if ( (strlen(acpi_param) =3D=3D 0) && acpi_disabled ) + { + printk("ACPI is disabled, notifying Domain 0 (acpi=3Doff)\= n"); + safe_strcpy(acpi_param, "off"); + } =20 - bd->kernel->cmdline_pa =3D __pa(cmdline); + if ( (strlen(acpi_param) !=3D 0) && !strstr(cmdline, "acpi=3D"= ) ) + { + strlcat(cmdline, " acpi=3D", cmdline_size); + strlcat(cmdline, acpi_param, cmdline_size); + } + bd->kernel->cmdline_pa =3D 0; + bd->cmdline =3D cmdline; + } } =20 bd->d =3D d; if ( construct_dom0(bd) !=3D 0 ) panic("Could not construct domain 0\n"); =20 + xfree(cmdline); + return d; } =20 --=20 2.30.2 From nobody Sat Dec 28 03:46:08 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=1735232326; cv=pass; d=zohomail.com; s=zohoarc; b=EPOoxbRzhCM1Wn9ZQ4FiFw4EXStMIp+qC9Er01Yif9oW1dqaN4Gc0qdoTfFG73rwQm3FIREn0iY6rVTWSr/PKb47zwEBlC1XXXM8Ph9a07AyZJDenR3/QJ6XTMr0t7Rxoet0YbIcwPZrF/Y1KtrvIzD8S7SX+3yjaTfFmOpzdEA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232326; 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=x++da7MTBOqDP2KwlGntWaTQGzUq2g/NoStpY3TKCOk=; b=SdBZ5BAw79PLz6n8V7yT0Rkp/c6gTWnI2g0bCBMyhOsbvtRc7jbLuRXa8f2qtnsoPoIJeImAlIyEX4TzpSxlBcd/g4UCtO3gu0w/blsKFUGTpC+1eLGp3MCca9ZMRbTZaCGszizeubgtZe+oO1nN7cNoBY4Rkh55JWm3GRxQ2ZA= 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 1735232326566253.53983909651424; Thu, 26 Dec 2024 08:58:46 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.863254.1274686 (Exim 4.92) (envelope-from ) id 1tQrBx-0003nW-ED; Thu, 26 Dec 2024 16:58:33 +0000 Received: by outflank-mailman (output) from mailman id 863254.1274686; Thu, 26 Dec 2024 16:58:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tQrBx-0003nO-BK; Thu, 26 Dec 2024 16:58:33 +0000 Received: by outflank-mailman (input) for mailman id 863254; Thu, 26 Dec 2024 16:58:31 +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 1tQrBv-00026T-QV for xen-devel@lists.xenproject.org; Thu, 26 Dec 2024 16:58:31 +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 a166dfd6-c3aa-11ef-a0da-8be0dac302b0; Thu, 26 Dec 2024 17:58:30 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1735232275282537.8488659077085; Thu, 26 Dec 2024 08:57:55 -0800 (PST) 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: a166dfd6-c3aa-11ef-a0da-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1735232278; cv=none; d=zohomail.com; s=zohoarc; b=W3DodgsazXFjX0SgC7QZPmQngljNi6P3X1Ga6aPmmqLyubSdmVWjkTTBkYcht06FJZ7FOZJLSRfuPKmV6bwsUdUbjpKrXhjymNJh0Q9VyRUJeHsekrFn0Fssm2r15UkUfUpYh/tyBAWZ/TDeeBJDlzNopnHqlZK6dSMd0XihsrA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232278; 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=x++da7MTBOqDP2KwlGntWaTQGzUq2g/NoStpY3TKCOk=; b=KnsTPMZO8WNaI3N0W9CgbY8vgQvswWQZ+fquFXtRPYzeJHzaoKpp7dlWovIPdcWELAhl64umXCL/rOgtY8dlfeKBIXovKc8PIwRkaBunWy3eRgM69KtE9Abug4QURByXyY83a5Rt8xbZvhLMirFaMCiDcj9PQwGeuTaWR0fzQRE= 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=1735232278; 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=x++da7MTBOqDP2KwlGntWaTQGzUq2g/NoStpY3TKCOk=; b=huWXxgNUFU9hytyQsge//J9qvUI1mnw7xIsSSmnZAX5i/Ntpz0LMUP/lngDLVUlh RSZsWYCje8sCmfil6MQemy1JsFNnRkZNCHDTiFWM3CKvdZswMx73En0skcxYdVlvXvv 3fg62La3zTl2+UwwGuYUnHGmj5ZE5NBh3KrRySvM= 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, Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v2 04/15] kconfig: introduce option to independently enable libfdt Date: Thu, 26 Dec 2024 11:57:29 -0500 Message-Id: <20241226165740.29812-5-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241226165740.29812-1-dpsmith@apertussolutions.com> References: <20241226165740.29812-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: 1735232328757116600 Content-Type: text/plain; charset="utf-8" Currently, the inclusion of libfdt is controlled by the CONFIG_HAS_DEVICE_T= REE kconfig flag. This flag also changes behavior in a few places, such as boot module processing for XSM. To support the ability to include libfdt without changing these behaviors, introduce CONFIG_LIB_DEVICE_TREE. The inclusion of libfdt is then moved under CONFIG_LIB_DEVICE_TREE. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v1: - grammar and spelling fixes to commit message - corrected indentation to Kconfig format - relocated LIB_DEVICE_TREE to alphabet ordered location --- xen/common/Kconfig | 4 ++++ xen/common/Makefile | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/xen/common/Kconfig b/xen/common/Kconfig index 6166327f4d14..028ed9c3631e 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -55,6 +55,7 @@ config HAS_COMPAT =20 config HAS_DEVICE_TREE bool + select LIB_DEVICE_TREE =20 config HAS_DIT # Data Independent Timing bool @@ -89,6 +90,9 @@ config HAS_UBSAN config HAS_VMAP bool =20 +config LIB_DEVICE_TREE + bool + config MEM_ACCESS_ALWAYS_ON bool =20 diff --git a/xen/common/Makefile b/xen/common/Makefile index cba3b32733ba..3d29aef01155 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -79,7 +79,7 @@ obj-y +=3D sched/ obj-$(CONFIG_UBSAN) +=3D ubsan/ =20 obj-$(CONFIG_NEEDS_LIBELF) +=3D libelf/ -obj-$(CONFIG_HAS_DEVICE_TREE) +=3D libfdt/ +obj-$(CONFIG_LIB_DEVICE_TREE) +=3D libfdt/ =20 CONF_FILE :=3D $(if $(patsubst /%,,$(KCONFIG_CONFIG)),$(objtree)/)$(KCONFI= G_CONFIG) $(obj)/config.gz: $(CONF_FILE) --=20 2.30.2 From nobody Sat Dec 28 03:46:08 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=1735232468; cv=pass; d=zohomail.com; s=zohoarc; b=CL8U5x2oxLH75wV4ttW+50iHkZv5YjUI1B7xlLcVDPF4NVlYV0ReCijeJFsU1YjKsCqDM+sctjY7y5xGjke2EZ2fIriyraDrKccOYe+cZGBanJJPpv1FgqSI5dH1APGXJxCsvjQBGZHgkM4KRiYxKyhFnHsX29xKrYAgPO67kXc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232468; 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=8yEFyhV1XLn4s2lQSWFXirGDySzcrcFW20gpc2BTrdE=; b=cK5q3Sy1SoTiazezbrMwA3Uh4aV/mT2r1Sg5vArAI6mzY+oewwZB+pJ5jP1/tKfQF0Ntm5ODlFerXsA8aAocZNm7W85nJ2fv2fppUBcOIsvf+uRBNt4pZfox87rs5E86xqr5WubtDy2otB26tCbC6GSnfh9uYq39tuWvUmkr8/4= 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 1735232468618482.1486169327419; Thu, 26 Dec 2024 09:01:08 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.863307.1274775 (Exim 4.92) (envelope-from ) id 1tQrE5-0000PY-4P; Thu, 26 Dec 2024 17:00:45 +0000 Received: by outflank-mailman (output) from mailman id 863307.1274775; Thu, 26 Dec 2024 17:00:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tQrE4-0000OY-VL; Thu, 26 Dec 2024 17:00:44 +0000 Received: by outflank-mailman (input) for mailman id 863307; Thu, 26 Dec 2024 17:00:42 +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 1tQrC9-00026T-2O for xen-devel@lists.xenproject.org; Thu, 26 Dec 2024 16:58:45 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a9a917e4-c3aa-11ef-a0da-8be0dac302b0; Thu, 26 Dec 2024 17:58:44 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1735232276554498.6175530673062; Thu, 26 Dec 2024 08:57:56 -0800 (PST) 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: a9a917e4-c3aa-11ef-a0da-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1735232279; cv=none; d=zohomail.com; s=zohoarc; b=M7NNEHXQn2ArpWBIQxAC0ps93lMWSHGq5oSivwW0+R8gPtzYljK8+60SNKgxIKx8oWgAWsfNozgdVR/REUWoUcYBehp1Jl2TESlPzKnNJqDUl0mUgjrAD0NWL4XZvjv+tvbSFBJ19YFMyeq6fZxI8vIDtaFGZ1tkCDOGUqgdBxw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232279; 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=8yEFyhV1XLn4s2lQSWFXirGDySzcrcFW20gpc2BTrdE=; b=Sjo7UcOJjZCiCDH7mVrwEr+aYJHgxVvMmktXLANiKegNebDK20xolGaiAvPan6+BOQk/KxLQaPPfWEIaAsXAdenkrD0ZBU3+t9jz7wzc9YEHZm88YKXsvGwAGkufLNcaYCshUHIIs2RS7gTuZfR3M4rOPhEK1gOqpbScs2f4j9Y= 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=1735232279; 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=8yEFyhV1XLn4s2lQSWFXirGDySzcrcFW20gpc2BTrdE=; b=EuxeSErU3fDeUZdkR7CTZ02vOLwuQf8rDS1fVGLmwmfiqgwUGIyGWEENBxSz2PUQ QSacve/gwL+VOnH/lbV8gaSkVG2+JrADznjiDHodOejSoJ1RQHx03BTsONA5zVOcXPt AkhX9UDFEf0eY/liexwx7UDxTknbqoEii17s1mLQ= 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 v2 05/15] kconfig: introduce domain builder config option Date: Thu, 26 Dec 2024 11:57:30 -0500 Message-Id: <20241226165740.29812-6-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241226165740.29812-1-dpsmith@apertussolutions.com> References: <20241226165740.29812-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: 1735232469452116600 Content-Type: text/plain; charset="utf-8" Hyperlaunch domain builder will be the consolidated boot time domain buildi= ng logic framework. Introduces the config option to enable this domain builder= to and turn on the ability to load the domain configuration via a flattened de= vice tree. Signed-off-by: Daniel P. Smith --- Changes since v1: - fixed Kconfig indentation - change directory name to use - instead of _ --- xen/arch/x86/Kconfig | 2 ++ xen/arch/x86/domain-builder/Kconfig | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 xen/arch/x86/domain-builder/Kconfig diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index 9cdd04721afa..25b9b75423c5 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -383,6 +383,8 @@ config ALTP2M =20 If unsure, stay with defaults. =20 +source "arch/x86/domain_builder/Kconfig" + endmenu =20 source "common/Kconfig" diff --git a/xen/arch/x86/domain-builder/Kconfig b/xen/arch/x86/domain-buil= der/Kconfig new file mode 100644 index 000000000000..8ed493c3b545 --- /dev/null +++ b/xen/arch/x86/domain-builder/Kconfig @@ -0,0 +1,15 @@ + +menu "Domain Builder Features" + +config DOMAIN_BUILDER + bool "Domain builder (UNSUPPORTED)" if UNSUPPORTED + select LIB_DEVICE_TREE + help + Enables the domain builder capability to configure boot domain + construction using a flattened device tree. + + This feature is currently experimental. + + If unsure, say N. + +endmenu --=20 2.30.2 From nobody Sat Dec 28 03:46:08 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=1735232444; cv=pass; d=zohomail.com; s=zohoarc; b=Q54s2AJd6cBo8mja1ABvfO6H6nwdnP8K731klaubk9lQEF1T3vb1G69UObcco0Mc/7Jq7O6BUzOGIRcBO4qbmDXm7cXGeeaCwfj+F8zcO/kbjODqbqWE1XdCXLSF+S1UQahYZYTl3/jcHr7cWt7I8QZREEDxXpNmT611coDcjBU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232444; 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=LG2YwRtPS1LBhMACiQKrmt4rkbz967gy6EJa6rK3Ja8=; b=bS0KMZp4vEqA2dr1OohfQHyK2Ub4QgZlflwoVnzsDbRaBXRG37st02OuKyB79xXGPKaVpRjsVjaZzs8SP10P3gf7lkyorsjG+7jBbXwYZKKW3lgHxp0I+CtJMHC0dkPiNWdnJ8PdJZCyKVsZh2OPQBeGoDknfEARYSdkXLgMdLc= 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 1735232444717552.0114540731286; Thu, 26 Dec 2024 09:00:44 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.863281.1274716 (Exim 4.92) (envelope-from ) id 1tQrDq-0006g6-Bm; Thu, 26 Dec 2024 17:00:30 +0000 Received: by outflank-mailman (output) from mailman id 863281.1274716; Thu, 26 Dec 2024 17:00:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tQrDq-0006fz-9A; Thu, 26 Dec 2024 17:00:30 +0000 Received: by outflank-mailman (input) for mailman id 863281; Thu, 26 Dec 2024 17:00:28 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tQrCH-00026T-H5 for xen-devel@lists.xenproject.org; Thu, 26 Dec 2024 16:58:53 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id aebecc99-c3aa-11ef-a0da-8be0dac302b0; Thu, 26 Dec 2024 17:58:53 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1735232277910815.1102165773889; Thu, 26 Dec 2024 08:57:57 -0800 (PST) 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: aebecc99-c3aa-11ef-a0da-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1735232281; cv=none; d=zohomail.com; s=zohoarc; b=WYIn9XY6vpvXFT5X8bk8CqZfaq6m+vH6VR+LqpDtUylJ8CrfmGej/AHOigsDE2/oIALnm2MkWKFv0ln7NoFIvtPRZPEu7+J1e8qvUFMfu7GivZBdoyLh5dSAzIo9I4jVv/5dKL+Q8awyXUN4HgxYIlU04i2Bh7NiNiBTRmnTUtM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232281; 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=LG2YwRtPS1LBhMACiQKrmt4rkbz967gy6EJa6rK3Ja8=; b=TcbymdHc2/avL3xTlTq3kMjj2x/Sc8amUCU7VD9roTH+ih43fp3lVW56/QpwAS86bA/jAc+I9LM55cSo7P10b2/qCPLFdpSXC779obFgTlofTRE2vEUH8qDtcNwyFPS0U4paQY9k+sQTgdiEx/FZk0mcguXKzpv1xSc7ChQR/wE= 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=1735232281; 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=LG2YwRtPS1LBhMACiQKrmt4rkbz967gy6EJa6rK3Ja8=; b=UZN+CVPV/422zdyxIt3TB+cW9hp2YjYet50NMIlJfAlfu8JWWnsu3fI057L142iZ h4R8VioyUXZPRDWULFU6/6kwrX6gODUeduDYng6KwHDPiuPXLxj/wUGRZNyoLSXTDQC zuJxV86UBFS7xPOBIBKY0AAWUdtvIhkGrJQ9mWzg= 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 v2 06/15] x86/hyperlaunch: introduce the domain builder Date: Thu, 26 Dec 2024 11:57:31 -0500 Message-Id: <20241226165740.29812-7-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241226165740.29812-1-dpsmith@apertussolutions.com> References: <20241226165740.29812-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: 1735232445601116600 Content-Type: text/plain; charset="utf-8" Introduce the domain builder which is capable of consuming a device tree as= the first boot module. If it finds a device tree as the first boot module, it w= ill set its type to BOOTMOD_FDT. This change only detects the boot module and continues to boot with slight change to the boot convention that the dom0 kernel is no longer first boot module but is the second. No functional change intended. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v1: - coding style compliance - removed unnecessary include of rangeset.h - fixed a missed change from 0 to i - add missing const - remove unnecessary first_boot_module_index() usages --- xen/arch/x86/Kconfig | 2 +- xen/arch/x86/Makefile | 2 + xen/arch/x86/domain-builder/Makefile | 3 ++ xen/arch/x86/domain-builder/core.c | 57 ++++++++++++++++++++++++ xen/arch/x86/domain-builder/fdt.c | 37 +++++++++++++++ xen/arch/x86/domain-builder/fdt.h | 21 +++++++++ xen/arch/x86/include/asm/bootinfo.h | 3 ++ xen/arch/x86/include/asm/domainbuilder.h | 8 ++++ xen/arch/x86/setup.c | 17 ++++--- 9 files changed, 143 insertions(+), 7 deletions(-) create mode 100644 xen/arch/x86/domain-builder/Makefile create mode 100644 xen/arch/x86/domain-builder/core.c create mode 100644 xen/arch/x86/domain-builder/fdt.c create mode 100644 xen/arch/x86/domain-builder/fdt.h create mode 100644 xen/arch/x86/include/asm/domainbuilder.h diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index 25b9b75423c5..50b4697da565 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -383,7 +383,7 @@ config ALTP2M =20 If unsure, stay with defaults. =20 -source "arch/x86/domain_builder/Kconfig" +source "arch/x86/domain-builder/Kconfig" =20 endmenu =20 diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index b35fd5196ce2..73b332dd471b 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -81,6 +81,8 @@ obj-$(CONFIG_COMPAT) +=3D x86_64/platform_hypercall.o obj-y +=3D sysctl.o endif =20 +obj-y +=3D domain-builder/ + extra-y +=3D asm-macros.i extra-y +=3D xen.lds =20 diff --git a/xen/arch/x86/domain-builder/Makefile b/xen/arch/x86/domain-bui= lder/Makefile new file mode 100644 index 000000000000..309a0c4bdd9e --- /dev/null +++ b/xen/arch/x86/domain-builder/Makefile @@ -0,0 +1,3 @@ +obj-$(CONFIG_DOMAIN_BUILDER) +=3D fdt.init.o +obj-y +=3D core.init.o + diff --git a/xen/arch/x86/domain-builder/core.c b/xen/arch/x86/domain-build= er/core.c new file mode 100644 index 000000000000..d6ae94f45c72 --- /dev/null +++ b/xen/arch/x86/domain-builder/core.c @@ -0,0 +1,57 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2024, Apertus Solutions, LLC + */ +#include +#include +#include +#include + +#include + +#include "fdt.h" + +void __init builder_init(struct boot_info *bi) +{ + if ( IS_ENABLED(CONFIG_DOMAIN_BUILDER) ) + { + int ret; + + switch ( ret =3D has_hyperlaunch_fdt(bi) ) + { + case 0: + printk("Hyperlaunch device tree detected\n"); + bi->hyperlaunch_enabled =3D true; + bi->mods[0].type =3D BOOTMOD_FDT; + break; + + case -EINVAL: + printk("Hyperlaunch device tree was not detected\n"); + bi->hyperlaunch_enabled =3D false; + break; + + case -ENOENT: + case -ENODATA: + printk("Device tree found, but not hyperlaunch (%d)\n", ret); + bi->hyperlaunch_enabled =3D false; + bi->mods[0].type =3D BOOTMOD_FDT; + break; + + default: + printk("Unknown error (%d) occured checking for hyperlaunch de= vice tree\n", + ret); + bi->hyperlaunch_enabled =3D false; + break; + } + } +} + +/* + * 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/domain-builder/fdt.c b/xen/arch/x86/domain-builde= r/fdt.c new file mode 100644 index 000000000000..4a3f80648f86 --- /dev/null +++ b/xen/arch/x86/domain-builder/fdt.c @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2024, Apertus Solutions, LLC + */ +#include +#include +#include +#include + +#include +#include +#include + +#include "fdt.h" + +int __init has_hyperlaunch_fdt(struct boot_info *bi) +{ + int ret =3D 0; + const void *fdt =3D bootstrap_map_bm(&bi->mods[HYPERLAUNCH_MODULE_IDX]= ); + + if ( fdt_check_header(fdt) < 0 ) + ret =3D -EINVAL; + + bootstrap_unmap(); + + return ret; +} + +/* + * 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/domain-builder/fdt.h b/xen/arch/x86/domain-builde= r/fdt.h new file mode 100644 index 000000000000..1c1569a9c633 --- /dev/null +++ b/xen/arch/x86/domain-builder/fdt.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) */ +#ifndef __XEN_X86_FDT_H__ +#define __XEN_X86_FDT_H__ + +#include + +#include + +/* hyperlaunch fdt is required to be module 0 */ +#define HYPERLAUNCH_MODULE_IDX 0 + +#ifdef CONFIG_DOMAIN_BUILDER +int has_hyperlaunch_fdt(struct boot_info *bi); +#else +static inline int __init has_hyperlaunch_fdt(struct boot_info *bi) +{ + return -EINVAL; +} +#endif + +#endif /* __XEN_X86_FDT_H__ */ diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index 9f65e2c8f62d..208bec90913d 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -27,6 +27,7 @@ enum bootmod_type { BOOTMOD_RAMDISK, BOOTMOD_MICROCODE, BOOTMOD_XSM_POLICY, + BOOTMOD_FDT, }; =20 struct boot_module { @@ -80,6 +81,8 @@ struct boot_info { paddr_t memmap_addr; size_t memmap_length; =20 + bool hyperlaunch_enabled; + unsigned int nr_modules; struct boot_module mods[MAX_NR_BOOTMODS + 1]; struct boot_domain domains[MAX_NR_BOOTDOMS]; diff --git a/xen/arch/x86/include/asm/domainbuilder.h b/xen/arch/x86/includ= e/asm/domainbuilder.h new file mode 100644 index 000000000000..aedc2b49f7c9 --- /dev/null +++ b/xen/arch/x86/include/asm/domainbuilder.h @@ -0,0 +1,8 @@ +#ifndef __XEN_X86_DOMBUILDER_H__ +#define __XEN_X86_DOMBUILDER_H__ + +#include + +void builder_init(struct boot_info *bi); + +#endif diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index a61131365477..e1aa9650d22e 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -33,6 +33,7 @@ #endif #include #include +#include #include #include #include @@ -1285,9 +1286,12 @@ void asmlinkage __init noreturn __start_xen(void) bi->nr_modules); } =20 - /* Dom0 kernel is always first */ - bi->mods[0].type =3D BOOTMOD_KERNEL; - bi->domains[0].kernel =3D &bi->mods[0]; + builder_init(bi); + + /* Find first unknown boot module to use as Dom0 kernel */ + i =3D first_boot_module_index(bi, BOOTMOD_UNKNOWN); + bi->mods[i].type =3D BOOTMOD_KERNEL; + bi->domains[0].kernel =3D &bi->mods[i]; =20 if ( pvh_boot ) { @@ -1470,8 +1474,9 @@ void asmlinkage __init noreturn __start_xen(void) xen->size =3D __2M_rwdata_end - _stext; } =20 - bi->mods[0].headroom =3D - bzimage_headroom(bootstrap_map_bm(&bi->mods[0]), bi->mods[0].size); + bi->domains[0].kernel->headroom =3D + bzimage_headroom(bootstrap_map_bm(bi->domains[0].kernel), + bi->domains[0].kernel->size); bootstrap_unmap(); =20 #ifndef highmem_start @@ -1595,7 +1600,7 @@ void asmlinkage __init noreturn __start_xen(void) #endif } =20 - if ( bi->mods[0].headroom && !bi->mods[0].relocated ) + if ( bi->domains[0].kernel->headroom && !bi->domains[0].kernel->reloca= ted ) 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 Sat Dec 28 03:46:08 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=1735232459; cv=pass; d=zohomail.com; s=zohoarc; b=QklEe5ZHBtuTZtC8eD9NyiaYFXZkm9L/eqEl6yYv4oOHz05rrV1eaieEF8rjm/dZxwWX23lOY5DkGIFLXtIk4VqoTBjJVQ0UWlXoiAzATpvAqhd3xHlmxIVVI4gRZ73ooZbs5SdY7JaiJtveMCXeYhuLr5rQa0N7bNs83evP4r0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232459; 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=l+K1+PF6tYPPI/bcF6jnw9iyso5PFiGOwV6wSVyGzFo=; b=Ompfg1skSV42u0DyhEq1kjxuM4k0pvVLUrBcYR2RuxIDph8sggk9R22aqeY/suMcpCtkxGymEs2SOJLDvEwSdCmgUc70kcqThytnmUPXgZRxkkYLxjG/f0/zbytEV3di0ojJ9z//oxIGYQtdNlGPZZm+jQEpcjC0e+2wjJlkpsM= 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 1735232459470575.1463951098842; Thu, 26 Dec 2024 09:00:59 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.863304.1274757 (Exim 4.92) (envelope-from ) id 1tQrE3-0008LL-IU; Thu, 26 Dec 2024 17:00:43 +0000 Received: by outflank-mailman (output) from mailman id 863304.1274757; Thu, 26 Dec 2024 17:00: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 1tQrE3-0008Kj-Et; Thu, 26 Dec 2024 17:00:43 +0000 Received: by outflank-mailman (input) for mailman id 863304; Thu, 26 Dec 2024 17:00:42 +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 1tQrCP-00026T-KG for xen-devel@lists.xenproject.org; Thu, 26 Dec 2024 16:59:01 +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 b37db99d-c3aa-11ef-a0da-8be0dac302b0; Thu, 26 Dec 2024 17:59:00 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1735232279134554.1038478858385; Thu, 26 Dec 2024 08:57:59 -0800 (PST) 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: b37db99d-c3aa-11ef-a0da-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1735232282; cv=none; d=zohomail.com; s=zohoarc; b=fhGuED3b+9JwfOn7hRYVcnYzUL01IFndlyCMN2Wxeo93W7iny9sMxjpM2R/YqL/m2OJRaFFWTYqCenY3p0FIKPQOxPg5cPFRvP5k8pCQVEHPUb+VR7bqJKaNI9S+gibLnmaTIs86xbuFMbhVb82C+T6zcGSyvYrCye+Uzghd/XU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232282; 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=l+K1+PF6tYPPI/bcF6jnw9iyso5PFiGOwV6wSVyGzFo=; b=GyELEK1whqY5u+kDlK3kz6yhxnwgvd9zJeybyCNvf3HL8VZ8qElJHm3GWl9rHoMyl0+lsdNVOCV20xMPbPhCU2AqJcbXAk4FCDglzF3ht/jwO0Xti7VJ209MWQw0Wyqf8M8/88A7lygbPXPeqVjD7LCWJ8b9MPf9VW9dzDKhaqI= 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=1735232282; 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=l+K1+PF6tYPPI/bcF6jnw9iyso5PFiGOwV6wSVyGzFo=; b=aF7r3pBsYUANy8qnqymROiM6burn8IsJCAIud6gNabC5tcOo3GvzY9QvaYPvRY/Z r+ZY0/5Uce4q7aXxVBkfprvICfANYeVGzUWPk7XpZyL8N6rQ25GgE2ReRnZ+rZNSIOa GxYfrE0PtzyDazkufBdwE/aFMpaVYbt0mGfTkEXc= 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 v2 07/15] x86/hyperlaunch: initial support for hyperlaunch device tree Date: Thu, 26 Dec 2024 11:57:32 -0500 Message-Id: <20241226165740.29812-8-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241226165740.29812-1-dpsmith@apertussolutions.com> References: <20241226165740.29812-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: 1735232461356116600 Content-Type: text/plain; charset="utf-8" Add the ability to detect both a formal hyperlaunch device tree or a dom0le= ss device tree. If the hyperlaunch device tree is found, then count the number= of domain entries, reporting an error if more than one is found. Signed-off-by: Daniel P. Smith --- Changes since v1: - corrected typo in error message - clarified commit message on "reporting" - added missing inline decl - code style --- xen/arch/x86/domain-builder/core.c | 15 +++++++ xen/arch/x86/domain-builder/fdt.c | 65 ++++++++++++++++++++++++++++- xen/arch/x86/domain-builder/fdt.h | 5 +++ xen/arch/x86/include/asm/bootinfo.h | 1 + 4 files changed, 85 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/domain-builder/core.c b/xen/arch/x86/domain-build= er/core.c index d6ae94f45c72..c50eff34fb68 100644 --- a/xen/arch/x86/domain-builder/core.c +++ b/xen/arch/x86/domain-builder/core.c @@ -44,6 +44,21 @@ void __init builder_init(struct boot_info *bi) break; } } + + if ( bi->hyperlaunch_enabled ) + { + int ret; + + printk(XENLOG_INFO "Hyperlaunch configuration:\n"); + if ( (ret =3D walk_hyperlaunch_fdt(bi)) < 0 ) + { + printk(XENLOG_INFO " walk of device tree failed (%d)\n", ret); + bi->hyperlaunch_enabled =3D false; + return; + } + + printk(XENLOG_INFO " Number of domains: %d\n", bi->nr_domains); + } } =20 /* diff --git a/xen/arch/x86/domain-builder/fdt.c b/xen/arch/x86/domain-builde= r/fdt.c index 4a3f80648f86..5793bdc9fd47 100644 --- a/xen/arch/x86/domain-builder/fdt.c +++ b/xen/arch/x86/domain-builder/fdt.c @@ -13,14 +13,77 @@ =20 #include "fdt.h" =20 +static int __init find_hyperlaunch_node(const void *fdt) +{ + int hv_node =3D fdt_path_offset(fdt, "/chosen/hypervisor"); + + if ( hv_node >=3D 0 ) + { + /* Anything other than zero indicates no match */ + if ( fdt_node_check_compatible(fdt, hv_node, "hypervisor,xen") ) + return -ENODATA; + else + return hv_node; + } + else + { + /* Lood for dom0less config */ + int node, chosen_node =3D fdt_path_offset(fdt, "/chosen"); + if ( chosen_node < 0 ) + return -ENOENT; + + fdt_for_each_subnode(node, fdt, chosen_node) + { + if ( fdt_node_check_compatible(fdt, node, "xen,domain") =3D=3D= 0 ) + return chosen_node; + } + } + + return -ENODATA; +} + int __init has_hyperlaunch_fdt(struct boot_info *bi) { int ret =3D 0; const void *fdt =3D bootstrap_map_bm(&bi->mods[HYPERLAUNCH_MODULE_IDX]= ); =20 - if ( fdt_check_header(fdt) < 0 ) + if ( !fdt || fdt_check_header(fdt) < 0 ) ret =3D -EINVAL; + else + ret =3D find_hyperlaunch_node(fdt); + + bootstrap_unmap(); + + return ret < 0 ? ret : 0; +} + +int __init walk_hyperlaunch_fdt(struct boot_info *bi) +{ + int ret =3D 0, hv_node, node; + void *fdt =3D bootstrap_map_bm(&bi->mods[HYPERLAUNCH_MODULE_IDX]); + + if ( unlikely(!fdt) ) + return -EINVAL; + + hv_node =3D find_hyperlaunch_node(fdt); + if ( hv_node < 0 ) + { + ret =3D hv_node; + goto err_out; + } + + fdt_for_each_subnode(node, fdt, hv_node) + { + ret =3D fdt_node_check_compatible(fdt, node, "xen,domain"); + if ( ret =3D=3D 0 ) + bi->nr_domains++; + } + + /* Until multi-domain construction is added, throw an error */ + if ( !bi->nr_domains || bi->nr_domains > 1 ) + printk(XENLOG_ERR "Hyperlaunch only supports dom0 construction\n"); =20 + err_out: bootstrap_unmap(); =20 return ret; diff --git a/xen/arch/x86/domain-builder/fdt.h b/xen/arch/x86/domain-builde= r/fdt.h index 1c1569a9c633..f5b89cb54b29 100644 --- a/xen/arch/x86/domain-builder/fdt.h +++ b/xen/arch/x86/domain-builder/fdt.h @@ -11,11 +11,16 @@ =20 #ifdef CONFIG_DOMAIN_BUILDER int has_hyperlaunch_fdt(struct boot_info *bi); +int walk_hyperlaunch_fdt(struct boot_info *bi); #else static inline int __init has_hyperlaunch_fdt(struct boot_info *bi) { return -EINVAL; } +static inline int __init walk_hyperlaunch_fdt(struct boot_info *bi) +{ + return -EINVAL; +} #endif =20 #endif /* __XEN_X86_FDT_H__ */ diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index 208bec90913d..683ca9dbe2e0 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -84,6 +84,7 @@ struct boot_info { bool hyperlaunch_enabled; =20 unsigned int nr_modules; + unsigned int nr_domains; struct boot_module mods[MAX_NR_BOOTMODS + 1]; struct boot_domain domains[MAX_NR_BOOTDOMS]; }; --=20 2.30.2 From nobody Sat Dec 28 03:46:08 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=1735232459; cv=pass; d=zohomail.com; s=zohoarc; b=cjAzej+m9e92C5YnqSMi9MgKAR50R0KIVtQjE2ex+m3yEX83oPGB3f7U67uLI0Z3iJOiPd1tWmSrkBKGTUDokr1vOODI83q48Zv4bfUiWVvEc/4jJqEWg86oWNayIyPrjf9YNPmIvPxPxX/5cze6gYxb4Uifd0KAhSMLyP0wd9w= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232459; 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=mhot9LKP2slvPRYXK9WmRlmz+pSAHze4P+sLwHMCIo4=; b=gfwdhEMtA3b91Qfo7Ef7F2PXvl9tUjftdeXhKcdGj7rpTHbuvdX3C4jet8gQ6S/TyPdx6JPMVe73TCAb55YQyq8AG3w9KcrvMD6lNdKIYsTPanfY0xNoe6yf1TA46+Fy8tZqOb/nd/bZqBPI0T9VuFXsoph0SSKDmqVMKybnRhY= 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 1735232459878109.88226048143144; Thu, 26 Dec 2024 09:00:59 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.863305.1274762 (Exim 4.92) (envelope-from ) id 1tQrE3-0008Pl-Uq; Thu, 26 Dec 2024 17:00:43 +0000 Received: by outflank-mailman (output) from mailman id 863305.1274762; Thu, 26 Dec 2024 17:00: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 1tQrE3-0008O1-Ll; Thu, 26 Dec 2024 17:00:43 +0000 Received: by outflank-mailman (input) for mailman id 863305; Thu, 26 Dec 2024 17:00:42 +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 1tQrCY-00026T-1D for xen-devel@lists.xenproject.org; Thu, 26 Dec 2024 16:59:10 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b8856058-c3aa-11ef-a0da-8be0dac302b0; Thu, 26 Dec 2024 17:59:09 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1735232280794596.6459264057604; Thu, 26 Dec 2024 08:58:00 -0800 (PST) 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: b8856058-c3aa-11ef-a0da-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1735232284; cv=none; d=zohomail.com; s=zohoarc; b=fNRrtQrI4DnLHPrEcf1U+eHVnfStHjVP44ovOqBH2sOpYuVnxB8iH8lGKPeahmO8iIq8bM9aXmWgLjfFfD2zCcqfdgTyjYJgSTTduZg+ZcAQS4YOSMXT3fxmRHkGik4DqT6+cWchfzFlp7OalGlC4O7MB2RtoznH1d/VOEbnj3M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232284; 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=mhot9LKP2slvPRYXK9WmRlmz+pSAHze4P+sLwHMCIo4=; b=PiygxbmYUe/JmcDlQnBi6Veoy/MMasnF1vd85GYDBtVA3VAMIcbDNVR2jERNEIl7wVDWEs3m8ehuaLpbsK+FT4rCNPYtmH/y1A9rgiUScGEXAYpjbCb+zAu8d/gTNrydsm0V5qZha8K3TtALflXNkZFUttagnt9PxXcN1hei+mM= 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=1735232284; 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=mhot9LKP2slvPRYXK9WmRlmz+pSAHze4P+sLwHMCIo4=; b=HJF5SrIgBMp8tPpth61zvRqaU+pZ4DjCS2NMyovsHNXnL+qoP3lNyGPQMbQ3oNvS UP+9ut71tRtTqU6Ow8B9/F1nMGXQSSLRT33mTaZykIuih2y5ebCRwrbRyGiOW47pxTI YsWURxWrjFd/NRbhfR9DmpkGeKQIKp16sHbQI+cs= 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?= , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel Subject: [PATCH v2 08/15] x86/hyperlaunch: locate dom0 kernel with hyperlaunch Date: Thu, 26 Dec 2024 11:57:33 -0500 Message-Id: <20241226165740.29812-9-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241226165740.29812-1-dpsmith@apertussolutions.com> References: <20241226165740.29812-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: 1735232461637116600 Content-Type: text/plain; charset="utf-8" Look for a subnode of type `multiboot,kernel` within a domain node. If foun= d, process the reg property for the MB1 module index. If the bootargs property= is present and there was not an MB1 string, then use the command line from the device tree definition. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v1: - moved low-level fdt handlers to libfdt-xen.h - coding style changes - moved default to "unknown" up to a local declaration - moved the general fdt parsing code out to libfdt - reworked device tree property parsing for module index - reworked parsers to take index as parameter - parsers now return success or error value - added check if kernel was already located, warn and continue --- xen/arch/x86/domain-builder/core.c | 11 +++ xen/arch/x86/domain-builder/fdt.c | 118 ++++++++++++++++++++++++++++ xen/arch/x86/domain-builder/fdt.h | 3 + xen/arch/x86/setup.c | 5 -- xen/include/xen/libfdt/libfdt-xen.h | 76 ++++++++++++++++++ 5 files changed, 208 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/domain-builder/core.c b/xen/arch/x86/domain-build= er/core.c index c50eff34fb68..eda7fa7a8ffa 100644 --- a/xen/arch/x86/domain-builder/core.c +++ b/xen/arch/x86/domain-builder/core.c @@ -59,6 +59,17 @@ void __init builder_init(struct boot_info *bi) =20 printk(XENLOG_INFO " Number of domains: %d\n", bi->nr_domains); } + else + { + unsigned int i; + + /* Find first unknown boot module to use as Dom0 kernel */ + printk("Falling back to using first boot module as dom0\n"); + i =3D first_boot_module_index(bi, BOOTMOD_UNKNOWN); + bi->mods[i].type =3D BOOTMOD_KERNEL; + bi->domains[0].kernel =3D &bi->mods[i]; + bi->nr_domains =3D 1; + } } =20 /* diff --git a/xen/arch/x86/domain-builder/fdt.c b/xen/arch/x86/domain-builde= r/fdt.c index 5793bdc9fd47..bcaee50689a6 100644 --- a/xen/arch/x86/domain-builder/fdt.c +++ b/xen/arch/x86/domain-builder/fdt.c @@ -13,6 +13,114 @@ =20 #include "fdt.h" =20 +static int __init hl_module_index(void *fdt, int node, uint32_t *idx) +{ + int ret =3D 0; + const struct fdt_property *prop =3D + fdt_get_property(fdt, node, "module-index", &ret); + + /* FDT error or bad idx pointer, translate to -EINVAL */ + if ( ret < 0 || idx =3D=3D NULL ) + return -EINVAL; + + fdt_cell_as_u32((fdt32_t *)prop->data, idx); + + if ( *idx > MAX_NR_BOOTMODS ) + return -ERANGE; + + return 0; +} + +static int __init dom0less_module_index( + void *fdt, int node, int size_size, int address_size, uint32_t *idx) +{ + uint64_t size =3D ~0UL, addr =3D ~0UL; + int ret =3D + fdt_get_reg_prop(fdt, node, address_size, size_size, &addr, &size,= 1); + + /* FDT error or bad idx pointer, translate to -EINVAL */ + if ( ret < 0 || idx =3D=3D NULL ) + return -EINVAL; + + /* Convention is that zero size indicates address is an index */ + if ( size !=3D 0 ) + return -EOPNOTSUPP; + + if ( addr > MAX_NR_BOOTMODS ) + return -ERANGE; + + /* + * MAX_NR_BOOTMODS cannot exceed the max for MB1, represented by a u32, + * thus the cast down to a u32 will be safe due to the prior check. + */ + *idx =3D (uint32_t)addr; + + return 0; +} + +static int __init process_domain_node( + struct boot_info *bi, void *fdt, int dom_node) +{ + int node; + struct boot_domain *bd =3D &bi->domains[bi->nr_domains]; + const char *name =3D fdt_get_name(fdt, dom_node, NULL) ?: "unknown"; + + fdt_for_each_subnode(node, fdt, dom_node) + { + if ( fdt_node_check_compatible(fdt, node, "multiboot,kernel") =3D= =3D 0 ) + { + unsigned int idx; + int ret =3D 0; + + if ( bd->kernel ) + { + printk(XENLOG_ERR "Duplicate kernel module for domain %s)\= n", + name); + continue; + } + + /* Try hyperlaunch property, fall back to dom0less property. */ + if ( hl_module_index(fdt, node, &idx) < 0 ) + { + int address_size =3D fdt_address_cells(fdt, dom_node); + int size_size =3D fdt_size_cells(fdt, dom_node); + + if ( address_size < 0 || size_size < 0 ) + ret =3D -EINVAL; + else + ret =3D dom0less_module_index( + fdt, node, size_size, address_size, &idx); + } + + if ( ret < 0 ) + { + printk(" failed processing kernel module for domain %s)\n= ", + name); + return ret; + } + + if ( idx > bi->nr_modules ) + { + printk(" invalid kernel module index for domain node (%d)= \n", + bi->nr_domains); + return -EINVAL; + } + + printk(" kernel: boot module %d\n", idx); + bi->mods[idx].type =3D BOOTMOD_KERNEL; + bd->kernel =3D &bi->mods[idx]; + } + } + + if ( !bd->kernel ) + { + printk(XENLOG_ERR "ERR: no kernel assigned to domain\n"); + return -EFAULT; + } + + return 0; +} + static int __init find_hyperlaunch_node(const void *fdt) { int hv_node =3D fdt_path_offset(fdt, "/chosen/hypervisor"); @@ -74,9 +182,19 @@ int __init walk_hyperlaunch_fdt(struct boot_info *bi) =20 fdt_for_each_subnode(node, fdt, hv_node) { + if ( bi->nr_domains >=3D MAX_NR_BOOTDOMS ) + { + printk(XENLOG_WARNING "WARN: more domains defined than max all= owed"); + break; + } + ret =3D fdt_node_check_compatible(fdt, node, "xen,domain"); if ( ret =3D=3D 0 ) + { + if ( (ret =3D process_domain_node(bi, fdt, node)) < 0 ) + break; bi->nr_domains++; + } } =20 /* Until multi-domain construction is added, throw an error */ diff --git a/xen/arch/x86/domain-builder/fdt.h b/xen/arch/x86/domain-builde= r/fdt.h index f5b89cb54b29..0be4ac771bc4 100644 --- a/xen/arch/x86/domain-builder/fdt.h +++ b/xen/arch/x86/domain-builder/fdt.h @@ -3,6 +3,8 @@ #define __XEN_X86_FDT_H__ =20 #include +#include +#include =20 #include =20 @@ -10,6 +12,7 @@ #define HYPERLAUNCH_MODULE_IDX 0 =20 #ifdef CONFIG_DOMAIN_BUILDER + int has_hyperlaunch_fdt(struct boot_info *bi); int walk_hyperlaunch_fdt(struct boot_info *bi); #else diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index e1aa9650d22e..71ce9315d3ac 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1288,11 +1288,6 @@ void asmlinkage __init noreturn __start_xen(void) =20 builder_init(bi); =20 - /* Find first unknown boot module to use as Dom0 kernel */ - i =3D first_boot_module_index(bi, BOOTMOD_UNKNOWN); - bi->mods[i].type =3D BOOTMOD_KERNEL; - bi->domains[0].kernel =3D &bi->mods[i]; - if ( pvh_boot ) { /* pvh_init() already filled in e820_raw */ diff --git a/xen/include/xen/libfdt/libfdt-xen.h b/xen/include/xen/libfdt/l= ibfdt-xen.h index a5340bc9f4e1..27d23df03af3 100644 --- a/xen/include/xen/libfdt/libfdt-xen.h +++ b/xen/include/xen/libfdt/libfdt-xen.h @@ -13,6 +13,82 @@ =20 #include =20 +static inline int __init fdt_cell_as_u32(const fdt32_t *cell, uint32_t *va= l) +{ + *val =3D fdt32_to_cpu(*cell); + + return 0; +} + +static inline int __init fdt_cell_as_u64(const fdt32_t *cell, uint64_t *va= l) +{ + *val =3D ((uint64_t)fdt32_to_cpu(cell[0]) << 32) | + (uint64_t)fdt32_to_cpu(cell[1]); + + return 0; +} + +/* + * Property: reg + * + * Defined in Section 2.3.6 of the Device Tree Specification is the "reg" + * standard property. The property is a prop-encoded-array that is encoded= as + * an arbitrary number of (address, length) pairs. + */ +static inline int __init fdt_get_reg_prop( + const void *fdt, int node, unsigned int asize, unsigned int ssize, + uint64_t *addr, uint64_t *size, unsigned int pairs) +{ + int ret; + unsigned int i, count; + const struct fdt_property *prop; + fdt32_t *cell; + + /* FDT spec max size is 4 (128bit int), but largest arch int size is 6= 4 */ + if ( ssize > 2 || asize > 2 ) + return -EINVAL; + + prop =3D fdt_get_property(fdt, node, "reg", &ret); + if ( !prop || ret < sizeof(u32) ) + return ret < 0 ? ret : -EINVAL; + + /* Get the number of (addr, size) pairs and clamp down. */ + count =3D fdt32_to_cpu(prop->len) / (ssize + asize); + count =3D count < pairs ? count : pairs; + + cell =3D (fdt32_t *)prop->data; + + for ( i =3D 0; i < count; i++ ) + { + /* read address field */ + if ( asize =3D=3D 1 ) + { + uint32_t val; + fdt_cell_as_u32(cell, &val); + addr[i] =3D val; + } + else + fdt_cell_as_u64(cell, &addr[i]); + + /* read size field */ + cell +=3D asize; + + if ( ssize =3D=3D 1 ) + { + uint32_t val; + fdt_cell_as_u32(cell, &val); + size[i] =3D val; + } + else + fdt_cell_as_u64(cell, &size[i]); + + /* move to next pair */ + cell +=3D ssize; + } + + return count; +} + static inline int fdt_get_mem_rsv_paddr(const void *fdt, int n, paddr_t *address, paddr_t *size) --=20 2.30.2 From nobody Sat Dec 28 03:46:08 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=1735232456; cv=pass; d=zohomail.com; s=zohoarc; b=B59ibKbJ/L8mkS6JazKxlxJv4RfP+hQ6yrtHtnGjmlyMhfmaW8zxRNvnwoASJ2+dlMqkrZneip+bBDzs6pUZ/wUjQ1xqWpWYC/E059pXq8pZuCWOhaJeKdNObhuXQOyl/o13ppoJ4+h7RJ6X3T2QZxqAKLaI6yHjVJsSxrr0Oxg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232456; 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=52qJQbf7jF223erY8P2R8ITOq6qxtcd4OGVYfyMQ2rc=; b=mBGzBGoAUZwMlyvwcNTYLZLnkHw4mDt/uWofiX08sPARResfJv9zGuarwPnebGwPTofxe1gjHwNX3AO2xTivl7tRM55pBm0CsEPvFE2Do5bpMDkSibQA+VtLE6EraESQ3a0b2tx4iPeF4g7JgfbFN8ixNU3fP3dHZrZ41S5xItE= 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 1735232456871313.92024785158685; Thu, 26 Dec 2024 09:00:56 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.863299.1274747 (Exim 4.92) (envelope-from ) id 1tQrE2-0007yy-4F; Thu, 26 Dec 2024 17:00:42 +0000 Received: by outflank-mailman (output) from mailman id 863299.1274747; Thu, 26 Dec 2024 17:00: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 1tQrE2-0007yp-0L; Thu, 26 Dec 2024 17:00:42 +0000 Received: by outflank-mailman (input) for mailman id 863299; Thu, 26 Dec 2024 17:00:40 +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 1tQrCo-00026T-NR for xen-devel@lists.xenproject.org; Thu, 26 Dec 2024 16:59:26 +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 c281d457-c3aa-11ef-a0da-8be0dac302b0; Thu, 26 Dec 2024 17:59:26 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1735232282410325.37290437121055; Thu, 26 Dec 2024 08:58:02 -0800 (PST) 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: c281d457-c3aa-11ef-a0da-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1735232286; cv=none; d=zohomail.com; s=zohoarc; b=RhWPoK4NIZjG4E6p6yzvJNhXjnhRAFyLWbXD1p759QmS2lQ4o+8HKYWJ+A0KaW3xHq1y6I4hpvEvH+uNpoa0e0Dp8TjGJByXcixe6KF4rWpaM7Yhj8DlO/M5vUWzfks/YwG43Jd9cnUXFVDYf3HL5UTBks7KFBJuEhHpM1ItkhY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232286; 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=52qJQbf7jF223erY8P2R8ITOq6qxtcd4OGVYfyMQ2rc=; b=GncS5m+hbU/SzMPAasNByTvqrnpV4itEGqfvBJhsgOkofnxJYL2kPb+i9wXtMeOmZOAn22oPJ2SJULTJ+oJNhBEIBqq5kW9W3DNFQs3amjRgDsXDw8198CLrliKId+I7iSvBbDgqjBKHkcg0bnpT9SJnj0JKhlRimWMS8ZwUc/c= 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=1735232286; 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=52qJQbf7jF223erY8P2R8ITOq6qxtcd4OGVYfyMQ2rc=; b=lOE1cm+9M1fTjj2O6PTdvk0lnczYdaSKhativ/JPZ9g4EBEOUCfBOSNu2SY3IaPK rxsWqwxkbhqDXuTAQJ8goejj0AOAbVlJjZPoGXuLJ6KdufWig6aA7LtSdQoIvxyXuW7 zjI5bYOIZWq4tVO1TNK4ajz7lWQOyBeOUjadQe0c= 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?= , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel Subject: [PATCH v2 09/15] x86/hyperlaunch: obtain cmdline from device tree Date: Thu, 26 Dec 2024 11:57:34 -0500 Message-Id: <20241226165740.29812-10-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241226165740.29812-1-dpsmith@apertussolutions.com> References: <20241226165740.29812-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: 1735232457356116600 Content-Type: text/plain; charset="utf-8" If a command line is not provided through the bootloader's mechanism, e.g. muiltboot module string field, then use one from the device tree if present. The device tree command line is located in the bootargs property of the `multiboot,kernel` node. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v1: - moved common fdt functions to libfdt - rename prop_as_offset to more correct prop_by_offset --- xen/arch/x86/domain-builder/core.c | 28 ++++++++++++++++++++++++ xen/arch/x86/domain-builder/fdt.c | 10 +++++++++ xen/arch/x86/domain-builder/fdt.h | 24 ++++++++++++++++++++ xen/arch/x86/include/asm/bootinfo.h | 6 +++-- xen/arch/x86/include/asm/domainbuilder.h | 4 ++++ xen/arch/x86/setup.c | 15 +++++++++---- xen/include/xen/libfdt/libfdt-xen.h | 24 ++++++++++++++++++++ 7 files changed, 105 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/domain-builder/core.c b/xen/arch/x86/domain-build= er/core.c index eda7fa7a8ffa..91d1b7367e76 100644 --- a/xen/arch/x86/domain-builder/core.c +++ b/xen/arch/x86/domain-builder/core.c @@ -8,9 +8,37 @@ #include =20 #include +#include =20 #include "fdt.h" =20 +size_t __init builder_get_cmdline_size(struct boot_info *bi, int offset) +{ +#ifdef CONFIG_DOMAIN_BUILDER + const void *fdt =3D bootstrap_map_bm(&bi->mods[HYPERLAUNCH_MODULE_IDX]= ); + int size =3D fdt_cmdline_prop_size(fdt, offset); + + bootstrap_unmap(); + return size < 0 ? 0 : (size_t) size; +#else + return 0; +#endif +} + +int __init builder_get_cmdline( + struct boot_info *bi, int offset, char *cmdline, size_t size) +{ +#ifdef CONFIG_DOMAIN_BUILDER + const void *fdt =3D bootstrap_map_bm(&bi->mods[HYPERLAUNCH_MODULE_IDX]= ); + int ret =3D fdt_cmdline_prop_copy(fdt, offset, cmdline, size); + + bootstrap_unmap(); + return ret; +#else + return 0; +#endif +} + void __init builder_init(struct boot_info *bi) { if ( IS_ENABLED(CONFIG_DOMAIN_BUILDER) ) diff --git a/xen/arch/x86/domain-builder/fdt.c b/xen/arch/x86/domain-builde= r/fdt.c index bcaee50689a6..1094c8dc8838 100644 --- a/xen/arch/x86/domain-builder/fdt.c +++ b/xen/arch/x86/domain-builder/fdt.c @@ -109,6 +109,16 @@ static int __init process_domain_node( printk(" kernel: boot module %d\n", idx); bi->mods[idx].type =3D BOOTMOD_KERNEL; bd->kernel =3D &bi->mods[idx]; + + /* If bootloader didn't set cmdline, see if FDT provides one. = */ + if ( bd->kernel->cmdline_pa && + !((char *)__va(bd->kernel->cmdline_pa))[0] ) + { + int ret =3D fdt_get_prop_by_offset( + fdt, node, "bootargs", &bd->kernel->cmdline_pa); + if ( ret > 0 ) + bd->kernel->fdt_cmdline =3D true; + } } } =20 diff --git a/xen/arch/x86/domain-builder/fdt.h b/xen/arch/x86/domain-builde= r/fdt.h index 0be4ac771bc4..3938b0d2619b 100644 --- a/xen/arch/x86/domain-builder/fdt.h +++ b/xen/arch/x86/domain-builder/fdt.h @@ -13,6 +13,30 @@ =20 #ifdef CONFIG_DOMAIN_BUILDER =20 +static inline int __init fdt_cmdline_prop_size(const void *fdt, int offset) +{ + int ret; + + fdt_get_property_by_offset(fdt, offset, &ret); + + return ret; +} + +static inline int __init fdt_cmdline_prop_copy( + const void *fdt, int offset, char *cmdline, size_t size) +{ + int ret; + const struct fdt_property *prop =3D + fdt_get_property_by_offset(fdt, offset, &ret); + + if ( ret < 0 ) + return ret; + + ASSERT(size > ret); + + return strlcpy(cmdline, prop->data, ret); +} + int has_hyperlaunch_fdt(struct boot_info *bi); int walk_hyperlaunch_fdt(struct boot_info *bi); #else diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index 683ca9dbe2e0..433a0e66121b 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -35,11 +35,13 @@ struct boot_module { =20 /* * Module State Flags: - * relocated: indicates module has been relocated in memory. - * released: indicates module's pages have been freed. + * relocated: indicates module has been relocated in memory. + * released: indicates module's pages have been freed. + * fdt_cmdline: indicates module's cmdline is in the FDT. */ bool relocated:1; bool released:1; + bool fdt_cmdline:1; =20 /* * A boot module may need decompressing by Xen. Headroom is an estima= te of diff --git a/xen/arch/x86/include/asm/domainbuilder.h b/xen/arch/x86/includ= e/asm/domainbuilder.h index aedc2b49f7c9..21221d8df8ec 100644 --- a/xen/arch/x86/include/asm/domainbuilder.h +++ b/xen/arch/x86/include/asm/domainbuilder.h @@ -3,6 +3,10 @@ =20 #include =20 +size_t __init builder_get_cmdline_size(struct boot_info *bi, int offset); +int __init builder_get_cmdline( + struct boot_info *bi, int offset, char *cmdline, size_t size); + void builder_init(struct boot_info *bi); =20 #endif diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 71ce9315d3ac..3dd04b9afca7 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -981,7 +981,10 @@ static size_t __init domain_cmdline_size( { size_t s =3D bi->kextra ? strlen(bi->kextra) : 0; =20 - s +=3D bd->kernel->cmdline_pa ? strlen(__va(bd->kernel->cmdline_pa)) := 0; + if ( bd->kernel->fdt_cmdline ) + s +=3D builder_get_cmdline_size(bi, bd->kernel->cmdline_pa); + else + s +=3D strlen(__va(bd->kernel->cmdline_pa)); =20 if ( s =3D=3D 0 ) return s; @@ -1039,7 +1042,8 @@ static struct domain *__init create_dom0(struct boot_= info *bi) =20 /* Grab the DOM0 command line. */ if ( (bd->kernel->cmdline_pa && - ((char *)__va(bd->kernel->cmdline_pa))[0]) || + (bd->kernel->fdt_cmdline || + ((char *)__va(bd->kernel->cmdline_pa))[0])) || bi->kextra ) { size_t cmdline_size =3D domain_cmdline_size(bi, bd); @@ -1049,9 +1053,12 @@ static struct domain *__init create_dom0(struct boot= _info *bi) if ( !(cmdline =3D xzalloc_array(char, cmdline_size)) ) panic("Error allocating cmdline buffer for %pd\n", d); =20 - if ( bd->kernel->cmdline_pa ) + if ( bd->kernel->fdt_cmdline ) + builder_get_cmdline( + bi, bd->kernel->cmdline_pa, cmdline, cmdline_size); + else strlcpy(cmdline, - cmdline_cook(__va(bd->kernel->cmdline_pa), bi->loa= der), + cmdline_cook(__va(bd->kernel->cmdline_pa),bi->load= er), cmdline_size); =20 if ( bi->kextra ) diff --git a/xen/include/xen/libfdt/libfdt-xen.h b/xen/include/xen/libfdt/l= ibfdt-xen.h index 27d23df03af3..0e54aeeb6cc2 100644 --- a/xen/include/xen/libfdt/libfdt-xen.h +++ b/xen/include/xen/libfdt/libfdt-xen.h @@ -28,6 +28,30 @@ static inline int __init fdt_cell_as_u64(const fdt32_t *= cell, uint64_t *val) return 0; } =20 +static inline int __init fdt_get_prop_by_offset( + const void *fdt, int node, const char *name, unsigned long *offset) +{ + int ret, poffset; + const char *pname; + size_t nsize =3D strlen(name); + + fdt_for_each_property_offset(poffset, fdt, node) + { + fdt_getprop_by_offset(fdt, poffset, &pname, &ret); + + if ( ret < 0 || strlen(pname) !=3D nsize ) + continue; + + if ( !strncmp(pname, name, nsize) ) + { + *offset =3D poffset; + return nsize; + } + } + + return -ENOENT; +} + /* * Property: reg * --=20 2.30.2 From nobody Sat Dec 28 03:46:08 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=1735232413; cv=pass; d=zohomail.com; s=zohoarc; b=MOfi4KSYhD0XlBA/FXrne+84vHjtORCexiS4CoGFPjk3tpgtpUJUBZ1faGIKcZQctd1DMlIQrD/ZGraufpYheN42IYXgCnoCW/1P83efp7xT8RDB/wUGvEHwpSpF+tgqNXZlksRbNTbTYejp6cBT6MPmRwk5FUxEhZzbVDoAF34= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232413; 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=FcFHTvIehUz+pCAW6d935kvWaFMj2gZMq8dfpZ6OKRU=; b=Ez997igpCPBhGyMmWiBNDbmRi7AdT1307F/JtHuxQgjiWqZ7mss+XZKoa+lxac7ne+kCz8E5xZfVp7Spqpa+lsLUEZfEWFx6rysONW2LbUI5GaJgFGZyJ1eFKyOtWAFQTWyg3ucvL+ZhOhxhNOAXyUlRH2Ylhl0DbZraeLWZWVA= 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 1735232413886959.9662155169793; Thu, 26 Dec 2024 09:00:13 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.863268.1274697 (Exim 4.92) (envelope-from ) id 1tQrDO-000521-Ou; Thu, 26 Dec 2024 17:00:02 +0000 Received: by outflank-mailman (output) from mailman id 863268.1274697; Thu, 26 Dec 2024 17:00:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tQrDO-00051a-Lm; Thu, 26 Dec 2024 17:00:02 +0000 Received: by outflank-mailman (input) for mailman id 863268; Thu, 26 Dec 2024 17:00:01 +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 1tQrDN-0004jO-Ea for xen-devel@lists.xenproject.org; Thu, 26 Dec 2024 17:00:01 +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 d63973b0-c3aa-11ef-99a3-01e77a169b0f; Thu, 26 Dec 2024 17:59:59 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1735232283698320.3434638736318; Thu, 26 Dec 2024 08:58:03 -0800 (PST) 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: d63973b0-c3aa-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1735232287; cv=none; d=zohomail.com; s=zohoarc; b=ijMgNeCTT+xj8yjpmZwQ/fAql3ZKsKdy3Y/i7OEnwbe1A6LLFtJ9Sm2Hoa8Tg9FGEDZqryhIznlzw2QS14sT4Vc69L+q66LCvFXyQ6Xb3zI6C5okVr6yJnwFYELxeFe22ACBu2yaKowy2wX6FSsovfu5pgQOFDXr2QHX0a21P2w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232287; 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=FcFHTvIehUz+pCAW6d935kvWaFMj2gZMq8dfpZ6OKRU=; b=V76opvHZbjx0B5F+qFLAq6tiaVAzp2Cq1LSeQFo/MkjruwH5xEDIHurLraLnl2RppGZvKGcX2vNo1Delfj4BWlfJDYUlgWNJj22sZJC9ozXAnYeXG4eXu3o9rm/imerEtlgIYdnjTMH3elyyJwrq3c/ztmVJDVR1jCJM+podp6w= 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=1735232287; 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=FcFHTvIehUz+pCAW6d935kvWaFMj2gZMq8dfpZ6OKRU=; b=tk8KiUFqogVIv/IkS1BHWxC1p39GfaV9IismgTdSk2RakH4MF2uHp6g2nWdvER2v G3OUBVu/55ow6aoASIk+UQJVmOMITA2p8AmuLJcwgITZUfwJ9sIFf1DOyJgP14sw5VJ VTXCN14kpphecT2SeaULz2s5c4er/Tx6VjOHH+gc= 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 v2 10/15] x86/hyperlaunch: locate dom0 initrd with hyperlaunch Date: Thu, 26 Dec 2024 11:57:35 -0500 Message-Id: <20241226165740.29812-11-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241226165740.29812-1-dpsmith@apertussolutions.com> References: <20241226165740.29812-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: 1735232415643116600 Content-Type: text/plain; charset="utf-8" Look for a subnode of type `multiboot,ramdisk` within a domain node. If found, process the reg property for the MB1 module index. Signed-off-by: Daniel P. Smith --- Changes since v1: - switch to nested else/if - dropped ternary name selection --- xen/arch/x86/domain-builder/fdt.c | 26 +++++++++++++++++++++++ xen/arch/x86/setup.c | 35 +++++++++++++++++-------------- 2 files changed, 45 insertions(+), 16 deletions(-) diff --git a/xen/arch/x86/domain-builder/fdt.c b/xen/arch/x86/domain-builde= r/fdt.c index 1094c8dc8838..27bc37ad45c9 100644 --- a/xen/arch/x86/domain-builder/fdt.c +++ b/xen/arch/x86/domain-builder/fdt.c @@ -119,6 +119,32 @@ static int __init process_domain_node( if ( ret > 0 ) bd->kernel->fdt_cmdline =3D true; } + + continue; + } + else if ( + fdt_node_check_compatible(fdt, node, "multiboot,ramdisk") =3D= =3D 0 ) + { + int idx =3D dom0less_module_node(fdt, node, size_size, address= _size); + if ( idx < 0 ) + { + printk(" failed processing ramdisk module for domain %s\n= ", + name); + return -EINVAL; + } + + if ( idx > bi->nr_modules ) + { + printk(" invalid ramdisk module index for domain node (%d= )\n", + bi->nr_domains); + return -EINVAL; + } + + printk(" ramdisk: boot module %d\n", idx); + bi->mods[idx].type =3D BOOTMOD_RAMDISK; + bd->ramdisk =3D &bi->mods[idx]; + + continue; } } =20 diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 3dd04b9afca7..25ff029ecdda 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1103,7 +1103,7 @@ void asmlinkage __init noreturn __start_xen(void) char *kextra; void *bsp_stack; struct cpu_info *info =3D get_cpu_info(), *bsp_info; - unsigned int initrdidx, num_parked =3D 0; + unsigned int num_parked =3D 0; struct boot_info *bi; unsigned long nr_pages, raw_max_page; int i, j, bytes =3D 0; @@ -2141,22 +2141,25 @@ void asmlinkage __init noreturn __start_xen(void) cpu_has_nx ? XENLOG_INFO : XENLOG_WARNING "Warning: ", cpu_has_nx ? "" : "not "); =20 - /* - * 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 ) + if ( !bi->hyperlaunch_enabled ) { - 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", - initrdidx); + /* + * At this point all capabilities that consume boot modules should= have + * claimed their boot modules. Find the first unclaimed boot modul= e and + * claim it as the initrd ramdisk. Do a second search to see if th= ere are + * any remaining unclaimed boot modules, and report them as unusue= d initrd + * candidates. + */ + unsigned int initrdidx =3D first_boot_module_index(bi, BOOTMOD_UNK= NOWN); + 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_BOO= TMODS ) + printk(XENLOG_WARNING + "Multiple initrd candidates, picking module #%u\n", + initrdidx); + } } =20 /* --=20 2.30.2 From nobody Sat Dec 28 03:46:08 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=1735232431; cv=pass; d=zohomail.com; s=zohoarc; b=Y3C406Tr1fSByGKqCmX1iOPLqassnmGCbZ/D3U4zvpD6Hj+LrIHIF5yM9Ed6AZahc1LEINj4KVOetz6zQ3goadtQt9aeLi/PDu/JZtUrdYILv94CC5m3qnNpDoQuLQTdoQeo1pIw8+Q8kaX8F55Y8ikU85iYlwyAjZFfC0aY1zo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232431; 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=+3VU4l/0ipLKSYE0pW048JWQkTZXYcfFfQtanDIG30U=; b=XGpWTBBAgwxQ31yKfBN9tab3kgnoRmrHTEHNOpza9Rpm/K7+KHqgYXZxzNUAh6BOfnM66P7jpZMmRg/yFJT5UYVZ/iXwa/jmU0mKIl9PeAg4XDBsC2rLQUiefj2X8QidZfEbKEyJ74+leCcVw6QVsrZw2kPRk40sFp+G8PrhNec= 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 1735232431112384.61702605496305; Thu, 26 Dec 2024 09:00:31 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.863269.1274707 (Exim 4.92) (envelope-from ) id 1tQrDX-0005xo-Vf; Thu, 26 Dec 2024 17:00:11 +0000 Received: by outflank-mailman (output) from mailman id 863269.1274707; Thu, 26 Dec 2024 17:00:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tQrDX-0005xh-SW; Thu, 26 Dec 2024 17:00:11 +0000 Received: by outflank-mailman (input) for mailman id 863269; Thu, 26 Dec 2024 17:00:10 +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 1tQrDW-0004jO-KQ for xen-devel@lists.xenproject.org; Thu, 26 Dec 2024 17:00:10 +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 dbdf9205-c3aa-11ef-99a3-01e77a169b0f; Thu, 26 Dec 2024 18:00:08 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1735232285226312.33226760964567; Thu, 26 Dec 2024 08:58:05 -0800 (PST) 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: dbdf9205-c3aa-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1735232289; cv=none; d=zohomail.com; s=zohoarc; b=alYzYrV8sfRXiHHUPlqhlhrlh6i/cb6wtqTfUkTWwlrqacFGbx2fSB9+rC3IF5RJ9z3szvw9Sob4cKBzpn7FgQ0xHT77KpxNcdSqsc3zLjbX9NEjZ6a+KPkVnfVMj87IYjzE3p9RFoYTJQ1Grr8fdGBL9eud6TNbr4HEYN0MRhM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232289; 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=+3VU4l/0ipLKSYE0pW048JWQkTZXYcfFfQtanDIG30U=; b=nzRcXdI0vSxNjSz+XvFb4lTgtxnF56fEYDLlLt2L6GfLarDvp1U09DFjjJydtaRiZhGJXrD2X0Rzo8AgS9T+bzckdArJvZGokoYi4W0HykuvybNw1kWT2xgkUvtoZ99G/FG5z+tkhyAJCXzxVc56uaTGI/gHb+FsEZYdRCF7N4o= 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=1735232289; 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=+3VU4l/0ipLKSYE0pW048JWQkTZXYcfFfQtanDIG30U=; b=QD1XEnj7i2BhFh19jpZHoN32WCt8CZZs4DmM0CwPG6uQUaOrBCBENwbskRjNUXXO r5rqxyMagDb/7vZthgGgmOpT2Pc1E/6m8GMMIJWfMpiNGW5GoGZKG663rLTTi3Pn8FJ lzm49s/eAo38pFIEDJMEytHwvAmPB9+TBKhlWan8= 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?= , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel Subject: [PATCH v2 11/15] x86/hyperlaunch: add domain id parsing to domain config Date: Thu, 26 Dec 2024 11:57:36 -0500 Message-Id: <20241226165740.29812-12-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241226165740.29812-1-dpsmith@apertussolutions.com> References: <20241226165740.29812-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: 1735232433238116600 Content-Type: text/plain; charset="utf-8" Introduce the ability to specify the desired domain id for the domain definition. The domain id will be populated in the domid property of the do= main node in the device tree configuration. Signed-off-by: Daniel P. Smith --- Changes since v1 - coding style changes - moved comment with code movement - updated warning message - unrolled match_fdt_property() --- xen/arch/x86/domain-builder/fdt.c | 63 ++++++++++++++++++++++++++++- xen/arch/x86/setup.c | 5 ++- xen/include/xen/libfdt/libfdt-xen.h | 9 +++++ 3 files changed, 73 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/domain-builder/fdt.c b/xen/arch/x86/domain-builde= r/fdt.c index 27bc37ad45c9..efce0927c645 100644 --- a/xen/arch/x86/domain-builder/fdt.c +++ b/xen/arch/x86/domain-builder/fdt.c @@ -8,6 +8,7 @@ #include =20 #include +#include #include #include =20 @@ -61,10 +62,40 @@ static int __init dom0less_module_index( static int __init process_domain_node( struct boot_info *bi, void *fdt, int dom_node) { - int node; + int node, property; struct boot_domain *bd =3D &bi->domains[bi->nr_domains]; const char *name =3D fdt_get_name(fdt, dom_node, NULL) ?: "unknown"; =20 + fdt_for_each_property_offset(property, fdt, dom_node) + { + const struct fdt_property *prop; + const char *prop_name; + int name_len; + + prop =3D fdt_get_property_by_offset(fdt, property, NULL); + if ( !prop ) + continue; /* silently skip */ + + prop_name =3D fdt_get_string(fdt, fdt32_to_cpu(prop->nameoff), &na= me_len); + + if ( strncmp(prop_name, "domid", name_len) =3D=3D 0 ) + { + uint32_t val =3D DOMID_INVALID; + if ( fdt_prop_as_u32(prop, &val) !=3D 0 ) + { + printk(" failed processing domain id for domain %s\n", na= me); + return -EINVAL; + } + if ( val >=3D DOMID_FIRST_RESERVED ) + { + printk(" invalid domain id for domain %s\n", name); + return -EINVAL; + } + bd->domid =3D (domid_t)val; + printk(" domid: %d\n", bd->domid); + } + } + fdt_for_each_subnode(node, fdt, dom_node) { if ( fdt_node_check_compatible(fdt, node, "multiboot,kernel") =3D= =3D 0 ) @@ -125,7 +156,29 @@ static int __init process_domain_node( else if ( fdt_node_check_compatible(fdt, node, "multiboot,ramdisk") =3D= =3D 0 ) { - int idx =3D dom0less_module_node(fdt, node, size_size, address= _size); + unsigned int idx; + int ret =3D 0; + + if ( bd->ramdisk ) + { + printk(XENLOG_ERR "Duplicate ramdisk module for domain %s)= \n", + name); + continue; + } + + /* Try hyperlaunch property, fall back to dom0less property. */ + if ( hl_module_index(fdt, node, &idx) < 0 ) + { + int address_size =3D fdt_address_cells(fdt, dom_node); + int size_size =3D fdt_size_cells(fdt, dom_node); + + if ( address_size < 0 || size_size < 0 ) + ret =3D -EINVAL; + else + ret =3D dom0less_module_index( + fdt, node, size_size, address_size, &idx); + } + if ( idx < 0 ) { printk(" failed processing ramdisk module for domain %s\n= ", @@ -154,6 +207,12 @@ static int __init process_domain_node( return -EFAULT; } =20 + if ( bd->domid =3D=3D DOMID_INVALID ) + bd->domid =3D get_initial_domain_id(); + else if ( bd->domid !=3D get_initial_domain_id() ) + printk(XENLOG_WARNING + "WARN: Booting without initial domid not supported.\n"); + return 0; } =20 diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 25ff029ecdda..027b224151d1 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1029,8 +1029,9 @@ static struct domain *__init create_dom0(struct boot_= info *bi) if ( iommu_enabled ) dom0_cfg.flags |=3D XEN_DOMCTL_CDF_iommu; =20 - /* Create initial domain. Not d0 for pvshim. */ - bd->domid =3D get_initial_domain_id(); + if ( bd->domid =3D=3D DOMID_INVALID ) + /* Create initial domain. Not d0 for pvshim. */ + 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", bd->domid, PTR_ERR(d)); diff --git a/xen/include/xen/libfdt/libfdt-xen.h b/xen/include/xen/libfdt/l= ibfdt-xen.h index 0e54aeeb6cc2..2057030dda45 100644 --- a/xen/include/xen/libfdt/libfdt-xen.h +++ b/xen/include/xen/libfdt/libfdt-xen.h @@ -28,6 +28,15 @@ static inline int __init fdt_cell_as_u64(const fdt32_t *= cell, uint64_t *val) return 0; } =20 +static inline int __init fdt_prop_as_u32( + const struct fdt_property *prop, uint32_t *val) +{ + if ( !prop || fdt32_to_cpu(prop->len) < sizeof(u32) ) + return -EINVAL; + + return fdt_cell_as_u32((fdt32_t *)prop->data, val); +} + static inline int __init fdt_get_prop_by_offset( const void *fdt, int node, const char *name, unsigned long *offset) { --=20 2.30.2 From nobody Sat Dec 28 03:46:08 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=1735232445; cv=pass; d=zohomail.com; s=zohoarc; b=gRKbbkrC/hS6aUqZzuIf5+EGteWjFINTvce5N8g36dIrYQgg68//5zqYLOSg0eSUjkGVfXslWl+ikLwU57itchJpw/UPrW7vKyPnwrHLaMls+yj+bmv8ifxo4y5GH6fWqYFZ3yiBzfiwqeNdNxKEPhr7XN3ncEQ0N/xa32pAcB8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232445; 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=ikPFYKTKplN0c3xIGklLy3D15rucauyk9qCtpxMJhbU=; b=C+Zc2SRCNvAD1NVT/XPfSV6fd1MQiRwDdvE0nJVHjRQOLR8IrrmpTOq/bIC4IUaRWIrTjS8p2FFKuFHKW/1rdiBYkK4sLN+4IAnpVPr9doW32wcuNVSK/+xzy10iGy4pwzJDo3dV90JtmCTAtCnuVRr9w9bHgXa/w6kfrm0aZYQ= 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 1735232445548512.181546320241; Thu, 26 Dec 2024 09:00:45 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.863282.1274721 (Exim 4.92) (envelope-from ) id 1tQrDq-0006jA-LW; Thu, 26 Dec 2024 17:00:30 +0000 Received: by outflank-mailman (output) from mailman id 863282.1274721; Thu, 26 Dec 2024 17:00:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tQrDq-0006hh-GQ; Thu, 26 Dec 2024 17:00:30 +0000 Received: by outflank-mailman (input) for mailman id 863282; Thu, 26 Dec 2024 17:00:28 +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 1tQrDo-0004jO-NU for xen-devel@lists.xenproject.org; Thu, 26 Dec 2024 17:00:28 +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 e6b3e858-c3aa-11ef-99a3-01e77a169b0f; Thu, 26 Dec 2024 18:00:26 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1735232286454203.59311331231754; Thu, 26 Dec 2024 08:58:06 -0800 (PST) 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: e6b3e858-c3aa-11ef-99a3-01e77a169b0f ARC-Seal: i=1; a=rsa-sha256; t=1735232291; cv=none; d=zohomail.com; s=zohoarc; b=P90n+tIGktjv3xZShWRRrejWe/HJ6Rq81+5MAzWjf9QaxZjbsE5AKH84oZCodLG8s8iQwi0iN3G/NV47C8QycNZslrDj8VWHbp8TcyHp3ucqO+1xoar4N+glIKcvFus71uKR+DGovv0z2x31FOXpNA7XcTgMseX7v36cW/Xx51s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232291; 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=ikPFYKTKplN0c3xIGklLy3D15rucauyk9qCtpxMJhbU=; b=hszDpf2JJ7VQsMetB8M3LK4UkCP7rsdCzPhMvW9lH4nmDvXQ8rGVyfwWSBEILOdnDvfOTVlby897VvbkEZuDBjEm2jo9axjKqMSc8WpQ+IMsn2C7Bnjb3cjrH38ehsTvQBIWj/WxIEXaI+ne5BTYpGI/QfjW4fmK3nweO9ekMts= 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=1735232291; 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=ikPFYKTKplN0c3xIGklLy3D15rucauyk9qCtpxMJhbU=; b=WcLEIFqT/hmgAmgcDIFeNGS7LXsVWtVTuISeySL3HCrzavpdsRatHARQN56uW2Xl lMHIEp1in7R+G+R1Yb57fXRaqh+xsSJE63MI3oBalPkkxOEDo5LLKUPtCKgyVwd+RHe NPQYWLCXGDUazPgahpK1aoTp21XbqiKcneG61qUo= 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 v2 12/15] x86/hyperlaunch: specify dom0 mode with device tree Date: Thu, 26 Dec 2024 11:57:37 -0500 Message-Id: <20241226165740.29812-13-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241226165740.29812-1-dpsmith@apertussolutions.com> References: <20241226165740.29812-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: 1735232447411116600 Content-Type: text/plain; charset="utf-8" Enable selecting the mode in which the domain will be built and ran. This includes: - whether it will be either a 32/64 bit domain - if it will be run as a PV or HVM domain - and if it will require a device model (not applicable for dom0) In the device tree, this will be represented as a bit map that will be carr= ied through into struct boot_domain. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v1: - switched to nested else if - dropped ternary op for reporting domain name - switch to strncmp for the check for mode prop - drop BUILD_MODE_LONG until PV construction series --- xen/arch/x86/domain-builder/fdt.c | 19 +++++++++++++++++++ xen/arch/x86/include/asm/bootdomain.h | 5 +++++ xen/arch/x86/setup.c | 3 ++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/domain-builder/fdt.c b/xen/arch/x86/domain-builde= r/fdt.c index efce0927c645..db584ba78e92 100644 --- a/xen/arch/x86/domain-builder/fdt.c +++ b/xen/arch/x86/domain-builder/fdt.c @@ -94,6 +94,25 @@ static int __init process_domain_node( bd->domid =3D (domid_t)val; printk(" domid: %d\n", bd->domid); } + else if ( strncmp(prop_name, "mode", name_len) =3D=3D 0 ) + { + if ( fdt_prop_as_u32(prop, &bd->mode) !=3D 0 ) + { + printk(" failed processing mode for domain %s\n", name); + return -EINVAL; + } + + printk(" mode: "); + if ( !(bd->mode & BUILD_MODE_PARAVIRT) ) + { + if ( bd->mode & BUILD_MODE_ENABLE_DM ) + printk("HVM\n"); + else + printk("PVH\n"); + } + else + printk("PV\n"); + } } =20 fdt_for_each_subnode(node, fdt, dom_node) diff --git a/xen/arch/x86/include/asm/bootdomain.h b/xen/arch/x86/include/a= sm/bootdomain.h index 101a0c643d74..5918aaf6bb63 100644 --- a/xen/arch/x86/include/asm/bootdomain.h +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -15,6 +15,11 @@ struct boot_domain { =20 domid_t domid; =20 + /* On | Off */ +#define BUILD_MODE_PARAVIRT (1 << 0) /* PV | PVH/HVM */ +#define BUILD_MODE_ENABLE_DM (1 << 1) /* HVM | PVH */ + uint32_t mode; + struct boot_module *kernel; struct boot_module *ramdisk; =20 diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 027b224151d1..a87e122b5a61 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1016,7 +1016,8 @@ static struct domain *__init create_dom0(struct boot_= info *bi) struct boot_domain *bd =3D &bi->domains[0]; struct domain *d; =20 - if ( opt_dom0_pvh ) + if ( opt_dom0_pvh || + (bi->hyperlaunch_enabled && !(bd->mode & BUILD_MODE_PARAVIRT)) ) { dom0_cfg.flags |=3D (XEN_DOMCTL_CDF_hvm | ((hvm_hap_supported() && !opt_dom0_shadow) ? --=20 2.30.2 From nobody Sat Dec 28 03:46:08 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=1735232450; cv=pass; d=zohomail.com; s=zohoarc; b=h8fXo51jbBTUFM9kwenD0O7+2u1klDsKLuiuHb0YnMMvUOYzZeyVM/I4EP5RsSYVtToCyn/J90GMkRfya7khcKBTyvzYdK5vBbSmKRQ9G59DQk58K4qlYKjdR+UpFcjQ/DjtvsdV9NVq3Wgtm6x4CMyhhRWPqi2LAniaYpD0G54= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232450; 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=8524a/8T2VisnHlwnmnufZLPjAccP9s5FDSrPRklWJU=; b=Qa2ugq2I81FRzFsKYF9j01mHBOgdeDd6lMNe9vYEoJPw9ZbKm+UhESYfOrGgGSrj35N0co3yXdZXYNtVzk2mNd+40iWCxD6h+6J9e+D9qujlFDbXJTO3VLj42U35Xiz8rQQfU0tTM/N7MUDgIDm/sfEJExWOSPE94n4/0qLBl5s= 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 1735232450008737.7651333900169; Thu, 26 Dec 2024 09:00:50 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.863289.1274737 (Exim 4.92) (envelope-from ) id 1tQrDy-0007QO-S8; Thu, 26 Dec 2024 17:00:38 +0000 Received: by outflank-mailman (output) from mailman id 863289.1274737; Thu, 26 Dec 2024 17:00: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 1tQrDy-0007QH-Ot; Thu, 26 Dec 2024 17:00:38 +0000 Received: by outflank-mailman (input) for mailman id 863289; Thu, 26 Dec 2024 17:00: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 1tQrDw-0005x0-Q3 for xen-devel@lists.xenproject.org; Thu, 26 Dec 2024 17:00:36 +0000 Received: from sender4-of-o51.zoho.com (sender4-of-o51.zoho.com [136.143.188.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ec3fc082-c3aa-11ef-a0da-8be0dac302b0; Thu, 26 Dec 2024 18:00:36 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1735232287974875.2271421466353; Thu, 26 Dec 2024 08:58:07 -0800 (PST) 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: ec3fc082-c3aa-11ef-a0da-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1735232292; cv=none; d=zohomail.com; s=zohoarc; b=lAfxM47CKcNwo4zgMtfQIL0ekyx8y0H3HohdlAJPDAILxbXBPRpE3PTCGlhQzaVaT+i7NisTLOBkKsncLw3pvwmeY0TuZZXw/CamRAK+Wz/vI6P3JWrpVOTddWWfIq+fq16+EMgYaYoxU6HiaN5rifigzy2cwgX0EbsvogqCLm4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232292; 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=8524a/8T2VisnHlwnmnufZLPjAccP9s5FDSrPRklWJU=; b=grdtl4e00u6mpMKVSsKSXPCRD5OvNa3Cmdz5d3E+ukF5kkKJlkyCxy0+/5gCaM4lNsKHw0QbZSA4Md9pKUCrqHqy/YwFZJMHCPwOvd295RDe+vkDHD7v7aolusBenIuqC3G/jsOFDSgKirLbR8YrjORb1kfn93RZ6BZ3Q+OmM38= 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=1735232292; 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=8524a/8T2VisnHlwnmnufZLPjAccP9s5FDSrPRklWJU=; b=sM3x+Hf8Y8Y0OT2ykY+7cIpkwCJjMLni+j/bLu1vkYVpiBNCjpd1y/aTuJQESi0P mPwXw1/3oP7IAiJipG4RUCa1pBBcMlWBDCjnLUJG/WPYCogZHXLYM2YIMW2NEg676bU h2xM5aqWria8jaPJz9MyypPV0pFu0C+zLigp3s4g= 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?= , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel Subject: [PATCH v2 13/15] x86/hyperlaunch: add memory parsing to domain config Date: Thu, 26 Dec 2024 11:57:38 -0500 Message-Id: <20241226165740.29812-14-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241226165740.29812-1-dpsmith@apertussolutions.com> References: <20241226165740.29812-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: 1735232451507116600 Content-Type: text/plain; charset="utf-8" Add three properties, memory, mem-min, and mem-max, to the domain node devi= ce tree parsing to define the memory allocation for a domain. All three fields= are expressed in kb and written as a u64 in the device tree entries. Signed-off-by: Daniel P. Smith --- Changes since v1 - moved common fdt parsing to libfdt - dropped ternary for name selection - swtich over from match_fdt to strncmp - change mem prints to kb --- xen/arch/x86/dom0_build.c | 8 +++++++ xen/arch/x86/domain-builder/fdt.c | 34 +++++++++++++++++++++++++++ xen/arch/x86/include/asm/bootdomain.h | 4 ++++ xen/include/xen/libfdt/libfdt-xen.h | 9 +++++++ 4 files changed, 55 insertions(+) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index c231191faec7..1c3b7ff0e658 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -609,6 +609,14 @@ int __init construct_dom0(struct boot_domain *bd) =20 process_pending_softirqs(); =20 + /* If param dom0_size was not set and HL config provided memory size */ + if ( !get_memsize(&dom0_size, LONG_MAX) && bd->mem_pages ) + dom0_size.nr_pages =3D bd->mem_pages; + if ( !get_memsize(&dom0_min_size, LONG_MAX) && bd->min_pages ) + dom0_size.nr_pages =3D bd->min_pages; + if ( !get_memsize(&dom0_max_size, LONG_MAX) && bd->max_pages ) + dom0_size.nr_pages =3D bd->max_pages; + if ( is_hvm_domain(d) ) rc =3D dom0_construct_pvh(bd); else if ( is_pv_domain(d) ) diff --git a/xen/arch/x86/domain-builder/fdt.c b/xen/arch/x86/domain-builde= r/fdt.c index db584ba78e92..aff1b8c3235d 100644 --- a/xen/arch/x86/domain-builder/fdt.c +++ b/xen/arch/x86/domain-builder/fdt.c @@ -6,6 +6,7 @@ #include #include #include +#include =20 #include #include @@ -113,6 +114,39 @@ static int __init process_domain_node( else printk("PV\n"); } + else if ( strncmp(prop_name, "memory", name_len) =3D=3D 0 ) + { + uint64_t kb; + if ( fdt_prop_as_u64(prop, &kb) !=3D 0 ) + { + printk(" failed processing memory for domain %s\n", name); + return -EINVAL; + } + bd->mem_pages =3D PFN_DOWN(kb * SZ_1K); + printk(" memory: %ld kb\n", kb); + } + else if ( strncmp(prop_name, "mem-min", name_len) =3D=3D 0 ) + { + uint64_t kb; + if ( fdt_prop_as_u64(prop, &kb) !=3D 0 ) + { + printk(" failed processing memory for domain %s\n", name); + return -EINVAL; + } + bd->min_pages =3D PFN_DOWN(kb * SZ_1K); + printk(" min memory: %ld kb\n", kb); + } + else if ( strncmp(prop_name, "mem-max", name_len) =3D=3D 0 ) + { + uint64_t kb; + if ( fdt_prop_as_u64(prop, &kb) !=3D 0 ) + { + printk(" failed processing memory for domain %s\n", name); + return -EINVAL; + } + bd->max_pages =3D PFN_DOWN(kb * SZ_1K); + printk(" max memory: %ld kb\n", kb); + } } =20 fdt_for_each_subnode(node, fdt, dom_node) diff --git a/xen/arch/x86/include/asm/bootdomain.h b/xen/arch/x86/include/a= sm/bootdomain.h index 5918aaf6bb63..d7092bc32ad7 100644 --- a/xen/arch/x86/include/asm/bootdomain.h +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -20,6 +20,10 @@ struct boot_domain { #define BUILD_MODE_ENABLE_DM (1 << 1) /* HVM | PVH */ uint32_t mode; =20 + unsigned long mem_pages; + unsigned long min_pages; + unsigned long max_pages; + struct boot_module *kernel; struct boot_module *ramdisk; =20 diff --git a/xen/include/xen/libfdt/libfdt-xen.h b/xen/include/xen/libfdt/l= ibfdt-xen.h index 2057030dda45..3b653e626842 100644 --- a/xen/include/xen/libfdt/libfdt-xen.h +++ b/xen/include/xen/libfdt/libfdt-xen.h @@ -37,6 +37,15 @@ static inline int __init fdt_prop_as_u32( return fdt_cell_as_u32((fdt32_t *)prop->data, val); } =20 +static inline int __init fdt_prop_as_u64( + const struct fdt_property *prop, uint64_t *val) +{ + if ( !prop || fdt32_to_cpu(prop->len) < sizeof(u64) ) + return -EINVAL; + + return fdt_cell_as_u64((fdt32_t *)prop->data, val); +} + static inline int __init fdt_get_prop_by_offset( const void *fdt, int node, const char *name, unsigned long *offset) { --=20 2.30.2 From nobody Sat Dec 28 03:46:08 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=1735233052; cv=pass; d=zohomail.com; s=zohoarc; b=n8cUC3PtTIjFvonIhvicbSshTvZc+pTAT+iLK9uBQJ+WfzNyEPO8eX8FXfqyXrIIw5G/i2n0Yrmb09o3EbisNDYw2jl5yLD4s6fQlRHZO8Q9Y+1w4ADwbAYZspXBkFCe/6xnkCBRJkGqzjjhiyQBpUnPire8z9RoqL9nfuivhA8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735233052; 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=hXdbAJzSfNTcSeY3krNKNli9zbh1A0XPeYZ31pxiNfM=; b=OLw5MN9zH2+YeehnO6aPWKaNLuI9AuY0vwN180vPjj7sBihpQf3gTwj9BNP8pbNps/v6z/ZO1suO0sBUraY/Miy+kIVgpzEmUfCi+vRfv6ynNu+RTr/JU5CiyNFYwycuDqMMGYw3NSbbIc4tH1l4dMZeSLztencX+Udit/NJbqE= 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 1735233052316933.911003732535; Thu, 26 Dec 2024 09:10:52 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.863332.1274788 (Exim 4.92) (envelope-from ) id 1tQrNX-0003Yh-4R; Thu, 26 Dec 2024 17:10:31 +0000 Received: by outflank-mailman (output) from mailman id 863332.1274788; Thu, 26 Dec 2024 17:10:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tQrNX-0003Ya-09; Thu, 26 Dec 2024 17:10:31 +0000 Received: by outflank-mailman (input) for mailman id 863332; Thu, 26 Dec 2024 17:10:30 +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 1tQrEE-0005x0-Te for xen-devel@lists.xenproject.org; Thu, 26 Dec 2024 17:00:54 +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 f7093153-c3aa-11ef-a0da-8be0dac302b0; Thu, 26 Dec 2024 18:00:54 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 17352322892101014.8069874254229; Thu, 26 Dec 2024 08:58:09 -0800 (PST) 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: f7093153-c3aa-11ef-a0da-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1735232294; cv=none; d=zohomail.com; s=zohoarc; b=bEsb+5V8TjawamDf4z6EdBZYmMuMB8eV7fPNaaqsUTzeVgaDz+pQvztXqs8r6j8ey2D495Jd9DFUjQcv47Pb173T5J1wycjQXE0jjuSKFgCx/5RtiixRofKtLtFPnM9JrEKNDhie4HW03G0U880Gw1bzqp3ubiuXRtLi3taGa80= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232294; 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=hXdbAJzSfNTcSeY3krNKNli9zbh1A0XPeYZ31pxiNfM=; b=KkNlPFMSTV2k0JrSlbRi5SCLP6+BFG2AWtz5PGLF/o4GVKgjMb7wFOczd4h8hjLmrsr/fxS1kmdC9sYhsCdeUalbRqckAL7XHGnpZS3ZfSqVv9Ap7VelpXiYwA3ZOBwHHbhdqqajmuQtHC6tM+tiZd5PX+ZFERXjJiNRxkO/d7Y= 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=1735232294; 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=hXdbAJzSfNTcSeY3krNKNli9zbh1A0XPeYZ31pxiNfM=; b=AHp9SqhMtXqFD/cwJHnmmy7w3dsFJpdG7fYX8NpgqugAiE3wa77MNYfsMaUmG39K EEoquxwGq46Tw4XuicLIogV4X9FfI9NdaMOTtIKbCILQkXynSrZqWm1bsg9MUB5be3R E7KN2YQ3/kU+BnQRaGmzSar8VAgiMYxtPNSXci68= 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 v2 14/15] x86/hyperlaunch: add max vcpu parsing of hyperlaunch device tree Date: Thu, 26 Dec 2024 11:57:39 -0500 Message-Id: <20241226165740.29812-15-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241226165740.29812-1-dpsmith@apertussolutions.com> References: <20241226165740.29812-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: 1735233054488116600 Content-Type: text/plain; charset="utf-8" Introduce the `cpus` property, named as such for dom0less compatibility, th= at represents the maximum number of vpcus to allocate for a domain. In the dev= ice tree, it will be encoded as a u32 value. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v1: - switched from match_fdt to strncmp - switched to nested else if - dropped ternary for name selection --- xen/arch/x86/dom0_build.c | 3 +++ xen/arch/x86/domain-builder/fdt.c | 11 +++++++++++ xen/arch/x86/include/asm/bootdomain.h | 2 ++ 3 files changed, 16 insertions(+) diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 1c3b7ff0e658..7ff052016bfd 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -617,6 +617,9 @@ int __init construct_dom0(struct boot_domain *bd) if ( !get_memsize(&dom0_max_size, LONG_MAX) && bd->max_pages ) dom0_size.nr_pages =3D bd->max_pages; =20 + if ( opt_dom0_max_vcpus_max =3D=3D UINT_MAX && bd->max_vcpus ) + opt_dom0_max_vcpus_max =3D bd->max_vcpus; + if ( is_hvm_domain(d) ) rc =3D dom0_construct_pvh(bd); else if ( is_pv_domain(d) ) diff --git a/xen/arch/x86/domain-builder/fdt.c b/xen/arch/x86/domain-builde= r/fdt.c index aff1b8c3235d..70a793db199b 100644 --- a/xen/arch/x86/domain-builder/fdt.c +++ b/xen/arch/x86/domain-builder/fdt.c @@ -147,6 +147,17 @@ static int __init process_domain_node( bd->max_pages =3D PFN_DOWN(kb * SZ_1K); printk(" max memory: %ld kb\n", kb); } + else if ( strncmp(prop_name, "cpus", name_len) =3D=3D 0 ) + { + uint32_t val =3D UINT_MAX; + if ( fdt_prop_as_u32(prop, &val) !=3D 0 ) + { + printk(" failed processing max_vcpus for domain %s\n", na= me); + return -EINVAL; + } + bd->max_vcpus =3D val; + printk(" max vcpus: %d\n", bd->max_vcpus); + } } =20 fdt_for_each_subnode(node, fdt, dom_node) diff --git a/xen/arch/x86/include/asm/bootdomain.h b/xen/arch/x86/include/a= sm/bootdomain.h index d7092bc32ad7..1a15273043f5 100644 --- a/xen/arch/x86/include/asm/bootdomain.h +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -24,6 +24,8 @@ struct boot_domain { unsigned long min_pages; unsigned long max_pages; =20 + unsigned int max_vcpus; + struct boot_module *kernel; struct boot_module *ramdisk; =20 --=20 2.30.2 From nobody Sat Dec 28 03:46:08 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=1735233095; cv=pass; d=zohomail.com; s=zohoarc; b=hDjXm0DMwYskpwGKR1H67aLXIzzrxcv0wzT8GzDTOZqCPCCIHKWhfTDJXsowLsalm5UznONZTPsl/56T90HjL4EXpjQUZZ91SPkl+vs/v+Tq3Td/vQohHIlXQy8BZ9GYmwtvXNPpTxZtf1BkP0umvYb6XH8hmRT+dFsweTRxgWQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735233095; 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=ZIGHKNiDcj/HqTL/IBZMznrIHbY4YhPeFEesoRFQtNI=; b=ZhhWCdV/IykEk+GLdceQAlnCNZunH+HBYctZnj14yagZsg7g+OtqvONK5dUI3Ywo+FDi9fO6marp+Xflq//EInE8+KAfh3t1yE68bCiMFrYmMgNkO0DNtafgWY8P2/oYg29zaYGJI/htYVbFNurCvz6qqB7cnTgZkwi55Zqnw0s= 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 1735233095867352.6787339135831; Thu, 26 Dec 2024 09:11:35 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.863362.1274797 (Exim 4.92) (envelope-from ) id 1tQrOM-0004im-G8; Thu, 26 Dec 2024 17:11:22 +0000 Received: by outflank-mailman (output) from mailman id 863362.1274797; Thu, 26 Dec 2024 17:11: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 1tQrOM-0004if-DR; Thu, 26 Dec 2024 17:11:22 +0000 Received: by outflank-mailman (input) for mailman id 863362; Thu, 26 Dec 2024 17:11:21 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tQrEM-0005x0-35 for xen-devel@lists.xenproject.org; Thu, 26 Dec 2024 17:01: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 fb622775-c3aa-11ef-a0da-8be0dac302b0; Thu, 26 Dec 2024 18:01:01 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1735232290582938.4677206553228; Thu, 26 Dec 2024 08:58:10 -0800 (PST) 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: fb622775-c3aa-11ef-a0da-8be0dac302b0 ARC-Seal: i=1; a=rsa-sha256; t=1735232296; cv=none; d=zohomail.com; s=zohoarc; b=fTx+RrBVql5Nk7YuBcEIige9Ew7ilaJgqad89L322VysMEZauUppeYqLmTSRtZ4zCd3j1CzQ62u82EFLQBWkXN6it0o86+d4lxZ+uzh8pjqkBO0+aVuMquMCcr9XMFUqM1kFjXc73r8A2mXHtQ62SIkn8moXvlTmQ7p0rTG3Wrs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735232296; 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=ZIGHKNiDcj/HqTL/IBZMznrIHbY4YhPeFEesoRFQtNI=; b=M0qUxiC1ouoi2PAeVimJd5aTTMRAX8BA2WkWIG5VtZSTyMjQxUDHl8a40gGap/KCRMKdPKckGd3cO5DnXSToslconFCgv/i8CWF1etC0KBFeiPRLFpoF9ERH4Oc/2f2LFg8T6Ol9rQ7CxLEPNggxCzOyjkRQhb7eXuESMcs1yMo= 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=1735232296; 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=ZIGHKNiDcj/HqTL/IBZMznrIHbY4YhPeFEesoRFQtNI=; b=dtZ2aAsqfLKFMwAS3FmW2ldAcmpPEHxEeOXqJ3RoFfT7Wg9E0AOzBidWuDvScR/h k4Jblh2ksmWmvaTJA2f1ho+tL/QuFtgFcADDU1JT9+e7Bu3n7hurTGxw3UK6I4Cxw/w wCttHrveFvzbUqybql8BX9WbCtrmEA5B1CoGsN3g= 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 v2 15/15] x86/hyperlaunch: add capabilities to boot domain Date: Thu, 26 Dec 2024 11:57:40 -0500 Message-Id: <20241226165740.29812-16-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241226165740.29812-1-dpsmith@apertussolutions.com> References: <20241226165740.29812-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: 1735233098214116600 Content-Type: text/plain; charset="utf-8" Introduce the ability to assign capabilities to a domain via its definition= in device tree. The first capability enabled to select is the control domain capability. The capability property is a bitfield in both the device tree a= nd `struct boot_domain`. Signed-off-by: Daniel P. Smith Reviewed-by: Jason Andryuk --- Changes since v1: - switch to nested else if - switch from match_fdt to strncmp - drop ternary for name selection - coding style changes --- xen/arch/x86/domain-builder/core.c | 1 + xen/arch/x86/domain-builder/fdt.c | 12 ++++++++++++ xen/arch/x86/include/asm/bootdomain.h | 4 ++++ xen/arch/x86/setup.c | 6 +++++- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/domain-builder/core.c b/xen/arch/x86/domain-build= er/core.c index 91d1b7367e76..589496b6a3e1 100644 --- a/xen/arch/x86/domain-builder/core.c +++ b/xen/arch/x86/domain-builder/core.c @@ -96,6 +96,7 @@ void __init builder_init(struct boot_info *bi) i =3D first_boot_module_index(bi, BOOTMOD_UNKNOWN); bi->mods[i].type =3D BOOTMOD_KERNEL; bi->domains[0].kernel =3D &bi->mods[i]; + bi->domains[0].capabilities |=3D BUILD_CAPS_CONTROL; bi->nr_domains =3D 1; } } diff --git a/xen/arch/x86/domain-builder/fdt.c b/xen/arch/x86/domain-builde= r/fdt.c index 70a793db199b..e90b230eeffe 100644 --- a/xen/arch/x86/domain-builder/fdt.c +++ b/xen/arch/x86/domain-builder/fdt.c @@ -158,6 +158,18 @@ static int __init process_domain_node( bd->max_vcpus =3D val; printk(" max vcpus: %d\n", bd->max_vcpus); } + else if ( strncmp(prop_name, "capabilities", name_len) =3D=3D 0 ) + { + if ( fdt_prop_as_u32(prop, &bd->capabilities) !=3D 0 ) + { + printk(" failed processing domain id for domain %s\n", na= me); + return -EINVAL; + } + printk(" caps: "); + if ( bd->capabilities & BUILD_CAPS_CONTROL ) + printk("c"); + printk("\n"); + } } =20 fdt_for_each_subnode(node, fdt, dom_node) diff --git a/xen/arch/x86/include/asm/bootdomain.h b/xen/arch/x86/include/a= sm/bootdomain.h index 1a15273043f5..67f43c13e905 100644 --- a/xen/arch/x86/include/asm/bootdomain.h +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -15,6 +15,10 @@ struct boot_domain { =20 domid_t domid; =20 +#define BUILD_CAPS_NONE (0) +#define BUILD_CAPS_CONTROL (1 << 0) + uint32_t capabilities; + /* On | Off */ #define BUILD_MODE_PARAVIRT (1 << 0) /* PV | PVH/HVM */ #define BUILD_MODE_ENABLE_DM (1 << 1) /* HVM | PVH */ diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index a87e122b5a61..0fb8572b7145 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1002,6 +1002,7 @@ static size_t __init domain_cmdline_size( static struct domain *__init create_dom0(struct boot_info *bi) { char *cmdline =3D NULL; + unsigned int create_flags =3D 0; struct xen_domctl_createdomain dom0_cfg =3D { .flags =3D IS_ENABLED(CONFIG_TBOOT) ? XEN_DOMCTL_CDF_s3_integrity = : 0, .max_evtchn_port =3D -1, @@ -1033,7 +1034,10 @@ static struct domain *__init create_dom0(struct boot= _info *bi) if ( bd->domid =3D=3D DOMID_INVALID ) /* Create initial domain. Not d0 for pvshim. */ bd->domid =3D get_initial_domain_id(); - d =3D domain_create(bd->domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged= ); + if ( bd->capabilities & BUILD_CAPS_CONTROL ) + create_flags |=3D CDF_privileged; + d =3D domain_create(bd->domid, &dom0_cfg, + pv_shim ? 0 : create_flags); if ( IS_ERR(d) ) panic("Error creating d%u: %ld\n", bd->domid, PTR_ERR(d)); =20 --=20 2.30.2