From nobody Fri Oct 31 23:30:44 2025 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=1745101293; cv=pass; d=zohomail.com; s=zohoarc; b=BSOHQFakILq6igkPEsvllhwhO0fpuCD7rVGHyogJiEGo873lO2n4e3Ss9pJNdLDC9G1iBdFztxQOfnaESzUDPCANCVCO7asj7B9cGVs4MJ9Ov1nOkWkdrN9WkSFiuHvT7KIwEmzLL0m4TWZQxq0PBk7NMVsfg+4NRoqkPdomc+Y= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1745101293; 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=ErU8vuQ7J87fC+REu5nsdOrzqMN/uQj7jaoh0kca6jQ=; b=kH5yPJh+gnvQmDMSq+59Uc/QlNHPo5uiQ8UWiz/gsrQ9K3CQbfzSUQWZdbLsxzGrivbjvpuGqrVgexGmNXBzGWe21ZmJM5LCUeqkvRyd3+bGZM9eeCX4MdX9N4r3ozTzdrIYvpuKEWhLuBHZTghIEspRp2f0TAg7NZbT7XxlnmE= 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 1745101293821427.9156058759181; Sat, 19 Apr 2025 15:21:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.960237.1352315 (Exim 4.92) (envelope-from ) id 1u6GYp-0003O5-7Q; Sat, 19 Apr 2025 22:21:19 +0000 Received: by outflank-mailman (output) from mailman id 960237.1352315; Sat, 19 Apr 2025 22:21:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u6GYo-0003Lz-QS; Sat, 19 Apr 2025 22:21:18 +0000 Received: by outflank-mailman (input) for mailman id 960237; Sat, 19 Apr 2025 22:21:17 +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 1u6GQa-0004yY-Es for xen-devel@lists.xenproject.org; Sat, 19 Apr 2025 22:12:48 +0000 Received: from sender4-of-o50.zoho.com (sender4-of-o50.zoho.com [136.143.188.50]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 6c1f3d9a-1d6b-11f0-9eb0-5ba50f476ded; Sun, 20 Apr 2025 00:12:47 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1745100552055701.4359410353334; Sat, 19 Apr 2025 15:09:12 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6c1f3d9a-1d6b-11f0-9eb0-5ba50f476ded ARC-Seal: i=1; a=rsa-sha256; t=1745100554; cv=none; d=zohomail.com; s=zohoarc; b=Pi5BETfqw22ls3M0dj/Fc9zbpkxZYOYO0Ys+U9C99s/UY5NuARj9msv0te8TZvdQ4YQEJepkp0Lh5caBXjSTgD+8cssYjNn818Ra5fzOvsuQ3L1PFSS2Lrnuk7LQrwkaFvvAT2gkZTptsZcfrKqc3E0tUxZRCy0+900I9/NtJ8E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1745100554; 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=ErU8vuQ7J87fC+REu5nsdOrzqMN/uQj7jaoh0kca6jQ=; b=TVW4abfNNk+4TTncybXwfIH8nIcwpmgRDmsMVmdLaZcQFpdP7kSlnDjJQbPVjfiMr9gCOL+7XRy7h3j0DNHHaEpd+e8V8OiuRF3+ACQcBc6fiLCVpBJvJH4Z9Bg0kPrJGTKjEz3T0XxFzNU11TIko3GoMeGmqNDBiteMFaPsBCo= 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=1745100554; 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=ErU8vuQ7J87fC+REu5nsdOrzqMN/uQj7jaoh0kca6jQ=; b=vezoF10khKIC1HNu4QNYl20h7IXUDCZJLJPS1LWcA1pre8zEF6vDZoLf2at6n15B h6vSOc6nY/7USaAhlG3e6B06KeGfkosDYtmtwL3unr8TH/Ubp/ZtcQtz3myTkvJNEJk ISZrDmDb0CDDiT8VL0N4kbhWrSmEujQDETsBaHaM= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, stefano.stabellini@amd.com, agarciav@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [RFC 27/38] x86/hyperlaunch: introduce domain builder general dom creation Date: Sat, 19 Apr 2025 18:08:09 -0400 Message-Id: <20250419220820.4234-28-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20250419220820.4234-1-dpsmith@apertussolutions.com> References: <20250419220820.4234-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: 1745101295147019000 Content-Type: text/plain; charset="utf-8" Introduce the builder_create_domains() function that provides the domain construciton abstraction for the hyperlaunch domain builder. Signed-off-by: Daniel P. Smith --- xen/arch/x86/domain-builder/core.c | 17 +++++++++++++++ xen/arch/x86/include/asm/bootinfo.h | 26 +++++++++++++++++++++++ xen/arch/x86/include/asm/domain-builder.h | 1 + xen/arch/x86/setup.c | 23 +++++++++++++++++--- 4 files changed, 64 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/domain-builder/core.c b/xen/arch/x86/domain-build= er/core.c index 8d137ecaaf84..2f0b8bd82c3a 100644 --- a/xen/arch/x86/domain-builder/core.c +++ b/xen/arch/x86/domain-builder/core.c @@ -9,6 +9,7 @@ =20 #include #include +#include =20 #include "fdt.h" =20 @@ -102,6 +103,22 @@ void __init builder_init(struct boot_info *bi) } } =20 +unsigned int __init builder_create_domains(struct boot_info *bi) +{ + unsigned int build_count =3D 0; + struct boot_domain *bd =3D &bi->domains[0]; + + if ( bd->kernel =3D=3D NULL && bd->capabilities & BUILD_CAPS_CONTROL ) + panic("%s: control domain missing kernel\n", __func__); + + + arch_create_dom(bi, bd); + if ( bd->d ) + build_count++; + + return build_count; +} + /* * Local variables: * mode: C diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm= /bootinfo.h index 5b2c93b1ef9e..430ae08cf5ef 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -132,6 +132,32 @@ static inline unsigned int __init next_boot_module_ind= ex( (i) <=3D (b)->nr_modules; \ (i) =3D next_boot_module_index(b, t, i + 1) ) =20 +/* + * next_boot_domain_index: + * Finds the next boot domain with capability cap, starting at array i= ndex + * start. + * + * Returns: + * Success - index in boot_domains array + * Failure - a value greater than MAX_NR_BOOTDOMS + */ +static inline unsigned int __init next_boot_domain_index( + const struct boot_info *bi, uint32_t cap, unsigned int start) +{ + int i; + + for ( i =3D start; i < bi->nr_domains; i++ ) + { + if ( bi->domains[i].capabilities & cap ) + return i; + } + + return MAX_NR_BOOTDOMS + 1; +} + +#define first_boot_domain_index(bi, cap) \ + next_boot_domain_index(bi, cap, 0) + #endif /* X86_BOOTINFO_H */ =20 /* diff --git a/xen/arch/x86/include/asm/domain-builder.h b/xen/arch/x86/inclu= de/asm/domain-builder.h index ccab02c3a1fd..5dc5661bec07 100644 --- a/xen/arch/x86/include/asm/domain-builder.h +++ b/xen/arch/x86/include/asm/domain-builder.h @@ -8,6 +8,7 @@ int __init builder_get_cmdline( struct boot_info *bi, int offset, char *cmdline, size_t size); =20 void builder_init(struct boot_info *bi); +unsigned int builder_create_domains(struct boot_info *bi); =20 struct domain *arch_create_dom( struct boot_info *bi, struct boot_domain *bd); diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 8f956b6eca4f..da5a8e8d8ed3 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -2015,9 +2015,26 @@ void asmlinkage __init noreturn __start_xen(void) * We're going to setup domain0 using the module(s) that we stashed sa= fely * above our heap. The second module, if present, is an initrd ramdisk. */ - dom0 =3D arch_create_dom(bi, &bi->domains[0]); - if ( !dom0 ) - panic("Could not set up DOM0 guest OS\n"); + ret =3D builder_create_domains(bi); + if ( ret <=3D 0 ) + panic("Could not set up boot-time domains\n"); + else + printk(XENLOG_INFO "Constructed %d boot-time domains\n", ret); + + /* Selection order: hardware domain, control domain, first domain */ + i =3D first_boot_domain_index(bi, BUILD_CAPS_HARDWARE); + if ( i >=3D MAX_NR_BOOTDOMS ) + { + i =3D first_boot_domain_index(bi, BUILD_CAPS_CONTROL); + if ( i >=3D MAX_NR_BOOTDOMS ) + { + printk(XENLOG_WARNING + "A hwdom/ctrldom not detected, using 0th domain\n"); + i =3D 0; + } + } + + dom0 =3D bi->domains[i].d; =20 heap_init_late(); =20 --=20 2.30.2