[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC 27/38] x86/hyperlaunch: introduce domain builder general dom creation


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • Date: Sat, 19 Apr 2025 18:08:09 -0400
  • Arc-authentication-results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@xxxxxxxxxxxxxxxxxxxx; dmarc=pass header.from=<dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • 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-seal: i=1; a=rsa-sha256; t=1745100554; cv=none; d=zohomail.com; s=zohoarc; b=Pi5BETfqw22ls3M0dj/Fc9zbpkxZYOYO0Ys+U9C99s/UY5NuARj9msv0te8TZvdQ4YQEJepkp0Lh5caBXjSTgD+8cssYjNn818Ra5fzOvsuQ3L1PFSS2Lrnuk7LQrwkaFvvAT2gkZTptsZcfrKqc3E0tUxZRCy0+900I9/NtJ8E=
  • Cc: "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, jason.andryuk@xxxxxxx, stefano.stabellini@xxxxxxx, agarciav@xxxxxxx, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Sat, 19 Apr 2025 22:21:19 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Introduce the builder_create_domains() function that provides the domain
construciton abstraction for the hyperlaunch domain builder.

Signed-off-by: Daniel P. Smith <dpsmith@xxxxxxxxxxxxxxxxxxxx>
---
 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-builder/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 @@
 
 #include <asm/bootinfo.h>
 #include <asm/setup.h>
+#include <asm/domain-builder.h>
 
 #include "fdt.h"
 
@@ -102,6 +103,22 @@ void __init builder_init(struct boot_info *bi)
     }
 }
 
+unsigned int __init builder_create_domains(struct boot_info *bi)
+{
+    unsigned int build_count = 0;
+    struct boot_domain *bd = &bi->domains[0];
+
+    if ( bd->kernel == 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_index(
           (i) <= (b)->nr_modules;                       \
           (i) = next_boot_module_index(b, t, i + 1) )
 
+/*
+ * next_boot_domain_index:
+ *     Finds the next boot domain with capability cap, starting at array index
+ *     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 = 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 */
 
 /*
diff --git a/xen/arch/x86/include/asm/domain-builder.h 
b/xen/arch/x86/include/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);
 
 void builder_init(struct boot_info *bi);
+unsigned int builder_create_domains(struct boot_info *bi);
 
 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 safely
      * above our heap. The second module, if present, is an initrd ramdisk.
      */
-    dom0 = arch_create_dom(bi, &bi->domains[0]);
-    if ( !dom0 )
-        panic("Could not set up DOM0 guest OS\n");
+    ret = builder_create_domains(bi);
+    if ( ret <= 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 = first_boot_domain_index(bi, BUILD_CAPS_HARDWARE);
+    if ( i >= MAX_NR_BOOTDOMS )
+    {
+        i = first_boot_domain_index(bi, BUILD_CAPS_CONTROL);
+        if ( i >= MAX_NR_BOOTDOMS )
+        {
+            printk(XENLOG_WARNING
+                   "A hwdom/ctrldom not detected, using 0th domain\n");
+            i = 0;
+        }
+    }
+
+    dom0 = bi->domains[i].d;
 
     heap_init_late();
 
-- 
2.30.2




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.