|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] xen: Refactor kernel_info to have a header like boot_domain
commit cf52fe3f6318f22e594b049dc5d9ede834d5caa3
Author: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
AuthorDate: Tue Jul 22 02:05:14 2025 +0200
Commit: Stefano Stabellini <stefano.stabellini@xxxxxxx>
CommitDate: Mon Jul 21 17:14:00 2025 -0700
xen: Refactor kernel_info to have a header like boot_domain
Create a struct field within kernel_info with the contents common to
kernel_info and boot_domain, and define that field in common code. This
enables x86 to use that field as-is and drop x86's boot_domain.
Note that x86 mutates the module when releasing it, calculating headroom,
etc. So they must be made non-const on move.
Not a functional change.
Signed-off-by: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
---
xen/arch/arm/dom0less-build.c | 8 ++++----
xen/arch/arm/domain_build.c | 20 ++++++++++----------
xen/arch/arm/kernel.c | 8 ++++----
xen/common/device-tree/dom0less-build.c | 18 +++++++++---------
xen/common/device-tree/domain-build.c | 20 ++++++++++----------
xen/common/device-tree/kernel.c | 20 ++++++++++----------
xen/include/xen/bootfdt.h | 9 +++++++++
xen/include/xen/fdt-kernel.h | 5 ++---
8 files changed, 58 insertions(+), 50 deletions(-)
diff --git a/xen/arch/arm/dom0less-build.c b/xen/arch/arm/dom0less-build.c
index 4b285cff5e..69b9ea22ce 100644
--- a/xen/arch/arm/dom0less-build.c
+++ b/xen/arch/arm/dom0less-build.c
@@ -32,7 +32,7 @@ static int __init make_gicv2_domU_node(struct kernel_info
*kinfo)
int res = 0;
__be32 reg[(GUEST_ROOT_ADDRESS_CELLS + GUEST_ROOT_SIZE_CELLS) * 2];
__be32 *cells;
- const struct domain *d = kinfo->d;
+ const struct domain *d = kinfo->bd.d;
res = domain_fdt_begin_node(fdt, "interrupt-controller",
vgic_dist_base(&d->arch.vgic));
@@ -85,7 +85,7 @@ static int __init make_gicv3_domU_node(struct kernel_info
*kinfo)
void *fdt = kinfo->fdt;
int res = 0;
__be32 *reg, *cells;
- const struct domain *d = kinfo->d;
+ const struct domain *d = kinfo->bd.d;
unsigned int i, len = 0;
res = domain_fdt_begin_node(fdt, "interrupt-controller",
@@ -152,7 +152,7 @@ static int __init make_gicv3_domU_node(struct kernel_info
*kinfo)
int __init make_intc_domU_node(struct kernel_info *kinfo)
{
- switch ( kinfo->d->arch.vgic.version )
+ switch ( kinfo->bd.d->arch.vgic.version )
{
#ifdef CONFIG_GICV3
case GIC_V3:
@@ -175,7 +175,7 @@ static int __init make_vpl011_uart_node(struct kernel_info
*kinfo)
gic_interrupt_t intr;
__be32 reg[GUEST_ROOT_ADDRESS_CELLS + GUEST_ROOT_SIZE_CELLS];
__be32 *cells;
- struct domain *d = kinfo->d;
+ struct domain *d = kinfo->bd.d;
res = domain_fdt_begin_node(fdt, "sbsa-uart", d->arch.vpl011.base_addr);
if ( res )
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index ed668bd61c..5f81d060dd 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -459,8 +459,8 @@ static int __init write_properties(struct domain *d, struct
kernel_info *kinfo,
int had_dom0_bootargs = 0;
struct dt_device_node *iommu_node;
- if ( kinfo->cmdline && kinfo->cmdline[0] )
- bootargs = &kinfo->cmdline[0];
+ if ( kinfo->bd.cmdline && kinfo->bd.cmdline[0] )
+ bootargs = &kinfo->bd.cmdline[0];
/*
* We always skip the IOMMU device when creating DT for hwdom if there is
@@ -574,7 +574,7 @@ static int __init write_properties(struct domain *d, struct
kernel_info *kinfo,
if ( dt_node_path_is_equal(node, "/chosen") )
{
- const struct boot_module *initrd = kinfo->initrd;
+ const struct boot_module *initrd = kinfo->bd.initrd;
if ( bootargs )
{
@@ -1456,7 +1456,7 @@ int __init make_timer_node(const struct kernel_info
*kinfo)
if ( res )
return res;
- if ( !is_64bit_domain(kinfo->d) )
+ if ( !is_64bit_domain(kinfo->bd.d) )
res = fdt_property_string(fdt, "compatible", "arm,armv7-timer");
else
res = fdt_property_string(fdt, "compatible", "arm,armv8-timer");
@@ -1468,7 +1468,7 @@ int __init make_timer_node(const struct kernel_info
*kinfo)
* It always exposes an active-low level-sensitive interrupt.
*/
- if ( is_hardware_domain(kinfo->d) )
+ if ( is_hardware_domain(kinfo->bd.d) )
{
irq[TIMER_PHYS_SECURE_PPI] = timer_get_irq(TIMER_PHYS_SECURE_PPI);
irq[TIMER_PHYS_NONSECURE_PPI] =
@@ -1517,7 +1517,7 @@ int __init make_chosen_node(const struct kernel_info
*kinfo)
{
int res;
const char *bootargs = NULL;
- const struct boot_module *initrd = kinfo->initrd;
+ const struct boot_module *initrd = kinfo->bd.initrd;
void *fdt = kinfo->fdt;
dt_dprintk("Create chosen node\n");
@@ -1525,9 +1525,9 @@ int __init make_chosen_node(const struct kernel_info
*kinfo)
if ( res )
return res;
- if ( kinfo->cmdline && kinfo->cmdline[0] )
+ if ( kinfo->bd.cmdline && kinfo->bd.cmdline[0] )
{
- bootargs = &kinfo->cmdline[0];
+ bootargs = &kinfo->bd.cmdline[0];
res = fdt_property(fdt, "bootargs", bootargs, strlen(bootargs) + 1);
if ( res )
return res;
@@ -1976,7 +1976,7 @@ static int __init construct_dom0(struct domain *d)
d->max_pages = dom0_mem >> PAGE_SHIFT;
kinfo.unassigned_mem = dom0_mem;
- kinfo.d = d;
+ kinfo.bd.d = d;
rc = kernel_probe(&kinfo, NULL);
if ( rc < 0 )
@@ -1988,7 +1988,7 @@ static int __init construct_dom0(struct domain *d)
int __init construct_hwdom(struct kernel_info *kinfo,
const struct dt_device_node *node)
{
- struct domain *d = kinfo->d;
+ struct domain *d = kinfo->bd.d;
int rc;
iommu_hwdom_init(d);
diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c
index e734ec5c1e..48f4b56d0c 100644
--- a/xen/arch/arm/kernel.c
+++ b/xen/arch/arm/kernel.c
@@ -46,7 +46,7 @@ static void __init place_modules(struct kernel_info *info,
paddr_t kernbase, paddr_t kernend)
{
/* Align DTB and initrd size to 2Mb. Linux only requires 4 byte alignment
*/
- const struct boot_module *mod = info->initrd;
+ const struct boot_module *mod = info->bd.initrd;
const struct membanks *mem = kernel_info_get_mem(info);
const paddr_t initrd_len = ROUNDUP(mod ? mod->size : 0, MB(2));
const paddr_t dtb_len = ROUNDUP(fdt_totalsize(info->fdt), MB(2));
@@ -152,12 +152,12 @@ static void __init kernel_zimage_load(struct kernel_info
*info)
kernel = ioremap_wc(paddr, len);
if ( !kernel )
- panic("Unable to map the %pd kernel\n", info->d);
+ panic("Unable to map the %pd kernel\n", info->bd.d);
- rc = copy_to_guest_phys_flush_dcache(info->d, load_addr,
+ rc = copy_to_guest_phys_flush_dcache(info->bd.d, load_addr,
kernel, len);
if ( rc != 0 )
- panic("Unable to copy the kernel in the %pd memory\n", info->d);
+ panic("Unable to copy the kernel in the %pd memory\n", info->bd.d);
iounmap(kernel);
}
diff --git a/xen/common/device-tree/dom0less-build.c
b/xen/common/device-tree/dom0less-build.c
index 0012046574..15b3c4b241 100644
--- a/xen/common/device-tree/dom0less-build.c
+++ b/xen/common/device-tree/dom0less-build.c
@@ -170,18 +170,18 @@ static int __init handle_passthrough_prop(struct
kernel_info *kinfo,
return -EINVAL;
}
- res = iomem_permit_access(kinfo->d, paddr_to_pfn(mstart),
+ res = iomem_permit_access(kinfo->bd.d, paddr_to_pfn(mstart),
paddr_to_pfn(PAGE_ALIGN(mstart + size - 1)));
if ( res )
{
printk(XENLOG_ERR "Unable to permit to dom%d access to"
" 0x%"PRIpaddr" - 0x%"PRIpaddr"\n",
- kinfo->d->domain_id,
+ kinfo->bd.d->domain_id,
mstart & PAGE_MASK, PAGE_ALIGN(mstart + size) - 1);
return res;
}
- res = map_regions_p2mt(kinfo->d,
+ res = map_regions_p2mt(kinfo->bd.d,
gaddr_to_gfn(gstart),
PFN_DOWN(size),
maddr_to_mfn(mstart),
@@ -220,7 +220,7 @@ static int __init handle_passthrough_prop(struct
kernel_info *kinfo,
return -EINVAL;
}
- res = map_device_irqs_to_domain(kinfo->d, node, true, NULL);
+ res = map_device_irqs_to_domain(kinfo->bd.d, node, true, NULL);
if ( res < 0 )
return res;
@@ -232,7 +232,7 @@ static int __init handle_passthrough_prop(struct
kernel_info *kinfo,
if ( xen_force && !dt_device_is_protected(node) )
return 0;
- return iommu_assign_dt_device(kinfo->d, node);
+ return iommu_assign_dt_device(kinfo->bd.d, node);
}
static int __init handle_prop_pfdt(struct kernel_info *kinfo,
@@ -299,14 +299,14 @@ static int __init handle_prop_pfdt(struct kernel_info
*kinfo,
address_cells, size_cells);
if ( res < 0 )
{
- printk(XENLOG_ERR "Failed to assign device to %pd\n", kinfo->d);
+ printk(XENLOG_ERR "Failed to assign device to %pd\n", kinfo->bd.d);
return res;
}
}
else if ( (xen_path && !xen_reg) || (xen_reg && !xen_path && !xen_force) )
{
printk(XENLOG_ERR "xen,reg or xen,path missing for %pd\n",
- kinfo->d);
+ kinfo->bd.d);
return -EINVAL;
}
@@ -608,7 +608,7 @@ static int __init alloc_xenstore_page(struct domain *d)
static int __init alloc_xenstore_params(struct kernel_info *kinfo)
{
- struct domain *d = kinfo->d;
+ struct domain *d = kinfo->bd.d;
int rc = 0;
#ifdef CONFIG_HVM
@@ -776,7 +776,7 @@ static int __init construct_domU(struct domain *d,
d->max_pages = ((paddr_t)mem * SZ_1K) >> PAGE_SHIFT;
- kinfo.d = d;
+ kinfo.bd.d = d;
rc = kernel_probe(&kinfo, node);
if ( rc < 0 )
diff --git a/xen/common/device-tree/domain-build.c
b/xen/common/device-tree/domain-build.c
index 4eea095e49..2fdea6624a 100644
--- a/xen/common/device-tree/domain-build.c
+++ b/xen/common/device-tree/domain-build.c
@@ -76,7 +76,7 @@ bool __init allocate_bank_memory(struct kernel_info *kinfo,
gfn_t sgfn,
paddr_t tot_size)
{
struct membanks *mem = kernel_info_get_mem(kinfo);
- struct domain *d = kinfo->d;
+ struct domain *d = kinfo->bd.d;
struct membank *bank;
/*
@@ -170,7 +170,7 @@ int __init find_unallocated_memory(const struct kernel_info
*kinfo,
unsigned int i, j;
int res;
- ASSERT(domain_use_host_layout(kinfo->d));
+ ASSERT(domain_use_host_layout(kinfo->bd.d));
unalloc_mem = rangeset_new(NULL, NULL, 0);
if ( !unalloc_mem )
@@ -341,23 +341,23 @@ void __init dtb_load(struct kernel_info *kinfo,
unsigned long left;
printk("Loading %pd DTB to 0x%"PRIpaddr"-0x%"PRIpaddr"\n",
- kinfo->d, kinfo->dtb_paddr,
+ kinfo->bd.d, kinfo->dtb_paddr,
kinfo->dtb_paddr + fdt_totalsize(kinfo->fdt));
- left = cb(kinfo->d, kinfo->dtb_paddr,
+ left = cb(kinfo->bd.d, kinfo->dtb_paddr,
kinfo->fdt,
fdt_totalsize(kinfo->fdt));
if ( left != 0 )
panic("Unable to copy the DTB to %pd memory (left = %lu bytes)\n",
- kinfo->d, left);
+ kinfo->bd.d, left);
xfree(kinfo->fdt);
}
void __init initrd_load(struct kernel_info *kinfo,
copy_to_guest_phys_cb cb)
{
- const struct boot_module *mod = kinfo->initrd;
+ const struct boot_module *mod = kinfo->bd.initrd;
paddr_t load_addr = kinfo->initrd_paddr;
paddr_t paddr, len;
int node;
@@ -373,7 +373,7 @@ void __init initrd_load(struct kernel_info *kinfo,
len = mod->size;
printk("Loading %pd initrd from %"PRIpaddr" to
0x%"PRIpaddr"-0x%"PRIpaddr"\n",
- kinfo->d, paddr, load_addr, load_addr + len);
+ kinfo->bd.d, paddr, load_addr, load_addr + len);
/* Fix up linux,initrd-start and linux,initrd-end in /chosen */
node = fdt_path_offset(kinfo->fdt, "/chosen");
@@ -396,11 +396,11 @@ void __init initrd_load(struct kernel_info *kinfo,
initrd = ioremap_wc(paddr, len);
if ( !initrd )
- panic("Unable to map the %pd initrd\n", kinfo->d);
+ panic("Unable to map the %pd initrd\n", kinfo->bd.d);
- res = cb(kinfo->d, load_addr, initrd, len);
+ res = cb(kinfo->bd.d, load_addr, initrd, len);
if ( res != 0 )
- panic("Unable to copy the initrd in the %pd memory\n", kinfo->d);
+ panic("Unable to copy the initrd in the %pd memory\n", kinfo->bd.d);
iounmap(initrd);
}
diff --git a/xen/common/device-tree/kernel.c b/xen/common/device-tree/kernel.c
index e1b22dc1c7..6de2334dbe 100644
--- a/xen/common/device-tree/kernel.c
+++ b/xen/common/device-tree/kernel.c
@@ -136,16 +136,16 @@ int __init kernel_probe(struct kernel_info *info,
/* domain is NULL only for the hardware domain */
if ( domain == NULL )
{
- ASSERT(is_hardware_domain(info->d));
+ ASSERT(is_hardware_domain(info->bd.d));
mod = boot_module_find_by_kind(BOOTMOD_KERNEL);
- info->kernel = mod;
- info->initrd = boot_module_find_by_kind(BOOTMOD_RAMDISK);
+ info->bd.kernel = mod;
+ info->bd.initrd = boot_module_find_by_kind(BOOTMOD_RAMDISK);
cmd = boot_cmdline_find_by_kind(BOOTMOD_KERNEL);
if ( cmd )
- info->cmdline = &cmd->cmdline[0];
+ info->bd.cmdline = &cmd->cmdline[0];
}
else
{
@@ -162,7 +162,7 @@ int __init kernel_probe(struct kernel_info *info,
dt_get_range(&val, node, &kernel_addr, &size);
mod = boot_module_find_by_addr_and_kind(
BOOTMOD_KERNEL, kernel_addr);
- info->kernel = mod;
+ info->bd.kernel = mod;
}
else if ( dt_device_is_compatible(node, "multiboot,ramdisk") )
{
@@ -171,7 +171,7 @@ int __init kernel_probe(struct kernel_info *info,
val = dt_get_property(node, "reg", &len);
dt_get_range(&val, node, &initrd_addr, &size);
- info->initrd = boot_module_find_by_addr_and_kind(
+ info->bd.initrd = boot_module_find_by_addr_and_kind(
BOOTMOD_RAMDISK, initrd_addr);
}
else if ( dt_device_is_compatible(node, "multiboot,device-tree") )
@@ -192,7 +192,7 @@ int __init kernel_probe(struct kernel_info *info,
name = dt_node_name(domain);
cmd = boot_cmdline_find_by_name(name);
if ( cmd )
- info->cmdline = &cmd->cmdline[0];
+ info->bd.cmdline = &cmd->cmdline[0];
}
if ( !mod || !mod->size )
{
@@ -201,10 +201,10 @@ int __init kernel_probe(struct kernel_info *info,
}
printk("Loading %pd kernel from boot module @ %"PRIpaddr"\n",
- info->d, info->kernel->start);
- if ( info->initrd )
+ info->bd.d, info->bd.kernel->start);
+ if ( info->bd.initrd )
printk("Loading ramdisk from boot module @ %"PRIpaddr"\n",
- info->initrd->start);
+ info->bd.initrd->start);
/*
* uImage isn't really used nowadays thereby leave kernel_uimage_probe()
diff --git a/xen/include/xen/bootfdt.h b/xen/include/xen/bootfdt.h
index 1218b23bb4..fceffaf2ec 100644
--- a/xen/include/xen/bootfdt.h
+++ b/xen/include/xen/bootfdt.h
@@ -100,6 +100,15 @@ struct shared_meminfo {
struct shmem_membank_extra extra[NR_SHMEM_BANKS];
};
+struct boot_domain {
+ struct domain *d;
+
+ struct boot_module *kernel;
+ struct boot_module *initrd;
+
+ const char *cmdline;
+};
+
#define BOOTMOD_MAX_CMDLINE 1024
struct boot_module {
boot_module_kind kind;
diff --git a/xen/include/xen/fdt-kernel.h b/xen/include/xen/fdt-kernel.h
index 12a0b42d17..8363865282 100644
--- a/xen/include/xen/fdt-kernel.h
+++ b/xen/include/xen/fdt-kernel.h
@@ -16,7 +16,7 @@
#endif
struct kernel_info {
- struct domain *d;
+ struct boot_domain bd;
void *fdt; /* flat device tree */
paddr_t unassigned_mem; /* RAM not (yet) assigned to a bank */
@@ -34,8 +34,7 @@ struct kernel_info {
paddr_t gnttab_size;
/* boot blob load addresses */
- const struct boot_module *kernel, *initrd, *dtb;
- const char* cmdline;
+ const struct boot_module *dtb;
paddr_t dtb_paddr;
paddr_t initrd_paddr;
--
generated by git-patchbot for /home/xen/git/xen.git#staging
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |