Allow x86 to unflatten DTs
v5 cover Allow x86 to unflatten DTs
pipeline: https://gitlab.com/xen-project/people/agvallejo/xen/-/pipelines
Hi,
New revision. It reconfigures Kconfig as discussed in v4. Otherwise it's same old-same old.
Contrary to the series name, x86 never really gains such an ability, but it's a trivial patch away.
Previous versions
=================
v4: https://lore.kernel.org/xen-devel/[email protected]/
v3: https://lore.kernel.org/xen-devel/[email protected]/
v3: https://lore.kernel.org/xen-devel/[email protected]/
v2: https://lore.kernel.org/xen-devel/[email protected]/
v1: https://lore.kernel.org/xen-devel/[email protected]/
Original cover letter
=====================
This is the aftermath of this discussion:
It's a first round of cleanup and preparation to have a much easier time later when integrating dom0less boot into hyperlaunch.
The refactor on device-tree/ is _fine_ by I'm open to other suggestions to achieve the same thing. In particular, after this series x86 can unflatten the DT host device tree when it has CONFIG_DOM0LESS_BOOT set, which enables the builder to use factored-out functions from dom0less-build.c (not done here).
The diffstat is deceptive because I renamed a large file and then created a new file with the same name. There aren't that many LoC changes.
Alejandro Vallejo (10):
x86: Replace arch-specific boot_module with common one
xen: Refactor kernel_info to have a header like boot_domain
x86: Replace arch-specific boot_domain with the common one xen/dt: Move bootfdt functions to xen/bootfdt.h xen/dt: Move bootinfo functions to a new bootinfo.h xen/dt: Rename bootfdt.c -> bootinfo-fdt.c
xen/dt: Extract helper to map nodes to module kinds
xen: Split HAS_DEVICE_TREE in two
xen/dt: ifdef out DEV_DT-related bits from device_tree.{c,h} xen/dt: Allow CONFIG_DEVICE_TREE_PARSE to include device-tree/
xen/Kconfig.debug | 2 +- xen/arch/arm/Kconfig | 2 +- xen/arch/arm/dom0less-build.c | 8 +- xen/arch/arm/domain_build.c | 21 +- xen/arch/arm/include/asm/setup.h | 2 +- xen/arch/arm/kernel.c | 8 +- xen/arch/arm/setup.c | 1 + xen/arch/ppc/Kconfig | 2 +- xen/arch/riscv/Kconfig | 2 +- xen/arch/riscv/cpufeature.c | 1 + xen/arch/riscv/mm.c | 2 +- xen/arch/riscv/setup.c | 2 +- xen/arch/riscv/smpboot.c | 1 + xen/arch/x86/cpu/microcode/core.c | 7 +- xen/arch/x86/hvm/dom0_build.c | 8 +- xen/arch/x86/include/asm/boot-domain.h | 33 -- xen/arch/x86/include/asm/bootfdt.h | 56 ++ xen/arch/x86/include/asm/bootinfo.h | 57 +-- xen/arch/x86/pv/dom0_build.c | 6 +- xen/arch/x86/setup.c | 55 +- xen/common/Kconfig | 13 +- xen/common/Makefile | 4 +- xen/common/device-tree/Makefile | 5 +- xen/common/device-tree/bootfdt.c | 654 ++---------------------- xen/common/device-tree/bootinfo-fdt.c | 583 +++++++++++++++++++++ xen/common/device-tree/bootinfo.c | 2 +- xen/common/device-tree/device-tree.c | 3 + xen/common/device-tree/dom0less-build.c | 20 +- xen/common/device-tree/domain-build.c | 22 +- xen/common/device-tree/kernel.c | 22 +- xen/common/device-tree/static-evtchn.c | 1 + xen/common/device.c | 4 +- xen/common/efi/boot.c | 2 +- xen/common/sched/Kconfig | 2 +- xen/common/sched/boot-cpupool.c | 1 + xen/drivers/char/ns16550.c | 6 +- xen/drivers/passthrough/Makefile | 2 +- xen/drivers/passthrough/iommu.c | 2 +- xen/include/asm-generic/device.h | 10 +- xen/include/xen/bootfdt.h | 300 ++++------- xen/include/xen/bootinfo.h | 213 ++++++++ xen/include/xen/device_tree.h | 82 +-- xen/include/xen/fdt-domain-build.h | 2 +- xen/include/xen/fdt-kernel.h | 7 +- xen/include/xen/iommu.h | 8 +- xen/include/xsm/dummy.h | 4 +- xen/include/xsm/xsm.h | 12 +- xen/xsm/dummy.c | 2 +- xen/xsm/flask/hooks.c | 6 +- xen/xsm/xsm_core.c | 4 +- xen/xsm/xsm_policy.c | 6 +- 51 files changed, 1159 insertions(+), 1121 deletions(-) delete mode 100644 xen/arch/x86/include/asm/boot-domain.h create mode 100644 xen/arch/x86/include/asm/bootfdt.h create mode 100644 xen/common/device-tree/bootinfo-fdt.c create mode 100644 xen/include/xen/bootinfo.h
base-commit: 64be4fecd7d95058fbbb9057a6170fb4e0e9ad06
Signature · 1 line
2.43.0
PATCH v5 1/10 x86: Replace arch-specific boot_module with common one
These types resemble each other very closely in layout and intent, and with "struct boot_module" already in common code it makes perfect sense to merge them. In order to do so, add an arch-specific area for x86-specific tidbits, and rename identical fields with conflicting names.
No functional change intended.
--- xen/arch/x86/cpu/microcode/core.c | 7 ++-- xen/arch/x86/hvm/dom0_build.c | 6 ++-- xen/arch/x86/include/asm/bootfdt.h | 50 ++++++++++++++++++++++++++ xen/arch/x86/include/asm/bootinfo.h | 56 +++-------------------------- xen/arch/x86/pv/dom0_build.c | 4 +-- xen/arch/x86/setup.c | 43 +++++++++++----------- xen/include/xen/bootfdt.h | 8 +++++ xen/xsm/xsm_policy.c | 2 +- 8 files changed, 93 insertions(+), 83 deletions(-) create mode 100644 xen/arch/x86/include/asm/bootfdt.h
xen/arch/x86/cpu/microcode/core.c +3 -4
@@ -764,8 +764,7 @@ static int __init early_microcode_load(struct boot_info *bi)struct cpio_data cd;/* Search anything unclaimed or likely to be a CPIO archive. */ -if ( bm->type !=BOOTMOD_UNKNOWN && - bm->type !=BOOTMOD_RAMDISK ) +if ( bm->kind !=BOOTMOD_UNKNOWN && bm->kind !=BOOTMOD_RAMDISK )continue ; size = bm->size;
@@ -815,12 +814,12 @@ static int __init early_microcode_load(struct boot_info *bi)return -ENODEV ; } -if ( bi->mods[idx].type !=BOOTMOD_UNKNOWN ) +if ( bi->mods[idx].kind !=BOOTMOD_UNKNOWN ) {printk (XENLOG_WARNING "Microcode: Chosen module %d already used\n" , idx);return -ENODEV ; } - bi->mods[idx].type =BOOTMOD_MICROCODE ; + bi->mods[idx].kind =BOOTMOD_MICROCODE ; size = bi->mods[idx].size; data =bootstrap_map_bm (&bi->mods[idx]);
xen/arch/x86/hvm/dom0_build.c +3 -3
@@ -650,7 +650,7 @@ static int __init pvh_load_kernel(struct boot_module *image = bd->kernel;struct boot_module *initrd = bd->module;void *image_base =bootstrap_map_bm (image); -void *image_start = image_base + image->headroom; +void *image_start = image_base + image->arch.headroom;unsigned long image_len = image->size;unsigned long initrd_len = initrd ? initrd->size :0 ;size_t cmdline_len = bd->cmdline ?strlen (bd->cmdline) +1 :0 ;
@@ -721,9 +721,9 @@ static int __init pvh_load_kernel( {size_t initrd_space =elf_round_up (&elf, initrd_len); -if ( initrd->cmdline_pa ) +if ( initrd->arch.cmdline_pa ) { - initrd_cmdline =__va (initrd->cmdline_pa); + initrd_cmdline =__va (initrd->arch.cmdline_pa);if ( !*initrd_cmdline ) initrd_cmdline =NULL ; }
xen/arch/x86/include/asm/bootfdt.h new file +50 -0
50 lines not on this page · raw message
xen/arch/x86/include/asm/bootinfo.h +4 -52
81 lines not on this page · raw message
xen/arch/x86/pv/dom0_build.c +2 -2
@@ -422,7 +422,7 @@ static int __init dom0_construct(const struct boot_domain *bd) image_base =bootstrap_map_bm (image); image_len = image->size; - image_start = image_base + image->headroom; + image_start = image_base + image->arch.headroom; d->max_pages = ~0U ;
@@ -659,7 +659,7 @@ static int __init dom0_construct(const struct boot_domain *bd)* pages. Tell the boot_module handling that we've freed it, so the * memory is left alone. */ - initrd->released = true; + initrd->arch.released = true; } iommu_memory_setup(d, "initrd", mfn_to_page(_mfn(initrd_mfn)),
xen/arch/x86/setup.c +22 -21
134 lines not on this page · raw message
xen/include/xen/bootfdt.h +8 -0
@@ -7,6 +7,10 @@#include <xen/macros.h> #include <xen/xmalloc.h> +#if __has_include(<asm/bootfdt.h>) +#include <asm/bootfdt.h> +#endif +#define MIN_FDT_ALIGN 8#define NR_MEM_BANKS 256
@@ -108,6 +112,10 @@ struct boot_module {bool domU;paddr_t start;paddr_t size; + +#if __has_include(<asm/bootfdt.h>) +struct arch_boot_module arch; +#endif };/* DT_MAX_NAME is the node name max length according the DT spec */
xen/xsm/xsm_policy.c +1 -1
@@ -53,7 +53,7 @@ int __init xsm_multiboot_policy_init(printk ("Policy len %#lx, start at %p.\n" , _policy_len,_policy_start); - bm->type =BOOTMOD_XSM_POLICY ; + bm->kind =BOOTMOD_XSM ;break ; }
Signature · 1 line
2.43.0
Re: [PATCH v5 01/10] x86: Replace arch-specific boot_module with common one
Quoted 10 lines · Alejandro Vallejo
These types resemble each other very closely in layout and intent, and with "struct
boot_module" already in common code it makes perfect sense to merge them. In order to do so, add an arch-specific area for x86-specific tidbits, and rename identical fields with conflicting names.No functional change intended.
Signed-off-by Alejandro Vallejo <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>
I'm largely okay with this change, just one question:
Quoted 14 lines
xen/include/xen/bootfdt.h +4
-0@@ -7,6 +7,10 @@#include <xen/macros.h> #include <xen/xmalloc.h> +#if __has_include(<asm/bootfdt.h>) +#include <asm/bootfdt.h> +#endif +#define MIN_FDT_ALIGN 8#define NR_MEM_BANKS 256
xen/include/xen/bootfdt.h struct boot_module { · line 119
Quoted 8 lines
xen/include/xen/bootfdt.h +4
-0@@ -108,6 +112,10 @@ struct boot_module {bool domU;paddr_t start;paddr_t size; + +#if __has_include(<asm/bootfdt.h>) +struct arch_boot_module arch; +#endif };
The pre-existing domU field isn't used by x86. Shouldn't that move into Arm's (to be created) struct arch_boot_module? Or is that intended to become dependent upon CONFIG_DOM0LESS_BOOT? (While we apparently didn't adopt Misra rule 2.2, this is imo precisely the situation where we would better follow it:
An unused struct field raises questions.)
Jan
Re: [PATCH v5 01/10] x86: Replace arch-specific boot_module with common one
Quoted 26 lines · Jan Beulich
Quoted 10 lines · Alejandro Vallejo
These types resemble each other very closely in layout and intent, and with "struct
boot_module" already in common code it makes perfect sense to merge them. In order to do so, add an arch-specific area for x86-specific tidbits, and rename identical fields with conflicting names.No functional change intended.
Signed-off-by Alejandro Vallejo <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>I'm largely okay with this change, just one question:
Quoted 12 lines
xen/include/xen/bootfdt.h +4
-0@@ -7,6 +7,10 @@#include <xen/macros.h> #include <xen/xmalloc.h> +#if __has_include(<asm/bootfdt.h>) +#include <asm/bootfdt.h> +#endif +#define MIN_FDT_ALIGN 8
Quoted 16 lines
xen/include/xen/bootfdt.h struct boot_module { · line 119
Quoted 10 lines
xen/include/xen/bootfdt.h +4
-0#define NR_MEM_BANKS 256@@ -108,6 +112,10 @@ struct boot_module {bool domU;paddr_t start;paddr_t size; + +#if __has_include(<asm/bootfdt.h>) +struct arch_boot_module arch; +#endif };The pre-existing domU field isn't used by x86. Shouldn't that move into Arm's (to be created) struct
arch_boot_module? Or is that intended to become dependent uponCONFIG_DOM0LESS_BOOT? (While we apparently didn't adopt Misra rule 2.2, this is imo precisely the situation where we would better follow it:
An unused struct field raises questions.)
That can be moved to an arch-specific header, yes.
I expect that domU field to eventually drop after dom0less adopts the more powerful hyperlaunch bindings for privilege separation. At that point it doesn't matter whether a domain is a domU or not, it's jut a domain to be constructed.
Cheers,
Alejandro
PATCH v5 2/10 xen: Refactor kernel_info to have a header like boot_domain
In reply to Alejandro VallejoCreate a struct header within kernel_info with the contents common to kernel_info and boot_domain, and define that header in common code. This enables x86 to use that header as-is and drop x86's boot_domain.
Not a functional change.
--- 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 | 10 ++++++++++ xen/include/xen/fdt-kernel.h | 5 ++--- 8 files changed, 59 insertions(+), 50 deletions(-)
xen/arch/arm/dom0less-build.c +4 -4
@@ -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->hdr.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->hdr.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->hdr.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->hdr.d; res =domain_fdt_begin_node (fdt,"sbsa-uart" , d->arch.vpl011.base_addr);if ( res )
xen/arch/arm/domain_build.c +10 -10
@@ -464,8 +464,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->hdr.cmdline && kinfo->hdr.cmdline[0 ] ) + bootargs = &kinfo->hdr.cmdline[0 ];/* * We always skip the IOMMU device when creating DT for hwdom if there is
@@ -579,7 +579,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->hdr.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->hdr.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->hdr.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->hdr.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->hdr.cmdline && kinfo->hdr.cmdline[0 ] ) { - bootargs = &kinfo->cmdline[0 ]; + bootargs = &kinfo->hdr.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.hdr.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->hdr.d;int rc;iommu_hwdom_init (d);
xen/arch/arm/kernel.c +4 -4
@@ -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->hdr.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->hdr.d); - rc =copy_to_guest_phys_flush_dcache (info->d, load_addr, + rc =copy_to_guest_phys_flush_dcache (info->hdr.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->hdr.d);iounmap (kernel); }
xen/common/device-tree/dom0less-build.c +9 -9
@@ -167,18 +167,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->hdr.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->hdr.d->domain_id, mstart &PAGE_MASK ,PAGE_ALIGN (mstart + size) -1 );return res; } - res = map_regions_p2mt(kinfo->d, + res = map_regions_p2mt(kinfo->hdr.d, gaddr_to_gfn(gstart), PFN_DOWN(size), maddr_to_mfn(mstart),
@@ -217,7 +217,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->hdr.d, node, true,NULL );if ( res <0 )return res;
@@ -229,7 +229,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->hdr.d, node); } static int __init handle_prop_pfdt(struct kernel_info *kinfo,
@@ -296,14 +296,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->hdr.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->hdr.d);return -EINVAL ; }
@@ -605,7 +605,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->hdr.d;int rc =0 ;#ifdef CONFIG_HVM
@@ -773,7 +773,7 @@ static int __init construct_domU(struct domain *d, d->max_pages = ((paddr_t )mem *SZ_1K ) >>PAGE_SHIFT ; - kinfo.d = d; + kinfo.hdr.d = d; rc =kernel_probe (&kinfo, node);if ( rc <0 )
xen/common/device-tree/domain-build.c +10 -10
@@ -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->hdr.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->hdr.d)); unalloc_mem =rangeset_new (NULL ,NULL ,0 );if ( !unalloc_mem )
@@ -336,23 +336,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->hdr.d, kinfo->dtb_paddr, kinfo->dtb_paddr +fdt_totalsize (kinfo->fdt)); - left =copy_to_guest (kinfo->d, kinfo->dtb_paddr, + left =copy_to_guest (kinfo->hdr.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->hdr.d, left);xfree (kinfo->fdt); }void __init initrd_load (struct kernel_info *kinfo,copy_to_guest_phys_cb copy_to_guest) { -const struct boot_module *mod = kinfo->initrd; +const struct boot_module *mod = kinfo->hdr.initrd;paddr_t load_addr = kinfo->initrd_paddr;paddr_t paddr, len;int node;
@@ -368,7 +368,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->hdr.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" );
@@ -391,12 +391,12 @@ 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->hdr.d); - res =copy_to_guest (kinfo->d, load_addr, + res =copy_to_guest (kinfo->hdr.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->hdr.d);iounmap (initrd); }
xen/common/device-tree/kernel.c +10 -10
@@ -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->hdr.d)); mod =boot_module_find_by_kind (BOOTMOD_KERNEL ); - info->kernel = mod; - info->initrd =boot_module_find_by_kind (BOOTMOD_RAMDISK ); + info->hdr.kernel = mod; + info->hdr.initrd =boot_module_find_by_kind (BOOTMOD_RAMDISK ); cmd =boot_cmdline_find_by_kind (BOOTMOD_KERNEL );if ( cmd ) - info->cmdline = &cmd->cmdline[0 ]; + info->hdr.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->hdr.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->hdr.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->hdr.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->hdr.d, info->hdr.kernel->start); +if ( info->hdr.initrd )printk ("Loading ramdisk from boot module @ %" PRIpaddr"\n" , - info->initrd->start); + info->hdr.initrd->start);/* * uImage isn't really used nowadays thereby leave kernel_uimage_probe()
xen/include/xen/bootfdt.h +10 -0
@@ -100,6 +100,16 @@ 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; +}; +/* * The domU flag is set for kernels and ramdisks of "xen,domain" nodes. * The purpose of the domU flag is to avoid getting confused in
xen/include/xen/fdt-kernel.h +2 -3
@@ -16,7 +16,7 @@#endif struct kernel_info { -struct domain *d; +struct boot_domain hdr;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;
Signature · 1 line
2.43.0
Re: [PATCH v5 02/10] xen: Refactor kernel_info to have a header like boot_domain
xen/include/xen/bootfdt.h struct shared_meminfo { · line 103
Quoted 7 lines · Alejandro Vallejo
xen/include/xen/bootfdt.h +1
-0@@ -100,6 +100,16 @@ struct shared_meminfo {struct shmem_membank_extra extra[NR_SHMEM_BANKS ]; }; +
Nit: No double blank lines please.
xen/include/xen/bootfdt.h struct shared_meminfo { · line 110
Quoted 7 lines
xen/include/xen/bootfdt.h +7
-0+struct boot_domain { +struct domain *d; + +struct boot_module *kernel; +struct boot_module *initrd; + +const char * cmdline;
Nit: * and blank want to change places.
Quoted 12 lines
xen/include/xen/fdt-kernel.h +1
-1@@ -16,7 +16,7 @@#endif struct kernel_info { -struct domain *d; +struct boot_domain hdr;void *fdt;/* flat device tree */ paddr_t unassigned_mem;/* RAM not (yet) assigned to a bank */
xen/include/xen/fdt-kernel.h struct kernel_info { · line 37
Quoted 4 lines
xen/include/xen/fdt-kernel.h +0
-1@@ -34,8 +34,7 @@ struct kernel_info {paddr_t gnttab_size;/* boot blob load addresses */ -const struct boot_module *kernel, *initrd, *dtb;
Where did this "const" go?
xen/include/xen/fdt-kernel.h struct kernel_info { · line 37
Quoted 2 lines
xen/include/xen/fdt-kernel.h +1
-1-const char * cmdline; +const struct boot_module *dtb;
This one only retains the intended effect here.
xen/include/xen/fdt-kernel.h struct kernel_info { · line 39
Quoted 2 lines
xen/include/xen/fdt-kernel.h +0
-0paddr_t dtb_paddr;paddr_t initrd_paddr;
"hdr" is an odd name here. That struct has no need to live at the beginning, afaict. How about "gen" for "generic" or "bd" for "boot_domain"?
Jan
Re: [PATCH v5 02/10] xen: Refactor kernel_info to have a header like boot_domain
Quoted 35 lines · Jan Beulich
xen/include/xen/bootfdt.h struct shared_meminfo { · line 103
Quoted 7 lines · Alejandro Vallejo
xen/include/xen/bootfdt.h +1
-0@@ -100,6 +100,16 @@ struct shared_meminfo {struct shmem_membank_extra extra[NR_SHMEM_BANKS ]; }; +Nit: No double blank lines please.
xen/include/xen/bootfdt.h struct shared_meminfo { · line 110
Quoted 7 lines
xen/include/xen/bootfdt.h +7
-0+struct boot_domain { +struct domain *d; + +struct boot_module *kernel; +struct boot_module *initrd; + +const char * cmdline;Nit: * and blank want to change places.
Quoted 14 lines
xen/include/xen/fdt-kernel.h +1
-1@@ -16,7 +16,7 @@#endif struct kernel_info { -struct domain *d; +struct boot_domain hdr;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;
Quoted 4 lines
xen/include/xen/fdt-kernel.h struct kernel_info { · line 37
Quoted 2 lines
xen/include/xen/fdt-kernel.h +0
-1/* boot blob load addresses */ -const struct boot_module *kernel, *initrd, *dtb;Where did this "const" go?
x86 mutates the boot module to set the released flag, the headroom, etc.
Quoted 5 lines
xen/include/xen/fdt-kernel.h struct kernel_info { · line 37
Quoted 3 lines
xen/include/xen/fdt-kernel.h +1
-1-const char * cmdline; +const struct boot_module *dtb;This one only retains the intended effect here.
Because x86 doesn't see or use the containing struct.
Quoted 8 lines
xen/include/xen/fdt-kernel.h struct kernel_info { · line 39
Quoted 3 lines
xen/include/xen/fdt-kernel.h +0
-0paddr_t dtb_paddr;paddr_t initrd_paddr;"hdr" is an odd name here. That struct has no need to live at the beginning, afaict. How about "gen" for "generic" or "bd" for "
boot_domain"?Jan
Sure. I'm fine with bd. Will adjust.
Cheers,
Alejandro
Re: [PATCH v5 02/10] xen: Refactor kernel_info to have a header like boot_domain
Quoted 16 lines · Alejandro Vallejo
Quoted 15 lines · Jan Beulich
Quoted 14 lines · Alejandro Vallejo
xen/include/xen/fdt-kernel.h +1
-1@@ -16,7 +16,7 @@#endif struct kernel_info { -struct domain *d; +struct boot_domain hdr;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;
Quoted 6 lines
Quoted 4 lines
xen/include/xen/fdt-kernel.h struct kernel_info { · line 37
Quoted 2 lines
xen/include/xen/fdt-kernel.h +0
-1/* boot blob load addresses */ -const struct boot_module *kernel, *initrd, *dtb;Where did this "const" go?
x86 mutates the boot module to set the released flag, the headroom, etc.
Might be nice to mention such an aspect in the description.
Jan
Re: [PATCH v5 02/10] xen: Refactor kernel_info to have a header like boot_domain
Quoted 22 lines · Jan Beulich
Quoted 21 lines · Alejandro Vallejo
Quoted 19 lines · Jan Beulich
Quoted 12 lines · Alejandro Vallejo
xen/include/xen/fdt-kernel.h +1
-1@@ -16,7 +16,7 @@#endif struct kernel_info { -struct domain *d; +struct boot_domain hdr;void *fdt;/* flat device tree */ paddr_t unassigned_mem;/* RAM not (yet) assigned to a bank */ xen/include/xen/fdt-kernel.h struct kernel_info { · line 37
Quoted 4 lines
xen/include/xen/fdt-kernel.h +0
-1@@ -34,8 +34,7 @@ struct kernel_info {paddr_t gnttab_size;/* boot blob load addresses */ -const struct boot_module *kernel, *initrd, *dtb;Where did this "const" go?
Quoted 5 lines
Quoted 1 line
x86 mutates the boot module to set the released flag, the headroom, etc.
Might be nice to mention such an aspect in the description.
Jan
Sure.
Cheers,
Alejandro
PATCH v5 3/10 x86: Replace arch-specific boot_domain with the common one
In reply to Alejandro VallejoAdd the single arch-specific field in an "arch" subfield defined in asm/bootfdt.h.
No functional change intended.
--- xen/arch/x86/hvm/dom0_build.c | 2 +- xen/arch/x86/include/asm/boot-domain.h | 33 -------------------------- xen/arch/x86/include/asm/bootfdt.h | 6 +++++ xen/arch/x86/include/asm/bootinfo.h | 1 - xen/arch/x86/pv/dom0_build.c | 2 +- xen/arch/x86/setup.c | 12 ++++++---- xen/include/xen/bootfdt.h | 4 ++++ 7 files changed, 19 insertions(+), 41 deletions(-) delete mode 100644 xen/arch/x86/include/asm/boot-domain.h
xen/arch/x86/hvm/dom0_build.c +1 -1
@@ -648,7 +648,7 @@ static int __init pvh_load_kernel( {struct domain *d = bd->d;struct boot_module *image = bd->kernel; -struct boot_module *initrd = bd->module; +struct boot_module *initrd = bd->initrd;void *image_base =bootstrap_map_bm (image);void *image_start = image_base + image->arch.headroom;unsigned long image_len = image->size;
xen/arch/x86/include/asm/boot-domain.h deleted +0 -33
@@ -1,33 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* -* Copyright (c) 2024 Apertus Solutions, LLC -* Author: Daniel P. Smith <[email protected]> -* Copyright (c) 2024 Christopher Clark <[email protected]> -*/ - -#ifndef __XEN_X86_BOOTDOMAIN_H__ -#define __XEN_X86_BOOTDOMAIN_H__ - -#include <public/xen.h> - -struct boot_domain { -domid_t domid; - -struct boot_module *kernel; -struct boot_module *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: -*/
xen/arch/x86/include/asm/bootfdt.h +6 -0
@@ -3,6 +3,12 @@#define X86_BOOTFDT_H #include <xen/types.h> +#include <public/xen.h> + +struct arch_boot_domain +{ +domid_t domid; +};struct arch_boot_module {
xen/arch/x86/include/asm/bootinfo.h +0 -1
@@ -12,7 +12,6 @@#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
xen/arch/x86/pv/dom0_build.c +1 -1
@@ -375,7 +375,7 @@ static int __init dom0_construct(const struct boot_domain *bd)struct vcpu *v = d->vcpu[0 ];struct boot_module *image = bd->kernel; -struct boot_module *initrd = bd->module; +struct boot_module *initrd = bd->initrd;void *image_base;unsigned long image_len;void *image_start;
xen/arch/x86/setup.c +7 -5
@@ -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 + }},/* * There's a MAX_NR_BOOTMODS-th entry in the array. It's not off by one. *
@@ -1048,11 +1050,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);
@@ -2171,7 +2173,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 = &bi->mods[initrdidx];if (first_boot_module_index (bi,BOOTMOD_UNKNOWN ) <MAX_NR_BOOTMODS ) printk(XENLOG_WARNING "Multiple initrd candidates, picking module #%u\n",
xen/include/xen/bootfdt.h +4 -0
@@ -108,6 +108,10 @@ struct boot_domain {struct boot_module *initrd;const char * cmdline; + +#if __has_include(<asm/bootfdt.h>) +struct arch_boot_domain arch; +#endif };/*
Signature · 1 line
2.43.0
Re: [PATCH v5 03/10] x86: Replace arch-specific boot_domain with the common one
Quoted 18 lines · Alejandro Vallejo
xen/arch/x86/include/asm/bootfdt.h +6
-0@@ -3,6 +3,12 @@#define X86_BOOTFDT_H #include <xen/types.h> +#include <public/xen.h> + +struct arch_boot_domain +{ +domid_t domid; +};struct arch_boot_module {@@ -1048,11 +1050,11 @@ static struct domain *__init create_dom0(struct boot_info *bi) dom0_cfg.flags |= XEN_DOMCTL_CDF_iommu;
xen/arch/x86/include/asm/bootfdt.h static struct domain *__init create_dom0(struct boot_info *bi) · line 1057
Quoted 10 lines
xen/arch/x86/include/asm/bootfdt.h +3
-3/* 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));
This being the only place where the (now) arch-specific field is used, why does it exist? A local variable would do? And if it's needed for (supposedly arch-agnostic) hyperlaunch, then it probably shouldn't be arch-specific? Daniel, Jason?
Jan
Re: [PATCH v5 03/10] x86: Replace arch-specific boot_domain with the common one
Quoted 35 lines · Jan Beulich
Quoted 18 lines · Alejandro Vallejo
xen/arch/x86/include/asm/bootfdt.h +6
-0@@ -3,6 +3,12 @@#define X86_BOOTFDT_H #include <xen/types.h> +#include <public/xen.h> + +struct arch_boot_domain +{ +domid_t domid; +};struct arch_boot_module {@@ -1048,11 +1050,11 @@ static struct domain *__init create_dom0(struct boot_info *bi) dom0_cfg.flags |= XEN_DOMCTL_CDF_iommu;xen/arch/x86/include/asm/bootfdt.h static struct domain *__init create_dom0(struct boot_info *bi) · line 1057
Quoted 10 lines
xen/arch/x86/include/asm/bootfdt.h +3
-3/* 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));This being the only place where the (now) arch-specific field is used, why does it exist? A local variable would do? And if it's needed for (supposedly arch-agnostic) hyperlaunch, then it probably shouldn't be arch-specific? Daniel, Jason?
Quoted 1 line
Jan
It eventually becomes a holding spot for the domid property of each domain in the DTB. It exists so we can describe every domain fully ahead of trying to construct it.
Cheers,
Alejandro
Re: [PATCH v5 03/10] x86: Replace arch-specific boot_domain with the common one
In reply to Jan BeulichQuoted 35 lines · Jan Beulich
Quoted 18 lines · Alejandro Vallejo
xen/arch/x86/include/asm/bootfdt.h +6
-0@@ -3,6 +3,12 @@#define X86_BOOTFDT_H #include <xen/types.h> +#include <public/xen.h> + +struct arch_boot_domain +{ +domid_t domid; +};struct arch_boot_module {@@ -1048,11 +1050,11 @@ static struct domain *__init create_dom0(struct boot_info *bi) dom0_cfg.flags |= XEN_DOMCTL_CDF_iommu;xen/arch/x86/include/asm/bootfdt.h static struct domain *__init create_dom0(struct boot_info *bi) · line 1057
Quoted 10 lines
xen/arch/x86/include/asm/bootfdt.h +3
-3/* 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));This being the only place where the (now) arch-specific field is used, why does it exist? A local variable would do? And if it's needed for (supposedly arch-agnostic) hyperlaunch, then it probably shouldn't be arch-specific? Daniel, Jason?
Quoted 1 line
Jan
As for the arch-agnostic side of things, arm needs some extra work to be able to do it safely. dom0less currently constructs domains immediately after parsing them, which is problematic for cases where some domains have the prop and others don't. The domid allocation strategy may preclude further otherwise good domains from being created just because their domid was stolen by a domain that didn't actually care about which domid it got.
It'll eventually want to leave the arch-specific area, but I don't want to do that work now.
Cheers,
Alejandro
Re: [PATCH v5 03/10] x86: Replace arch-specific boot_domain with the common one
Quoted 43 lines · Alejandro Vallejo
Quoted 20 lines · Jan Beulich
Quoted 19 lines · Alejandro Vallejo
xen/arch/x86/include/asm/bootfdt.h +6
-0@@ -3,6 +3,12 @@#define X86_BOOTFDT_H #include <xen/types.h> +#include <public/xen.h> + +struct arch_boot_domain +{ +domid_t domid; +};struct arch_boot_module {@@ -1048,11 +1050,11 @@ static struct domain *__init create_dom0(struct boot_info *bi) dom0_cfg.flags |= XEN_DOMCTL_CDF_iommu;Quoted 14 lines
xen/arch/x86/include/asm/bootfdt.h static struct domain *__init create_dom0(struct boot_info *bi) · line 1057
Quoted 9 lines
xen/arch/x86/include/asm/bootfdt.h +3
-3/* 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));This being the only place where the (now) arch-specific field is used, why does it exist? A local variable would do? And if it's needed for (supposedly arch-agnostic) hyperlaunch, then it probably shouldn't be arch-specific? Daniel, Jason?
As for the arch-agnostic side of things, arm needs some extra work to be able to do it safely. dom0less currently constructs domains immediately after parsing them, which is problematic for cases where some domains have the prop and others don't. The domid allocation strategy may preclude further otherwise good domains from being created just because their domid was stolen by a domain that didn't actually care about which domid it got.
Quoted 2 lines
It'll eventually want to leave the arch-specific area, but I don't want to do that work now.
But if the domU field is fine to live in a common struct despite being unused on x86, why can't the domid field live in a common struct too, despite being unused on non-x86? Otherwise it'll be extra churn for no gain to later move it there.
Jan
Re: [PATCH v5 03/10] x86: Replace arch-specific boot_domain with the common one
Quoted 47 lines · Jan Beulich
Quoted 43 lines · Alejandro Vallejo
Quoted 20 lines · Jan Beulich
Quoted 19 lines · Alejandro Vallejo
xen/arch/x86/include/asm/bootfdt.h +6
-0@@ -3,6 +3,12 @@#define X86_BOOTFDT_H #include <xen/types.h> +#include <public/xen.h> + +struct arch_boot_domain +{ +domid_t domid; +};struct arch_boot_module {@@ -1048,11 +1050,11 @@ static struct domain *__init create_dom0(struct boot_info *bi) dom0_cfg.flags |= XEN_DOMCTL_CDF_iommu;Quoted 14 lines
xen/arch/x86/include/asm/bootfdt.h static struct domain *__init create_dom0(struct boot_info *bi) · line 1057
Quoted 9 lines
xen/arch/x86/include/asm/bootfdt.h +3
-3/* 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));This being the only place where the (now) arch-specific field is used, why does it exist? A local variable would do? And if it's needed for (supposedly arch-agnostic) hyperlaunch, then it probably shouldn't be arch-specific? Daniel, Jason?
As for the arch-agnostic side of things, arm needs some extra work to be able to do it safely. dom0less currently constructs domains immediately after parsing them, which is problematic for cases where some domains have the prop and others don't. The domid allocation strategy may preclude further otherwise good domains from being created just because their domid was stolen by a domain that didn't actually care about which domid it got.
Quoted 2 lines
It'll eventually want to leave the arch-specific area, but I don't want to do that work now.
Quoted 6 lines
But if the domU field is fine to live in a common struct despite being unused on x86, why can't the domid field live in a common struct too, despite being unused on non-x86? Otherwise it'll be extra churn for no gain to later move it there.
Jan
Mostly out of tidiness. Otherwise it's hard to know which fields serve a purpose where.
I genuinely forgot about the domU field. I'm more than happy to drop that arch subfield and have domid in the main body of the struct, but I suspect MISRA would have something to say about dead data?
Cheers,
Alejandro
Re: [PATCH v5 03/10] x86: Replace arch-specific boot_domain with the common one
Quoted 53 lines · Alejandro Vallejo
Quoted 44 lines · Jan Beulich
Quoted 43 lines · Alejandro Vallejo
Quoted 20 lines · Jan Beulich
Quoted 19 lines · Alejandro Vallejo
xen/arch/x86/include/asm/bootfdt.h +6
-0@@ -3,6 +3,12 @@#define X86_BOOTFDT_H #include <xen/types.h> +#include <public/xen.h> + +struct arch_boot_domain +{ +domid_t domid; +};struct arch_boot_module {@@ -1048,11 +1050,11 @@ static struct domain *__init create_dom0(struct boot_info *bi) dom0_cfg.flags |= XEN_DOMCTL_CDF_iommu;Quoted 14 lines
xen/arch/x86/include/asm/bootfdt.h static struct domain *__init create_dom0(struct boot_info *bi) · line 1057
Quoted 9 lines
xen/arch/x86/include/asm/bootfdt.h +3
-3/* 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));This being the only place where the (now) arch-specific field is used, why does it exist? A local variable would do? And if it's needed for (supposedly arch-agnostic) hyperlaunch, then it probably shouldn't be arch-specific? Daniel, Jason?
As for the arch-agnostic side of things, arm needs some extra work to be able to do it safely. dom0less currently constructs domains immediately after parsing them, which is problematic for cases where some domains have the prop and others don't. The domid allocation strategy may preclude further otherwise good domains from being created just because their domid was stolen by a domain that didn't actually care about which domid it got.
Quoted 7 lines
Quoted 2 lines
It'll eventually want to leave the arch-specific area, but I don't want to do that work now.
But if the domU field is fine to live in a common struct despite being unused on x86, why can't the domid field live in a common struct too, despite being unused on non-x86? Otherwise it'll be extra churn for no gain to later move it there.
Quoted 6 lines
Mostly out of tidiness. Otherwise it's hard to know which fields serve a purpose where.
I genuinely forgot about the domU field. I'm more than happy to drop that arch subfield and have domid in the main body of the struct, but I suspect MISRA would have something to say about dead data?
In principle yes (and then also about the domU field), but we rejected the respective rule altogether (for now? plus for a reason that I must have forgot and that escapes me).
Jan
Re: [PATCH v5 03/10] x86: Replace arch-specific boot_domain with the common one
Quoted 61 lines · Jan Beulich
Quoted 53 lines · Alejandro Vallejo
Quoted 44 lines · Jan Beulich
Quoted 43 lines · Alejandro Vallejo
Quoted 20 lines · Jan Beulich
Quoted 19 lines · Alejandro Vallejo
xen/arch/x86/include/asm/bootfdt.h +6
-0@@ -3,6 +3,12 @@#define X86_BOOTFDT_H #include <xen/types.h> +#include <public/xen.h> + +struct arch_boot_domain +{ +domid_t domid; +};struct arch_boot_module {@@ -1048,11 +1050,11 @@ static struct domain *__init create_dom0(struct boot_info *bi) dom0_cfg.flags |= XEN_DOMCTL_CDF_iommu;Quoted 14 lines
xen/arch/x86/include/asm/bootfdt.h static struct domain *__init create_dom0(struct boot_info *bi) · line 1057
Quoted 9 lines
xen/arch/x86/include/asm/bootfdt.h +3
-3/* 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));This being the only place where the (now) arch-specific field is used, why does it exist? A local variable would do? And if it's needed for (supposedly arch-agnostic) hyperlaunch, then it probably shouldn't be arch-specific? Daniel, Jason?
As for the arch-agnostic side of things, arm needs some extra work to be able to do it safely. dom0less currently constructs domains immediately after parsing them, which is problematic for cases where some domains have the prop and others don't. The domid allocation strategy may preclude further otherwise good domains from being created just because their domid was stolen by a domain that didn't actually care about which domid it got.
Quoted 7 lines
Quoted 2 lines
It'll eventually want to leave the arch-specific area, but I don't want to do that work now.
But if the domU field is fine to live in a common struct despite being unused on x86, why can't the domid field live in a common struct too, despite being unused on non-x86? Otherwise it'll be extra churn for no gain to later move it there.
Quoted 6 lines
Mostly out of tidiness. Otherwise it's hard to know which fields serve a purpose where.
I genuinely forgot about the domU field. I'm more than happy to drop that arch subfield and have domid in the main body of the struct, but I suspect MISRA would have something to say about dead data?
Quoted 5 lines
In principle yes (and then also about the domU field), but we rejected the respective rule altogether (for now? plus for a reason that I must have forgot and that escapes me).
Jan
Actually, moving it to an arch-specific field is rather annoying. everyone but x86 needs the field. I'll just compile it out for x86 specifically with ifdef guards, even if it is common code.
For the record, I hope to get rid of it on arm/riscv/ppc entirely later on by deducing domU vs dom0 from the capabilities property.
Cheers,
Alejandro
PATCH v5 4/10 xen/dt: Move bootfdt functions to xen/bootfdt.h
In reply to Alejandro VallejoPart of an unpicking process to extract bootfdt contents independent of bootinfo to a separate file for x86 to take.
Move functions required for early FDT parsing from device_tree.h and arm's setup.h onto bootfdt.h
Declaration motion only. Not a functional change.
--- xen/arch/riscv/cpufeature.c | 1 + xen/arch/riscv/smpboot.c | 1 + xen/common/device-tree/device-tree.c | 1 + xen/common/device-tree/static-evtchn.c | 1 + xen/common/sched/boot-cpupool.c | 1 + xen/include/xen/bootfdt.h | 91 ++++++++++++++++++++++++++ xen/include/xen/device_tree.h | 78 ---------------------- 7 files changed, 96 insertions(+), 78 deletions(-)
xen/arch/riscv/cpufeature.c +1 -0
@@ -8,6 +8,7 @@*/ #include <xen/bitmap.h> +#include <xen/bootfdt.h> #include <xen/ctype.h> #include <xen/device_tree.h> #include <xen/errno.h>
xen/arch/riscv/smpboot.c +1 -0
@@ -1,3 +1,4 @@ +#include <xen/bootfdt.h> #include <xen/cpumask.h> #include <xen/device_tree.h> #include <xen/errno.h>
xen/common/device-tree/device-tree.c +1 -0
@@ -7,6 +7,7 @@* [email protected] */ +#include <xen/bootfdt.h> #include <xen/types.h> #include <xen/init.h> #include <xen/guest_access.h>
xen/common/device-tree/static-evtchn.c +1 -0
@@ -1,5 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ +#include <xen/bootfdt.h> #include <xen/event.h> #include <xen/static-evtchn.h>
xen/common/sched/boot-cpupool.c +1 -0
@@ -7,6 +7,7 @@* Copyright (C) 2022 Arm Ltd. */ +#include <xen/bootfdt.h> #include <xen/acpi.h> #include <xen/sched.h>
xen/include/xen/bootfdt.h +91 -0
111 lines not on this page · raw message
xen/include/xen/device_tree.h +0 -78
116 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v5 5/10 xen/dt: Move bootinfo functions to a new bootinfo.h
In reply to Alejandro VallejoPart of an unpicking process to extract bootfdt contents independent of bootinfo to a separate file for x86 to take.
With this, bootfdt.h can be cleanly included from x86. A later patch extracts the definitions so the functions may be called too.
Not a functional change.
--- xen/arch/arm/domain_build.c | 1 + xen/arch/arm/include/asm/setup.h | 2 +- xen/arch/arm/setup.c | 1 + xen/arch/riscv/mm.c | 2 +- xen/arch/riscv/setup.c | 2 +- xen/common/device-tree/bootfdt.c | 2 +- xen/common/device-tree/bootinfo.c | 2 +- xen/common/device-tree/dom0less-build.c | 2 +- xen/common/device-tree/domain-build.c | 2 +- xen/common/device-tree/kernel.c | 2 +- xen/include/xen/bootfdt.h | 208 ----------------------- xen/include/xen/bootinfo.h | 213 ++++++++++++++++++++++++ xen/include/xen/fdt-domain-build.h | 2 +- xen/include/xen/fdt-kernel.h | 2 +- 14 files changed, 225 insertions(+), 218 deletions(-) create mode 100644 xen/include/xen/bootinfo.h
xen/arch/arm/domain_build.c +1 -0
@@ -1,5 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ #include <xen/init.h> +#include <xen/bootinfo.h> #include <xen/compile.h> #include <xen/fdt-domain-build.h> #include <xen/fdt-kernel.h>
xen/arch/arm/include/asm/setup.h +1 -1
@@ -3,7 +3,7 @@#include <public/version.h> #include <asm/p2m.h> -#include <xen/bootfdt.h> +#include <xen/bootinfo.h> #include <xen/device_tree.h> #if defined(CONFIG_MMU )
xen/arch/arm/setup.c +1 -0
@@ -8,6 +8,7 @@* Copyright (c) 2011 Citrix Systems. */ +#include <xen/bootinfo.h> #include <xen/compile.h> #include <xen/device_tree.h> #include <xen/domain_page.h>
xen/arch/riscv/mm.c +1 -1
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ -#include <xen/bootfdt.h> +#include <xen/bootinfo.h> #include <xen/bug.h> #include <xen/compiler.h> #include <xen/domain_page.h>
xen/arch/riscv/setup.c +1 -1
@@ -2,7 +2,7 @@#include <xen/acpi.h> #include <xen/bug.h> -#include <xen/bootfdt.h> +#include <xen/bootinfo.h> #include <xen/compile.h> #include <xen/device_tree.h> #include <xen/init.h>
xen/common/device-tree/bootfdt.c +1 -1
@@ -5,7 +5,7 @@* Copyright (C) 2012-2014 Citrix Systems, Inc. */ -#include <xen/bootfdt.h> +#include <xen/bootinfo.h> #include <xen/device_tree.h> #include <xen/efi.h> #include <xen/init.h>
xen/common/device-tree/bootinfo.c +1 -1
@@ -10,7 +10,7 @@*/ #include <xen/acpi.h> -#include <xen/bootfdt.h> +#include <xen/bootinfo.h> #include <xen/bug.h> #include <xen/device_tree.h> #include <xen/init.h>
xen/common/device-tree/dom0less-build.c +1 -1
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ -#include <xen/bootfdt.h> +#include <xen/bootinfo.h> #include <xen/device_tree.h> #include <xen/domain.h> #include <xen/domain_page.h>
xen/common/device-tree/domain-build.c +1 -1
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ -#include <xen/bootfdt.h> +#include <xen/bootinfo.h> #include <xen/fdt-domain-build.h> #include <xen/init.h> #include <xen/lib.h>
xen/common/device-tree/kernel.c +1 -1
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ -#include <xen/bootfdt.h> +#include <xen/bootinfo.h> #include <xen/device_tree.h> #include <xen/fdt-kernel.h> #include <xen/errno.h>
xen/include/xen/bootfdt.h +0 -208
237 lines not on this page · raw message
xen/include/xen/bootinfo.h new file +213 -0
213 lines not on this page · raw message
xen/include/xen/fdt-domain-build.h +1 -1
@@ -3,7 +3,7 @@#ifndef __XEN_FDT_DOMAIN_BUILD_H__#define __XEN_FDT_DOMAIN_BUILD_H__ -#include <xen/bootfdt.h> +#include <xen/bootinfo.h> #include <xen/device_tree.h> #include <xen/fdt-kernel.h> #include <xen/mm.h>
xen/include/xen/fdt-kernel.h +1 -1
@@ -7,7 +7,7 @@#ifndef __XEN_FDT_KERNEL_H__#define __XEN_FDT_KERNEL_H__ -#include <xen/bootfdt.h> +#include <xen/bootinfo.h> #include <xen/device_tree.h> #include <xen/types.h>
Signature · 1 line
2.43.0
PATCH v5 6/10 xen/dt: Rename bootfdt.c -> bootinfo-fdt.c
In reply to Alejandro VallejoThis file will eventually contain bootfdt helpers that make heavy use of bootinfo. To simplify git history do the rename here explicitly. A later patch extracts bootinfo-independent helpers into bootfdt.c.
Doing so here would needlessly pollute the diffs.
Not a functional change.
--- xen/common/device-tree/Makefile | 1 + xen/common/device-tree/bootfdt.c | 646 +------------------------- xen/common/device-tree/bootinfo-fdt.c | 597 ++++++++++++++++++++++++ 3 files changed, 619 insertions(+), 625 deletions(-) create mode 100644 xen/common/device-tree/bootinfo-fdt.c
xen/common/device-tree/Makefile +1 -0
@@ -1,4 +1,5 @@ obj-y += bootfdt.init.o +obj-y += bootinfo-fdt.init.o obj-y += bootinfo.init.o obj-y += device-tree.o obj-$(CONFIG_DOMAIN_BUILD_HELPERS) += domain-build.init.o
xen/common/device-tree/bootfdt.c +21 -625
674 lines not on this page · raw message
xen/common/device-tree/bootinfo-fdt.c new file +597 -0
597 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v5 7/10 xen/dt: Extract helper to map nodes to module kinds
In reply to Alejandro VallejoThis will be required later by x86 code in order to do early identification of boot modules when booting off a DTB.
Not a functional change.
--- xen/common/device-tree/bootfdt.c | 18 ++++++++++++++++++ xen/common/device-tree/bootinfo-fdt.c | 16 +--------------- xen/include/xen/bootfdt.h | 7 +++++++ 3 files changed, 26 insertions(+), 15 deletions(-)
xen/common/device-tree/bootfdt.c +18 -0
@@ -4,6 +4,24 @@#include <xen/lib.h> #include <xen/libfdt/libfdt.h> +boot_module_kind __init fdt_node_to_kind (const void *fdt,int node) +{ +if (fdt_node_check_compatible (fdt, node,"xen,linux-zimage" ) ==0 || +fdt_node_check_compatible (fdt, node,"multiboot,kernel" ) ==0 ) +return BOOTMOD_KERNEL ; +if (fdt_node_check_compatible (fdt, node,"xen,linux-initrd" ) ==0 || +fdt_node_check_compatible (fdt, node,"multiboot,ramdisk" ) ==0 ) +return BOOTMOD_RAMDISK ; +if (fdt_node_check_compatible (fdt, node,"xen,xsm-policy" ) ==0 ) +return BOOTMOD_XSM ; +if (fdt_node_check_compatible (fdt, node,"multiboot,device-tree" ) ==0 ) +return BOOTMOD_GUEST_DTB ; +if (fdt_node_check_compatible (fdt, node,"multiboot,microcode" ) ==0 ) +return BOOTMOD_MICROCODE ; + +return BOOTMOD_UNKNOWN ; +} +u32 __init device_tree_get_u32 (const void *fdt,int node,const char *prop_name,u32 dflt) {
xen/common/device-tree/bootinfo-fdt.c +1 -15
@@ -236,21 +236,7 @@ static void __init process_multiboot_node(const void *fdt, int node, cell = (const __be32 *)prop->data;device_tree_get_reg (&cell, address_cells, size_cells, &start, &size); - -if (fdt_node_check_compatible (fdt, node,"xen,linux-zimage" ) ==0 || -fdt_node_check_compatible (fdt, node,"multiboot,kernel" ) ==0 ) - kind =BOOTMOD_KERNEL ; -else if (fdt_node_check_compatible (fdt, node,"xen,linux-initrd" ) ==0 || -fdt_node_check_compatible (fdt, node,"multiboot,ramdisk" ) ==0 ) - kind =BOOTMOD_RAMDISK ; -else if (fdt_node_check_compatible (fdt, node,"xen,xsm-policy" ) ==0 ) - kind =BOOTMOD_XSM ; -else if (fdt_node_check_compatible (fdt, node,"multiboot,device-tree" ) ==0 ) - kind =BOOTMOD_GUEST_DTB ; -else if (fdt_node_check_compatible (fdt, node,"multiboot,microcode" ) ==0 ) - kind =BOOTMOD_MICROCODE ; -else - kind =BOOTMOD_UNKNOWN ; + kind =fdt_node_to_kind (fdt, node);/** * Guess the kind of these first two unknowns respectively:
xen/include/xen/bootfdt.h +7 -0
@@ -143,4 +143,11 @@ u32 device_tree_get_u32(const void *fdt, int node,void device_tree_get_reg (const __be32 **cell,uint32_t address_cells,uint32_t size_cells,paddr_t *start,paddr_t *size); +/* +* Probe an FDT node thought to be a boot module to identify its kind. +* +* If correctly identified, returns the detected kind, otherwise BOOTMOD_UNKNOWN +*/ +boot_module_kind fdt_node_to_kind (const void *fdt,int node); +#endif /* XEN_BOOTFDT_H */
Signature · 1 line
2.43.0
PATCH v5 8/10 xen: Split HAS_DEVICE_TREE in two
In reply to Alejandro VallejoMoving forward the idea is for there to be:
1. Basic DT support: used by dom0less/hyperlaunch.
2. Full DT support: used for device discovery and HW setup.
Rename HAS_DEVICE_TREE to HAS_DEVICE_TREE_DISCOVERY to describe (2) and create a new DEVICE_TREE_PARSE to describe (1).
Have DEVICE_TREE_PARSE selected by both HAS_DEVICE_TREE_DISCOVERY and DOM0LESS_BOOT.
Add a dependency on STATIC_MEMORY for discovery, as it relies on the memory map itself being described on the DTB.
---
v5:
* Replaces the old "xen: Rename CONFIG_HAS_DEVICE_TREE to CONFIG_HAS_DEVICE_TREE_DISCOVERY", though it renames largely a rename.
One could imagine STATIC_MEMORY being adapted for x86, but it's no small amount of work, so I shan't.
I didn't add Stefano's R-by because the patch seems functionally different even if its diff is very similar.
--- xen/Kconfig.debug | 2 +- xen/arch/arm/Kconfig | 2 +- xen/arch/ppc/Kconfig | 2 +- xen/arch/riscv/Kconfig | 2 +- xen/common/Kconfig | 13 +++++++++---- xen/common/Makefile | 4 ++-- xen/common/device.c | 4 ++-- xen/common/efi/boot.c | 2 +- xen/common/sched/Kconfig | 2 +- xen/drivers/char/ns16550.c | 6 +++--- xen/drivers/passthrough/Makefile | 2 +- xen/drivers/passthrough/iommu.c | 2 +- xen/include/asm-generic/device.h | 10 +++++----- xen/include/xen/iommu.h | 8 ++++---- xen/include/xsm/dummy.h | 4 ++-- xen/include/xsm/xsm.h | 12 ++++++------ xen/xsm/dummy.c | 2 +- xen/xsm/flask/hooks.c | 6 +++--- xen/xsm/xsm_core.c | 4 ++-- xen/xsm/xsm_policy.c | 4 ++-- 20 files changed, 49 insertions(+), 44 deletions(-)
xen/Kconfig.debug +1 -1
@@ -92,7 +92,7 @@ config VERBOSE_DEBUG config DEVICE_TREE_DEBUG bool "Device tree debug messages" - depends on HAS_DEVICE_TREE + depends on DEVICE_TREE_PARSE help Device tree parsing and DOM0 device tree building messages are logged in the Xen ring buffer.
xen/arch/arm/Kconfig +1 -1
@@ -15,7 +15,7 @@ config ARM select FUNCTION_ALIGNMENT_4B select GENERIC_UART_INIT select HAS_ALTERNATIVE if HAS_VMAP - select HAS_DEVICE_TREE + select HAS_DEVICE_TREE_DISCOVERY select HAS_DOM0LESS select HAS_GRANT_CACHE_FLUSH if GRANT_TABLE select HAS_STACK_PROTECTOR
xen/arch/ppc/Kconfig +1 -1
@@ -1,7 +1,7 @@ config PPC def_bool y select FUNCTION_ALIGNMENT_4B - select HAS_DEVICE_TREE + select HAS_DEVICE_TREE_DISCOVERY select HAS_UBSAN select HAS_VMAP
xen/arch/riscv/Kconfig +1 -1
@@ -2,7 +2,7 @@ config RISCV def_bool y select FUNCTION_ALIGNMENT_16B select GENERIC_BUG_FRAME - select HAS_DEVICE_TREE + select HAS_DEVICE_TREE_DISCOVERY select HAS_PMAP select HAS_UBSAN select HAS_VMAP
xen/common/Kconfig +9 -4
@@ -14,7 +14,8 @@ config CORE_PARKING config DOM0LESS_BOOT bool "Dom0less boot support" if EXPERT - depends on HAS_DOM0LESS && HAS_DEVICE_TREE && DOMAIN_BUILD_HELPERS + depends on HAS_DOM0LESS && DOMAIN_BUILD_HELPERS + select DEVICE_TREE_PARSE default y help Dom0less boot support enables Xen to create and start domU guests during
@@ -85,7 +86,11 @@ config HAS_ALTERNATIVE config HAS_COMPAT bool -config HAS_DEVICE_TREE +config HAS_DEVICE_TREE_DISCOVERY + bool + select DEVICE_TREE_PARSE + +config DEVICE_TREE_PARSE bool select LIBFDT
@@ -154,7 +159,7 @@ config NUMA config STATIC_MEMORY bool "Static Allocation Support (UNSUPPORTED)" if UNSUPPORTED - depends on DOM0LESS_BOOT + depends on DOM0LESS_BOOT && HAS_DEVICE_TREE_DISCOVERY help Static Allocation refers to system or sub-system(domains) for which memory areas are pre-defined by configuration using physical
@@ -553,7 +558,7 @@ config DOM0_MEM config DTB_FILE string "Absolute path to device tree blob" - depends on HAS_DEVICE_TREE + depends on HAS_DEVICE_TREE_DISCOVERY help When using a bootloader that has no device tree support or when there is no bootloader at all, use this option to specify the absolute path
xen/common/Makefile +2 -2
@@ -6,9 +6,9 @@ obj-$(CONFIG_HYPFS_CONFIG) += config_data.o obj-$(CONFIG_CORE_PARKING) += core_parking.o obj-y += cpu.o obj-$(CONFIG_DEBUG_TRACE) += debugtrace.o -obj-$(CONFIG_HAS_DEVICE_TREE) += device.o +obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) += device.o obj-$(filter-out $(CONFIG_X86),$(CONFIG_ACPI)) += device.o -obj-$(CONFIG_HAS_DEVICE_TREE) += device-tree/ +obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) += device-tree/ obj-$(CONFIG_IOREQ_SERVER) += dm.o obj-y += domain.o obj-y += event_2l.o
xen/common/device.c +2 -2
@@ -11,7 +11,7 @@#include <asm/device.h> -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY extern const struct device_desc _sdevice[], _edevice[];
@@ -56,7 +56,7 @@ enum device_class device_get_class(const struct dt_device_node *dev) return DEVICE_UNKNOWN; } -#endif +#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */ #ifdef CONFIG_ACPI
xen/common/efi/boot.c +1 -1
@@ -623,7 +623,7 @@ static int __init __maybe_unused set_color(uint32_t mask, int bpp,return max (*pos + *sz, bpp); } -#ifndef CONFIG_HAS_DEVICE_TREE +#ifndef CONFIG_HAS_DEVICE_TREE_DISCOVERY static int __init efi_check_dt_boot (const EFI_LOADED_IMAGE *loaded_image) {return 0 ;
xen/common/sched/Kconfig +1 -1
@@ -67,7 +67,7 @@ endmenu config BOOT_TIME_CPUPOOLS bool "Create cpupools at boot time" - depends on HAS_DEVICE_TREE + depends on HAS_DEVICE_TREE_DISCOVERY help Creates cpupools during boot time and assigns cpus to them. Cpupools options can be specified in the device tree.
xen/drivers/char/ns16550.c +3 -3
@@ -34,7 +34,7 @@#include <xen/8250-uart.h> #include <xen/vmap.h> #include <asm/io.h> -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY #include <asm/device.h> #endif #ifdef CONFIG_X86
@@ -1766,7 +1766,7 @@ void __init ns16550_init(int index, struct ns16550_defaults *defaults)#endif /* CONFIG_X86 */ -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY static int __init ns16550_uart_dt_init (struct dt_device_node *dev,const void *data) {
@@ -1845,7 +1845,7 @@ DT_DEVICE_START(ns16550, "NS16550 UART", DEVICE_SERIAL) .init = ns16550_uart_dt_init, DT_DEVICE_END -#endif /* HAS_DEVICE_TREE */ +#endif /* HAS_DEVICE_TREE_DISCOVERY */ #if defined(CONFIG_ACPI ) && defined(CONFIG_ARM )#include <xen/acpi.h>
xen/drivers/passthrough/Makefile +1 -1
@@ -5,6 +5,6 @@ obj-$(CONFIG_ARM) += arm/ obj-y += iommu.o obj-$(CONFIG_HAS_PCI) += pci.o -obj-$(CONFIG_HAS_DEVICE_TREE) += device_tree.o +obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) += device_tree.o obj-$(CONFIG_HAS_PCI) += ats.o obj-$(CONFIG_HAS_PCI_MSI) += msi.o
xen/drivers/passthrough/iommu.c +1 -1
@@ -638,7 +638,7 @@ int iommu_do_domctl( ret =iommu_do_pci_domctl (domctl, d, u_domctl);#endif -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY if ( ret == -ENODEV ) ret =iommu_do_dt_domctl (domctl, d, u_domctl);#endif
xen/include/asm-generic/device.h +5 -5
@@ -6,7 +6,7 @@enum device_type { -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY DEV_DT ,#endif DEV_PCI
@@ -26,7 +26,7 @@ enum device_classstruct device {enum device_type type; -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY struct dt_device_node *of_node;/* Used by drivers imported from Linux */ #endif #ifdef CONFIG_HAS_PASSTHROUGH
@@ -37,7 +37,7 @@ struct devicetypedef struct device device_t ; -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY #include <xen/device_tree.h>
@@ -87,9 +87,9 @@ struct device_desc { int (*init)(struct dt_device_node *dev, const void *data); }; -#else /* !CONFIG_HAS_DEVICE_TREE */ +#else /* !CONFIG_HAS_DEVICE_TREE_DISCOVERY */ #define dev_is_dt (dev) ((void)(dev), false) -#endif /* CONFIG_HAS_DEVICE_TREE */ +#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */ #define dev_is_pci (dev) ((dev)->type == DEV_PCI)
xen/include/xen/iommu.h +4 -4
@@ -230,7 +230,7 @@ struct msi_msg;#define PT_IRQ_TIME_OUT MILLISECS(8)#endif /* HAS_PCI */ -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY #include <xen/device_tree.h> #ifdef CONFIG_HAS_PASSTHROUGH
@@ -288,7 +288,7 @@ static inline int iommu_release_dt_devices(struct domain *d)#endif /* HAS_PASSTHROUGH */ -#endif /* HAS_DEVICE_TREE */ +#endif /* HAS_DEVICE_TREE_DISCOVERY */ struct page_info ;
@@ -355,7 +355,7 @@ struct iommu_ops {int (*get_reserved_device_memory)(iommu_grdm_t *func,void *ctxt);void (*dump_page_tables)(struct domain *d); -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY /* * All IOMMU drivers which support generic IOMMU DT bindings should use * this callback. This is a way for the framework to provide the driver
@@ -403,7 +403,7 @@ struct domain_iommu {/* iommu_ops */ const struct iommu_ops *platform_ops; -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY /* List of DT devices assigned to this domain */ struct list_head dt_devices;#endif
xen/include/xsm/dummy.h +2 -2
@@ -423,7 +423,7 @@ static XSM_INLINE int cf_check xsm_deassign_device(#endif /* HAS_PASSTHROUGH && HAS_PCI */ -#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE ) +#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY ) static XSM_INLINE int cf_check xsm_assign_dtdevice( XSM_DEFAULT_ARG struct domain *d, const char *dtpath) {
@@ -438,7 +438,7 @@ static XSM_INLINE int cf_check xsm_deassign_dtdevice(return xsm_default_action (action, current->domain, d); } -#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE */ +#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE_DISCOVERY */ static XSM_INLINE int cf_check xsm_resource_plug_core(XSM_DEFAULT_VOID) {
xen/include/xsm/xsm.h +6 -6
@@ -125,7 +125,7 @@ struct xsm_ops {int (*deassign_device)(struct domain *d,uint32_t machine_bdf);#endif -#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE ) +#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY )int (*assign_dtdevice)(struct domain *d,const char *dtpath);int (*deassign_dtdevice)(struct domain *d,const char *dtpath);#endif
@@ -535,7 +535,7 @@ static inline int xsm_deassign_device( }#endif /* HAS_PASSTHROUGH && HAS_PCI) */ -#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE ) +#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY )static inline int xsm_assign_dtdevice (xsm_default_t def,struct domain *d,const char *dtpath) {
@@ -548,7 +548,7 @@ static inline int xsm_deassign_dtdevice( return alternative_call(xsm_ops.deassign_dtdevice, d, dtpath); } -#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE */ +#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE_DISCOVERY */ static inline int xsm_resource_plug_pci (xsm_default_t def,uint32_t machine_bdf) {
@@ -789,7 +789,7 @@ int xsm_multiboot_policy_init( struct boot_info *bi, void **policy_buffer, size_t *policy_size);#endif -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY /* * Initialize XSM *
@@ -839,7 +839,7 @@ static inline int xsm_multiboot_init(struct boot_info *bi) }#endif -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY static inline int xsm_dt_init (void ) {return 0 ;
@@ -849,7 +849,7 @@ static inline bool has_xsm_magic(paddr_t start) {return false; } -#endif /* CONFIG_HAS_DEVICE_TREE */ +#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */ #endif /* CONFIG_XSM */
xen/xsm/dummy.c +1 -1
@@ -81,7 +81,7 @@ static const struct xsm_ops __initconst_cf_clobber dummy_ops = { .deassign_device = xsm_deassign_device,#endif -#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE ) +#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY ) .assign_dtdevice = xsm_assign_dtdevice, .deassign_dtdevice = xsm_deassign_dtdevice,#endif
xen/xsm/flask/hooks.c +3 -3
@@ -1456,7 +1456,7 @@ static int cf_check flask_deassign_device( }#endif /* HAS_PASSTHROUGH && HAS_PCI */ -#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE ) +#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY )static int flask_test_assign_dtdevice (const char *dtpath) {uint32_t rsid;
@@ -1517,7 +1517,7 @@ static int cf_check flask_deassign_dtdevice(return avc_current_has_perm (rsid,SECCLASS_RESOURCE ,RESOURCE__REMOVE_DEVICE ,NULL ); } -#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE */ +#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE_DISCOVERY */ static int cf_check flask_platform_op(uint32_t op) {
@@ -1981,7 +1981,7 @@ static const struct xsm_ops __initconst_cf_clobber flask_ops = { .deassign_device = flask_deassign_device,#endif -#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE ) +#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY ) .assign_dtdevice = flask_assign_dtdevice, .deassign_dtdevice = flask_deassign_dtdevice,#endif
xen/xsm/xsm_core.c +2 -2
@@ -25,7 +25,7 @@#include <asm/setup.h> #endif -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY #include <asm/setup.h> #endif
@@ -166,7 +166,7 @@ int __init xsm_multiboot_init(struct boot_info *bi) }#endif -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY int __init xsm_dt_init (void ) {int ret =0 ;
xen/xsm/xsm_policy.c +2 -2
@@ -24,7 +24,7 @@#include <asm/setup.h> #endif #include <xen/bitops.h> -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY # include <asm/setup.h> # include <xen/device_tree.h> #endif
@@ -65,7 +65,7 @@ int __init xsm_multiboot_policy_init( }#endif -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY int __init xsm_dt_policy_init (void **policy_buffer,size_t *policy_size) {struct boot_module *mod =boot_module_find_by_kind (BOOTMOD_XSM );
Signature · 1 line
2.43.0
Re: [PATCH v5 08/10] xen: Split HAS_DEVICE_TREE in two
xen/common/Kconfig config HAS_ALTERNATIVE · line 96
Quoted 13 lines · Alejandro Vallejo
xen/common/Kconfig +5
-1@@ -85,7 +86,11 @@ config HAS_ALTERNATIVE config HAS_COMPAT bool -config HAS_DEVICE_TREE +config HAS_DEVICE_TREE_DISCOVERY + bool + select DEVICE_TREE_PARSE + +config DEVICE_TREE_PARSE bool select LIBFDT
We're in the middle of various ([almost] alphabetically sorted) HAS_* here. Thus DEVICE_TREE_PARSE wants to move elsewhere. Or we want to move back to naming it HAS_DEVICE_TREE_PARSE, but I think there was a reason why we didn't want it like that? Just that I don't recall what that reason was ...
xen/common/sched/Kconfig endmenu · line 70
Quoted 8 lines
xen/common/sched/Kconfig +1
-1@@ -67,7 +67,7 @@ endmenu config BOOT_TIME_CPUPOOLS bool "Create cpupools at boot time" - depends on HAS_DEVICE_TREE + depends on HAS_DEVICE_TREE_DISCOVERY
Is this correct? CPU pool creation isn't driven by DT discovery, I thought, but is a software-only thing much like dom0less?
Quoted 12 lines
xen/include/xsm/dummy.h +1
-1@@ -423,7 +423,7 @@ static XSM_INLINE int cf_check xsm_deassign_device(#endif /* HAS_PASSTHROUGH && HAS_PCI */ -#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE ) +#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY ) static XSM_INLINE int cf_check xsm_assign_dtdevice( XSM_DEFAULT_ARG struct domain *d, const char *dtpath) {
xen/include/xsm/dummy.h static XSM_INLINE int cf_check xsm_deassign_dtdevice( · line 441
Quoted 5 lines
xen/include/xsm/dummy.h +1
-1@@ -438,7 +438,7 @@ static XSM_INLINE int cf_check xsm_deassign_dtdevice( return xsm_default_action(action, current->domain, d); } -#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE */ +#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE_DISCOVERY */
Here I'm similarly unsure: Pass-through again isn't a platform thing, is it?
Quoted 19 lines
xen/include/xsm/dummy.h +2
-2@@ -789,7 +789,7 @@ int xsm_multiboot_policy_init( struct boot_info *bi, void **policy_buffer, size_t *policy_size);#endif -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY /* * Initialize XSM * @@ -839,7 +839,7 @@ static inline int xsm_multiboot_init(struct boot_info *bi) }#endif -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY static inline int xsm_dt_init (void ) {return 0 ;
xen/include/xsm/dummy.h static inline bool has_xsm_magic(paddr_t start) · line 852
Quoted 5 lines
xen/include/xsm/dummy.h +1
-1@@ -849,7 +849,7 @@ static inline bool has_xsm_magic(paddr_t start) {return false; } -#endif /* CONFIG_HAS_DEVICE_TREE */ +#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */
The situation is yet less clear to me here.
Jan
Re: [PATCH v5 08/10] xen: Split HAS_DEVICE_TREE in two
Quoted 5 lines · Jan Beulich
Quoted 4 lines · Alejandro Vallejo
xen/common/Kconfig +0
-0@@ -85,7 +86,11 @@ config HAS_ALTERNATIVE config HAS_COMPAT bool
Quoted 14 lines
xen/common/Kconfig config HAS_ALTERNATIVE · line 96
Quoted 9 lines
xen/common/Kconfig +5
-1-config HAS_DEVICE_TREE +config HAS_DEVICE_TREE_DISCOVERY + bool + select DEVICE_TREE_PARSE + +config DEVICE_TREE_PARSE bool select LIBFDTWe're in the middle of various ([almost] alphabetically sorted) HAS_* here. Thus
DEVICE_TREE_PARSEwants to move elsewhere. Or we want to move back to naming itHAS_DEVICE_TREE_PARSE, but I think there was a reason why we didn't want it like that? Just that I don't recall what that reason was ...
AIUI, HAS_X are options selected by your architecture. Things that tell you whether X is supported in your arch or not. In this case, HAS_DEVICE_TREE_PARSE would be supported everywhere, while DEVICE_TREE_PARSE is not an arch property, but an option selected by DOM0LESS_BOOT (which appears in menuconfig) and HAS_DEVICE_TREE_DISCOVERY.
I can move it elsewhere, but it's unfortunate to separate two so closely related options.
Quoted 5 lines
Quoted 5 lines
xen/common/sched/Kconfig +0
-0@@ -67,7 +67,7 @@ endmenu
Quoted 7 lines
xen/common/sched/Kconfig endmenu · line 70
Quoted 4 lines
xen/common/sched/Kconfig +1
-1config BOOT_TIME_CPUPOOLS bool "Create cpupools at boot time" - depends on HAS_DEVICE_TREE + depends on HAS_DEVICE_TREE_DISCOVERYIs this correct? CPU pool creation isn't driven by DT discovery, I thought, but is a software-only thing much like dom0less?
In principle it would be possible. But I haven't tested the configuration, so I'd rather err on the side of caution and not enable features prematurely.
In time, this should become DOM0LESS_BOOT || HAS_DEVICE_TREE_DISCOVERY.
Quoted 16 lines
Quoted 16 lines
xen/include/xsm/dummy.h +1
-1@@ -423,7 +423,7 @@ static XSM_INLINE int cf_check xsm_deassign_device(#endif /* HAS_PASSTHROUGH && HAS_PCI */ -#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE ) +#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY ) static XSM_INLINE int cf_check xsm_assign_dtdevice( XSM_DEFAULT_ARG struct domain *d, const char *dtpath) {@@ -438,7 +438,7 @@ static XSM_INLINE int cf_check xsm_deassign_dtdevice(return xsm_default_action (action, current->domain, d); }
Quoted 4 lines
xen/include/xsm/dummy.h static XSM_INLINE int cf_check xsm_deassign_dtdevice( · line 441
Quoted 2 lines
xen/include/xsm/dummy.h +1
-1-#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE */ +#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE_DISCOVERY */ Here I'm similarly unsure: Pass-through again isn't a platform thing, is it?
This has to do strictly with passthrough of devices discovered via DT.
Quoted 14 lines
Quoted 14 lines
xen/include/xsm/dummy.h +1
-1@@ -789,7 +789,7 @@ int xsm_multiboot_policy_init( struct boot_info *bi, void **policy_buffer, size_t *policy_size);#endif -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY /* * Initialize XSM * @@ -839,7 +839,7 @@ static inline int xsm_multiboot_init(struct boot_info *bi) }#endif
Quoted 13 lines
xen/include/xsm/dummy.h static inline bool has_xsm_magic(paddr_t start) · line 852
Quoted 11 lines
xen/include/xsm/dummy.h +2
-2-#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY static inline int xsm_dt_init (void ) {return 0 ;@@ -849,7 +849,7 @@ static inline bool has_xsm_magic(paddr_t start) {return false; } -#endif /* CONFIG_HAS_DEVICE_TREE */ +#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */ The situation is yet less clear to me here
XSM segregates multibooting and DT-booting, this refers strictly to the latter.
By DT-booting I mean platforms where the DT is given by the platform rather than the user as a module.
Cheers,
Alejandro
Re: [PATCH v5 08/10] xen: Split HAS_DEVICE_TREE in two
Quoted 21 lines · Alejandro Vallejo
Quoted 5 lines · Jan Beulich
Quoted 4 lines · Alejandro Vallejo
xen/common/Kconfig +0
-0@@ -85,7 +86,11 @@ config HAS_ALTERNATIVE config HAS_COMPAT boolQuoted 14 lines
xen/common/Kconfig config HAS_ALTERNATIVE · line 96
Quoted 9 lines
xen/common/Kconfig +5
-1-config HAS_DEVICE_TREE +config HAS_DEVICE_TREE_DISCOVERY + bool + select DEVICE_TREE_PARSE + +config DEVICE_TREE_PARSE bool select LIBFDTWe're in the middle of various ([almost] alphabetically sorted) HAS_* here. Thus
DEVICE_TREE_PARSEwants to move elsewhere. Or we want to move back to naming itHAS_DEVICE_TREE_PARSE, but I think there was a reason why we didn't want it like that? Just that I don't recall what that reason was ...
Quoted 5 lines
AIUI,
HAS_Xare options selected by your architecture. Things that tell you whether X is supported in your arch or not. In this case,HAS_DEVICE_TREE_PARSEwould be supported everywhere, whileDEVICE_TREE_PARSEis not an arch property, but an option selected byDOM0LESS_BOOT(which appears in menuconfig) andHAS_DEVICE_TREE_DISCOVERY.
It's on the edge here, I agree. Yet we have other cases where one HAS_* selects another HAS_*, and I think we're in the process of gaining more.
Quoted 2 lines
I can move it elsewhere, but it's unfortunate to separate two so closely related options.
Imo there's only one of two options - move it or rename it.
Quoted 12 lines
Quoted 11 lines
xen/common/sched/Kconfig endmenu · line 70
Quoted 8 lines
xen/common/sched/Kconfig +1
-1@@ -67,7 +67,7 @@ endmenu config BOOT_TIME_CPUPOOLS bool "Create cpupools at boot time" - depends on HAS_DEVICE_TREE + depends on HAS_DEVICE_TREE_DISCOVERYIs this correct? CPU pool creation isn't driven by DT discovery, I thought, but is a software-only thing much like dom0less?
Quoted 4 lines
In principle it would be possible. But I haven't tested the configuration, so I'd rather err on the side of caution and not enable features prematurely.
In time, this should become
DOM0LESS_BOOT||HAS_DEVICE_TREE_DISCOVERY.
DEVICE_TREE_PARSE, that is?
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
xen/include/xsm/dummy.h +1
-1@@ -423,7 +423,7 @@ static XSM_INLINE int cf_check xsm_deassign_device(#endif /* HAS_PASSTHROUGH && HAS_PCI */ -#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE ) +#if defined(CONFIG_HAS_PASSTHROUGH ) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY ) static XSM_INLINE int cf_check xsm_assign_dtdevice( XSM_DEFAULT_ARG struct domain *d, const char *dtpath) {@@ -438,7 +438,7 @@ static XSM_INLINE int cf_check xsm_deassign_dtdevice(return xsm_default_action (action, current->domain, d); }
Quoted 6 lines
Quoted 4 lines
xen/include/xsm/dummy.h static XSM_INLINE int cf_check xsm_deassign_dtdevice( · line 441
Quoted 2 lines
xen/include/xsm/dummy.h +1
-1-#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE */ +#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE_DISCOVERY */ Here I'm similarly unsure: Pass-through again isn't a platform thing, is it?
This has to do strictly with passthrough of devices discovered via DT.
Wait, no. You discover devices via DT, but you don't "discover" what domain to pass them through. For the latter, DT is again only a vehicle.
Quoted 27 lines
Quoted 13 lines
Quoted 13 lines
xen/include/xsm/dummy.h +1
-1@@ -789,7 +789,7 @@ int xsm_multiboot_policy_init( struct boot_info *bi, void **policy_buffer, size_t *policy_size);#endif -#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY /* * Initialize XSM * @@ -839,7 +839,7 @@ static inline int xsm_multiboot_init(struct boot_info *bi) }#endif Quoted 13 lines
xen/include/xsm/dummy.h static inline bool has_xsm_magic(paddr_t start) · line 852
Quoted 11 lines
xen/include/xsm/dummy.h +2
-2-#ifdef CONFIG_HAS_DEVICE_TREE +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY static inline int xsm_dt_init (void ) {return 0 ;@@ -849,7 +849,7 @@ static inline bool has_xsm_magic(paddr_t start) {return false; } -#endif /* CONFIG_HAS_DEVICE_TREE */ +#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */ The situation is yet less clear to me here
Quoted 4 lines
XSM segregates multibooting and DT-booting, this refers strictly to the latter.
By DT-booting I mean platforms where the DT is given by the platform rather than the user as a module.
Yet the platform as such hardly even knows of XSM (or in fact any of the software that's going to run there).
I think we need DT maintainer input here.
Jan
Re: [PATCH v5 08/10] xen: Split HAS_DEVICE_TREE in two
Quoted 22 lines · Jan Beulich
Quoted 21 lines · Alejandro Vallejo
Quoted 19 lines · Jan Beulich
xen/common/Kconfig config HAS_ALTERNATIVE · line 96
Quoted 13 lines · Alejandro Vallejo
xen/common/Kconfig +5
-1@@ -85,7 +86,11 @@ config HAS_ALTERNATIVE config HAS_COMPAT bool -config HAS_DEVICE_TREE +config HAS_DEVICE_TREE_DISCOVERY + bool + select DEVICE_TREE_PARSE + +config DEVICE_TREE_PARSE bool select LIBFDTWe're in the middle of various ([almost] alphabetically sorted) HAS_* here. Thus
DEVICE_TREE_PARSEwants to move elsewhere. Or we want to move back to naming itHAS_DEVICE_TREE_PARSE, but I think there was a reason why we didn't want it like that? Just that I don't recall what that reason was ...
Quoted 8 lines
Quoted 5 lines
AIUI,
HAS_Xare options selected by your architecture. Things that tell you whether X is supported in your arch or not. In this case,HAS_DEVICE_TREE_PARSEwould be supported everywhere, whileDEVICE_TREE_PARSEis not an arch property, but an option selected byDOM0LESS_BOOT(which appears in menuconfig) andHAS_DEVICE_TREE_DISCOVERY.It's on the edge here, I agree. Yet we have other cases where one HAS_* selects another HAS_*, and I think we're in the process of gaining more.
HAS_* selecting another HAS_* makes sense to me, but that's not what would be going on here. On x86:
HAS_DOM0LESS => DOM0LESS_BOOT[y] => HAS_DEVICE_TREE_PARSE
thus leading to HAS_DEVICE_TREE_PARSE being indirectly selectable via DOM0LESS_BOOT, which is hardly a HAS_* relationship.
Quoted 5 lines
Quoted 3 lines
I can move it elsewhere, but it's unfortunate to separate two so closely related options.
Imo there's only one of two options - move it or rename it.
I'll just move it elsewhere then.
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
xen/common/sched/Kconfig endmenu · line 70
Quoted 9 lines
xen/common/sched/Kconfig +1
-1@@ -67,7 +67,7 @@ endmenu config BOOT_TIME_CPUPOOLS bool "Create cpupools at boot time" - depends on HAS_DEVICE_TREE + depends on HAS_DEVICE_TREE_DISCOVERYIs this correct? CPU pool creation isn't driven by DT discovery, I thought, but is a software-only thing much like dom0less?
Quoted 6 lines
Quoted 4 lines
In principle it would be possible. But I haven't tested the configuration, so I'd rather err on the side of caution and not enable features prematurely.
In time, this should become
DOM0LESS_BOOT||HAS_DEVICE_TREE_DISCOVERY.
DEVICE_TREE_PARSE, that is?
Yes :)
Cheers,
Alejandro
PATCH v5 9/10 xen/dt: ifdef out DEV_DT-related bits from device_tree.{c,h}
In reply to Alejandro VallejoArchitectures that don't discover devices via DT may skip anything to do with device_t during the DT unflattening phase. Make device-tree.c stop requiring CONFIG_HAS_DEVICE_TREE_DISCOVERY so it may function with CONFIG_DEVICE_TREE_PARSE alone.
This allows CONFIG_DEVICE_TREE_PARSE to unflatten a DT ignoring its devices if CONFIG_HAS_DEVICE_TREE_DISCOVERY is not selected.
---
v5:
* New commit message to make it more general
--- xen/common/device-tree/device-tree.c | 2 ++ xen/include/xen/device_tree.h | 4 ++++ 2 files changed, 6 insertions(+)
xen/common/device-tree/device-tree.c +2 -0
@@ -2029,9 +2029,11 @@ static unsigned long unflatten_dt_node(const void *fdt, ((char *)pp->value)[sz -1 ] =0 ;dt_dprintk ("fixed up name for %s -> %s\n" , pathp, (char *)pp->value); +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY /* Generic device initialization */ np->dev.type =DEV_DT ; np->dev.of_node = np; +#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */ } }if ( allnextpp )
xen/include/xen/device_tree.h +4 -0
@@ -108,9 +108,12 @@ struct dt_device_node {*/ struct list_head domain_list; +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY struct device dev; +#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */ }; +#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY #define dt_to_dev (dt_node) (&(dt_node)->dev)static inline struct dt_device_node *dev_to_dt (struct device *dev)
@@ -119,6 +122,7 @@ static inline struct dt_device_node *dev_to_dt(struct device *dev) return container_of(dev, struct dt_device_node, dev); } +#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */ #define MAX_PHANDLE_ARGS 16struct dt_phandle_args {
Signature · 1 line
2.43.0
PATCH v5 10/10 xen/dt: Allow CONFIG_DEVICE_TREE_PARSE to include device-tree/
In reply to Alejandro VallejoThis allows bootfdt.c and device-tree.c to be usable without CONFIG_HAS_DEVICE_TREE_DISCOVERY.
Gate everything else on CONFIG_HAS_DEVICE_TREE_DISCOVERY.
--- xen/common/Makefile | 2 +- xen/common/device-tree/Makefile | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
xen/common/Makefile +1 -1
@@ -8,7 +8,7 @@ obj-y += cpu.o obj-$(CONFIG_DEBUG_TRACE) += debugtrace.o obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) += device.o obj-$(filter-out $(CONFIG_X86),$(CONFIG_ACPI)) += device.o -obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) += device-tree/ +obj-$(CONFIG_DEVICE_TREE_PARSE) += device-tree/ obj-$(CONFIG_IOREQ_SERVER) += dm.o obj-y += domain.o obj-y += event_2l.o
xen/common/device-tree/Makefile +3 -3
@@ -1,11 +1,11 @@ obj-y += bootfdt.init.o -obj-y += bootinfo-fdt.init.o -obj-y += bootinfo.init.o +obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) += bootinfo-fdt.init.o +obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) += bootinfo.init.o obj-y += device-tree.o obj-$(CONFIG_DOMAIN_BUILD_HELPERS) += domain-build.init.o obj-$(CONFIG_DOM0LESS_BOOT) += dom0less-build.init.o obj-$(CONFIG_OVERLAY_DTB) += dt-overlay.o -obj-y += intc.o +obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) += intc.o obj-$(CONFIG_DOMAIN_BUILD_HELPERS) += kernel.o obj-$(CONFIG_STATIC_EVTCHN) += static-evtchn.init.o obj-$(CONFIG_STATIC_MEMORY) += static-memory.init.o
Signature · 1 line
2.43.0