[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 11/19] x86: Replace boot_domain with kernel_info
kernel_info and boot_domain serve basically the same role. Unify them so they can be used in common code for domain building purposes across all architectures. kernel_info has a lot of fields x86 doesn't care about, but riscv and arm do. Hence rather than moving them to the arch-specific files, x86 is ifdeffed out of those so arm and riscv can still keep sharing the definitions. Also, deconstify module pointers inside kernel_info, because x86 relies on mutating through them. Signed-off-by: Alejandro Vallejo <agarciav@xxxxxxx> --- I'd be happier renaming struct kernel_info to struct bootdomain to clean up the misnaming but I don't want to deal with the refactor in arm+riscv right now. I've typedeffed it on x86 to bootdomain_t to reduce the diff delta. (otherwise there's a lot of useless s/bd/ki/) Some headers still use "struct kernel_info" in x86 to avoid extra includes. Re-typedeffing only works from C11 onwards. --- xen/arch/x86/dom0_build.c | 2 +- xen/arch/x86/hvm/dom0_build.c | 10 ++++---- xen/arch/x86/include/asm/boot-domain.h | 33 -------------------------- xen/arch/x86/include/asm/bootinfo.h | 7 ++++-- xen/arch/x86/include/asm/dom0_build.h | 6 ++--- xen/arch/x86/include/asm/kernel.h | 20 ++++++++++++++++ xen/arch/x86/include/asm/setup.h | 4 ++-- xen/arch/x86/pv/dom0_build.c | 8 +++---- xen/arch/x86/setup.c | 26 ++++++++++---------- xen/include/xen/fdt-kernel.h | 2 +- 10 files changed, 55 insertions(+), 63 deletions(-) delete mode 100644 xen/arch/x86/include/asm/boot-domain.h create mode 100644 xen/arch/x86/include/asm/kernel.h diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 0b467fd4a4..5bd4d39d10 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -615,7 +615,7 @@ int __init dom0_setup_permissions(struct domain *d) return rc; } -int __init construct_dom0(const struct boot_domain *bd) +int __init construct_dom0(const bootdomain_t *bd) { int rc; const struct domain *d = bd->d; diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index 96410344a8..66d7046577 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -644,11 +644,11 @@ static bool __init check_and_adjust_load_address( } static int __init pvh_load_kernel( - const struct boot_domain *bd, paddr_t *entry, paddr_t *start_info_addr) + const bootdomain_t *bd, paddr_t *entry, paddr_t *start_info_addr) { struct domain *d = bd->d; - struct bootmodule *image = bd->kernel; - struct bootmodule *initrd = bd->module; + struct bootmodule *image = bd->kernel_bootmodule; + struct bootmodule *initrd = bd->initrd_bootmodule; void *image_base = bootstrap_map_bm(image); void *image_start = image_base + image->arch.headroom; unsigned long image_len = image->size; @@ -1329,7 +1329,7 @@ static void __hwdom_init pvh_setup_mmcfg(struct domain *d) } } -int __init dom0_construct_pvh(const struct boot_domain *bd) +int __init dom0_construct_pvh(const bootdomain_t *bd) { paddr_t entry, start_info; struct domain *d = bd->d; @@ -1337,7 +1337,7 @@ int __init dom0_construct_pvh(const struct boot_domain *bd) printk(XENLOG_INFO "*** Building a PVH Dom%d ***\n", d->domain_id); - if ( bd->kernel == NULL ) + if ( bd->kernel_bootmodule == NULL ) panic("Missing kernel boot module for %pd construction\n", d); if ( is_hardware_domain(d) ) diff --git a/xen/arch/x86/include/asm/boot-domain.h b/xen/arch/x86/include/asm/boot-domain.h deleted file mode 100644 index 242e9c9c2b..0000000000 --- a/xen/arch/x86/include/asm/boot-domain.h +++ /dev/null @@ -1,33 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Copyright (c) 2024 Apertus Solutions, LLC - * Author: Daniel P. Smith <dpsmith@xxxxxxxxxxxxxxxxxxxx> - * Copyright (c) 2024 Christopher Clark <christopher.w.clark@xxxxxxxxx> - */ - -#ifndef __XEN_X86_BOOTDOMAIN_H__ -#define __XEN_X86_BOOTDOMAIN_H__ - -#include <public/xen.h> - -struct boot_domain { - domid_t domid; - - struct bootmodule *kernel; - struct bootmodule *module; - const char *cmdline; - - 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 f3210b7d6a..6b151c7759 100644 --- a/xen/arch/x86/include/asm/bootinfo.h +++ b/xen/arch/x86/include/asm/bootinfo.h @@ -9,10 +9,10 @@ #define X86_BOOTINFO_H #include <xen/bootfdt.h> +#include <xen/fdt-kernel.h> #include <xen/init.h> #include <xen/multiboot.h> #include <xen/types.h> -#include <asm/boot-domain.h> /* Max number of boot modules a bootloader can provide in addition to Xen */ #define MAX_NR_BOOTMODS 63 @@ -20,6 +20,9 @@ /* Max number of boot domains that Xen can construct */ #define MAX_NR_BOOTDOMS 1 +/* kernel_info is a misnomer. It holds information for a to-be domain. */ +typedef struct kernel_info bootdomain_t; + /* * Xen internal representation of information provided by the * bootloader/environment, or derived from the information. @@ -34,7 +37,7 @@ struct boot_info { unsigned int nr_modules; struct bootmodule mods[MAX_NR_BOOTMODS + 1]; - struct boot_domain domains[MAX_NR_BOOTDOMS]; + bootdomain_t 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 ff021c24af..68dc5e487c 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_domain; -int dom0_construct_pv(const struct boot_domain *bd); -int dom0_construct_pvh(const struct boot_domain *bd); +struct kernel_info; +int dom0_construct_pv(const struct kernel_info *bd); +int dom0_construct_pvh(const struct kernel_info *bd); unsigned long dom0_paging_pages(const struct domain *d, unsigned long nr_pages); diff --git a/xen/arch/x86/include/asm/kernel.h b/xen/arch/x86/include/asm/kernel.h new file mode 100644 index 0000000000..f945f0957b --- /dev/null +++ b/xen/arch/x86/include/asm/kernel.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __ARCH_X86_KERNEL_H__ +#define __ARCH_X86_KERNEL_H__ + +#include <public/xen.h> + +typedef struct arch_kernel_info { + domid_t domid; +} arch_bootdomain_t; + +#endif /* #__ARCH_X86_KERNEL_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h index c7deaba109..2183036da3 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_domain; -int construct_dom0(const struct boot_domain *bd); +struct kernel_info; /* bootdomain_t */ +int construct_dom0(const struct kernel_info *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 e6c77413f5..2bb5d1bcdf 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(const struct boot_domain *bd) +static int __init dom0_construct(const bootdomain_t *bd) { unsigned int i; int rc, order, machine; @@ -374,8 +374,8 @@ static int __init dom0_construct(const struct boot_domain *bd) struct domain *d = bd->d; struct vcpu *v = d->vcpu[0]; - struct bootmodule *image = bd->kernel; - struct bootmodule *initrd = bd->module; + struct bootmodule *image = bd->kernel_bootmodule; + struct bootmodule *initrd = bd->initrd_bootmodule; void *image_base; unsigned long image_len; void *image_start; @@ -1070,7 +1070,7 @@ out: return rc; } -int __init dom0_construct_pv(const struct boot_domain *bd) +int __init dom0_construct_pv(const bootdomain_t *bd) { unsigned long cr4 = read_cr4(); int rc; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index a6b3dbfc8c..aa3d913191 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -297,7 +297,9 @@ static const char *cmdline_cook(const char *p, const char *loader_name); struct boot_info __initdata xen_boot_info = { .loader = "unknown", .cmdline = "", - .domains = { [0 ... MAX_NR_BOOTDOMS - 1] = { .domid = DOMID_INVALID } }, + .domains = { [0 ... MAX_NR_BOOTDOMS - 1] = { + .arch = { .domid = DOMID_INVALID } + }}, .mods = { [0 ... MAX_NR_BOOTMODS] = { .kind = BOOTMOD_UNKNOWN } }, }; @@ -982,10 +984,10 @@ static unsigned int __init copy_bios_e820(struct e820entry *map, unsigned int li } static size_t __init domain_cmdline_size(const struct boot_info *bi, - const struct boot_domain *bd) + const bootdomain_t *bd) { size_t s = bi->kextra ? strlen(bi->kextra) : 0; - const struct arch_bootmodule *abm = &bd->kernel->arch; + const struct arch_bootmodule *abm = &bd->kernel_bootmodule->arch; s += abm->cmdline_pa ? strlen(__va(abm->cmdline_pa)) : 0; @@ -1017,7 +1019,7 @@ 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]; + bootdomain_t *bd = &bi->domains[0]; struct domain *d; if ( opt_dom0_pvh ) @@ -1034,11 +1036,11 @@ static struct domain *__init create_dom0(struct boot_info *bi) dom0_cfg.flags |= XEN_DOMCTL_CDF_iommu; /* Create initial domain. Not d0 for pvshim. */ - bd->domid = get_initial_domain_id(); - d = domain_create(bd->domid, &dom0_cfg, + bd->arch.domid = get_initial_domain_id(); + d = domain_create(bd->arch.domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged | CDF_hardware); if ( IS_ERR(d) ) - panic("Error creating d%u: %ld\n", bd->domid, PTR_ERR(d)); + panic("Error creating d%u: %ld\n", bd->arch.domid, PTR_ERR(d)); init_dom0_cpuid_policy(d); @@ -1051,9 +1053,9 @@ static struct domain *__init create_dom0(struct boot_info *bi) if ( !(cmdline = xzalloc_array(char, cmdline_size)) ) panic("Error allocating cmdline buffer for %pd\n", d); - if ( bd->kernel->arch.cmdline_pa ) + if ( bd->kernel_bootmodule->arch.cmdline_pa ) strlcpy(cmdline, - cmdline_cook(__va(bd->kernel->arch.cmdline_pa), + cmdline_cook(__va(bd->kernel_bootmodule->arch.cmdline_pa), bi->loader), cmdline_size); @@ -1076,7 +1078,7 @@ static struct domain *__init create_dom0(struct boot_info *bi) strlcat(cmdline, " acpi=", cmdline_size); strlcat(cmdline, acpi_param, cmdline_size); } - bd->kernel->arch.cmdline_pa = 0; + bd->kernel_bootmodule->arch.cmdline_pa = 0; bd->cmdline = cmdline; } @@ -1290,7 +1292,7 @@ void asmlinkage __init noreturn __start_xen(void) /* Dom0 kernel is always first */ bi->mods[0].kind = BOOTMOD_KERNEL; - bi->domains[0].kernel = &bi->mods[0]; + bi->domains[0].kernel_bootmodule = &bi->mods[0]; if ( pvh_boot ) { @@ -2157,7 +2159,7 @@ void asmlinkage __init noreturn __start_xen(void) if ( initrdidx < MAX_NR_BOOTMODS ) { bi->mods[initrdidx].kind = BOOTMOD_RAMDISK; - bi->domains[0].module = &bi->mods[initrdidx]; + bi->domains[0].initrd_bootmodule = &bi->mods[initrdidx]; if ( first_boot_module_index(bi, BOOTMOD_UNKNOWN) < MAX_NR_BOOTMODS ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n", diff --git a/xen/include/xen/fdt-kernel.h b/xen/include/xen/fdt-kernel.h index 1939c3ebf7..2f0ee42ebc 100644 --- a/xen/include/xen/fdt-kernel.h +++ b/xen/include/xen/fdt-kernel.h @@ -34,7 +34,7 @@ struct kernel_info { paddr_t gnttab_size; /* boot blob load addresses */ - const struct bootmodule *kernel_bootmodule, *initrd_bootmodule, *dtb_bootmodule; + struct bootmodule *kernel_bootmodule, *initrd_bootmodule, *dtb_bootmodule; const char* cmdline; paddr_t dtb_paddr; paddr_t initrd_paddr; -- 2.43.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |