From: "Daniel P. Smith" <dpsmith@apertussolutions.com>
To: xen-devel@lists.xenproject.org
Cc: "Daniel P. Smith" <dpsmith@apertussolutions.com>,
jason.andryuk@amd.com, christopher.w.clark@gmail.com,
stefano.stabellini@amd.com, "Jan Beulich" <jbeulich@suse.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [PATCH 01/15] x86/boot: introduce boot domain
Date: Sat, 23 Nov 2024 13:20:30 -0500 [thread overview]
Message-ID: <20241123182044.30687-2-dpsmith@apertussolutions.com> (raw)
In-Reply-To: <20241123182044.30687-1-dpsmith@apertussolutions.com>
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, <xen/asm/bootdomain.h>, 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 <dpsmith@apertussolutions.com>
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
---
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 <xen/softirq.h>
#include <asm/amd.h>
+#include <asm/bootinfo.h>
#include <asm/dom0_build.h>
#include <asm/guest.h>
#include <asm/hpet.h>
@@ -596,9 +597,10 @@ int __init dom0_setup_permissions(struct domain *d)
return rc;
}
-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 = bd->d;
/* Sanity! */
BUG_ON(!pv_shim && d->domain_id != 0);
@@ -608,9 +610,9 @@ int __init construct_dom0(struct boot_info *bi, struct domain *d)
process_pending_softirqs();
if ( is_hvm_domain(d) )
- rc = dom0_construct_pvh(bi, d);
+ rc = dom0_construct_pvh(bd);
else if ( is_pv_domain(d) )
- rc = dom0_construct_pv(bi, d);
+ rc = dom0_construct_pv(bd);
else
panic("Cannot construct Dom0. No guest interface available\n");
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 domain *d)
}
}
-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 = NULL;
- unsigned int idx;
+ struct boot_module *image = bd->kernel;
+ struct boot_module *initrd = bd->ramdisk;
+ struct domain *d = bd->d;
int rc;
printk(XENLOG_INFO "*** Building a PVH Dom%d ***\n", d->domain_id);
- idx = first_boot_module_index(bi, BOOTMOD_KERNEL);
- if ( idx >= bi->nr_modules )
+ if ( image == NULL )
panic("Missing kernel boot module for %pd construction\n", d);
- image = &bi->mods[idx];
-
- idx = first_boot_module_index(bi, BOOTMOD_RAMDISK);
- if ( idx < bi->nr_modules )
- initrd = &bi->mods[idx];
-
if ( is_hardware_domain(d) )
{
/*
diff --git a/xen/arch/x86/include/asm/bootdomain.h b/xen/arch/x86/include/asm/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 <dpsmith@apertussolutions.com>
+ * Copyright (c) 2024 Christopher Clark <christopher.w.clark@gmail.com>
+ */
+
+#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 <xen/init.h>
#include <xen/multiboot.h>
#include <xen/types.h>
+#include <asm/bootdomain.h>
/* Max number of boot modules a bootloader can provide in addition to Xen */
#define MAX_NR_BOOTMODS 63
+/* 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 {
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/dom0_build.h b/xen/arch/x86/include/asm/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);
-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);
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/setup.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);
void init_IRQ(void);
-struct boot_info;
-int construct_dom0(struct boot_info *bi, struct domain *d);
+struct boot_domain;
+int construct_dom0(struct boot_domain *bd);
void setup_io_bitmap(struct domain *d);
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 domain *d,
return page;
}
-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 = NULL;
unsigned int flush_flags = 0;
start_info_t *si;
+ struct domain *d = bd->d;
struct vcpu *v = d->vcpu[0];
- struct boot_module *image;
- struct boot_module *initrd = NULL;
+ struct boot_module *image = bd->kernel;
+ struct boot_module *initrd = bd->ramdisk;
void *image_base;
unsigned long image_len;
void *image_start;
- unsigned long initrd_len = 0;
+ unsigned long initrd_len = initrd ? initrd->size : 0;
l4_pgentry_t *l4tab = NULL, *l4start = NULL;
l3_pgentry_t *l3tab = NULL, *l3start = NULL;
@@ -416,22 +417,13 @@ static int __init dom0_construct(struct boot_info *bi, struct domain *d)
printk(XENLOG_INFO "*** Building a PV Dom%d ***\n", d->domain_id);
- i = first_boot_module_index(bi, BOOTMOD_KERNEL);
- if ( i >= bi->nr_modules )
+ if ( !image )
panic("Missing kernel boot module for %pd construction\n", d);
- image = &bi->mods[i];
image_base = bootstrap_map_bm(image);
image_len = image->size;
image_start = image_base + image->headroom;
- i = first_boot_module_index(bi, BOOTMOD_RAMDISK);
- if ( i < bi->nr_modules )
- {
- initrd = &bi->mods[i];
- initrd_len = initrd->size;
- }
-
d->max_pages = ~0U;
if ( (rc = bzimage_parse(image_base, &image_start, &image_len)) != 0 )
@@ -1078,7 +1070,7 @@ out:
return rc;
}
-int __init dom0_construct_pv(struct boot_info *bi, struct domain *d)
+int __init dom0_construct_pv(struct boot_domain *bd)
{
unsigned long cr4 = read_cr4();
int rc;
@@ -1096,7 +1088,7 @@ int __init dom0_construct_pv(struct boot_info *bi, struct domain *d)
write_cr4(cr4 & ~X86_CR4_SMAP);
}
- rc = dom0_construct(bi, d);
+ rc = dom0_construct(bd);
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_info *bi)
.misc_flags = opt_dom0_msr_relaxed ? XEN_X86_MSR_RELAXED : 0,
},
};
+ struct boot_domain *bd = &bi->domains[0];
struct domain *d;
domid_t domid;
- struct boot_module *image;
- unsigned int idx;
-
- idx = first_boot_module_index(bi, BOOTMOD_KERNEL);
- if ( idx >= bi->nr_modules )
- panic("Missing kernel boot module for building domain\n");
-
- image = &bi->mods[idx];
if ( opt_dom0_pvh )
{
@@ -1013,11 +1006,11 @@ static struct domain *__init create_dom0(struct boot_info *bi)
panic("Error creating d%uv0\n", domid);
/* 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->loader));
if ( bi->kextra )
/* kextra always includes exactly one leading space. */
@@ -1039,10 +1032,11 @@ static struct domain *__init create_dom0(struct boot_info *bi)
safe_strcat(cmdline, acpi_param);
}
- image->cmdline_pa = __pa(cmdline);
+ bd->kernel->cmdline_pa = __pa(cmdline);
}
- if ( construct_dom0(bi, d) != 0 )
+ bd->d = d;
+ if ( construct_dom0(bd) != 0 )
panic("Could not construct domain 0\n");
return d;
@@ -1249,6 +1243,7 @@ void asmlinkage __init noreturn __start_xen(void)
/* Dom0 kernel is always first */
bi->mods[0].type = BOOTMOD_KERNEL;
+ bi->domains[0].kernel = &bi->mods[0];
if ( pvh_boot )
{
@@ -2110,6 +2105,7 @@ void asmlinkage __init noreturn __start_xen(void)
if ( initrdidx < MAX_NR_BOOTMODS )
{
bi->mods[initrdidx].type = BOOTMOD_RAMDISK;
+ bi->domains[0].ramdisk = &bi->mods[initrdidx];
if ( first_boot_module_index(bi, BOOTMOD_UNKNOWN) < MAX_NR_BOOTMODS )
printk(XENLOG_WARNING
"Multiple initrd candidates, picking module #%u\n",
--
2.30.2
next prev parent reply other threads:[~2024-11-23 18:21 UTC|newest]
Thread overview: 86+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-23 18:20 [PATCH 00/15] Hyperlaunch device tree for dom0 Daniel P. Smith
2024-11-23 18:20 ` Daniel P. Smith [this message]
2024-12-02 9:57 ` [PATCH 01/15] x86/boot: introduce boot domain Jan Beulich
2024-12-04 19:16 ` Daniel P. Smith
2024-11-23 18:20 ` [PATCH 02/15] x86/boot: introduce domid field to struct boot_domain Daniel P. Smith
2024-11-23 18:20 ` [PATCH 03/15] x86/boot: add cmdline " Daniel P. Smith
2024-11-25 15:36 ` Jason Andryuk
2024-12-11 2:56 ` Daniel P. Smith
2024-12-02 9:49 ` Jan Beulich
2024-12-11 3:01 ` Daniel P. Smith
2024-11-23 18:20 ` [PATCH 04/15] kconfig: introduce option to independently enable libfdt Daniel P. Smith
2024-11-25 15:42 ` Jason Andryuk
2024-12-11 3:03 ` Daniel P. Smith
2024-11-26 10:03 ` Jan Beulich
2024-11-26 10:05 ` Jan Beulich
2024-12-11 3:05 ` Daniel P. Smith
2024-12-11 3:04 ` Daniel P. Smith
2024-11-23 18:20 ` [PATCH 05/15] kconfig: introduce domain builder config option Daniel P. Smith
2024-11-25 17:55 ` Jason Andryuk
2024-12-11 3:13 ` Daniel P. Smith
2024-11-26 10:09 ` Jan Beulich
2024-12-11 3:15 ` Daniel P. Smith
2024-11-23 18:20 ` [PATCH 06/15] x86/hyperlaunch: introduce the domain builder Daniel P. Smith
2024-11-25 17:52 ` Jason Andryuk
2024-11-25 20:23 ` Jason Andryuk
2024-12-02 9:55 ` Jan Beulich
2024-12-02 15:31 ` Jason Andryuk
2024-12-11 11:14 ` Daniel P. Smith
2024-12-02 10:10 ` Jan Beulich
2024-12-11 12:36 ` Daniel P. Smith
2024-12-12 11:06 ` Jan Beulich
2024-12-12 15:24 ` Daniel P. Smith
2024-11-23 18:20 ` [PATCH 07/15] x86/hyperlaunch: initial support for hyperlaunch device tree Daniel P. Smith
2024-11-25 20:11 ` Jason Andryuk
2024-12-11 12:49 ` Daniel P. Smith
2024-12-02 11:37 ` Jan Beulich
2024-12-11 12:55 ` Daniel P. Smith
2024-11-23 18:20 ` [PATCH 08/15] x86/hyperlaunch: locate dom0 kernel with hyperlaunch Daniel P. Smith
2024-11-25 22:54 ` Jason Andryuk
2024-12-11 14:19 ` Daniel P. Smith
2024-12-02 11:53 ` Jan Beulich
2024-12-11 15:41 ` Daniel P. Smith
2024-12-12 11:25 ` Jan Beulich
2024-11-23 18:20 ` [PATCH 09/15] x86/hyperlaunch: obtain cmdline from device tree Daniel P. Smith
2024-11-25 23:12 ` Jason Andryuk
2024-12-11 15:46 ` Daniel P. Smith
2024-11-23 18:20 ` [PATCH 10/15] x86/hyperlaunch: locate dom0 initrd with hyperlaunch Daniel P. Smith
2024-11-25 23:34 ` Jason Andryuk
2024-12-11 15:49 ` Daniel P. Smith
2024-11-23 18:20 ` [PATCH 11/15] x86/hyperlaunch: add domain id parsing to domain config Daniel P. Smith
2024-11-25 23:45 ` Jason Andryuk
2024-12-02 12:00 ` Jan Beulich
2024-12-11 16:07 ` Daniel P. Smith
2024-12-11 16:06 ` Daniel P. Smith
2024-12-02 12:02 ` Jan Beulich
2024-12-11 16:21 ` Daniel P. Smith
2024-12-19 16:40 ` Daniel P. Smith
2024-11-23 18:20 ` [PATCH 12/15] x86/hyperlaunch: specify dom0 mode with device tree Daniel P. Smith
2024-11-25 23:52 ` Jason Andryuk
2024-12-11 16:24 ` Daniel P. Smith
2024-12-02 12:05 ` Jan Beulich
2024-12-11 16:31 ` Daniel P. Smith
2024-12-02 12:06 ` Jan Beulich
2024-12-11 17:48 ` Daniel P. Smith
2024-12-12 11:31 ` Jan Beulich
2024-11-23 18:20 ` [PATCH 13/15] x86/hyperlaunch: add memory parsing to domain config Daniel P. Smith
2024-11-26 0:03 ` Jason Andryuk
2024-12-11 17:59 ` Daniel P. Smith
2024-12-26 16:16 ` Daniel P. Smith
2024-12-02 12:14 ` Jan Beulich
2024-12-11 18:02 ` Daniel P. Smith
2024-12-12 11:34 ` Jan Beulich
2024-11-23 18:20 ` [PATCH 14/15] x86/hyperlaunch: add max vcpu parsing of hyperlaunch device tree Daniel P. Smith
2024-11-26 0:05 ` Jason Andryuk
2024-12-11 18:05 ` Daniel P. Smith
2024-12-02 12:19 ` Jan Beulich
2024-12-11 19:49 ` Daniel P. Smith
2024-12-12 11:37 ` Jan Beulich
2024-11-23 18:20 ` [PATCH 15/15] x86/hyperlaunch: add capabilities to boot domain Daniel P. Smith
2024-11-26 0:09 ` Jason Andryuk
2024-12-11 19:51 ` Daniel P. Smith
2024-12-02 12:23 ` Jan Beulich
2024-12-11 19:56 ` Daniel P. Smith
2024-12-12 11:40 ` Jan Beulich
2024-11-26 0:11 ` [PATCH 00/15] Hyperlaunch device tree for dom0 Jason Andryuk
2024-12-11 19:57 ` Daniel P. Smith
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241123182044.30687-2-dpsmith@apertussolutions.com \
--to=dpsmith@apertussolutions.com \
--cc=andrew.cooper3@citrix.com \
--cc=christopher.w.clark@gmail.com \
--cc=jason.andryuk@amd.com \
--cc=jbeulich@suse.com \
--cc=roger.pau@citrix.com \
--cc=stefano.stabellini@amd.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.