From nobody Thu Dec 26 21:10:13 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=1732386107; cv=pass; d=zohomail.com; s=zohoarc; b=dJ5aqsYM9ThlUTGEtb7D2A+BSecDrqnW/zqLTHQ3N8VxpR3xQuvTI/pQjPxlEezpafqOoENsDEBLwcYBjn7LJB+lpRYze0GJd1hl0aJUOE/XxDP5jJ0dwbV6UHGPKpvBQAEOnnwNwZOqXH/RpbksdSdTDsGE2fTjpR+L7FkjWXM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386107; 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=M7ik0aSzKPd3BJHMKYDz05cECtsesKuj5O3Ckc6jgOI=; b=hJ/W0QXm08ukh2nPzw8Dmd9TRk33QON0dz+EU/nc9fSuUtLHIIHmrS4fvsGqXFCIJbleiYXnS0rb0YOUxJbI6e36gg29v7WyFUcg/4hYKJU+eIYHWgLeNvgkuSV3BcN7VJdwqGtTM5e579YkWdvFd/R4LMqIfSO4cqecMp14t3g= 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 1732386107534204.2899092491191; Sat, 23 Nov 2024 10:21:47 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.842121.1257543 (Exim 4.92) (envelope-from ) id 1tEul1-000651-J2; Sat, 23 Nov 2024 18:21:23 +0000 Received: by outflank-mailman (output) from mailman id 842121.1257543; Sat, 23 Nov 2024 18:21:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tEul1-00064u-FE; Sat, 23 Nov 2024 18:21:23 +0000 Received: by outflank-mailman (input) for mailman id 842121; Sat, 23 Nov 2024 18:21:22 +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 1tEul0-0005pL-Jp for xen-devel@lists.xenproject.org; Sat, 23 Nov 2024 18:21:22 +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 badd0d31-a9c7-11ef-99a3-01e77a169b0f; Sat, 23 Nov 2024 19:21:18 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1732386053316340.2128762400505; Sat, 23 Nov 2024 10:20: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: badd0d31-a9c7-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6ImJhZGQwZDMxLWE5YzctMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMyMzg2MDc4Ljk3ODE3Miwic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1732386057; cv=none; d=zohomail.com; s=zohoarc; b=gIkAybyGGgWyc6umRoRbvZTAKVhMfEJcebmS9OHYeFLPXUpjP8wOomQrZWAMCR02A7BLyEVzob1xcuWTVzzw5nqXLvWXzz84cXWaw37PTPtELauvB0iSDzMwXzQN2idYXBn2zhHSCLY0sxRi0mrYuQZcVUcs3XFtonLCiINgoHA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386057; 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=M7ik0aSzKPd3BJHMKYDz05cECtsesKuj5O3Ckc6jgOI=; b=ah5rvWfHS8BpdbspXOS5Hljr1Nd22/AsN8W43IRtkhql2whVluUmWXz4u29CaOQCmLN98oDPGod9ZupKc6GyRE9NNCs/EuwGDuOfKYBHzn4IPMhyXxnxXXNhP0svV2rknZFaws+n9CxCk0WIEyw60shltSgHAjl1j+jWLKSBPNE= 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=1732386057; 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=M7ik0aSzKPd3BJHMKYDz05cECtsesKuj5O3Ckc6jgOI=; b=MO187BFOEfivCgIzO/ESTHGOMXBN4URPneHKSYgOhHBIDwVU2cGLYEI86cQKRmW7 wGL8iuwRg0qhdyqccHeePK4wiwSVJOuJdG+b20PzcsdzLaeOTwYd+0J1Om1tnYCYu6u rywHp7kcaVs1FWMFfmjnIK1yUtsVg6NiL8G2bILI= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 01/15] x86/boot: introduce boot domain Date: Sat, 23 Nov 2024 13:20:30 -0500 Message-Id: <20241123182044.30687-2-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241123182044.30687-1-dpsmith@apertussolutions.com> References: <20241123182044.30687-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: 1732386109825116600 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 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 | 17 +++++---------- xen/arch/x86/include/asm/bootdomain.h | 31 +++++++++++++++++++++++++++ xen/arch/x86/include/asm/bootinfo.h | 5 +++++ xen/arch/x86/include/asm/dom0_build.h | 6 +++--- xen/arch/x86/include/asm/setup.h | 4 ++-- xen/arch/x86/pv/dom0_build.c | 24 +++++++-------------- xen/arch/x86/setup.c | 24 +++++++++------------ 8 files changed, 69 insertions(+), 50 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..a9384af14304 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -1301,26 +1301,19 @@ static void __hwdom_init pvh_setup_mmcfg(struct dom= ain *d) } } =20 -int __init dom0_construct_pvh(struct boot_info *bi, struct domain *d) +int __init dom0_construct_pvh(struct boot_domain *bd) { paddr_t entry, start_info; - struct boot_module *image; - struct boot_module *initrd =3D NULL; - unsigned int idx; + struct boot_module *image =3D bd->kernel; + struct boot_module *initrd =3D bd->ramdisk; + struct domain *d =3D bd->d; int rc; =20 printk(XENLOG_INFO "*** Building a PVH Dom%d ***\n", d->domain_id); =20 - idx =3D first_boot_module_index(bi, BOOTMOD_KERNEL); - if ( idx >=3D bi->nr_modules ) + if ( image =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) ) { /* diff --git a/xen/arch/x86/include/asm/bootdomain.h b/xen/arch/x86/include/a= sm/bootdomain.h new file mode 100644 index 000000000000..12c19ab37bd8 --- /dev/null +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (c) 2024 Apertus Solutions, LLC + * Author: Daniel P. Smith + * Copyright (c) 2024 Christopher Clark + */ + +#ifndef __XEN_X86_BOOTDOMAIN_H__ +#define __XEN_X86_BOOTDOMAIN_H__ + +struct boot_module; +struct domain; + +struct boot_domain { + struct boot_module *kernel; + struct boot_module *ramdisk; + + struct domain *d; +}; + +#endif + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index 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 d8661d7ca699..460157def8ea 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -977,16 +977,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 ) { @@ -1013,11 +1006,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. */ @@ -1039,10 +1032,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; @@ -1249,6 +1243,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 ) { @@ -2110,6 +2105,7 @@ void asmlinkage __init noreturn __start_xen(void) if ( initrdidx < MAX_NR_BOOTMODS ) { bi->mods[initrdidx].type =3D BOOTMOD_RAMDISK; + bi->domains[0].ramdisk =3D &bi->mods[initrdidx]; if ( first_boot_module_index(bi, BOOTMOD_UNKNOWN) < MAX_NR_BOOTMOD= S ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", --=20 2.30.2 From nobody Thu Dec 26 21:10:13 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=1732386108; cv=pass; d=zohomail.com; s=zohoarc; b=J8T9on4QTs1FUI8S5D4ApRMZutlZ4LmbAwVETa6oFTa0VL2+P58gDzDwQl97EUr7KmUmQ/H7HwoYb/VPpbCarzUkyIQPuCokHwr73d//EWKQiDYBGkZnSaxaO1vhYxeyJDW1yH95iwYG8X46OqNnz+hu3X67ODzUuLywNouvhjU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386108; 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=GLAmJCFT18dTLQQRusDt7pLXOrCOqVBeVV2VQ8odAtI=; b=jdfIxMk5I+ALU0XcahE6H7tqERe3FgpcYlswFgYpUNUG97Dd5R01K9O9/L7jBsA0VQ36QetfvEQdFY0A9R8Q3IhKkTbnoF7X1rIR7j5uH5prXP6ld43GRmI1XZvfNswILxvqqapbOW8beKJyKP9q4ZDvEblgGjVa+KMUH85sYhI= 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 1732386108942525.371612920541; Sat, 23 Nov 2024 10:21:48 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.842124.1257553 (Exim 4.92) (envelope-from ) id 1tEulE-0006SW-PH; Sat, 23 Nov 2024 18:21:36 +0000 Received: by outflank-mailman (output) from mailman id 842124.1257553; Sat, 23 Nov 2024 18:21:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tEulE-0006SP-MN; Sat, 23 Nov 2024 18:21:36 +0000 Received: by outflank-mailman (input) for mailman id 842124; Sat, 23 Nov 2024 18:21:35 +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 1tEulD-0005pL-As for xen-devel@lists.xenproject.org; Sat, 23 Nov 2024 18:21:35 +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 c2b5ba2c-a9c7-11ef-99a3-01e77a169b0f; Sat, 23 Nov 2024 19:21:31 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1732386055104491.61463410551505; Sat, 23 Nov 2024 10:20: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: c2b5ba2c-a9c7-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6ImMyYjViYTJjLWE5YzctMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMyMzg2MDkyLjAwODkwOSwic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1732386059; cv=none; d=zohomail.com; s=zohoarc; b=K1uAHTeIGO53ndbxGR7cK3NhvO+SlT0YVCMHCF/6G4dQGk0stnrh82Fb3T1qksxCO0/NTDxgdUc+A9jShaYCesweNCaQ181aebLdEM+++gSnXTfFWAWYeIfTnK5fyNKCU56BIFJ8/8+1B6lsl1+EYVQx9IrP18FkDDHwghuaUGQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386059; 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=GLAmJCFT18dTLQQRusDt7pLXOrCOqVBeVV2VQ8odAtI=; b=cJp0c6uC6f9nfJP5dgY43HBqatEJ0qg8ZBFKOfL8VOMyE/hj/lQC7lMjDqzW/bHmudXnT4mOAa9mVkqFVKRLr8Br0b11119ttDajioKmBmhr0/U/mX30/NZ6jhKaI7QduZhSDi7JChJSS4PS5T8nzZWcPltFx5o9B9rGjIozNy0= 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=1732386059; 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=GLAmJCFT18dTLQQRusDt7pLXOrCOqVBeVV2VQ8odAtI=; b=VLMLQ98dtFyNI0B5nEKpGCmeOPnUdRMmOWSidv9KwJX+Y6tmWvULyeji/8Vsuvco TuAL9LKgjV3YLCt+hqlCjIWVgzJdp3T049lHVaEcdkK1EUERc6JIVtB77eBVtpV3DRW W8ZsB82Z0dmQcL9UdwK+MzA8o0gddX5DdAk9rbJE= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 02/15] x86/boot: introduce domid field to struct boot_domain Date: Sat, 23 Nov 2024 13:20:31 -0500 Message-Id: <20241123182044.30687-3-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241123182044.30687-1-dpsmith@apertussolutions.com> References: <20241123182044.30687-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: 1732386109627116600 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 v9 boot modules - missing include for domid_t def --- xen/arch/x86/include/asm/bootdomain.h | 4 ++++ xen/arch/x86/setup.c | 12 +++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/include/asm/bootdomain.h b/xen/arch/x86/include/a= sm/bootdomain.h index 12c19ab37bd8..bcbf36b13f25 100644 --- a/xen/arch/x86/include/asm/bootdomain.h +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -5,6 +5,8 @@ * Copyright (c) 2024 Christopher Clark */ =20 +#include + #ifndef __XEN_X86_BOOTDOMAIN_H__ #define __XEN_X86_BOOTDOMAIN_H__ =20 @@ -12,6 +14,8 @@ struct boot_module; struct domain; =20 struct boot_domain { + domid_t domid; + struct boot_module *kernel; struct boot_module *ramdisk; =20 diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 460157def8ea..a2178d5e8cc5 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -339,6 +339,9 @@ static struct boot_info *__init multiboot_fill_boot_inf= o( /* Variable 'i' should be one entry past the last module. */ bi->mods[i].type =3D BOOTMOD_XEN; =20 + for ( i =3D 0; i < MAX_NR_BOOTDOMS; i++ ) + bi->domains[i].domid =3D DOMID_INVALID; + return bi; } =20 @@ -979,7 +982,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 ) { @@ -995,15 +997,15 @@ static struct domain *__init create_dom0(struct boot_= info *bi) dom0_cfg.flags |=3D XEN_DOMCTL_CDF_iommu; =20 /* Create initial domain. Not d0 for pvshim. */ - domid =3D get_initial_domain_id(); - d =3D domain_create(domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged); + bd->domid =3D get_initial_domain_id(); + d =3D domain_create(bd->domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged= ); if ( IS_ERR(d) ) - panic("Error creating d%u: %ld\n", domid, PTR_ERR(d)); + panic("Error creating d%u: %ld\n", bd->domid, PTR_ERR(d)); =20 init_dom0_cpuid_policy(d); =20 if ( alloc_dom0_vcpu0(d) =3D=3D NULL ) - panic("Error creating d%uv0\n", domid); + panic("Error creating d%uv0\n", bd->domid); =20 /* Grab the DOM0 command line. */ if ( bd->kernel->cmdline_pa || bi->kextra ) --=20 2.30.2 From nobody Thu Dec 26 21:10:13 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=1732386120; cv=pass; d=zohomail.com; s=zohoarc; b=nx+nmkR/tNPOKIVrboeEwOrxeovyymEin/g/zbYs+PXBdgx5qaW7GHewsM1oiSjft3sxGiUuzZ9n+bT4ZY52ekZ8edjQytvyoJPJJVDS86BEoZGmXNhDnEpYbZkvHh6L9VMqWBeeiUpTDShfrs/NYSEqQOMJJ+o1mgD/FDqCgW8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386120; 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=I+F0axhJZN1WzppDStYP9VFrjwWkiiTOqoo1NlWCXfk=; b=au8gJXxY8sd4pWa5rWB/OCfHWwsV5uLvvcuDg77hQugatId27WlYI5xp85O8kc/4M0OJRWSFsXCKecKQFqp2Ncxr4PTy0YvvJakcc6Hi7tE5T5HEBzj4EBMZOxDAYLu3HoHasYLsqr+Q33qMY/g2vAlVhwWn7QvQSYLazlmDulo= 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 1732386120372135.27056661496204; Sat, 23 Nov 2024 10:22:00 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.842130.1257562 (Exim 4.92) (envelope-from ) id 1tEulP-0006xs-04; Sat, 23 Nov 2024 18:21:47 +0000 Received: by outflank-mailman (output) from mailman id 842130.1257562; Sat, 23 Nov 2024 18:21:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tEulO-0006xl-TK; Sat, 23 Nov 2024 18:21:46 +0000 Received: by outflank-mailman (input) for mailman id 842130; Sat, 23 Nov 2024 18:21:45 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tEulN-0006MT-Oc for xen-devel@lists.xenproject.org; Sat, 23 Nov 2024 18:21: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 c946c568-a9c7-11ef-a0cc-8be0dac302b0; Sat, 23 Nov 2024 19:21:42 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1732386056772694.2528303649441; Sat, 23 Nov 2024 10:20: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: c946c568-a9c7-11ef-a0cc-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6ImM5NDZjNTY4LWE5YzctMTFlZi1hMGNjLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyMzg2MTAyLjk1MjAxMywic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1732386061; cv=none; d=zohomail.com; s=zohoarc; b=nI9yP9H+KknU1cIqdsrbidXbV1o40VvzQL3RE4LJI+Fr5xGAhl7MZWvJvgPIYKxSNfJipf9pA4qKnV0ux7TlWHJmMH4O7HN6pT3rJg2TAocrbNlhWUjGJMmda07mLANZOs0d4Ioe+xX2dlmTCh85cIk+8M4YuezMk/exDcwrT2U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386061; 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=I+F0axhJZN1WzppDStYP9VFrjwWkiiTOqoo1NlWCXfk=; b=YiqmIjUKSJaCs2BEEjAkEfs99nKq0ZpZlq+pvoIFthNAWQ7EsPx6axFdGDc6Ltd9DGIHSNsZ6VEcAA3u4g4RjslLYG90ZhIYRZqEGCCyTawF55siXX+f+vggXRWNKp/E/e5xHGxmNTf2X9+owvq0jq4uUP/RYGH0MBZkmirTvJc= 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=1732386061; 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=I+F0axhJZN1WzppDStYP9VFrjwWkiiTOqoo1NlWCXfk=; b=d6V8YTvs5eP4xhtYlkBLMJpwEM0w4OCwmAha/7+q2Y0nMvaSXAa54KvO+fhbeaWg QhB7WMkB6QV1/iLi3288NIdoBGXApKIOC6sfChEP4zoxYrqe9opynyY6O8ePBuGpbCv i6MPKMiFaSuN6Qc1g7vK/ghCOWKZpbETZqqf7EIo= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 03/15] x86/boot: add cmdline to struct boot_domain Date: Sat, 23 Nov 2024 13:20:32 -0500 Message-Id: <20241123182044.30687-4-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241123182044.30687-1-dpsmith@apertussolutions.com> References: <20241123182044.30687-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: 1732386123964116600 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 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 | 12 +++--- xen/arch/x86/include/asm/bootdomain.h | 2 + xen/arch/x86/pv/dom0_build.c | 4 +- xen/arch/x86/setup.c | 54 ++++++++++++++++++++++----- 4 files changed, 54 insertions(+), 18 deletions(-) diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index a9384af14304..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; @@ -1304,14 +1306,12 @@ static void __hwdom_init pvh_setup_mmcfg(struct dom= ain *d) int __init dom0_construct_pvh(struct boot_domain *bd) { paddr_t entry, start_info; - struct boot_module *image =3D bd->kernel; - struct boot_module *initrd =3D bd->ramdisk; struct domain *d =3D bd->d; int rc; =20 printk(XENLOG_INFO "*** Building a PVH Dom%d ***\n", d->domain_id); =20 - if ( image =3D=3D NULL ) + if ( bd->kernel =3D=3D NULL ) panic("Missing kernel boot module for %pd construction\n", d); =20 if ( is_hardware_domain(d) ) @@ -1351,7 +1351,7 @@ int __init dom0_construct_pvh(struct boot_domain *bd) 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 index bcbf36b13f25..ffda1509a63f 100644 --- a/xen/arch/x86/include/asm/bootdomain.h +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -14,6 +14,8 @@ struct boot_module; struct domain; =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 a2178d5e8cc5..e6580382d247 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -965,10 +965,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; + + return s; +} =20 +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, @@ -1008,19 +1027,30 @@ 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 ) { + size_t cmdline_size =3D domain_cmdline_size(bi, bd); + + if ( cmdline_size =3D=3D 0 ) + goto skip_cmdline; + + if ( !(cmdline =3D xzalloc_array(char, cmdline_size)) ) + panic("Error allocating cmdline buffer for %pd\n", d); + if ( bd->kernel->cmdline_pa ) - safe_strcpy(cmdline, - cmdline_cook(__va(bd->kernel->cmdline_pa), bi->loa= der)); + strlcpy(cmdline, + cmdline_cook(__va(bd->kernel->cmdline_pa),bi->loader), + cmdline_size); =20 if ( bi->kextra ) /* kextra always includes exactly one leading space. */ - safe_strcat(cmdline, bi->kextra); + strlcat(cmdline, bi->kextra, cmdline_size); =20 /* Append any extra parameters. */ if ( skip_ioapic_setup && !strstr(cmdline, "noapic") ) - safe_strcat(cmdline, " noapic"); + strlcat(cmdline, " noapic", cmdline_size); =20 if ( (strlen(acpi_param) =3D=3D 0) && acpi_disabled ) { @@ -1030,17 +1060,21 @@ static struct domain *__init create_dom0(struct boo= t_info *bi) =20 if ( (strlen(acpi_param) !=3D 0) && !strstr(cmdline, "acpi=3D") ) { - safe_strcat(cmdline, " acpi=3D"); - safe_strcat(cmdline, acpi_param); + strlcat(cmdline, " acpi=3D", cmdline_size); + strlcat(cmdline, acpi_param, cmdline_size); } =20 - bd->kernel->cmdline_pa =3D __pa(cmdline); + bd->cmdline =3D cmdline; } =20 + skip_cmdline: bd->d =3D d; if ( construct_dom0(bd) !=3D 0 ) panic("Could not construct domain 0\n"); =20 + if ( cmdline ) + xfree(cmdline); + return d; } =20 --=20 2.30.2 From nobody Thu Dec 26 21:10:13 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=1732386130; cv=pass; d=zohomail.com; s=zohoarc; b=fQrx72P5sqqeHnT6Gu0ZkrKao25mLvJsBNo27BWVSFfZVdnK09329YgxzrV2ai4KttBJ77XiUykSUYG3EZTkQOa636d1HXnja5uw68Rve+/aXCQq3D6/Ft5CG9d+3hhzqSjb12dKr/mA4JJzyDrGzcI+mQDeMoSwKwfm5GfAhAA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386130; 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=7kQp6O2mc6cHBoZxlvkzYOcwjpPdg5e+ctsTL3O8uUc=; b=DAYBXJhBletfSid8IuWm/GzecJHfUFnru3G3y5pFylea27th8SUTKNtzeINuONB9MBh7+W6TB1plKkRyDUaBT+cJ1/myHBOJ9aacIPBoI70uX4EXu1vk8PVpwHroq0azRPt+jACGekrICjtiDJ0tSlZybaT1s27W3mVOv1vnvf8= 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 1732386130174115.4230900002027; Sat, 23 Nov 2024 10:22:10 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.842135.1257573 (Exim 4.92) (envelope-from ) id 1tEulY-0007QZ-CF; Sat, 23 Nov 2024 18:21:56 +0000 Received: by outflank-mailman (output) from mailman id 842135.1257573; Sat, 23 Nov 2024 18:21:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tEulY-0007QO-82; Sat, 23 Nov 2024 18:21:56 +0000 Received: by outflank-mailman (input) for mailman id 842135; Sat, 23 Nov 2024 18:21:54 +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 1tEulW-0006MT-CX for xen-devel@lists.xenproject.org; Sat, 23 Nov 2024 18:21: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 ceeccf12-a9c7-11ef-a0cc-8be0dac302b0; Sat, 23 Nov 2024 19:21:52 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1732386058592745.5673185331648; Sat, 23 Nov 2024 10:20:58 -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: ceeccf12-a9c7-11ef-a0cc-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6ImNlZWNjZjEyLWE5YzctMTFlZi1hMGNjLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyMzg2MTEyLjU2Mjg1LCJzZW5kZXIiOiJkcHNtaXRoQGFwZXJ0dXNzb2x1dGlvbnMuY29tIiwicmVjaXBpZW50IjoieGVuLWRldmVsQGxpc3RzLnhlbnByb2plY3Qub3JnIn0= ARC-Seal: i=1; a=rsa-sha256; t=1732386062; cv=none; d=zohomail.com; s=zohoarc; b=SnFo088t2rfUVSWrOoGKtu1gmKKaiQm9jnSngpa10SC2uFNfMP6eh2Ijhg4M1QzZ4eZA0RRvWK9Ha996hzzUq4Wz7xnIyQ7voOwqJGdqapAb7y1TOn1juJwX92F3+W2jBfFjyQWSfhR19OBSYZafPkwMuwj1hA+Jl3CoWsL6wJA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386062; 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=7kQp6O2mc6cHBoZxlvkzYOcwjpPdg5e+ctsTL3O8uUc=; b=aIKQMKIxIOGZ7cnv7741xU4l+9Ty3TFGW0RPn3m2kC01WEJK8DOwEL/ANY9tX7clAEc5pd/qcNWTuKHKm3zvqDuTF19mqktmmZiVOKBEN9j9g8VxPImkUhJuMtGzMEf40bp2HNlSXivt9r/YJESA/vYu24l3/kBq21pzKrpWEPA= 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=1732386062; 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=7kQp6O2mc6cHBoZxlvkzYOcwjpPdg5e+ctsTL3O8uUc=; b=tGgFlmFjTwLuS/GwUqS49R+PuhQxKEw82ykmASFJLgWAiZMfZg09YQKHEJf53o7y Frnd97WcgeQCwWtqF7+qgb3qQQmSTNNfkxjanjRRFON+2puENB5WrMInHGTqEDCwjku hNlqyZqdBa+ecHdkhsY1E7l8J4bmzjs9cpn0sOvo= 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 , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [PATCH 04/15] kconfig: introduce option to independently enable libfdt Date: Sat, 23 Nov 2024 13:20:33 -0500 Message-Id: <20241123182044.30687-5-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241123182044.30687-1-dpsmith@apertussolutions.com> References: <20241123182044.30687-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: 1732386131663116600 Content-Type: text/plain; charset="utf-8" Currently the inclusion of libfdt is controlled by the CONFIG_HAS_DEVICE_TR= EE kconfig flag. This flag also changes behvaior 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 --- 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 90268d92499a..5c592dbdc703 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -53,8 +53,12 @@ config HAS_ALTERNATIVE config HAS_COMPAT bool =20 +config LIB_DEVICE_TREE + bool + config HAS_DEVICE_TREE bool + select LIB_DEVICE_TREE =20 config HAS_DIT # Data Independent Timing bool diff --git a/xen/common/Makefile b/xen/common/Makefile index b279b09bfb2b..ff1795de5dda 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -78,7 +78,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 Thu Dec 26 21:10:13 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=1732386661; cv=pass; d=zohomail.com; s=zohoarc; b=IQAK21RIvA7uLge7LMMUvhNXfEGgHl/eXbuvkYOc9Cl4S2MQoB79UJIQ0k8zCbqObY7hzlX4TMzQdA86+1abzkW9SKB25C9EHVu2vTBkAGIfdsBvsj0u7VIwgdhae1syqv0cCp4h4DuDwwZPHltc7vgi6DRNQkFiXtKaGWZWILg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386661; 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=lbJ1kYoT11hAmwZ4EpUrvdMfSFs0q+QjdARR8BxX4a0=; b=NITv2GwltVWoTDeJHlHXGMlbcwX1gC5lRPzSEzsAefFAmxPUSGsGL6UdOQttizvzTGZrb6bx6CO5M1RR4bUhtvxCsQ1oEdei5Uwa1jW4Tit1tqdM7baH/KOoDiVc8VaffbU0YPst1s46d5j81bPzlIDnnI8WAws18yowMZFc3+g= 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 1732386661398456.6785405590384; Sat, 23 Nov 2024 10:31:01 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.842170.1257623 (Exim 4.92) (envelope-from ) id 1tEuu3-0002ij-6a; Sat, 23 Nov 2024 18:30:43 +0000 Received: by outflank-mailman (output) from mailman id 842170.1257623; Sat, 23 Nov 2024 18:30: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 1tEuu3-0002ic-2l; Sat, 23 Nov 2024 18:30:43 +0000 Received: by outflank-mailman (input) for mailman id 842170; Sat, 23 Nov 2024 18:30:41 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tEuln-0006MT-9s for xen-devel@lists.xenproject.org; Sat, 23 Nov 2024 18:22: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 d8eb2951-a9c7-11ef-a0cc-8be0dac302b0; Sat, 23 Nov 2024 19:22:08 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1732386060588445.6400500771855; Sat, 23 Nov 2024 10:21: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: d8eb2951-a9c7-11ef-a0cc-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6ImQ4ZWIyOTUxLWE5YzctMTFlZi1hMGNjLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyMzg2MTI5LjMzMTY5NCwic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1732386064; cv=none; d=zohomail.com; s=zohoarc; b=LuKtf6yGrosFtvb+ZQDDnHtqkFccL6yvnBuL7iLv4HM+7KvvSt/33sBY0MF+skZy/ryyb+b0S+GX3Ka+8TenUsNLvVMZWwP7LvuQoYW7QfGYWpX4TCZS4uxtz53N6O772TeQei+PR8IiXfCGI2NdFzXv+3s7LEY8oJR49PL/NpU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386064; 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=lbJ1kYoT11hAmwZ4EpUrvdMfSFs0q+QjdARR8BxX4a0=; b=HRP2q0nhKt7/tNLQfZkFss67cRQhCbW8x5Z5PQpvaMUZ7r6gKmkQq9QezLKxIyPsp5yfvhyCj5e7jF+HMlb6Z9To/0yeRY5i6BGzk8RVEp5wT/hDe9j35fHskqylWqIwEshmbwIrHILxY23+7Mlr45JdaRGlwPwv2qVwhpH4wIg= 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=1732386064; 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=lbJ1kYoT11hAmwZ4EpUrvdMfSFs0q+QjdARR8BxX4a0=; b=k7Wy/bENWPhRGKEvUdRPIm3xlLwULPPWHkSVOrfQ4QVzm++6BtfUHQw+V8UDJTcV XQl/jMz1DtIqVeS9mxL4Db0RNl52G7/CKN2Oq4hQN6fAyRtkkGxuM82xP+AJIdL52Qu ri/GcnolgcqI1hFaVbETq2B3k7jAcNQm+HJiPh30= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 05/15] kconfig: introduce domain builder config option Date: Sat, 23 Nov 2024 13:20:34 -0500 Message-Id: <20241123182044.30687-6-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241123182044.30687-1-dpsmith@apertussolutions.com> References: <20241123182044.30687-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: 1732386663767116600 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 Reviewed-by: Jason Andryuk --- 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..7be2ec3ed00f --- /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 Thu Dec 26 21:10:13 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=1732386670; cv=pass; d=zohomail.com; s=zohoarc; b=I5gdmGwxMMJ/hjqn9dfOfom8YUxTyMbtW0PrEVrvlW6GX1tzIJ2/KefaaIK7PBq9SDnrAan1Ldb73xMm/eXOgnHdHmOV7S5GCO0Gl948N1Rrhzqn4S7o8r2hkRf5Opo3w1i4sGROyviRCRwpVo1vBhcw8bLHqHpORj7mQ2Ckh+k= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386670; 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=1omJKkP+0j2puNPs37j9yE6XvhKUdiF+dq26Zr7hacg=; b=ZAfy7c2BsEqJuuzDBZIO1XIAniKwLAYOgRMfHdoNcSYntXV0w0xrJnt4SNHUlOHm79dPvd3+xyG+EWBJIfeHx/deZK79bYzQwFZDstVfOVdXjPkS5yaHwfzjW0xkVZt3QBIS2Ur3n0b/Ntt0Qn41xpm2qvwPviKP7DCTOebH5XA= 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 1732386669992220.51278549697577; Sat, 23 Nov 2024 10:31:09 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.842177.1257633 (Exim 4.92) (envelope-from ) id 1tEuu8-0003Gl-Hw; Sat, 23 Nov 2024 18:30:48 +0000 Received: by outflank-mailman (output) from mailman id 842177.1257633; Sat, 23 Nov 2024 18:30:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tEuu8-0003GV-C5; Sat, 23 Nov 2024 18:30:48 +0000 Received: by outflank-mailman (input) for mailman id 842177; Sat, 23 Nov 2024 18:30:48 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tEulw-0006MT-W4 for xen-devel@lists.xenproject.org; Sat, 23 Nov 2024 18:22:20 +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 de2a0ddc-a9c7-11ef-a0cc-8be0dac302b0; Sat, 23 Nov 2024 19:22:17 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1732386062160265.24358577296607; Sat, 23 Nov 2024 10:21: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: de2a0ddc-a9c7-11ef-a0cc-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6ImRlMmEwZGRjLWE5YzctMTFlZi1hMGNjLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyMzg2MTM3LjkzOTA1Mywic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1732386066; cv=none; d=zohomail.com; s=zohoarc; b=H+dMhTBoYUtWdhM3m74cTXrvpda8DA5/1bDAw/EyU2CSeG4YCOd1fGn0JE3nWQM8PpDDsPlTrVSMEaODlz3G4zp+A/WNNUMEFHAcc11r4vZpyI3k6Sy0jVGIOFIDxKG179aeHR+3sNmLRRYcv9Gz5mjgGqpIOnMykBy33Vde7IA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386066; 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=1omJKkP+0j2puNPs37j9yE6XvhKUdiF+dq26Zr7hacg=; b=JeLh95NbMZSpzhJu1hYVvS0go3wyIYJiq7r4po+59ui2I4zwFi2Ig7ygJjemBmUorIVdG3hGrLC+hkmzHd0qUGjKMaJJw3TIQCezXPRaW5C2NmKBE5pyXsyAA11bmH4WSsKJRklnBt/4g8bhIIng0TwcbXIcduV/Puh+K8nIsKM= 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=1732386066; 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=1omJKkP+0j2puNPs37j9yE6XvhKUdiF+dq26Zr7hacg=; b=VWrA8SJwlmdSKe1AfY6ugrp2XtiQtRcPOzsNe8Q7u4THShckrXilzrrLAZVDGDKl +vyuem+zfwY8zZFlxf7LEiOKGigokLImLXbvLkXu8ofMNJ4HTkNZLiDjpKY8BzjmeEQ +O2Tsb2UpWbj3yZUYuxmbrjT99W3xgYkmQnBeby0= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 06/15] x86/hyperlaunch: introduce the domain builder Date: Sat, 23 Nov 2024 13:20:35 -0500 Message-Id: <20241123182044.30687-7-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241123182044.30687-1-dpsmith@apertussolutions.com> References: <20241123182044.30687-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: 1732386671989116600 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 --- xen/arch/x86/Makefile | 2 + xen/arch/x86/domain_builder/Makefile | 3 ++ xen/arch/x86/domain_builder/core.c | 55 ++++++++++++++++++++++++ xen/arch/x86/domain_builder/fdt.c | 38 ++++++++++++++++ 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 | 18 +++++--- 8 files changed, 142 insertions(+), 6 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/Makefile b/xen/arch/x86/Makefile index b35fd5196ce2..45e4c963edcd 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..211359895d84 --- /dev/null +++ b/xen/arch/x86/domain_builder/core.c @@ -0,0 +1,55 @@ +/* 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: + fallthrough; + 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; + } + + } +} + +/* + * 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..3f9dda8c34c3 --- /dev/null +++ b/xen/arch/x86/domain_builder/fdt.c @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2024, Apertus Solutions, LLC + */ +#include +#include +#include +#include +#include /* required for asm/setup.h */ + +#include +#include +#include + +#include "fdt.h" + +int __init has_hyperlaunch_fdt(struct boot_info *bi) +{ + int ret =3D 0; + 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 e6580382d247..8041aeb3dcfd 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -33,6 +33,7 @@ #endif #include #include +#include #include #include #include @@ -1277,9 +1278,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 ) { @@ -1466,8 +1470,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); + i =3D first_boot_module_index(bi, BOOTMOD_KERNEL); + bi->mods[i].headroom =3D + bzimage_headroom(bootstrap_map_bm(&bi->mods[i]), bi->mods[i].size); bootstrap_unmap(); =20 #ifndef highmem_start @@ -1591,7 +1596,8 @@ void asmlinkage __init noreturn __start_xen(void) #endif } =20 - if ( bi->mods[0].headroom && !bi->mods[0].relocated ) + i =3D first_boot_module_index(bi, BOOTMOD_KERNEL); + if ( bi->mods[i].headroom && !bi->mods[0].relocated ) panic("Not enough memory to relocate the dom0 kernel image\n"); for ( i =3D 0; i < bi->nr_modules; ++i ) { --=20 2.30.2 From nobody Thu Dec 26 21:10:13 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=1732386665; cv=pass; d=zohomail.com; s=zohoarc; b=jGIVVaPWW/ljZtGUm/oA4rhSI7M72ClK+H7DPc44wzpAeomYkIofo5LlGOxB6jCEPwvLj8JEXeIq/Arkqm+hk9fcyGAnbSvl39k8Nh1A6qDjxVcrAakPezgMdplc0G9y+mRi6EEMjVVjZycnxdE2PsXc8Rk8kkqBpnNpVgBPSqw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386665; 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=50hQ5FtSJpLrNxu6yxxP08QLa9SwhIW1DEp9JlMJYIs=; b=Rz3btq6A/UNpFEyVcCAMUULSYgHDY/I9OeYr/A0TDYlf+ICqEJ1ImN1B/8IzXX4SoxATEPaJ5R3dexxA07J+44WbyctdEBq4Xz60dVCdqORuI7gby1XYVE93sHeflXKFWYtx+WAB6ZdO1FTC+5iMA28piYTrybIgTvxxaQ9HFDE= 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 1732386665796606.6268119990664; Sat, 23 Nov 2024 10:31:05 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.842178.1257644 (Exim 4.92) (envelope-from ) id 1tEuu9-0003We-QE; Sat, 23 Nov 2024 18:30:49 +0000 Received: by outflank-mailman (output) from mailman id 842178.1257644; Sat, 23 Nov 2024 18:30:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tEuu9-0003WV-KD; Sat, 23 Nov 2024 18:30:49 +0000 Received: by outflank-mailman (input) for mailman id 842178; Sat, 23 Nov 2024 18:30:48 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tEum5-0006MT-VJ for xen-devel@lists.xenproject.org; Sat, 23 Nov 2024 18:22:29 +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 e4057396-a9c7-11ef-a0cc-8be0dac302b0; Sat, 23 Nov 2024 19:22:27 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1732386063716280.39222882890044; Sat, 23 Nov 2024 10:21: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: e4057396-a9c7-11ef-a0cc-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6ImU0MDU3Mzk2LWE5YzctMTFlZi1hMGNjLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyMzg2MTQ3Ljk3MzA3Mywic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1732386067; cv=none; d=zohomail.com; s=zohoarc; b=CA5ufyF49tWEw6HEUKFlIdTnFNCFdZM9fXV1eeYpdEbCK6N7KMzLSeDqTUZrS5+3pKut7pguGip938h0kqikUEAOplpK68wphBChOJurChqxS67tHTXXmHmt6lTnZlYTRz0w1jTsXZ8U8Oi26SGzvjCH/naS4BqGnCpB7VfJwio= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386067; 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=50hQ5FtSJpLrNxu6yxxP08QLa9SwhIW1DEp9JlMJYIs=; b=UXqmBAFUJ7uDZn4U+5B6DZLlS73amZ1gkzctwzvcc2q60vVLmd3edUpZmKd2xmf/LMjba/lv0DXt6/2oXzq92mmeOASV7+UlqkaW5/gSK1tK1uEshsRCJ/gtH39qQLmw0SxdvkfoDXFnSsTjW5qfP0/+ipBzxWIznt6bju2mvqc= 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=1732386067; 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=50hQ5FtSJpLrNxu6yxxP08QLa9SwhIW1DEp9JlMJYIs=; b=P21QJxxpnZoyOpzGdmbggaKgpYfpOewE+2FBhkAQvoVEHzTlAEdgTs0yqajshgQS NMlJJuBQc5dZqOKAcjjt2p53AWJM+LcqjVfyDaNfQibVCuYNpylegvDipB1he5ekNYy MsnipOwGC0SIgYPfX2feb2t1CL0SbTEDTDhdydNQ= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 07/15] x86/hyperlaunch: initial support for hyperlaunch device tree Date: Sat, 23 Nov 2024 13:20:36 -0500 Message-Id: <20241123182044.30687-8-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241123182044.30687-1-dpsmith@apertussolutions.com> References: <20241123182044.30687-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: 1732386667865116600 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 if more than one is found. Signed-off-by: Daniel P. Smith --- xen/arch/x86/domain_builder/core.c | 14 +++++++ xen/arch/x86/domain_builder/fdt.c | 64 ++++++++++++++++++++++++++++- xen/arch/x86/domain_builder/fdt.h | 5 +++ xen/arch/x86/include/asm/bootinfo.h | 1 + 4 files changed, 83 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/domain_builder/core.c b/xen/arch/x86/domain_build= er/core.c index 211359895d84..a80f3711c306 100644 --- a/xen/arch/x86/domain_builder/core.c +++ b/xen/arch/x86/domain_builder/core.c @@ -40,7 +40,21 @@ void __init builder_init(struct boot_info *bi) ret); bi->hyperlaunch_enabled =3D false; } + } + + if ( bi->hyperlaunch_enabled ) + { + int ret; + + printk(XENLOG_INFO "Hyperlauch 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; + } =20 + 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 3f9dda8c34c3..ff1ba58b6907 100644 --- a/xen/arch/x86/domain_builder/fdt.c +++ b/xen/arch/x86/domain_builder/fdt.c @@ -14,14 +14,76 @@ =20 #include "fdt.h" =20 +static int __init find_hyperlaunch_node(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; 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..84126db208ea 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 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 Thu Dec 26 21:10:13 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=1732386683; cv=pass; d=zohomail.com; s=zohoarc; b=DmpjbxQ+DJBkVHPW47BxDm8IS889G9bkuzM2AeX+IWZykFB/7XdJA4Iaj7DVW5Ifz7dghJlaUE/wMLkD6fQCVBcHV5fRQ3X8XhBlXr5tXNfh8bLSgwRa9+XKSsPmbOHzxupfRJLa1HBcFzAOtise7ao5nViCnriN6JjyKsaSi9c= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386683; 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=ZWZK/83JdulzZ9aZB923YFMwC874tCiPARHq42V04YE=; b=bSi4/z/Ekn36G4i0qUVg00HAok+Ft8ryn6DjWIjzjJJjCdtzuYC1C7cP9RCaBtFysQWL/5hWHSqIMTlGOSv4f17+ki5PG8XFuG1tD87WzyJkE1gMz7USeL3XMZjHYCMg0VICvXWRfGxm4C2YNbEV5gTBiehC8GskDC28dcuEcjQ= 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 1732386683970299.15541515618077; Sat, 23 Nov 2024 10:31:23 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.842208.1257673 (Exim 4.92) (envelope-from ) id 1tEuuS-0005TZ-Nc; Sat, 23 Nov 2024 18:31:08 +0000 Received: by outflank-mailman (output) from mailman id 842208.1257673; Sat, 23 Nov 2024 18:31:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tEuuS-0005TO-JV; Sat, 23 Nov 2024 18:31:08 +0000 Received: by outflank-mailman (input) for mailman id 842208; Sat, 23 Nov 2024 18:31:08 +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 1tEumF-0006MT-7b for xen-devel@lists.xenproject.org; Sat, 23 Nov 2024 18:22:39 +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 e98ddbdb-a9c7-11ef-a0cc-8be0dac302b0; Sat, 23 Nov 2024 19:22:36 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1732386065328293.98410454837483; Sat, 23 Nov 2024 10:21: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: e98ddbdb-a9c7-11ef-a0cc-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6ImU5OGRkYmRiLWE5YzctMTFlZi1hMGNjLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyMzg2MTU3LjA2MDMwNSwic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1732386069; cv=none; d=zohomail.com; s=zohoarc; b=Vwle6eevgHpVpwva1S5/KjZzrgrwePyomr2PCP5A9cXSVI1k9uMR996qaHiUA3QSRPeGcGrsor6FzgVGbOxzieotIB9HM/AGm+CifFLukqMHjC6/seNTsM8lej+szxqBbPVjoXT9y+M+j/qJvskmrhIfNGpV1XFMTZEuBqrYIX4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386069; 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=ZWZK/83JdulzZ9aZB923YFMwC874tCiPARHq42V04YE=; b=dv/6J1B6t7xkTRyk8Xo2an2jKddwFkKuLr2uHjeDTi7hIsSb+yzWivACghLc12WLwjzmr6DPnMio3qM8YCY9V1StFr9j5HK0auUKwzk/HPhpK5PPvQ19oXuZbHyvJBcKVrQJ4cLuouUCrq1EY15MMib1Sdkxam6U0snjUmTpycI= 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=1732386069; 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=ZWZK/83JdulzZ9aZB923YFMwC874tCiPARHq42V04YE=; b=uPhrkV4TmISWfSUjqeji4UWrKAWKAmGlU2b62L6lskCmIOAWT4UGMsTmmSS5ghOF ibTjpWt4LW8NHMijieoZ60MQ8S+guAS5reeRSWIcjU8eSvyRLgI6Xl2I6TVUV6R/1AO BL8GK94FbqJNwOVIKGQdPbJna3MKdrYciVx8PHcw= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 08/15] x86/hyperlaunch: locate dom0 kernel with hyperlaunch Date: Sat, 23 Nov 2024 13:20:37 -0500 Message-Id: <20241123182044.30687-9-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241123182044.30687-1-dpsmith@apertussolutions.com> References: <20241123182044.30687-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: 1732386685958116600 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 --- xen/arch/x86/domain_builder/core.c | 12 +++ xen/arch/x86/domain_builder/fdt.c | 126 +++++++++++++++++++++++++++++ xen/arch/x86/domain_builder/fdt.h | 17 ++++ xen/arch/x86/setup.c | 5 -- 4 files changed, 155 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/domain_builder/core.c b/xen/arch/x86/domain_build= er/core.c index a80f3711c306..9335f3a9ebef 100644 --- a/xen/arch/x86/domain_builder/core.c +++ b/xen/arch/x86/domain_builder/core.c @@ -56,6 +56,18 @@ void __init builder_init(struct boot_info *bi) =20 printk(XENLOG_INFO " Number of domains: %d\n", bi->nr_domains); } + else + { + 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 ff1ba58b6907..6bf1c4a297fe 100644 --- a/xen/arch/x86/domain_builder/fdt.c +++ b/xen/arch/x86/domain_builder/fdt.c @@ -14,6 +14,122 @@ =20 #include "fdt.h" =20 +static inline int __init fdt_get_prop_as_reg( + const void *fdt, int node, const char *name, unsigned int ssize, + unsigned int asize, uint64_t *size, uint64_t *addr) +{ + int ret; + 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, name, &ret); + if ( !prop || ret < sizeof(u32) ) + return ret < 0 ? ret : -EINVAL; + + /* read address field */ + cell =3D (fdt32_t *)prop->data; + + if ( asize =3D=3D 1 ) + { + uint32_t val; + fdt_cell_as_u32(cell, &val); + *addr =3D (uint64_t)val; + } + else + fdt_cell_as_u64(cell, addr); + + /* read size field */ + cell +=3D asize; + + if ( ssize =3D=3D 1 ) + { + uint32_t val; + fdt_cell_as_u32(cell, &val); + *size =3D (uint64_t)val; + } + else + fdt_cell_as_u64(cell, size); + + return 0; +} + +static int __init dom0less_module_node( + void *fdt, int node, int size_size, int address_size) +{ + uint64_t size, addr; + int ret =3D fdt_get_prop_as_reg(fdt, node, "reg", size_size, address_s= ize, + &size, &addr); + /* An FDT error value may have been returned, translate to -EINVAL */ + if ( ret < 0 ) + return -EINVAL; + + 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. + */ + return (int)addr; +} + +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); + 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 ) + { + printk(" failed processing #address or #size for domain %s)\n", + name =3D=3D NULL ? "unknown" : name); + return -EINVAL; + } + + fdt_for_each_subnode(node, fdt, dom_node) + { + if ( fdt_node_check_compatible(fdt, node, "multiboot,kernel") =3D= =3D 0 ) + { + int idx =3D dom0less_module_node(fdt, node, size_size, address= _size); + if ( idx < 0 ) + { + printk(" failed processing kernel module for domain %s)\n= ", + name =3D=3D NULL ? "unknown" : name); + return idx; + } + + 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(void *fdt) { int hv_node =3D fdt_path_offset(fdt, "/chosen/hypervisor"); @@ -74,9 +190,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 84126db208ea..558d00a994fa 100644 --- a/xen/arch/x86/domain_builder/fdt.h +++ b/xen/arch/x86/domain_builder/fdt.h @@ -3,6 +3,7 @@ #define __XEN_X86_FDT_H__ =20 #include +#include =20 #include =20 @@ -10,6 +11,22 @@ #define HYPERLAUNCH_MODULE_IDX 0 =20 #ifdef CONFIG_DOMAIN_BUILDER + +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; +} + 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 8041aeb3dcfd..d6e9d4c1769c 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1280,11 +1280,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 */ --=20 2.30.2 From nobody Thu Dec 26 21:10:13 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=1732386676; cv=pass; d=zohomail.com; s=zohoarc; b=Xs2uvBc5qZgZeZ7I5LttwqYqdqmimbH7HKBWVIuILM+qEGd9V4xKkIh2Nq/O2OeqjIJJc7xTSs7PzWEUMgRFk91k+OcxrppWEho2wealJua3y7uDm/jlUq/Orygmhp6X0/tI+2O6d/I42RJT6djfaYAacgXkg4rwFZlnf1sSZdM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386676; 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=6nktQzed9lDrO9uE3JtQT7owTGCSLDNcsYsfTAI8TMA=; b=mcwlMZKzBS9XMUjv4r4N2tQelfpUsMw1tWi8IQ3WVDqrbnx1UcVmJUlkwu/v/u2vgAjsS4vT3zTYJzKnl3dpI/1OLbd3hjyPS8zEV1CP5kA5rFCdhV9Ae8fuqpGYL8HSU0EAb0gNYvaq0dnXyITLj6ElT5V2DsDlDloHh0/NMI8= 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 1732386676653718.8626885907705; Sat, 23 Nov 2024 10:31:16 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.842192.1257663 (Exim 4.92) (envelope-from ) id 1tEuuG-0004Tw-DS; Sat, 23 Nov 2024 18:30:56 +0000 Received: by outflank-mailman (output) from mailman id 842192.1257663; Sat, 23 Nov 2024 18:30:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tEuuG-0004To-87; Sat, 23 Nov 2024 18:30:56 +0000 Received: by outflank-mailman (input) for mailman id 842192; Sat, 23 Nov 2024 18:30:54 +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 1tEumP-0006MT-7t for xen-devel@lists.xenproject.org; Sat, 23 Nov 2024 18:22:49 +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 ef8dcde2-a9c7-11ef-a0cc-8be0dac302b0; Sat, 23 Nov 2024 19:22:46 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1732386066952250.35025180529567; Sat, 23 Nov 2024 10:21: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: ef8dcde2-a9c7-11ef-a0cc-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6ImVmOGRjZGUyLWE5YzctMTFlZi1hMGNjLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyMzg2MTY3LjEyMDI3NCwic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1732386071; cv=none; d=zohomail.com; s=zohoarc; b=nW7sXvRohpjbWo9DOULba7c3yNZXlSaTIi6cPllaObd24azcYKZy9UD8gkMqIod7vOTnfhmFFN5hZO/PHETfD1K8pMLRcB97CL4cmLU03haha1F5MpVoGX4j1Dz3dv1H/dUyioNrS2L+dp+di1DzqHDI0Zn54nuRHlJg0cM5jTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386071; 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=6nktQzed9lDrO9uE3JtQT7owTGCSLDNcsYsfTAI8TMA=; b=UVkq2JeulPhigV6ZmU1QmwTo6m3L+QCzMxf/fEJPG0olKftcIpqniOC6EDCTo+KpNuRu0BJ6B6K1OGSzLwpnexyQ3hYTBM+ki1VGu5kL+CZ0viAIKe8N9w2VWo/oRNbg1+3XcfI+XvOnheqAWAJqFNFnDpt/3cUhy6GSTOIUzWI= 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=1732386071; 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=6nktQzed9lDrO9uE3JtQT7owTGCSLDNcsYsfTAI8TMA=; b=molRG/TKbVQA+zX3mdPTgB1F02AjyWJbd50jFynNFlgXrIsNqv4UcrjEaghqozcc Of2hmdwC8XZ/VPvd+6XJOyzP/q3dlyArtycuO0FZnxIESPh+CdEijCgkOgJAFq0aSy6 8WjludgyR2X9ciI+9qJXw1EHfk4hVnShywAqE1WQ= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 09/15] x86/hyperlaunch: obtain cmdline from device tree Date: Sat, 23 Nov 2024 13:20:38 -0500 Message-Id: <20241123182044.30687-10-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241123182044.30687-1-dpsmith@apertussolutions.com> References: <20241123182044.30687-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: 1732386677955116600 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 --- xen/arch/x86/domain_builder/core.c | 28 +++++++++++++++++++ xen/arch/x86/domain_builder/fdt.c | 34 ++++++++++++++++++++++++ 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 | 10 +++++-- 6 files changed, 102 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/domain_builder/core.c b/xen/arch/x86/domain_build= er/core.c index 9335f3a9ebef..95cab06e6159 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 6bf1c4a297fe..f8ddb11b339e 100644 --- a/xen/arch/x86/domain_builder/fdt.c +++ b/xen/arch/x86/domain_builder/fdt.c @@ -57,6 +57,30 @@ static inline int __init fdt_get_prop_as_reg( return 0; } =20 +static int __init fdt_get_prop_as_offset( + const void *fdt, int node, const char *name, unsigned long *a) +{ + 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) ) + { + *a =3D poffset; + return nsize; + } + } + + return -ENOENT; +} + static int __init dom0less_module_node( void *fdt, int node, int size_size, int address_size) { @@ -118,6 +142,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_as_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 558d00a994fa..ab2b43872e25 100644 --- a/xen/arch/x86/domain_builder/fdt.h +++ b/xen/arch/x86/domain_builder/fdt.h @@ -27,6 +27,30 @@ static inline int __init fdt_cell_as_u64(const fdt32_t *= cell, uint64_t *val) return 0; } =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 d6e9d4c1769c..fda4fc71e205 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -971,7 +971,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; @@ -1040,7 +1043,10 @@ 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->loader), cmdline_size); --=20 2.30.2 From nobody Thu Dec 26 21:10:13 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=1732386643; cv=pass; d=zohomail.com; s=zohoarc; b=PNdeHcx/KmieeWB3GkI4nlXsxMJDC2LWWwXuG/Ik4/ipZXI5B2qxM0knLmnx94stBd9P7ckRaeCzwVcq5QzeNHgurp3uOdN9THHa82UpT1p88SXIr2O5uaZYZh8gPffDspRjjf7QOfY1xkEwxFU3sdRnYehmJMdJoJqLEHj3B4A= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386643; 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=scVK3BeFw1PvCPw+5+IJFV23lyxFsbSuS2LWmdnsIGU=; b=LdNroZAQ/mCZMSE9bLFOXn9n9UaP7fV6kEJDjOtZ+pM9QWvMdEHxmNPZLjv28pPURMRufF7qQhRhHfmTzCXUktt2hHW0Kbas6n0HWglFjtcPTNEsgqqycG7Sc2ei4dYZtxD9OO7aO5Pzn37zxdnBm8MC7DUo9CBtGlnIv9MyluY= 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 1732386643341289.8972624403757; Sat, 23 Nov 2024 10:30:43 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.842162.1257613 (Exim 4.92) (envelope-from ) id 1tEutr-00027W-Oj; Sat, 23 Nov 2024 18:30:31 +0000 Received: by outflank-mailman (output) from mailman id 842162.1257613; Sat, 23 Nov 2024 18:30: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 1tEutr-00027E-Ky; Sat, 23 Nov 2024 18:30:31 +0000 Received: by outflank-mailman (input) for mailman id 842162; Sat, 23 Nov 2024 18:30: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 1tEumZ-0006MT-Es for xen-devel@lists.xenproject.org; Sat, 23 Nov 2024 18:22:59 +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 f5953219-a9c7-11ef-a0cc-8be0dac302b0; Sat, 23 Nov 2024 19:22:57 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1732386068616924.1851128683724; Sat, 23 Nov 2024 10:21:08 -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: f5953219-a9c7-11ef-a0cc-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6ImY1OTUzMjE5LWE5YzctMTFlZi1hMGNjLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyMzg2MTc3LjIzOTQyNiwic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1732386073; cv=none; d=zohomail.com; s=zohoarc; b=O2H3MgRv1sOoO7bTYKOWHf8SEqYjZeaNb5QEwUVLaWUHqNNdDCPCkbuqq7zVs3nu6PG9d4gvzo06ME8I+UxlgNFoYKpGzAyC5GvNutgNa0XxQvhYdrcqb9JvRZTpbuPUO/SXy26XlYLfZ83UtkbFH7YSHKZzbGxJCN/v4ZtGOTY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386073; 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=scVK3BeFw1PvCPw+5+IJFV23lyxFsbSuS2LWmdnsIGU=; b=WAGg98RlGwHi+eBGWTjI5a90lKB1xyPtHab/BmbdRdNDmBkc2ksi57bRXLazi/m4ff9ELwyyHl4/Ij/c+m++6+oWEndd2qHJ7NB1dORxkfkW5stb0qJm4656027ZhFe0bp5k3ZANNRXojTTbzl8LM9BxHp1xi/NaqKQ6wlb5k1s= 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=1732386072; 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=scVK3BeFw1PvCPw+5+IJFV23lyxFsbSuS2LWmdnsIGU=; b=oPaf+LuNH1U8j4O9iPJgi844HDJIy9ob5SKz5Wr0pVlo5NtUYgxp5NElWPVH7fAA FisYz8cvC9diNy6SLXC1e904Q0zFGaGpeRViEXaTfmp8xA1xAV41cn9yY9CCghsXbQS ZSs1/rXeeu3zWQmXY0rxYLbDxTu9czevbKf5RQiA= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 10/15] x86/hyperlaunch: locate dom0 initrd with hyperlaunch Date: Sat, 23 Nov 2024 13:20:39 -0500 Message-Id: <20241123182044.30687-11-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241123182044.30687-1-dpsmith@apertussolutions.com> References: <20241123182044.30687-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: 1732386645871116600 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 --- xen/arch/x86/domain_builder/fdt.c | 25 ++++++++++++++++++++++ xen/arch/x86/setup.c | 35 +++++++++++++++++-------------- 2 files changed, 44 insertions(+), 16 deletions(-) diff --git a/xen/arch/x86/domain_builder/fdt.c b/xen/arch/x86/domain_builde= r/fdt.c index f8ddb11b339e..bc8054a80ec1 100644 --- a/xen/arch/x86/domain_builder/fdt.c +++ b/xen/arch/x86/domain_builder/fdt.c @@ -152,6 +152,31 @@ static int __init process_domain_node( if ( ret > 0 ) bd->kernel->fdt_cmdline =3D true; } + + continue; + } + 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 =3D=3D NULL ? "unknown" : 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 fda4fc71e205..eaac87b02f78 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1094,7 +1094,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, e820_warn =3D 0, bytes =3D 0; @@ -2137,22 +2137,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 Thu Dec 26 21:10:13 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=1732386654; cv=pass; d=zohomail.com; s=zohoarc; b=JabpbVu6gM127xdeHcP1/W1e5AtJL610yL2YMdjr5UuTNr71Y4OjS7imwwHZhMYJeLcJMVHPVu7ohp1hsaz3QDtIsRN+FL0EwzPW3BYuzoMdwSEYfApCfZLzcu2yDiU1dyAcIJFeogxUzF+1VpKewdyZL/sCGW8T21sWhR82iWI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386654; 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=rShRbMHkLlgH633oW5JK+yICpJ3QPlDKQOW5Dw/tj1E=; b=nIk9uY9+44r0nTEDzwdZeU4UnJzn22tTpMoXL1T8iFSuRtnNBh3auufOYKslmyU81zGobcyRm7XiPfY3iHbuTOfkyIP/+JzZbxD6/RojPl3wj95j+o+3OmDngHYd3Ow14mJ9ZWD93Ej9r0H7up/rVvliysvkQR6Et1YmnEhaVgQ= 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 1732386654208667.7261812080295; Sat, 23 Nov 2024 10:30:54 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.842159.1257593 (Exim 4.92) (envelope-from ) id 1tEutp-0001cd-AZ; Sat, 23 Nov 2024 18:30:29 +0000 Received: by outflank-mailman (output) from mailman id 842159.1257593; Sat, 23 Nov 2024 18:30:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tEutp-0001cW-7X; Sat, 23 Nov 2024 18:30:29 +0000 Received: by outflank-mailman (input) for mailman id 842159; Sat, 23 Nov 2024 18:30: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 1tEumj-0006MT-A4 for xen-devel@lists.xenproject.org; Sat, 23 Nov 2024 18:23:09 +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 fb581bfc-a9c7-11ef-a0cc-8be0dac302b0; Sat, 23 Nov 2024 19:23:06 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1732386070200329.6100039493838; Sat, 23 Nov 2024 10:21: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: fb581bfc-a9c7-11ef-a0cc-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6ImZiNTgxYmZjLWE5YzctMTFlZi1hMGNjLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyMzg2MTg3LjI2NzE5Nywic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1732386074; cv=none; d=zohomail.com; s=zohoarc; b=ZWs7IeWmT+umhUvpU7XzMc5NSNYPa2xdZ//G3vlWJrGcHG+XLZKlJskDcaCplPQL7sAuY51YkBhay6Qm0GACCLbOJiA2wu+pr5XqDgTkK/dFge4znJDFzHc1+yx42GZOSCy/RubAX7ILpCMTWGWHPk2/EHAfit3IsZtZyNbuiSU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386074; 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=rShRbMHkLlgH633oW5JK+yICpJ3QPlDKQOW5Dw/tj1E=; b=c+QTZlnWB/6t8ESve8HX/NXxfaFSjKuCJMf9kcI4yJECTug1cNu361+SlG01/4bxF1kumkbeGBQ2LTZk+lq2zA8/CccfGt8IU2I5R833Zo6dPEVPUerhWfYVbCOoIIfdi0veRCzCCHYTJ50cPW5iOiX8/ljDHza66+LvsnpF3j0= 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=1732386074; 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=rShRbMHkLlgH633oW5JK+yICpJ3QPlDKQOW5Dw/tj1E=; b=C4oxj/A5x5OlBNpLcZe+QXpmLmgtDOfUiweDTX8bQixEYJseDHIBjKvSv9+/VE1i TYXjfP+3gFZaibMYg0RZ2MiBzS7Qer5govgBP2pvfRrtIZwfDV4KeJxQUZfwsEYN9nm KqyUvUXqM1OYu38WNr/wmzpd9JNSSy+AP1omBBf4= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 11/15] x86/hyperlaunch: add domain id parsing to domain config Date: Sat, 23 Nov 2024 13:20:40 -0500 Message-Id: <20241123182044.30687-12-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241123182044.30687-1-dpsmith@apertussolutions.com> References: <20241123182044.30687-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: 1732386655811116600 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 --- xen/arch/x86/domain_builder/fdt.c | 31 ++++++++++++++++++++++++++++++- xen/arch/x86/domain_builder/fdt.h | 18 ++++++++++++++++++ xen/arch/x86/setup.c | 3 ++- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/domain_builder/fdt.c b/xen/arch/x86/domain_builde= r/fdt.c index bc8054a80ec1..3a6b4fbc09a9 100644 --- a/xen/arch/x86/domain_builder/fdt.c +++ b/xen/arch/x86/domain_builder/fdt.c @@ -9,6 +9,7 @@ #include /* required for asm/setup.h */ =20 #include +#include #include #include =20 @@ -107,7 +108,7 @@ static int __init dom0less_module_node( 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); int address_size =3D fdt_address_cells(fdt, dom_node); @@ -120,6 +121,28 @@ static int __init process_domain_node( return -EINVAL; } =20 + fdt_for_each_property_offset(property, fdt, dom_node) + { + const struct fdt_property *prop; + + prop =3D fdt_get_property_by_offset(fdt, property, NULL); + if ( !prop ) + continue; /* silently skip */ + + if ( match_fdt_property(fdt, prop, "domid" ) ) + { + uint32_t val =3D DOMID_INVALID; + if ( fdt_prop_as_u32(prop, &val) !=3D 0 ) + { + printk(" failed processing domain id for domain %s\n", + name =3D=3D NULL ? "unknown" : 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 ) @@ -186,6 +209,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: unsuported booting not using init= ial domid\n"); + return 0; } =20 diff --git a/xen/arch/x86/domain_builder/fdt.h b/xen/arch/x86/domain_builde= r/fdt.h index ab2b43872e25..06ead05a2583 100644 --- a/xen/arch/x86/domain_builder/fdt.h +++ b/xen/arch/x86/domain_builder/fdt.h @@ -27,6 +27,24 @@ 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 bool __init match_fdt_property( + const void *fdt, const struct fdt_property *prop, const char *s) +{ + int slen, len =3D strlen(s); + const char *p =3D fdt_get_string(fdt, fdt32_to_cpu(prop->nameoff), &sl= en); + + return p && (slen =3D=3D len) && (memcmp(p, s, len) =3D=3D 0); +} + static inline int __init fdt_cmdline_prop_size(const void *fdt, int offset) { int ret; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index eaac87b02f78..317349b80ac6 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1020,7 +1020,8 @@ static struct domain *__init create_dom0(struct boot_= info *bi) dom0_cfg.flags |=3D XEN_DOMCTL_CDF_iommu; =20 /* Create initial domain. Not d0 for pvshim. */ - bd->domid =3D get_initial_domain_id(); + if ( bd->domid =3D=3D DOMID_INVALID ) + 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)); --=20 2.30.2 From nobody Thu Dec 26 21:10:13 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=1732386687; cv=pass; d=zohomail.com; s=zohoarc; b=Cr/HLzmnraAjv0Ny1HesiQBEMiNjMwJRthEJ7EshcJAf0ad5zxomJGlkXRXRu7mef/rxEb79CQigd/BEizL3dZA1NH3zoLyueD27KSCBq6SPK2yFEfr1pF75NT6E2l2T4XsXR5GLcdQ1IBRJrRYJsZ5LQnFR1ZO831NlJ3v5KaA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386687; 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=P31ngclTABjM2fHDD0BXApDz5VKpKh+1+vkjeCGngCQ=; b=IFLiV2G14iOo0RistvHimelrO13xg1kSIrS4ET4M6bTXk5Zk9fXR+6+8MEEGbjEQ4kk0Dim18XLkXiDb77TdEzAQnV4oQBITmEPDL0woPSdzXTuzx3sY4doLBfH6hG+1MoP1KXC3vDKmfIKgN/IXuqShaRsLstex6zC12Ww62w0= 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 1732386687878107.21484668386609; Sat, 23 Nov 2024 10:31:27 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.842209.1257677 (Exim 4.92) (envelope-from ) id 1tEuuT-0005X4-2J; Sat, 23 Nov 2024 18:31:09 +0000 Received: by outflank-mailman (output) from mailman id 842209.1257677; Sat, 23 Nov 2024 18:31:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tEuuS-0005Wm-SE; Sat, 23 Nov 2024 18:31:08 +0000 Received: by outflank-mailman (input) for mailman id 842209; Sat, 23 Nov 2024 18:31:08 +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 1tEumt-0006MT-Ib for xen-devel@lists.xenproject.org; Sat, 23 Nov 2024 18:23: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 019bc668-a9c8-11ef-a0cc-8be0dac302b0; Sat, 23 Nov 2024 19:23:17 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1732386071864907.6802124955447; Sat, 23 Nov 2024 10:21:11 -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: 019bc668-a9c8-11ef-a0cc-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6IjAxOWJjNjY4LWE5YzgtMTFlZi1hMGNjLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyMzg2MTk3LjYyNTczMSwic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1732386076; cv=none; d=zohomail.com; s=zohoarc; b=jiDTkyhg1PvFAUImU9Eo45XMlkkg3TroZ5+v4MjHS3CahYpFLkwPj3f22Zx/0497GWdS3WnROUVhPfMTq438fM8CeTa/RSAGbDTcyPdxNq5vf5FeU5EVuBadu3mu2ucFEbeLEAeRIGl4FKXLUb2MljtXUbTthVvqWnlbaEzS9ug= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386076; 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=P31ngclTABjM2fHDD0BXApDz5VKpKh+1+vkjeCGngCQ=; b=Y9xbEq5vXvq8Xg1tPQmj+65BEzwe0hZEMedD3bDtdI6U19BSiq92TqKEn5cnIVQUvRFLqRyEulHaltnWAwV0mliJWIuNsuMqIC4TH/ZNBhK5B5G8zTWsTTV+yk4qz6vHZDX0hY5+tYY8EAHV1CbipDz90H4t8WLPVZRzUSNLLn8= 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=1732386076; 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=P31ngclTABjM2fHDD0BXApDz5VKpKh+1+vkjeCGngCQ=; b=kORFGEXrPEW+vOCh1FJPls/nJ1VRBxFBecSurziXVRVg71GWTDZAGQ9G6uS61+F3 TmxBqBlcfXJvQhlO/3ix3o7m31RBYD/kieijkBIXuIG7SJCYyHU+EIaapgHLUfAorLX wIC1TVruiDFgnEHLQGha1Z3iScFVVtmc3mz1QTck= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, christopher.w.clark@gmail.com, stefano.stabellini@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 12/15] x86/hyperlaunch: specify dom0 mode with device tree Date: Sat, 23 Nov 2024 13:20:41 -0500 Message-Id: <20241123182044.30687-13-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241123182044.30687-1-dpsmith@apertussolutions.com> References: <20241123182044.30687-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: 1732386689904116600 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 --- xen/arch/x86/domain_builder/fdt.c | 19 +++++++++++++++++++ xen/arch/x86/include/asm/bootdomain.h | 6 ++++++ xen/arch/x86/setup.c | 3 ++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/domain_builder/fdt.c b/xen/arch/x86/domain_builde= r/fdt.c index 3a6b4fbc09a9..09e72d96a752 100644 --- a/xen/arch/x86/domain_builder/fdt.c +++ b/xen/arch/x86/domain_builder/fdt.c @@ -141,6 +141,25 @@ static int __init process_domain_node( bd->domid =3D (domid_t)val; printk(" domid: %d\n", bd->domid); } + if ( match_fdt_property(fdt, prop, "mode" ) ) + { + if ( fdt_prop_as_u32(prop, &bd->mode) !=3D 0 ) + { + printk(" failed processing mode for domain %s\n", + name =3D=3D NULL ? "unknown" : 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 ffda1509a63f..50c33d183e07 100644 --- a/xen/arch/x86/include/asm/bootdomain.h +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -18,6 +18,12 @@ 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 */ +#define BUILD_MODE_LONG (1 << 2) /* 64 BIT | 32 BIT */ + 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 317349b80ac6..dae25721994d 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1006,7 +1006,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 Thu Dec 26 21:10:13 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=1732386646; cv=pass; d=zohomail.com; s=zohoarc; b=MJNTOGveh8rd61fgKUuwf5uW1ZVd3Hta6mzloxwiXxF/HMOq+kzbxSOkHmv4v3Uk3buVVXf+JigAgmcbE569K+9VBVV4UDdxNU4xDF15ByPCH+34aHQJsGr6GhI14PtTN/Rt+dMm0C3YXNF3IZ1ZmH6G/XxOhGCN7gapeNHnDzk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386646; 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=cScA2Yfp0/eaEM0ZCMnKxC8CljJcPTHUxp3FhbTB/C4=; b=fSw+ZUbPzRGw+cB1cK9ucL7dXYnh+erxpk9mDD+eJN+hZPvEPz717odXx7YaxchSZdBipaBAVQN832N19cxX0bgMziH3ZiqgMVjSHpp3ZBPd6ZzJ+rjz5fTMZyQ+swcDuHKEYfbRIqKOjeXJtWNiiTILf8AdWTZcpolrHEd0D5k= 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 1732386646627283.2244582078082; Sat, 23 Nov 2024 10:30:46 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.842161.1257597 (Exim 4.92) (envelope-from ) id 1tEutp-0001eb-HR; Sat, 23 Nov 2024 18:30:29 +0000 Received: by outflank-mailman (output) from mailman id 842161.1257597; Sat, 23 Nov 2024 18:30:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tEutp-0001eD-Dt; Sat, 23 Nov 2024 18:30:29 +0000 Received: by outflank-mailman (input) for mailman id 842161; Sat, 23 Nov 2024 18:30: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 1tEun4-0006MT-E1 for xen-devel@lists.xenproject.org; Sat, 23 Nov 2024 18:23:30 +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 080b27b4-a9c8-11ef-a0cc-8be0dac302b0; Sat, 23 Nov 2024 19:23:28 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1732386073413790.5767891836485; Sat, 23 Nov 2024 10:21:13 -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: 080b27b4-a9c8-11ef-a0cc-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6IjA4MGIyN2I0LWE5YzgtMTFlZi1hMGNjLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyMzg2MjA4LjM5MDI3NCwic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1732386077; cv=none; d=zohomail.com; s=zohoarc; b=Fr24IfvJgyLHtBIZMvNA8kHeL2+RsVYv0RhJ4yAxFJyTlxqYn2D4FRww19YzzMwu76LQkFoybkoEwI17HCd0Sa+xTIQ/d7UE41XZumujoS7XXWmnVttuLPBumDhYyajuwiQfMivW/9rJRhyBG5dV7jwKZg3kdnTTu8vkUbbj93o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386077; 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=cScA2Yfp0/eaEM0ZCMnKxC8CljJcPTHUxp3FhbTB/C4=; b=dDB77pWuYRQ2YVkbG3j4HZSjXhguTE57cU6E8ID9VY+4YqlJSNsYLlDUGdbOyf80Es+2Pk7R6Q0TuK7luoRHkvYzkChBFTTEAms+bIQvSYafRzMAWPpSdOjeA1Drlvn/l6BJyQklEDBq/MHbylFj0McbR9nU10KceRSsDp8reB4= 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=1732386077; 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=cScA2Yfp0/eaEM0ZCMnKxC8CljJcPTHUxp3FhbTB/C4=; b=U77LMkFA0Ehw9RB61uLGdSeicuHgW1VBgmtWneKnZbKmT+ikxCJcAJhJ8y+m7anF Q16kWVHgNeS6bhrYJybjBlGJ8oAXS7ysJx3L+iPSPxKamzdV06KMvleaWDtvHOv2OOq 19dhIMoUpNk5YdSGHbk+wFtdwj/SBrABg6zrlbec= 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 13/15] x86/hyperlaunch: add memory parsing to domain config Date: Sat, 23 Nov 2024 13:20:42 -0500 Message-Id: <20241123182044.30687-14-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241123182044.30687-1-dpsmith@apertussolutions.com> References: <20241123182044.30687-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: 1732386647919116600 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 --- xen/arch/x86/dom0_build.c | 8 ++++++ xen/arch/x86/domain_builder/fdt.c | 37 +++++++++++++++++++++++++++ xen/arch/x86/domain_builder/fdt.h | 9 +++++++ xen/arch/x86/include/asm/bootdomain.h | 4 +++ 4 files changed, 58 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 09e72d96a752..b8ace5c18c6a 100644 --- a/xen/arch/x86/domain_builder/fdt.c +++ b/xen/arch/x86/domain_builder/fdt.c @@ -7,6 +7,7 @@ #include #include #include /* required for asm/setup.h */ +#include =20 #include #include @@ -160,6 +161,42 @@ static int __init process_domain_node( else printk("PV\n"); } + if ( match_fdt_property(fdt, prop, "memory" ) ) + { + uint64_t kb; + if ( fdt_prop_as_u64(prop, &kb) !=3D 0 ) + { + printk(" failed processing memory for domain %s\n", + name =3D=3D NULL ? "unknown" : name); + return -EINVAL; + } + bd->mem_pages =3D PFN_DOWN(kb * SZ_1K); + printk(" memory: %ld\n", bd->mem_pages << PAGE_SHIFT); + } + if ( match_fdt_property(fdt, prop, "mem-min" ) ) + { + uint64_t kb; + if ( fdt_prop_as_u64(prop, &kb) !=3D 0 ) + { + printk(" failed processing memory for domain %s\n", + name =3D=3D NULL ? "unknown" : name); + return -EINVAL; + } + bd->min_pages =3D PFN_DOWN(kb * SZ_1K); + printk(" min memory: %ld\n", bd->min_pages << PAGE_SHIFT); + } + if ( match_fdt_property(fdt, prop, "mem-max" ) ) + { + uint64_t kb; + if ( fdt_prop_as_u64(prop, &kb) !=3D 0 ) + { + printk(" failed processing memory for domain %s\n", + name =3D=3D NULL ? "unknown" : name); + return -EINVAL; + } + bd->max_pages =3D PFN_DOWN(kb * SZ_1K); + printk(" max memory: %ld\n", bd->max_pages << PAGE_SHIFT); + } } =20 fdt_for_each_subnode(node, fdt, dom_node) diff --git a/xen/arch/x86/domain_builder/fdt.h b/xen/arch/x86/domain_builde= r/fdt.h index 06ead05a2583..73d02019b3c7 100644 --- a/xen/arch/x86/domain_builder/fdt.h +++ b/xen/arch/x86/domain_builder/fdt.h @@ -36,6 +36,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 bool __init match_fdt_property( const void *fdt, const struct fdt_property *prop, const char *s) { diff --git a/xen/arch/x86/include/asm/bootdomain.h b/xen/arch/x86/include/a= sm/bootdomain.h index 50c33d183e07..9a5ba2931665 100644 --- a/xen/arch/x86/include/asm/bootdomain.h +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -24,6 +24,10 @@ struct boot_domain { #define BUILD_MODE_LONG (1 << 2) /* 64 BIT | 32 BIT */ 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 --=20 2.30.2 From nobody Thu Dec 26 21:10:13 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=1732386671; cv=pass; d=zohomail.com; s=zohoarc; b=Tt++z3eo6a202gCnIzwYXUdTY5mbvrElIUaDBpidCmpremsfabLhBYtIklj+2Z4+uISWB1y+vr0C9b5Z0ZStMuBe5rt7V++vIK11ctjd6c5LRRCdGi1foBzRvml6Lrp4NoUV5YRoKEA+EWiotTNNDsNj8EioRwjdVd/4oEgaxZ4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386671; 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=QKzJS5eFtECZxvuLdDMttAltTe8m1ybZIito+adUWcs=; b=b/pIJAQW/3XcFvBNm0Np9JnU9zhl529/0s8TdK3+2x86SeOEwwJJFnWJtbPbOowSiTrYpZ5DmRM3IEu9bNE8y2mmeELAmWvAZuKXh/ZUg1Qe1hNtpS/HF3KjoNc+rn34/KVHOFeqShWNvzLWBKD15UxCQcWTRzMeK9OfkKneZmM= 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 1732386671073661.4361485655278; Sat, 23 Nov 2024 10:31:11 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.842185.1257652 (Exim 4.92) (envelope-from ) id 1tEuuB-0003vb-VN; Sat, 23 Nov 2024 18:30:51 +0000 Received: by outflank-mailman (output) from mailman id 842185.1257652; Sat, 23 Nov 2024 18:30:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tEuuB-0003vP-Rt; Sat, 23 Nov 2024 18:30:51 +0000 Received: by outflank-mailman (input) for mailman id 842185; Sat, 23 Nov 2024 18:30:50 +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 1tEunD-0006MT-Hw for xen-devel@lists.xenproject.org; Sat, 23 Nov 2024 18:23:39 +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 0d839d35-a9c8-11ef-a0cc-8be0dac302b0; Sat, 23 Nov 2024 19:23:37 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1732386074952625.5918532207943; Sat, 23 Nov 2024 10:21:14 -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: 0d839d35-a9c8-11ef-a0cc-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6IjBkODM5ZDM1LWE5YzgtMTFlZi1hMGNjLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyMzg2MjE3LjU3MDk5Nywic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1732386079; cv=none; d=zohomail.com; s=zohoarc; b=JfjUzRuVdgu03JmMJ5s2O0voxRwbLJ4CBYjs3PrFIMUo88e9iNtvVL1L+OFGNHhYT94FoIq72vGrI96jmy8ArAJRs/qmc7JA1n0W2fw185eflojlr2SEhNgFRfFzbrCTznDSV5j+Fud7r3rtxLeoKfV89Sc4R6h0IY+GH702ttg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386079; 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=QKzJS5eFtECZxvuLdDMttAltTe8m1ybZIito+adUWcs=; b=lVOALTE35FkFWXsyQ6e06tDp/mGh/sYIAdoEicwRCaEG4zFWBJejQkbWE3+OX7KRD59N5TcKr2MigVEDzY0ZK2Ifid8u3ASewIIJmpI7yiv2Jysik0cnoQo7qDW/nstV7Wk+KPjyQTdkkovK+sn6CMFldF/KjSKM48XwI0ALVyo= 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=1732386079; 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=QKzJS5eFtECZxvuLdDMttAltTe8m1ybZIito+adUWcs=; b=M6pe5kk4JKInmhmAxvKDezN1KYBLvsWBIvhyOjWo/VOpWSiKjFOrcWrWJyLq8NyA kzfE57oAC+F0MgaULEbNNFxcxOWNy5mBFMdWD/AjnwzjgfSgqUIYfcIFCML4gJC9f4L P2h3DHF+2yUBF3PtHqNfhmCXX0nR65guQvqqkpoM= 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 14/15] x86/hyperlaunch: add max vcpu parsing of hyperlaunch device tree Date: Sat, 23 Nov 2024 13:20:43 -0500 Message-Id: <20241123182044.30687-15-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241123182044.30687-1-dpsmith@apertussolutions.com> References: <20241123182044.30687-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: 1732386673765116600 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 --- xen/arch/x86/dom0_build.c | 3 +++ xen/arch/x86/domain_builder/fdt.c | 12 ++++++++++++ xen/arch/x86/include/asm/bootdomain.h | 2 ++ 3 files changed, 17 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 b8ace5c18c6a..d24e265f2378 100644 --- a/xen/arch/x86/domain_builder/fdt.c +++ b/xen/arch/x86/domain_builder/fdt.c @@ -197,6 +197,18 @@ static int __init process_domain_node( bd->max_pages =3D PFN_DOWN(kb * SZ_1K); printk(" max memory: %ld\n", bd->max_pages << PAGE_SHIFT); } + if ( match_fdt_property(fdt, prop, "cpus" ) ) + { + uint32_t val =3D UINT_MAX; + if ( fdt_prop_as_u32(prop, &val) !=3D 0 ) + { + printk(" failed processing max_vcpus for domain %s\n", + name =3D=3D NULL ? "unknown" : name); + 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 9a5ba2931665..d144d6173400 100644 --- a/xen/arch/x86/include/asm/bootdomain.h +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -28,6 +28,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 Thu Dec 26 21:10:13 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=1732386244; cv=pass; d=zohomail.com; s=zohoarc; b=Wf4VUt6oXVVgZlZShyP95UfF1taKQZud6ev3VgjeCpn819V6+JmlcKOn5eOc+7EdCEQ9XbX5BnYfjPJUMpCxDjIRgZ0e6NDEW70PRyUbGHYjwq7RpVI59wjmHNz5BAwC1gX8ydyk40Yb40SmDcjNyOLMiDuwnCJ/shXHI//gbOI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386244; 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=kGDrQzVGJffHLng67CVtl7JaehFGVtrHTRbUgIidSbY=; b=e4dAk3G7i+QOr/JR70olVyOWvLy1SQryGJsXZsXq+kny4Y0ttoAlbcWSwauPj4ZlBdTKmND5LxKIgEmeGbMJTkGst2/eQNeo7TxvPoInnEOAvQ+8kPhr+OAhguszKJnUSVDQxg0fQcoAxbJfx2/hB0ZecFg5d2B91a8D95mhNXk= 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 1732386244745291.81273142316763; Sat, 23 Nov 2024 10:24:04 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.842146.1257583 (Exim 4.92) (envelope-from ) id 1tEunP-0008OY-NF; Sat, 23 Nov 2024 18:23:51 +0000 Received: by outflank-mailman (output) from mailman id 842146.1257583; Sat, 23 Nov 2024 18:23:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tEunP-0008OR-KC; Sat, 23 Nov 2024 18:23:51 +0000 Received: by outflank-mailman (input) for mailman id 842146; Sat, 23 Nov 2024 18:23:49 +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 1tEunN-0008OL-R3 for xen-devel@lists.xenproject.org; Sat, 23 Nov 2024 18:23:49 +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 12f8c85e-a9c8-11ef-99a3-01e77a169b0f; Sat, 23 Nov 2024 19:23:46 +0100 (CET) Received: by mx.zohomail.com with SMTPS id 1732386076488696.0833111040206; Sat, 23 Nov 2024 10:21:16 -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: 12f8c85e-a9c8-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjEzNi4xNDMuMTg4LjUxIiwiaGVsbyI6InNlbmRlcjQtb2YtbzUxLnpvaG8uY29tIn0= X-Custom-Transaction: eyJpZCI6IjEyZjhjODVlLWE5YzgtMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMyMzg2MjI2LjQ3NTY0NSwic2VuZGVyIjoiZHBzbWl0aEBhcGVydHVzc29sdXRpb25zLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 ARC-Seal: i=1; a=rsa-sha256; t=1732386081; cv=none; d=zohomail.com; s=zohoarc; b=T+mA76iBA1TcOBLOKRxAmyDYO7cT37goqM0wyAVnB3jGTpFBGMJH+CYXP1vptb902FhHAtSkWBsayFvWYTQdBJMdDplLYQBXkCNjRLM5R0z0YGm40Vij4auGCI2N5/m1rw64g2OMBIqb38CP69q15OrRGtg7gbDquayuwJ+zm2U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732386081; 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=kGDrQzVGJffHLng67CVtl7JaehFGVtrHTRbUgIidSbY=; b=Gh0kjY7wAwKetrAzgASO0zmvpK5j7LEtxYZ8E0ZncQlONLliPcwV2Rxb+7alua6NQYqDJER2emMob9O6cBTxZ4CWXVvQK6JgJaJ+8OFrpM78yWILtf8hXTKnpabQRbbe3Kym2yPg6zxYWlum/YGbRMcvJmvSJV1bZHwIw656hCg= 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=1732386081; 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=kGDrQzVGJffHLng67CVtl7JaehFGVtrHTRbUgIidSbY=; b=pp1Zn23W/AezqSEvTrK72Wd0GClkVvC62Eov5f65Kgog1ZaEBMu+l0OZQaEsUIgk iWV1cAb27Cnmbl1Tf7kMPYmDpw8DbYnNnq5dXsDQX9Z7xfNe51hRASm3cpUTqh3HYDY IZ+q4OSbjePDCpdYzWjwqS5RzLydJrxSOUzPn1/Y= 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 15/15] x86/hyperlaunch: add capabilities to boot domain Date: Sat, 23 Nov 2024 13:20:44 -0500 Message-Id: <20241123182044.30687-16-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20241123182044.30687-1-dpsmith@apertussolutions.com> References: <20241123182044.30687-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: 1732386246181116600 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 --- xen/arch/x86/domain_builder/core.c | 2 +- xen/arch/x86/domain_builder/fdt.c | 13 +++++++++++++ xen/arch/x86/include/asm/bootdomain.h | 4 ++++ xen/arch/x86/setup.c | 6 +++++- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/domain_builder/core.c b/xen/arch/x86/domain_build= er/core.c index 95cab06e6159..eaa019472724 100644 --- a/xen/arch/x86/domain_builder/core.c +++ b/xen/arch/x86/domain_builder/core.c @@ -93,9 +93,9 @@ 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; } - } =20 /* diff --git a/xen/arch/x86/domain_builder/fdt.c b/xen/arch/x86/domain_builde= r/fdt.c index d24e265f2378..9499e337938c 100644 --- a/xen/arch/x86/domain_builder/fdt.c +++ b/xen/arch/x86/domain_builder/fdt.c @@ -209,6 +209,19 @@ static int __init process_domain_node( bd->max_vcpus =3D val; printk(" max vcpus: %d\n", bd->max_vcpus); } + if ( match_fdt_property(fdt, prop, "capabilities" ) ) + { + if ( fdt_prop_as_u32(prop, &bd->capabilities) !=3D 0 ) + { + printk(" failed processing domain id for domain %s\n", + name =3D=3D NULL ? "unknown" : name); + 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 d144d6173400..51ebf1f68189 100644 --- a/xen/arch/x86/include/asm/bootdomain.h +++ b/xen/arch/x86/include/asm/bootdomain.h @@ -18,6 +18,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 dae25721994d..28e750a420e8 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -992,6 +992,7 @@ static size_t __init domain_cmdline_size( static struct domain *__init create_dom0(struct boot_info *bi) { char *cmdline =3D NULL; + 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, @@ -1023,7 +1024,10 @@ static struct domain *__init create_dom0(struct boot= _info *bi) /* Create initial domain. Not d0 for pvshim. */ if ( bd->domid =3D=3D DOMID_INVALID ) 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