|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [RFCv2 26/38] x86/hyperlaunch: introduce domain builder general dom creation
Introduce the builder_create_domains() function that provides the general
domain construction abstraction that selects between classic dom0 construction
and the hyperlaunch domain builder.
Signed-off-by: Daniel P. Smith <dpsmith@xxxxxxxxxxxxxxxxxxxx>
---
xen/arch/x86/domain-builder/Makefile | 1 +
xen/arch/x86/domain-builder/core.c | 36 ++++++++++++++++++++++++++++
xen/arch/x86/include/asm/bootinfo.h | 26 ++++++++++++++++++++
xen/arch/x86/setup.c | 23 +++++++++++++++---
xen/include/xen/domain-builder.h | 2 ++
5 files changed, 85 insertions(+), 3 deletions(-)
create mode 100644 xen/arch/x86/domain-builder/core.c
diff --git a/xen/arch/x86/domain-builder/Makefile
b/xen/arch/x86/domain-builder/Makefile
index 69a7c574a8d8..96040bf66a04 100644
--- a/xen/arch/x86/domain-builder/Makefile
+++ b/xen/arch/x86/domain-builder/Makefile
@@ -1 +1,2 @@
+obj-y += core.o
obj-y += domain.o
diff --git a/xen/arch/x86/domain-builder/core.c
b/xen/arch/x86/domain-builder/core.c
new file mode 100644
index 000000000000..3b315e59b188
--- /dev/null
+++ b/xen/arch/x86/domain-builder/core.c
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2025, Apertus Solutions, LLC
+ */
+
+#include <xen/domain-builder.h>
+#include <xen/init.h>
+#include <xen/lib.h>
+
+#include <asm/bootinfo.h>
+
+unsigned int __init builder_create_domains(struct boot_info *bi)
+{
+ unsigned int build_count = 0;
+ struct boot_domain *bd = &bi->domains[0];
+
+ if ( bd->capabilities & DOMAIN_CAPS_HARDWARE && bd->kernel == NULL )
+ panic("%s: hardware domain missing kernel\n", __func__);
+
+
+ arch_create_dom(bi, bd);
+ if ( bd->d )
+ build_count++;
+
+ return build_count;
+}
+
+/*
+ * 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 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/setup.c b/xen/arch/x86/setup.c
index 2458a43902e6..b2c7846be18f 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -2026,9 +2026,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, DOMAIN_CAPS_HARDWARE);
+ if ( i >= MAX_NR_BOOTDOMS )
+ {
+ i = first_boot_domain_index(bi, DOMAIN_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();
diff --git a/xen/include/xen/domain-builder.h b/xen/include/xen/domain-builder.h
index a9df326682ac..c26f670d4f66 100644
--- a/xen/include/xen/domain-builder.h
+++ b/xen/include/xen/domain-builder.h
@@ -43,4 +43,6 @@ void domain_vcpus_create(struct domain *d);
struct domain *arch_create_dom(
struct boot_info *bi, struct boot_domain *bd);
+unsigned int builder_create_domains(struct boot_info *bi);
+
#endif /* __XEN_DOMAIN_BUILDER_H__ */
--
2.30.2
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |