Allow x86 to unflatten DTs
v3 cover Allow x86 to unflatten DTs
Hi,
New summary when compared to v2:
* Patches 1 and 2 are just cleanup
* Patch 3 is a modification of the CODING_STYLE to reflect the unwritten rule of splitting type names in words.
* Patch 4 is a rename of struct bootmodule{,s} to boot_module{,s}, in accordance to the modification of patch 3.
* Patch 5-7 replaces x86-specific boot_{domain,module} defs in favour of common ones.
* The rest are code motion and enablement of x86 to unflatten DTs and use some dom0less helpers.
v3 pipeline: https://gitlab.com/xen-project/people/agvallejo/xen/-/pipelines/1868636712
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 (14):
arm/gnttab: Remove xen/grant_table.h cyclic include
x86: Preinitialise all modules to be of kind BOOTMOD_UNKNOWN
CODING_STYLE: Custom type names must be snake-cased by word.
xen: Rename bootmodule{,s} to boot_module{,s}
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 common one bootdomain 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/dt: ifdef out DEV_DT-related bits from device_tree.{c,h} xen/dt: Allow CONFIG_DOM0LESS_BOOT to include device-tree/
kconfig: Allow x86 to pick CONFIG_DOM0LESS_BOOT
CODING_STYLE | 3 + xen/arch/arm/dom0less-build.c | 8 +- xen/arch/arm/domain_build.c | 21 +- xen/arch/arm/efi/efi-boot.h | 6 +- xen/arch/arm/include/asm/grant_table.h | 1 - xen/arch/arm/kernel.c | 10 +- xen/arch/arm/llc-coloring.c | 8 +- xen/arch/arm/mmu/setup.c | 10 +- xen/arch/arm/setup.c | 11 +- xen/arch/riscv/mm.c | 2 +- xen/arch/riscv/setup.c | 2 +- xen/arch/x86/Kconfig | 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 | 58 ++- xen/common/Kconfig | 13 +- xen/common/Makefile | 2 +- xen/common/device-tree/Makefile | 9 +- xen/common/device-tree/bootfdt.c | 654 ++---------------------- xen/common/device-tree/bootinfo-fdt.c | 583 +++++++++++++++++++++ xen/common/device-tree/bootinfo.c | 54 +- xen/common/device-tree/device-tree.c | 2 + xen/common/device-tree/dom0less-build.c | 45 +- xen/common/device-tree/domain-build.c | 22 +- xen/common/device-tree/kernel.c | 30 +- xen/include/xen/bootfdt.h | 277 +++------- xen/include/xen/bootinfo.h | 213 ++++++++ xen/include/xen/device_tree.h | 44 +- xen/include/xen/fdt-domain-build.h | 2 +- xen/include/xen/fdt-kernel.h | 12 +- xen/xsm/xsm_policy.c | 4 +- 35 files changed, 1162 insertions(+), 1112 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
Signature · 1 line
2.43.0
PATCH v3 1/14 arm/gnttab: Remove xen/grant_table.h cyclic include
The way they currently include each other, with one of the includes being conditional on CONFIG_GRANT_TABLE, makes it hard to know which contents are included when.
Break the cycle by removing the asm/grant_table.h include.
Not a functional change because.
---
v3:
* Strictly remove the cycle in asm/grant_table.h (Keeping the conditional include is a terrible idea, IMO)
--- xen/arch/arm/include/asm/grant_table.h | 1 - 1 file changed, 1 deletion(-)
xen/arch/arm/include/asm/grant_table.h +0 -1
@@ -1,7 +1,6 @@#ifndef __ASM_GRANT_TABLE_H__#define __ASM_GRANT_TABLE_H__ -#include <xen/grant_table.h> #include <xen/kernel.h> #include <xen/pfn.h> #include <xen/sched.h>
Signature · 1 line
2.43.0
Re: [PATCH v3 01/14] arm/gnttab: Remove xen/grant_table.h cyclic include
Quoted 9 lines · Alejandro Vallejo
The way they currently include each other, with one of the includes being conditional on
CONFIG_GRANT_TABLE, makes it hard to know which contents are included when.Break the cycle by removing the
asm/grant_table.hinclude.Not a functional change because.
Signed-off-by Alejandro Vallejo <[email protected]>
Quoted 23 lines
---
v3:
* Strictly remove the cycle inasm/grant_table.h(Keeping the conditional include is a terrible idea, IMO)--- xen/arch/arm/include/asm/grant_table.h | 1 - 1 file changed, 1 deletion(-)xen/arch/arm/include/asm/grant_table.h +0
-1@@ -1,7 +1,6 @@#ifndef __ASM_GRANT_TABLE_H__#define __ASM_GRANT_TABLE_H__ -#include <xen/grant_table.h> #include <xen/kernel.h> #include <xen/pfn.h> #include <xen/sched.h> Signature · 1 line
2.43.0
PATCH v3 2/14 x86: Preinitialise all modules to be of kind BOOTMOD_UNKNOWN
In reply to Alejandro VallejoA later patch removes boot_module and replaces its uses with bootmodule. The equivalent field for "type" doesn't have BOOTMOD_UNKNOWN as a zero value, so it must be explicitly set in the static xen_boot_info.
Not a functional change.
--- xen/arch/x86/setup.c | 6 ++++++ 1 file changed, 6 insertions(+)
xen/arch/x86/setup.c +6 -0
@@ -298,6 +298,12 @@ struct boot_info __initdata xen_boot_info = { .loader = "unknown", .cmdline = "", .domains = { [0 ... MAX_NR_BOOTDOMS - 1] = { .domid = DOMID_INVALID } }, +/* +* There's a MAX_NR_BOOTMODS-th entry in the array. It's not off by one. +* +* The extra entry exists to be able to add the Xen image as a module. +*/ + .mods = { [0 ... MAX_NR_BOOTMODS] = { .type = BOOTMOD_UNKNOWN } }, }; static struct boot_info *__init multiboot_fill_boot_info(
Signature · 1 line
2.43.0
Re: [PATCH v3 02/14] x86: Preinitialise all modules to be of kind BOOTMOD_UNKNOWN
Quoted 8 lines · Alejandro Vallejo
A later patch removes
boot_moduleand replaces its uses with bootmodule. The equivalent field for "type" doesn't haveBOOTMOD_UNKNOWNas a zero value, so it must be explicitly set in the staticxen_boot_info.Not a functional change.
Signed-off-by Alejandro Vallejo <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>
PATCH v3 3/14 CODING_STYLE: Custom type names must be snake-cased by word.
In reply to Alejandro VallejoThere's the unwritten convention in x86 of splitting type names using underscores. Add such convention to the CODINNG_STYLE to make it common and less unwritten.
--- CODING_STYLE | 3 +++ 1 file changed, 3 insertions(+)
CODING_STYLE +3 -0
@@ -126,6 +126,9 @@ register). Especially with pointer types, whenever the pointed to object is not (supposed to be) modified, qualify the pointed to type with "const". +When defining types, split its words using underscores (e.g: prefer my_foo to +myfoo). + Comments --------
Signature · 1 line
2.43.0
Re: [PATCH v3 03/14] CODING_STYLE: Custom type names must be snake-cased by word.
Quoted 2 lines · Alejandro Vallejo
There's the unwritten convention in x86 of splitting type names using underscores. Add such convention to the
CODINNG_STYLEto make it
^ CODING_STYLE
Quoted 12 lines
common and less unwritten.
Signed-off-by Alejandro Vallejo <[email protected]>--- CODING_STYLE | 3 +++ 1 file changed, 3 insertions(+)CODING_STYLE +0
-0
CODING_STYLE register). · line 130
Quoted 5 lines
CODING_STYLE +2
-0@@ -126,6 +126,9 @@ register). Especially with pointer types, whenever the pointed to object is not (supposed to be) modified, qualify the pointed to type with "const". +When defining types, split its words using underscores (e.g: prefer my_foo to +myfoo).
Minor NIT:
When defining types, separate words using underscores (for example, use "my_foo" instead of "myfoo").
Quoted 6 lines
CODING_STYLE +0
-0Comments --------Signature · 1 line
2.43.0
Re: [PATCH v3 03/14] CODING_STYLE: Custom type names must be snake-cased by word.
Quoted 20 lines · Stefano Stabellini
Quoted 2 lines · Alejandro Vallejo
There's the unwritten convention in x86 of splitting type names using underscores. Add such convention to the
CODINNG_STYLEto make it^
CODING_STYLEQuoted 15 lines
common and less unwritten.
Signed-off-by Alejandro Vallejo <[email protected]>--- CODING_STYLE | 3 +++ 1 file changed, 3 insertions(+)CODING_STYLE +0
-0@@ -126,6 +126,9 @@ register). Especially with pointer types, whenever the pointed to object is not (supposed to be) modified, qualify the pointed to type with "const".
Quoted 6 lines
CODING_STYLE register). · line 130
Quoted 2 lines
CODING_STYLE +2
-0+When defining types, split its words using underscores (e.g: prefer my_foo to +myfoo).Minor NIT:
When defining types, separate words using underscores (for example, use "my_foo" instead of "myfoo").
Fine by me. That's clearer.
Quoted 3 lines
Reviewed-by Stefano Stabellini <[email protected]>
Thanks!
Quoted 8 lines
Quoted 8 lines
CODING_STYLE +0
-0Comments --------Signature · 1 line
2.43.0
Cheers,
Alejandro
Re: [PATCH v3 03/14] CODING_STYLE: Custom type names must be snake-cased by word.
In reply to Alejandro VallejoQuoted 14 lines · Alejandro Vallejo
There's the unwritten convention in x86 of splitting type names using underscores. Add such convention to the
CODINNG_STYLEto make it common and less unwritten.Signed-off-by Alejandro Vallejo <[email protected]>--- CODING_STYLE | 3 +++ 1 file changed, 3 insertions(+)CODING_STYLE +0
-0
CODING_STYLE register). · line 130
Quoted 5 lines
CODING_STYLE +2
-0@@ -126,6 +126,9 @@ register). Especially with pointer types, whenever the pointed to object is not (supposed to be) modified, qualify the pointed to type with "const". +When defining types, split its words using underscores (e.g: prefer my_foo to +myfoo).
Why's this being put in the Types section? This is about identifiers, and ought to not be limited to the names of types.
Jan
Re: [PATCH v3 03/14] CODING_STYLE: Custom type names must be snake-cased by word.
Quoted 18 lines · Jan Beulich
Quoted 17 lines · Alejandro Vallejo
There's the unwritten convention in x86 of splitting type names using underscores. Add such convention to the
CODINNG_STYLEto make it common and less unwritten.Signed-off-by Alejandro Vallejo <[email protected]>--- CODING_STYLE | 3 +++ 1 file changed, 3 insertions(+)CODING_STYLE +0
-0@@ -126,6 +126,9 @@ register). Especially with pointer types, whenever the pointed to object is not (supposed to be) modified, qualify the pointed to type with "const".
Quoted 7 lines
CODING_STYLE register). · line 130
Quoted 2 lines
CODING_STYLE +2
-0+When defining types, split its words using underscores (e.g: prefer my_foo to +myfoo).Why's this being put in the Types section? This is about identifiers, and ought to not be limited to the names of types.
Jan
Because the existing argument had to do with type names and I wanted to limit the blast radius of the new rules on architectures that don't currently follow them. I don't care where it sits or how large its scope is. If others are equally happy to generalise to any identifier, I'm happy to do so.
Cheers,
Alejandro
PATCH v3 4/14 xen: Rename bootmodule{,s} to boot_module{,s}
In reply to Alejandro Vallejo... in alignment with the new coding style on word splitting for type names.
This aligns its name with the largely duplicate boot_module struct in x86. While there's no equivalent to "struct bootmodules" in x86, changing one and not the other is just confusing. Same with various comments and function names.
Rather than making a long subfield name even longer, remove the _bootmodule suffix in the kernel, initrd and dtb subfields.
Not a functional change.
--- xen/arch/arm/domain_build.c | 4 +- xen/arch/arm/efi/efi-boot.h | 6 +-- xen/arch/arm/kernel.c | 4 +- xen/arch/arm/llc-coloring.c | 8 ++-- xen/arch/arm/mmu/setup.c | 10 ++--- xen/arch/arm/setup.c | 10 ++--- xen/common/device-tree/bootfdt.c | 4 +- xen/common/device-tree/bootinfo.c | 52 ++++++++++++------------- xen/common/device-tree/dom0less-build.c | 25 ++++++------ xen/common/device-tree/domain-build.c | 2 +- xen/common/device-tree/kernel.c | 22 +++++------ xen/include/xen/bootfdt.h | 26 ++++++------- xen/include/xen/fdt-kernel.h | 7 ++-- xen/xsm/xsm_policy.c | 2 +- 14 files changed, 90 insertions(+), 92 deletions(-)
xen/arch/arm/domain_build.c +2 -2
@@ -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 bootmodule *initrd = kinfo->initrd_bootmodule; +const struct boot_module *initrd = kinfo->initrd;if ( bootargs ) {
@@ -1447,7 +1447,7 @@ int __init make_chosen_node(const struct kernel_info *kinfo) {int res;const char *bootargs =NULL ; -const struct bootmodule *initrd = kinfo->initrd_bootmodule; +const struct boot_module *initrd = kinfo->initrd;void *fdt = kinfo->fdt;dt_dprintk ("Create chosen node\n" );
xen/arch/arm/efi/efi-boot.h +3 -3
@@ -20,7 +20,7 @@ typedef struct { } module_info;/* -* Binaries will be translated into bootmodules, the maximum number for them is +* Binaries will be translated into boot_modules, the maximum number for them is * MAX_MODULES where we should remove a unit for Xen and one for Xen DTB */ #define MAX_UEFI_MODULES (MAX_MODULES - 2)
@@ -602,9 +602,9 @@ static void __init efi_arch_handle_module(const struct file *file,/* * modules_available is decremented here because for each dom0 file added -* from the configuration file, there will be an additional bootmodule, +* from the configuration file, there will be an additional boot_module, * so the number of available slots will be decremented because there is a -* maximum amount of bootmodules that can be loaded. +* maximum amount of boot_modules that can be loaded. */ modules_available--; }
xen/arch/arm/kernel.c +2 -2
@@ -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 bootmodule *mod = info->initrd_bootmodule; +const struct boot_module *mod = info->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 ));
@@ -175,7 +175,7 @@ static void __init kernel_zimage_load(struct kernel_info *info)* Check if the image is a uImage and setup kernel_info */ int __init kernel_uimage_probe (struct kernel_info *info, -struct bootmodule *mod) +struct boot_module *mod) {struct {__be32 magic;/* Image Header Magic Number */
xen/arch/arm/llc-coloring.c +4 -4
@@ -123,12 +123,12 @@ static paddr_t __init xen_colored_map_size(void)void __init arch_llc_coloring_init (void ) { -struct bootmodule *xen_bootmodule =boot_module_find_by_kind (BOOTMOD_XEN ); +struct boot_module *xen_boot_module =boot_module_find_by_kind (BOOTMOD_XEN ); -BUG_ON (!xen_bootmodule); +BUG_ON (!xen_boot_module); - xen_bootmodule->size =xen_colored_map_size (); - xen_bootmodule->start =get_xen_paddr (xen_bootmodule->size); + xen_boot_module->size =xen_colored_map_size (); + xen_boot_module->start =get_xen_paddr (xen_boot_module->size); }/*
xen/arch/arm/mmu/setup.c +5 -5
@@ -246,7 +246,7 @@ paddr_t __init consider_modules(paddr_t s, paddr_t e,#ifdef CONFIG_STATIC_SHM const struct membanks *shmem =bootinfo_get_shmem ();#endif -const struct bootmodules *mi = &bootinfo.modules; +const struct boot_modules *mi = &bootinfo.modules;int i;int nr;
@@ -273,8 +273,8 @@ paddr_t __init consider_modules(paddr_t s, paddr_t e, }/* -* i is the current bootmodule we are evaluating, across all -* possible kinds of bootmodules. +* i is the current boot_module we are evaluating, across all +* possible kinds of boot_modules. * * When retrieving the corresponding reserved-memory addresses, we * need to index the reserved_mem bank starting from 0, and only counting
@@ -328,8 +328,8 @@ static void __init create_llc_coloring_mappings(void) {lpae_t pte;unsigned int i; -struct bootmodule *xen_bootmodule =boot_module_find_by_kind (BOOTMOD_XEN ); -mfn_t start_mfn =maddr_to_mfn (xen_bootmodule->start), mfn; +struct boot_module *xen_boot_module =boot_module_find_by_kind (BOOTMOD_XEN ); +mfn_t start_mfn =maddr_to_mfn (xen_boot_module->start), mfn; for_each_xen_colored_mfn ( start_mfn, mfn, i ) {
xen/arch/arm/setup.c +5 -5
@@ -206,11 +206,11 @@ static void __init processor_id(void)void __init discard_initial_modules (void ) { -struct bootmodules *mi = &bootinfo.modules; +struct boot_modules *mi = &bootinfo.modules;int i;/* -* When using static heap feature, don't give bootmodules memory back to +* When using static heap feature, don't give boot_modules memory back to * the heap allocator */ if ( using_static_heap )
@@ -303,7 +303,7 @@ void asmlinkage __init start_xen(unsigned long fdt_paddr) {size_t fdt_size;const char *cmdline; -struct bootmodule *xen_bootmodule; +struct boot_module *xen_boot_module;struct domain *d;int rc, i;
@@ -327,10 +327,10 @@ void asmlinkage __init start_xen(unsigned long fdt_paddr) fdt_paddr);/* Register Xen's load address as a boot module. */ - xen_bootmodule =add_boot_module (BOOTMOD_XEN , + xen_boot_module =add_boot_module (BOOTMOD_XEN ,virt_to_maddr (_start), (paddr_t)(uintptr_t)(_end - _start), false); -BUG_ON (!xen_bootmodule); +BUG_ON (!xen_boot_module); fdt_size =boot_fdt_info (device_tree_flattened, fdt_paddr);
xen/common/device-tree/bootfdt.c +2 -2
@@ -314,7 +314,7 @@ static void __init process_multiboot_node(const void *fdt, int node,static int __initdata kind_guess =0 ;const struct fdt_property *prop;const __be32 *cell; -bootmodule_kind kind; +boot_module_kind kind;paddr_t start, size;int len;/* sizeof("/chosen/") + DT_MAX_NAME + '/' + DT_MAX_NAME + '/0' => 92 */
@@ -518,7 +518,7 @@ static void __init early_print_info(void) {const struct membanks *mi =bootinfo_get_mem ();const struct membanks *mem_resv =bootinfo_get_reserved_mem (); -struct bootmodules *mods = &bootinfo.modules; +struct boot_modules *mods = &bootinfo.modules;struct bootcmdlines *cmds = &bootinfo.cmdlines;unsigned int i;
xen/common/device-tree/bootinfo.c +26 -26
120 lines not on this page · raw message
xen/common/device-tree/dom0less-build.c +12 -13
@@ -44,13 +44,13 @@ void __init set_xs_domain(struct domain *d)bool __init is_dom0less_mode (void ) { -struct bootmodules *mods = &bootinfo.modules; -struct bootmodule *mod; +struct boot_modules *mods = &bootinfo.modules; +struct boot_module *mod;unsigned int i;bool dom0found = false;bool domUfound = false; -/* Look into the bootmodules */ +/* Look into the boot_modules */ for ( i =0 ; i < mods->nr_mods ; i++ ) { mod = &mods->module[i];
@@ -374,18 +374,17 @@ static int __init check_partial_fdt(void *pfdt, size_t size)return 0 ; } -static int __init domain_handle_dtb_bootmodule (struct domain *d, -struct kernel_info *kinfo) +static int __init domain_handle_dtb_boot_module (struct domain *d, +struct kernel_info *kinfo) {void *pfdt;int res, node_next; - pfdt =ioremap_cache (kinfo->dtb_bootmodule->start, - kinfo->dtb_bootmodule->size); + pfdt =ioremap_cache (kinfo->dtb->start, kinfo->dtb->size);if ( pfdt ==NULL )return -EFAULT ; - res =check_partial_fdt (pfdt, kinfo->dtb_bootmodule->size); + res =check_partial_fdt (pfdt, kinfo->dtb->size);if ( res <0 ) goto out;
@@ -459,8 +458,8 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo) sizecells =GUEST_ROOT_SIZE_CELLS ;/* Account for domU passthrough DT size */ -if ( kinfo->dtb_bootmodule ) - fdt_size += kinfo->dtb_bootmodule->size; +if ( kinfo->dtb ) + fdt_size += kinfo->dtb->size;/* Cap to max DT size if needed */ fdt_size =min (fdt_size,SZ_2M );
@@ -507,13 +506,13 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo) goto err;/* -* domain_handle_dtb_bootmodule has to be called before the rest of +* domain_handle_dtb_boot_module has to be called before the rest of * the device tree is generated because it depends on the value of * the field phandle_intc. */ -if ( kinfo->dtb_bootmodule ) +if ( kinfo->dtb ) { - ret =domain_handle_dtb_bootmodule (d, kinfo); + ret =domain_handle_dtb_boot_module (d, kinfo);if ( ret ) goto err; }
xen/common/device-tree/domain-build.c +1 -1
@@ -347,7 +347,7 @@ void __init dtb_load(struct kernel_info *kinfo,void __init initrd_load (struct kernel_info *kinfo,copy_to_guest_phys_cb copy_to_guest) { -const struct bootmodule *mod = kinfo->initrd_bootmodule; +const struct boot_module *mod = kinfo->initrd;paddr_t load_addr = kinfo->initrd_paddr;paddr_t paddr, len;int node;
xen/common/device-tree/kernel.c +11 -11
@@ -21,7 +21,7 @@ static uint32_t __init output_length(char *image, unsigned long image_len)return *(uint32_t *)&image[image_len -4 ]; } -int __init kernel_decompress (struct bootmodule *mod,uint32_t offset) +int __init kernel_decompress (struct boot_module *mod,uint32_t offset) {char *output, *input;char magic[2 ];
@@ -92,7 +92,7 @@ int __init kernel_decompress(struct bootmodule *mod, uint32_t offset)free_domheap_page (pages + i);/* -* When using static heap feature, don't give bootmodules memory back to +* When using static heap feature, don't give boot_modules memory back to * the heap allocator */ if ( using_static_heap )
@@ -118,7 +118,7 @@ int __init kernel_decompress(struct bootmodule *mod, uint32_t offset)int __init kernel_probe (struct kernel_info *info,const struct dt_device_node *domain) { -struct bootmodule *mod =NULL ; +struct boot_module *mod =NULL ;struct bootcmdline *cmd =NULL ;struct dt_device_node *node;u64 kernel_addr, initrd_addr, dtb_addr, size;
@@ -140,8 +140,8 @@ int __init kernel_probe(struct kernel_info *info, mod =boot_module_find_by_kind (BOOTMOD_KERNEL ); - info->kernel_bootmodule = mod; - info->initrd_bootmodule =boot_module_find_by_kind (BOOTMOD_RAMDISK ); + info->kernel = mod; + info->initrd =boot_module_find_by_kind (BOOTMOD_RAMDISK ); cmd =boot_cmdline_find_by_kind (BOOTMOD_KERNEL );if ( cmd )
@@ -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_bootmodule = mod; + info->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_bootmodule =boot_module_find_by_addr_and_kind ( + info->initrd =boot_module_find_by_addr_and_kind (BOOTMOD_RAMDISK , initrd_addr); }else if (dt_device_is_compatible (node,"multiboot,device-tree" ) )
@@ -183,7 +183,7 @@ int __init kernel_probe(struct kernel_info *info,if ( val ==NULL )continue ;dt_get_range (&val, node, &dtb_addr, &size); - info->dtb_bootmodule =boot_module_find_by_addr_and_kind ( + info->dtb =boot_module_find_by_addr_and_kind (BOOTMOD_GUEST_DTB , dtb_addr); }else
@@ -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_bootmodule->start); -if ( info->initrd_bootmodule ) + info->d, info->kernel->start); +if ( info->initrd )printk ("Loading ramdisk from boot module @ %" PRIpaddr"\n" , - info->initrd_bootmodule->start); + info->initrd->start);/* * uImage isn't really used nowadays thereby leave kernel_uimage_probe()
xen/include/xen/bootfdt.h +13 -13
@@ -23,7 +23,7 @@ typedef enum {BOOTMOD_GUEST_DTB ,BOOTMOD_MICROCODE , BOOTMOD_UNKNOWN -} bootmodule_kind; +} boot_module_kind;enum membank_type {/*
@@ -103,8 +103,8 @@ struct shared_meminfo {* initrd to be compatible with all versions of the multiboot spec. */ #define BOOTMOD_MAX_CMDLINE 1024 -struct bootmodule { -bootmodule_kind kind; +struct boot_module { +boot_module_kind kind;bool domU;paddr_t start;paddr_t size;
@@ -113,16 +113,16 @@ struct bootmodule {/* DT_MAX_NAME is the node name max length according the DT spec */ #define DT_MAX_NAME 41struct bootcmdline { -bootmodule_kind kind; +boot_module_kind kind;bool domU;paddr_t start;char dt_name[DT_MAX_NAME ];char cmdline[BOOTMOD_MAX_CMDLINE ]; }; -struct bootmodules { +struct boot_modules {int nr_mods; -struct bootmodule module[MAX_MODULES ]; +struct boot_module module[MAX_MODULES ]; };struct bootcmdlines {
@@ -134,7 +134,7 @@ struct bootinfo {struct meminfo mem;/* The reserved regions are only used when booting using Device-Tree */ struct meminfo reserved_mem; -struct bootmodules modules; +struct boot_modules modules;struct bootcmdlines cmdlines;#ifdef CONFIG_ACPI struct meminfo acpi;
@@ -176,16 +176,16 @@ bool check_reserved_regions_overlap(paddr_t region_start,paddr_t region_size, bool allow_memreserve_overlap); -struct bootmodule *add_boot_module (bootmodule_kind kind, +struct boot_module *add_boot_module (boot_module_kind kind,paddr_t start,paddr_t size,bool domU); -struct bootmodule *boot_module_find_by_kind (bootmodule_kind kind); -struct bootmodule *boot_module_find_by_addr_and_kind (bootmodule_kind kind, +struct boot_module *boot_module_find_by_kind (boot_module_kind kind); +struct boot_module *boot_module_find_by_addr_and_kind (boot_module_kind kind,paddr_t start);void add_boot_cmdline (const char *name,const char *cmdline, -bootmodule_kind kind,paddr_t start,bool domU); -struct bootcmdline *boot_cmdline_find_by_kind (bootmodule_kind kind); +boot_module_kind kind,paddr_t start,bool domU); +struct bootcmdline *boot_cmdline_find_by_kind (boot_module_kind kind);struct bootcmdline *boot_cmdline_find_by_name (const char *name); -const char *boot_module_kind_as_string (bootmodule_kind kind); +const char *boot_module_kind_as_string (boot_module_kind kind);void populate_boot_allocator (void );
xen/include/xen/fdt-kernel.h +3 -4
@@ -34,7 +34,7 @@ struct kernel_info {paddr_t gnttab_size;/* boot blob load addresses */ -const struct bootmodule *kernel_bootmodule, *initrd_bootmodule, *dtb_bootmodule; +const struct boot_module *kernel, *initrd, *dtb;const char * cmdline;paddr_t dtb_paddr;paddr_t initrd_paddr;
@@ -121,7 +121,7 @@ int kernel_probe(struct kernel_info *info, const struct dt_device_node *domain);*/ void kernel_load (struct kernel_info *info); -int kernel_decompress (struct bootmodule *mod,uint32_t offset); +int kernel_decompress (struct boot_module *mod,uint32_t offset);int kernel_zimage_probe (struct kernel_info *info,paddr_t addr,paddr_t size);
@@ -130,8 +130,7 @@ int kernel_zimage_probe(struct kernel_info *info, paddr_t addr, paddr_t size);* call here just for compatability with Arm code. */ #ifdef CONFIG_ARM -struct bootmodule ; -int kernel_uimage_probe (struct kernel_info *info,struct bootmodule *mod); +int kernel_uimage_probe (struct kernel_info *info,struct boot_module *mod);#endif #endif /* __XEN_FDT_KERNEL_H__ */
xen/xsm/xsm_policy.c +1 -1
@@ -68,7 +68,7 @@ int __init xsm_multiboot_policy_init(#ifdef CONFIG_HAS_DEVICE_TREE int __init xsm_dt_policy_init (void **policy_buffer,size_t *policy_size) { -struct bootmodule *mod =boot_module_find_by_kind (BOOTMOD_XSM ); +struct boot_module *mod =boot_module_find_by_kind (BOOTMOD_XSM );paddr_t paddr, len;if ( !mod || !mod->size )
Signature · 1 line
2.43.0
Re: [PATCH v3 04/14] xen: Rename bootmodule{,s} to boot_module{,s}
Quoted 618 lines · Alejandro Vallejo
... in alignment with the new coding style on word splitting for type names.
This aligns its name with the largely duplicate
boot_modulestruct in x86. While there's no equivalent to "struct bootmodules" in x86, changing one and not the other is just confusing. Same with various comments and function names.Rather than making a long subfield name even longer, remove the
_bootmodulesuffix in the kernel, initrd and dtb subfields.Not a functional change.
Signed-off-by Alejandro Vallejo <[email protected]>--- xen/arch/arm/domain_build.c | 4 +- xen/arch/arm/efi/efi-boot.h | 6 +-- xen/arch/arm/kernel.c | 4 +- xen/arch/arm/llc-coloring.c | 8 ++-- xen/arch/arm/mmu/setup.c | 10 ++--- xen/arch/arm/setup.c | 10 ++--- xen/common/device-tree/bootfdt.c | 4 +- xen/common/device-tree/bootinfo.c | 52 ++++++++++++------------- xen/common/device-tree/dom0less-build.c | 25 ++++++------ xen/common/device-tree/domain-build.c | 2 +- xen/common/device-tree/kernel.c | 22 +++++------ xen/include/xen/bootfdt.h | 26 ++++++------- xen/include/xen/fdt-kernel.h | 7 ++-- xen/xsm/xsm_policy.c | 2 +- 14 files changed, 90 insertions(+), 92 deletions(-)xen/arch/arm/domain_build.c +2
-2@@ -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 bootmodule *initrd = kinfo->initrd_bootmodule; +const struct boot_module *initrd = kinfo->initrd;if ( bootargs ) {@@ -1447,7 +1447,7 @@ int __init make_chosen_node(const struct kernel_info *kinfo) {int res;const char *bootargs =NULL ; -const struct bootmodule *initrd = kinfo->initrd_bootmodule; +const struct boot_module *initrd = kinfo->initrd;void *fdt = kinfo->fdt;dt_dprintk ("Create chosen node\n" );xen/arch/arm/efi/efi-boot.h +3
-3@@ -20,7 +20,7 @@ typedef struct { } module_info;/* -* Binaries will be translated into bootmodules, the maximum number for them is +* Binaries will be translated into boot_modules, the maximum number for them is * MAX_MODULES where we should remove a unit for Xen and one for Xen DTB */ #define MAX_UEFI_MODULES (MAX_MODULES - 2)@@ -602,9 +602,9 @@ static void __init efi_arch_handle_module(const struct file *file,/* * modules_available is decremented here because for each dom0 file added -* from the configuration file, there will be an additional bootmodule, +* from the configuration file, there will be an additional boot_module, * so the number of available slots will be decremented because there is a -* maximum amount of bootmodules that can be loaded. +* maximum amount of boot_modules that can be loaded. */ modules_available--; }xen/arch/arm/kernel.c +2
-2@@ -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 bootmodule *mod = info->initrd_bootmodule; +const struct boot_module *mod = info->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 ));@@ -175,7 +175,7 @@ static void __init kernel_zimage_load(struct kernel_info *info)* Check if the image is a uImage and setup kernel_info */ int __init kernel_uimage_probe (struct kernel_info *info, -struct bootmodule *mod) +struct boot_module *mod) {struct {__be32 magic;/* Image Header Magic Number */ xen/arch/arm/llc-coloring.c +4
-4@@ -123,12 +123,12 @@ static paddr_t __init xen_colored_map_size(void)void __init arch_llc_coloring_init (void ) { -struct bootmodule *xen_bootmodule =boot_module_find_by_kind (BOOTMOD_XEN ); +struct boot_module *xen_boot_module =boot_module_find_by_kind (BOOTMOD_XEN ); -BUG_ON (!xen_bootmodule); +BUG_ON (!xen_boot_module); - xen_bootmodule->size =xen_colored_map_size (); - xen_bootmodule->start =get_xen_paddr (xen_bootmodule->size); + xen_boot_module->size =xen_colored_map_size (); + xen_boot_module->start =get_xen_paddr (xen_boot_module->size); }/* xen/arch/arm/mmu/setup.c +5
-5@@ -246,7 +246,7 @@ paddr_t __init consider_modules(paddr_t s, paddr_t e,#ifdef CONFIG_STATIC_SHM const struct membanks *shmem =bootinfo_get_shmem ();#endif -const struct bootmodules *mi = &bootinfo.modules; +const struct boot_modules *mi = &bootinfo.modules;int i;int nr;@@ -273,8 +273,8 @@ paddr_t __init consider_modules(paddr_t s, paddr_t e, }/* -* i is the current bootmodule we are evaluating, across all -* possible kinds of bootmodules. +* i is the current boot_module we are evaluating, across all +* possible kinds of boot_modules. * * When retrieving the corresponding reserved-memory addresses, we * need to index the reserved_mem bank starting from 0, and only counting @@ -328,8 +328,8 @@ static void __init create_llc_coloring_mappings(void) {lpae_t pte;unsigned int i; -struct bootmodule *xen_bootmodule =boot_module_find_by_kind (BOOTMOD_XEN ); -mfn_t start_mfn =maddr_to_mfn (xen_bootmodule->start), mfn; +struct boot_module *xen_boot_module =boot_module_find_by_kind (BOOTMOD_XEN ); +mfn_t start_mfn =maddr_to_mfn (xen_boot_module->start), mfn; for_each_xen_colored_mfn ( start_mfn, mfn, i ) {xen/arch/arm/setup.c +5
-5@@ -206,11 +206,11 @@ static void __init processor_id(void)void __init discard_initial_modules (void ) { -struct bootmodules *mi = &bootinfo.modules; +struct boot_modules *mi = &bootinfo.modules;int i;/* -* When using static heap feature, don't give bootmodules memory back to +* When using static heap feature, don't give boot_modules memory back to * the heap allocator */ if ( using_static_heap )@@ -303,7 +303,7 @@ void asmlinkage __init start_xen(unsigned long fdt_paddr) {size_t fdt_size;const char *cmdline; -struct bootmodule *xen_bootmodule; +struct boot_module *xen_boot_module;struct domain *d;int rc, i;@@ -327,10 +327,10 @@ void asmlinkage __init start_xen(unsigned long fdt_paddr) fdt_paddr);/* Register Xen's load address as a boot module. */ - xen_bootmodule =add_boot_module (BOOTMOD_XEN , + xen_boot_module =add_boot_module (BOOTMOD_XEN ,virt_to_maddr (_start), (paddr_t)(uintptr_t)(_end - _start), false); -BUG_ON (!xen_bootmodule); +BUG_ON (!xen_boot_module); fdt_size =boot_fdt_info (device_tree_flattened, fdt_paddr);xen/common/device-tree/bootfdt.c +2
-2@@ -314,7 +314,7 @@ static void __init process_multiboot_node(const void *fdt, int node,static int __initdata kind_guess =0 ;const struct fdt_property *prop;const __be32 *cell; -bootmodule_kind kind; +boot_module_kind kind;paddr_t start, size;int len;/* sizeof("/chosen/") + DT_MAX_NAME + '/' + DT_MAX_NAME + '/0' => 92 */ @@ -518,7 +518,7 @@ static void __init early_print_info(void) {const struct membanks *mi =bootinfo_get_mem ();const struct membanks *mem_resv =bootinfo_get_reserved_mem (); -struct bootmodules *mods = &bootinfo.modules; +struct boot_modules *mods = &bootinfo.modules;struct bootcmdlines *cmds = &bootinfo.cmdlines;unsigned int i;xen/common/device-tree/bootinfo.c +26
-26@@ -21,7 +21,7 @@struct bootinfo __initdata bootinfo =BOOTINFO_INIT ; -const char *__init boot_module_kind_as_string (bootmodule_kind kind) +const char *__init boot_module_kind_as_string (boot_module_kind kind) {switch ( kind ) {@@ -49,7 +49,7 @@ static void __init dt_unreserved_regions(paddr_t s, paddr_t e,unsigned int i;/* -* i is the current bootmodule we are evaluating across all possible +* i is the current boot_module we are evaluating across all possible * kinds. */ for ( i = first; i < reserved_mem->nr_banks; i++ )@@ -143,18 +143,18 @@ static bool __init meminfo_overlap_check(const struct membanks *mem,* TODO: '*_end' could be 0 if the module/region is at the end of the physical * address space. This is for now not handled as it requires more rework. */ -static bool __init bootmodules_overlap_check (struct bootmodules *bootmodules, -paddr_t region_start, -paddr_t region_size) +static bool __init boot_modules_overlap_check (struct boot_modules *boot_modules, +paddr_t region_start, +paddr_t region_size) {paddr_t mod_start =INVALID_PADDR , mod_end =0 ;paddr_t region_end = region_start + region_size; -unsigned int i, mod_num = bootmodules->nr_mods; +unsigned int i, mod_num = boot_modules->nr_mods;for ( i =0 ; i < mod_num; i++ ) { - mod_start = bootmodules->module[i].start; - mod_end = mod_start + bootmodules->module[i].size; + mod_start = boot_modules->module[i].start; + mod_end = mod_start + boot_modules->module[i].size;if ( region_end <= mod_start || region_start >= mod_end )continue ;@@ -210,20 +210,20 @@ bool __init check_reserved_regions_overlap(paddr_t region_start, allow_memreserve_overlap) )return true; -/* Check if input region is overlapping with bootmodules */ -if (bootmodules_overlap_check (&bootinfo.modules, - region_start, region_size) ) +/* Check if input region is overlapping with boot_modules */ +if (boot_modules_overlap_check (&bootinfo.modules, + region_start, region_size) )return true;return false; } -struct bootmodule __init *add_boot_module (bootmodule_kind kind, -paddr_t start,paddr_t size, -bool domU) +struct boot_module __init *add_boot_module (boot_module_kind kind, +paddr_t start,paddr_t size, +bool domU) { -struct bootmodules *mods = &bootinfo.modules; -struct bootmodule *mod; +struct boot_modules *mods = &bootinfo.modules; +struct boot_module *mod;unsigned int i;if ( mods->nr_mods ==MAX_MODULES )@@ -266,10 +266,10 @@ struct bootmodule __init *add_boot_module(bootmodule_kind kind,* XSM, DTB) or Dom0 modules. This is not suitable for looking up guest * modules. */ -struct bootmodule *__init boot_module_find_by_kind (bootmodule_kind kind) +struct boot_module *__init boot_module_find_by_kind (boot_module_kind kind) { -struct bootmodules *mods = &bootinfo.modules; -struct bootmodule *mod; +struct boot_modules *mods = &bootinfo.modules; +struct boot_module *mod;int i;for (i =0 ; i < mods->nr_mods ; i++ ) {@@ -281,7 +281,7 @@ struct bootmodule * __init boot_module_find_by_kind(bootmodule_kind kind) }void __init add_boot_cmdline (const char *name,const char *cmdline, -bootmodule_kind kind,paddr_t start,bool domU) +boot_module_kind kind,paddr_t start,bool domU) {struct bootcmdlines *cmds = &bootinfo.cmdlines;struct bootcmdline *cmd;@@ -310,7 +310,7 @@ void __init add_boot_cmdline(const char *name, const char *cmdline,* XSM, DTB) or Dom0 modules. This is not suitable for looking up guest * modules. */ -struct bootcmdline *__init boot_cmdline_find_by_kind (bootmodule_kind kind) +struct bootcmdline *__init boot_cmdline_find_by_kind (boot_module_kind kind) {struct bootcmdlines *cmds = &bootinfo.cmdlines;struct bootcmdline *cmd;@@ -340,11 +340,11 @@ struct bootcmdline * __init boot_cmdline_find_by_name(const char *name)return NULL ; } -struct bootmodule *__init boot_module_find_by_addr_and_kind (bootmodule_kind kind, -paddr_t start) +struct boot_module *__init boot_module_find_by_addr_and_kind ( +boot_module_kind kind,paddr_t start) { -struct bootmodules *mods = &bootinfo.modules; -struct bootmodule *mod; +struct boot_modules *mods = &bootinfo.modules; +struct boot_module *mod;unsigned int i;for (i =0 ; i < mods->nr_mods ; i++ )@@ -366,7 +366,7 @@ struct bootmodule * __init boot_module_find_by_addr_and_kind(bootmodule_kind kin*/ static paddr_t __init next_module (paddr_t s,paddr_t *end) { -struct bootmodules *mi = &bootinfo.modules; +struct boot_modules *mi = &bootinfo.modules;paddr_t lowest = ~(paddr_t )0 ;int i;xen/common/device-tree/dom0less-build.c +12
-13@@ -44,13 +44,13 @@ void __init set_xs_domain(struct domain *d)bool __init is_dom0less_mode (void ) { -struct bootmodules *mods = &bootinfo.modules; -struct bootmodule *mod; +struct boot_modules *mods = &bootinfo.modules; +struct boot_module *mod;unsigned int i;bool dom0found = false;bool domUfound = false; -/* Look into the bootmodules */ +/* Look into the boot_modules */ for ( i =0 ; i < mods->nr_mods ; i++ ) { mod = &mods->module[i];@@ -374,18 +374,17 @@ static int __init check_partial_fdt(void *pfdt, size_t size)return 0 ; } -static int __init domain_handle_dtb_bootmodule (struct domain *d, -struct kernel_info *kinfo) +static int __init domain_handle_dtb_boot_module (struct domain *d, +struct kernel_info *kinfo) {void *pfdt;int res, node_next; - pfdt =ioremap_cache (kinfo->dtb_bootmodule->start, - kinfo->dtb_bootmodule->size); + pfdt =ioremap_cache (kinfo->dtb->start, kinfo->dtb->size);if ( pfdt ==NULL )return -EFAULT ; - res =check_partial_fdt (pfdt, kinfo->dtb_bootmodule->size); + res =check_partial_fdt (pfdt, kinfo->dtb->size);if ( res <0 ) goto out;@@ -459,8 +458,8 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo) sizecells =GUEST_ROOT_SIZE_CELLS ;/* Account for domU passthrough DT size */ -if ( kinfo->dtb_bootmodule ) - fdt_size += kinfo->dtb_bootmodule->size; +if ( kinfo->dtb ) + fdt_size += kinfo->dtb->size;/* Cap to max DT size if needed */ fdt_size =min (fdt_size,SZ_2M );@@ -507,13 +506,13 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo) goto err;/* -* domain_handle_dtb_bootmodule has to be called before the rest of +* domain_handle_dtb_boot_module has to be called before the rest of * the device tree is generated because it depends on the value of * the field phandle_intc. */ -if ( kinfo->dtb_bootmodule ) +if ( kinfo->dtb ) { - ret =domain_handle_dtb_bootmodule (d, kinfo); + ret =domain_handle_dtb_boot_module (d, kinfo);if ( ret ) goto err; }xen/common/device-tree/domain-build.c +1
-1@@ -347,7 +347,7 @@ void __init dtb_load(struct kernel_info *kinfo,void __init initrd_load (struct kernel_info *kinfo,copy_to_guest_phys_cb copy_to_guest) { -const struct bootmodule *mod = kinfo->initrd_bootmodule; +const struct boot_module *mod = kinfo->initrd;paddr_t load_addr = kinfo->initrd_paddr;paddr_t paddr, len;int node;xen/common/device-tree/kernel.c +11
-11@@ -21,7 +21,7 @@ static uint32_t __init output_length(char *image, unsigned long image_len)return *(uint32_t *)&image[image_len -4 ]; } -int __init kernel_decompress (struct bootmodule *mod,uint32_t offset) +int __init kernel_decompress (struct boot_module *mod,uint32_t offset) {char *output, *input;char magic[2 ];@@ -92,7 +92,7 @@ int __init kernel_decompress(struct bootmodule *mod, uint32_t offset)free_domheap_page (pages + i);/* -* When using static heap feature, don't give bootmodules memory back to +* When using static heap feature, don't give boot_modules memory back to * the heap allocator */ if ( using_static_heap )@@ -118,7 +118,7 @@ int __init kernel_decompress(struct bootmodule *mod, uint32_t offset)int __init kernel_probe (struct kernel_info *info,const struct dt_device_node *domain) { -struct bootmodule *mod =NULL ; +struct boot_module *mod =NULL ;struct bootcmdline *cmd =NULL ;struct dt_device_node *node;u64 kernel_addr, initrd_addr, dtb_addr, size;@@ -140,8 +140,8 @@ int __init kernel_probe(struct kernel_info *info, mod =boot_module_find_by_kind (BOOTMOD_KERNEL ); - info->kernel_bootmodule = mod; - info->initrd_bootmodule =boot_module_find_by_kind (BOOTMOD_RAMDISK ); + info->kernel = mod; + info->initrd =boot_module_find_by_kind (BOOTMOD_RAMDISK ); cmd =boot_cmdline_find_by_kind (BOOTMOD_KERNEL );if ( cmd )@@ -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_bootmodule = mod; + info->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_bootmodule =boot_module_find_by_addr_and_kind ( + info->initrd =boot_module_find_by_addr_and_kind (BOOTMOD_RAMDISK , initrd_addr); }else if (dt_device_is_compatible (node,"multiboot,device-tree" ) )@@ -183,7 +183,7 @@ int __init kernel_probe(struct kernel_info *info,if ( val ==NULL )continue ;dt_get_range (&val, node, &dtb_addr, &size); - info->dtb_bootmodule =boot_module_find_by_addr_and_kind ( + info->dtb =boot_module_find_by_addr_and_kind (BOOTMOD_GUEST_DTB , dtb_addr); }else @@ -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_bootmodule->start); -if ( info->initrd_bootmodule ) + info->d, info->kernel->start); +if ( info->initrd )printk ("Loading ramdisk from boot module @ %" PRIpaddr"\n" , - info->initrd_bootmodule->start); + info->initrd->start);/* * uImage isn't really used nowadays thereby leave kernel_uimage_probe() xen/include/xen/bootfdt.h +13
-13@@ -23,7 +23,7 @@ typedef enum {BOOTMOD_GUEST_DTB ,BOOTMOD_MICROCODE , BOOTMOD_UNKNOWN -} bootmodule_kind; +} boot_module_kind;enum membank_type {/* @@ -103,8 +103,8 @@ struct shared_meminfo {* initrd to be compatible with all versions of the multiboot spec. */ #define BOOTMOD_MAX_CMDLINE 1024 -struct bootmodule { -bootmodule_kind kind; +struct boot_module { +boot_module_kind kind;bool domU;paddr_t start;paddr_t size;@@ -113,16 +113,16 @@ struct bootmodule {/* DT_MAX_NAME is the node name max length according the DT spec */ #define DT_MAX_NAME 41struct bootcmdline { -bootmodule_kind kind; +boot_module_kind kind;bool domU;paddr_t start;char dt_name[DT_MAX_NAME ];char cmdline[BOOTMOD_MAX_CMDLINE ]; }; -struct bootmodules { +struct boot_modules {int nr_mods; -struct bootmodule module[MAX_MODULES ]; +struct boot_module module[MAX_MODULES ]; };struct bootcmdlines {@@ -134,7 +134,7 @@ struct bootinfo {struct meminfo mem;/* The reserved regions are only used when booting using Device-Tree */ struct meminfo reserved_mem; -struct bootmodules modules; +struct boot_modules modules;struct bootcmdlines cmdlines;#ifdef CONFIG_ACPI struct meminfo acpi;@@ -176,16 +176,16 @@ bool check_reserved_regions_overlap(paddr_t region_start,paddr_t region_size, bool allow_memreserve_overlap); -struct bootmodule *add_boot_module (bootmodule_kind kind, +struct boot_module *add_boot_module (boot_module_kind kind,paddr_t start,paddr_t size,bool domU); -struct bootmodule *boot_module_find_by_kind (bootmodule_kind kind); -struct bootmodule *boot_module_find_by_addr_and_kind (bootmodule_kind kind, +struct boot_module *boot_module_find_by_kind (boot_module_kind kind); +struct boot_module *boot_module_find_by_addr_and_kind (boot_module_kind kind,paddr_t start);void add_boot_cmdline (const char *name,const char *cmdline, -bootmodule_kind kind,paddr_t start,bool domU); -struct bootcmdline *boot_cmdline_find_by_kind (bootmodule_kind kind); +boot_module_kind kind,paddr_t start,bool domU); +struct bootcmdline *boot_cmdline_find_by_kind (boot_module_kind kind);struct bootcmdline *boot_cmdline_find_by_name (const char *name); -const char *boot_module_kind_as_string (bootmodule_kind kind); +const char *boot_module_kind_as_string (boot_module_kind kind);void populate_boot_allocator (void );xen/include/xen/fdt-kernel.h +2
-2@@ -34,7 +34,7 @@ struct kernel_info {paddr_t gnttab_size;/* boot blob load addresses */ -const struct bootmodule *kernel_bootmodule, *initrd_bootmodule, *dtb_bootmodule; +const struct boot_module *kernel, *initrd, *dtb;const char * cmdline;paddr_t dtb_paddr;paddr_t initrd_paddr;@@ -121,7 +121,7 @@ int kernel_probe(struct kernel_info *info, const struct dt_device_node *domain);*/ void kernel_load (struct kernel_info *info); -int kernel_decompress (struct bootmodule *mod,uint32_t offset); +int kernel_decompress (struct boot_module *mod,uint32_t offset);int kernel_zimage_probe (struct kernel_info *info,paddr_t addr,paddr_t size);
xen/include/xen/fdt-kernel.h int kernel_zimage_probe(struct kernel_info *info, paddr_t addr, paddr_t size); · line 133
Quoted 4 lines
xen/include/xen/fdt-kernel.h +0
-1@@ -130,8 +130,7 @@ int kernel_zimage_probe(struct kernel_info *info, paddr_t addr, paddr_t size);* call here just for compatability with Arm code. */ #ifdef CONFIG_ARM -struct bootmodule ;
I just wanted to mention that I went line by line and this is the only not search-and-replace change in this patch.
Quoted 21 lines
xen/include/xen/fdt-kernel.h +1
-1-int kernel_uimage_probe (struct kernel_info *info,struct bootmodule *mod); +int kernel_uimage_probe (struct kernel_info *info,struct boot_module *mod);#endif #endif /* __XEN_FDT_KERNEL_H__ */ xen/xsm/xsm_policy.c +1
-1@@ -68,7 +68,7 @@ int __init xsm_multiboot_policy_init(#ifdef CONFIG_HAS_DEVICE_TREE int __init xsm_dt_policy_init (void **policy_buffer,size_t *policy_size) { -struct bootmodule *mod =boot_module_find_by_kind (BOOTMOD_XSM ); +struct boot_module *mod =boot_module_find_by_kind (BOOTMOD_XSM );paddr_t paddr, len;if ( !mod || !mod->size )Signature · 1 line
2.43.0
Re: [PATCH v3 04/14] xen: Rename bootmodule{,s} to boot_module{,s}
In reply to Alejandro VallejoV/r,
Daniel P. Smith
Apertus Solutions, LLC
Quoted 14 lines · Alejandro Vallejo
... in alignment with the new coding style on word splitting for type names.
This aligns its name with the largely duplicate
boot_modulestruct in x86. While there's no equivalent to "struct bootmodules" in x86, changing one and not the other is just confusing. Same with various comments and function names.Rather than making a long subfield name even longer, remove the
_bootmodulesuffix in the kernel, initrd and dtb subfields.Not a functional change.
Signed-off-by Alejandro Vallejo <[email protected]>
Quoted 17 lines
--- xen/arch/arm/domain_build.c | 4 +- xen/arch/arm/efi/efi-boot.h | 6 +-- xen/arch/arm/kernel.c | 4 +- xen/arch/arm/llc-coloring.c | 8 ++-- xen/arch/arm/mmu/setup.c | 10 ++--- xen/arch/arm/setup.c | 10 ++--- xen/common/device-tree/bootfdt.c | 4 +- xen/common/device-tree/bootinfo.c | 52 ++++++++++++------------- xen/common/device-tree/dom0less-build.c | 25 ++++++------ xen/common/device-tree/domain-build.c | 2 +- xen/common/device-tree/kernel.c | 22 +++++------ xen/include/xen/bootfdt.h | 26 ++++++------- xen/include/xen/fdt-kernel.h | 7 ++-- xen/xsm/xsm_policy.c | 2 +- 14 files changed, 90 insertions(+), 92 deletions(-)
<snip/>
xen/xsm/xsm_policy.c int __init xsm_multiboot_policy_init( · line 74
Quoted 13 lines
xen/xsm/xsm_policy.c +1
-1@@ -68,7 +68,7 @@ int __init xsm_multiboot_policy_init(#ifdef CONFIG_HAS_DEVICE_TREE int __init xsm_dt_policy_init (void **policy_buffer,size_t *policy_size) { -struct bootmodule *mod =boot_module_find_by_kind (BOOTMOD_XSM ); +struct boot_module *mod =boot_module_find_by_kind (BOOTMOD_XSM );paddr_t paddr, len;if ( !mod || !mod->size )
PATCH v3 5/14 x86: Replace arch-specific boot_module with common one
In reply to Alejandro VallejoThese 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 | 8 ++--- xen/arch/x86/include/asm/bootfdt.h | 50 ++++++++++++++++++++++++++ xen/arch/x86/include/asm/bootinfo.h | 56 +++-------------------------- xen/arch/x86/pv/dom0_build.c | 6 ++-- xen/arch/x86/setup.c | 42 +++++++++++----------- xen/include/xen/bootfdt.h | 8 +++++ xen/xsm/xsm_policy.c | 2 +- 8 files changed, 95 insertions(+), 84 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 +4 -4
@@ -648,9 +648,9 @@ 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->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 +3 -3
@@ -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;
@@ -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 -20
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 v3 05/14] x86: Replace arch-specific boot_module with common one
Quoted 9 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]>
Hi Alejandro, this patch doesn't apply to staging anymore, it conflict with 3998da124.
Quoted 46 lines
--- xen/arch/x86/cpu/microcode/core.c | 7 ++-- xen/arch/x86/hvm/dom0_build.c | 8 ++--- xen/arch/x86/include/asm/bootfdt.h | 50 ++++++++++++++++++++++++++ xen/arch/x86/include/asm/bootinfo.h | 56 +++-------------------------- xen/arch/x86/pv/dom0_build.c | 6 ++-- xen/arch/x86/setup.c | 42 +++++++++++----------- xen/include/xen/bootfdt.h | 8 +++++ xen/xsm/xsm_policy.c | 2 +- 8 files changed, 95 insertions(+), 84 deletions(-) create mode 100644 xen/arch/x86/include/asm/bootfdt.hxen/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 +0
-0
xen/arch/x86/hvm/dom0_build.c static int __init pvh_load_kernel( · line 651
Quoted 5 lines
xen/arch/x86/hvm/dom0_build.c +1
-1@@ -648,9 +648,9 @@ 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;
It looks like struct boot_domain is still calling its member "module" at this point
Quoted 387 lines
xen/arch/x86/hvm/dom0_build.c +3
-3void *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@@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef X86_BOOTFDT_H +#define X86_BOOTFDT_H + +#include <xen/types.h> + +struct arch_boot_module +{ +/* +* Module State Flags: +* relocated: indicates module has been relocated in memory. +* released: indicates module's pages have been freed. +*/ +bool relocated:1 ; +bool released:1 ; + +/* +* A boot module may need decompressing by Xen. Headroom is an estimate of +* the additional space required to decompress the module. +* +* Headroom is accounted for at the start of the module. Decompressing is +* done in-place with input=start, output=start-headroom, expecting the +* pointers to become equal (give or take some rounding) when decompression +* is complete. +* +* Memory layout at boot: +* +* start ----+ +* v +* |<-----headroom------>|<------size------->| +* +-------------------+ +* | Compressed Module | +* +---------------------+-------------------+ +* | Decompressed Module | +* +-----------------------------------------+ +*/ +unsigned long headroom; +paddr_t cmdline_pa; +}; + +#endif /* X86_BOOTFDT_H */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/ xen/arch/x86/include/asm/bootinfo.h +4
-52@@ -8,6 +8,7 @@#ifndef X86_BOOTINFO_H #define X86_BOOTINFO_H +#include <xen/bootfdt.h> #include <xen/init.h> #include <xen/multiboot.h> #include <xen/types.h> @@ -19,55 +20,6 @@/* Max number of boot domains that Xen can construct */ #define MAX_NR_BOOTDOMS 1 -/* Boot module binary type / purpose */ -enum bootmod_type { -BOOTMOD_UNKNOWN , -BOOTMOD_XEN , -BOOTMOD_KERNEL , -BOOTMOD_RAMDISK , -BOOTMOD_MICROCODE , -BOOTMOD_XSM_POLICY , -}; - -struct boot_module { -enum bootmod_type type; - -/* -* Module State Flags: -* relocated: indicates module has been relocated in memory. -* released: indicates module's pages have been freed. -*/ -bool relocated:1 ; -bool released:1 ; - -/* -* A boot module may need decompressing by Xen. Headroom is an estimate of -* the additional space required to decompress the module. -* -* Headroom is accounted for at the start of the module. Decompressing is -* done in-place with input=start, output=start-headroom, expecting the -* pointers to become equal (give or take some rounding) when decompression -* is complete. -* -* Memory layout at boot: -* -* start ----+ -* v -* |<-----headroom------>|<------size------->| -* +-------------------+ -* | Compressed Module | -* +---------------------+-------------------+ -* | Decompressed Module | -* +-----------------------------------------+ -*/ -unsigned long headroom; - -paddr_t cmdline_pa; - -paddr_t start; -size_t size; -}; -/* * Xen internal representation of information provided by the * bootloader/environment, or derived from the information. @@ -94,16 +46,16 @@ struct boot_info {* Failure - a value greater than MAX_NR_BOOTMODS */ static inline unsigned int __init next_boot_module_index ( -const struct boot_info *bi,enum bootmod_type t,unsigned int start) +const struct boot_info *bi,boot_module_kind k,unsigned int start) {unsigned int i; -if ( t ==BOOTMOD_XEN ) +if ( k ==BOOTMOD_XEN )return bi->nr_modules;for ( i = start; i < bi->nr_modules; i++ ) { -if ( bi->mods[i].type == t ) +if ( bi->mods[i].kind == k )return i; }xen/arch/x86/pv/dom0_build.c +3
-3@@ -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;@@ -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
-20@@ -303,7 +303,7 @@ struct boot_info __initdata xen_boot_info = {* * The extra entry exists to be able to add the Xen image as a module. */ - .mods = { [0 ... MAX_NR_BOOTMODS] = { .type = BOOTMOD_UNKNOWN } }, + .mods = { [0 ... MAX_NR_BOOTMODS] = { .kind = BOOTMOD_UNKNOWN } }, }; static struct boot_info *__init multiboot_fill_boot_info(@@ -338,7 +338,7 @@ static struct boot_info *__init multiboot_fill_boot_info(*/ for ( i =0 ; i <MAX_NR_BOOTMODS && i < bi->nr_modules; i++ ) { - bi->mods[i].cmdline_pa = mods[i].string; + bi->mods[i].arch.cmdline_pa = mods[i].string;if (efi_enabled (EFI_LOADER ) ) {@@ -361,7 +361,7 @@ static struct boot_info *__init multiboot_fill_boot_info( }/* Variable 'i' should be one entry past the last module. */ - bi->mods[i].type =BOOTMOD_XEN ; + bi->mods[i].kind =BOOTMOD_XEN ;return bi; }@@ -388,11 +388,11 @@ unsigned long __init initial_images_nrpages(nodeid_t node)void __init release_boot_module (struct boot_module *bm) { -ASSERT (!bm->released); +ASSERT (!bm->arch.released);init_domheap_pages (bm->start, bm->start +PAGE_ALIGN (bm->size)); - bm->released = true; + bm->arch.released = true; }void __init free_boot_modules (void )@@ -402,7 +402,7 @@ void __init free_boot_modules(void)for ( i =0 ; i < bi->nr_modules; ++i ) { -if ( bi->mods[i].released ) +if ( bi->mods[i].arch.released )continue ;release_boot_module (&bi->mods[i]);@@ -990,8 +990,9 @@ static size_t __init domain_cmdline_size(const struct boot_info *bi, const struct boot_domain *bd) {size_t s = bi->kextra ?strlen (bi->kextra) :0 ; +const struct arch_boot_module *abm = &bd->kernel->arch; - s += bd->kernel->cmdline_pa ?strlen (__va (bd->kernel->cmdline_pa)) :0 ; + s += abm->cmdline_pa ?strlen (__va (abm->cmdline_pa)) :0 ;if ( s ==0 )return s;@@ -1055,9 +1056,10 @@ static struct domain *__init create_dom0(struct boot_info *bi)if ( !(cmdline =xzalloc_array (char, cmdline_size)) )panic ("Error allocating cmdline buffer for %pd\n" , d); -if ( bd->kernel->cmdline_pa ) +if ( bd->kernel->arch.cmdline_pa )strlcpy (cmdline, -cmdline_cook (__va (bd->kernel->cmdline_pa), bi->loader), +cmdline_cook (__va (bd->kernel->arch.cmdline_pa), + bi->loader), cmdline_size);if ( bi->kextra )@@ -1079,7 +1081,7 @@ static struct domain *__init create_dom0(struct boot_info *bi)strlcat (cmdline," acpi=" , cmdline_size);strlcat (cmdline, acpi_param, cmdline_size); } - bd->kernel->cmdline_pa =0 ; + bd->kernel->arch.cmdline_pa =0 ; bd->cmdline = cmdline; }@@ -1292,7 +1294,7 @@ void asmlinkage __init noreturn __start_xen(void) }/* Dom0 kernel is always first */ - bi->mods[0 ].type =BOOTMOD_KERNEL ; + bi->mods[0 ].kind =BOOTMOD_KERNEL ; bi->domains[0 ].kernel = &bi->mods[0 ];if ( pvh_boot )@@ -1476,7 +1478,7 @@ void asmlinkage __init noreturn __start_xen(void) xen->size = __2M_rwdata_end - _stext; } - bi->mods[0 ].headroom = + bi->mods[0 ].arch.headroom =bzimage_headroom (bootstrap_map_bm (&bi->mods[0 ]), bi->mods[0 ].size);bootstrap_unmap ();@@ -1558,9 +1560,9 @@ void asmlinkage __init noreturn __start_xen(void)for ( j = bi->nr_modules -1 ; j >=0 ; j-- ) {struct boot_module *bm = &bi->mods[j]; -unsigned long size =PAGE_ALIGN (bm->headroom + bm->size); +unsigned long size =PAGE_ALIGN (bm->arch.headroom + bm->size); -if ( bm->relocated ) +if ( bm->arch.relocated )continue ;/* Don't overlap with other modules (or Xen itself). */ @@ -1570,12 +1572,12 @@ void asmlinkage __init noreturn __start_xen(void)if ( highmem_start && end > highmem_start )continue ; -if ( s < end && (bm->headroom || (end - size) > bm->start) ) +if ( s < end && (bm->arch.headroom || (end - size) > bm->start) ) { -move_memory (end - size + bm->headroom, bm->start, bm->size); +move_memory (end - size + bm->arch.headroom, bm->start, bm->size); bm->start = (end - size); - bm->size += bm->headroom; - bm->relocated = true; + bm->size += bm->arch.headroom; + bm->arch.relocated = true; } }@@ -1601,7 +1603,7 @@ void asmlinkage __init noreturn __start_xen(void)#endif } -if ( bi->mods[0 ].headroom && !bi->mods[0 ].relocated ) +if ( bi->mods[0 ].arch.headroom && !bi->mods[0 ].arch.relocated )panic ("Not enough memory to relocate the dom0 kernel image\n" );for ( i =0 ; i < bi->nr_modules; ++i ) {@@ -2159,7 +2161,7 @@ void asmlinkage __init noreturn __start_xen(void) initrdidx =first_boot_module_index (bi,BOOTMOD_UNKNOWN );if ( initrdidx <MAX_NR_BOOTMODS ) { - bi->mods[initrdidx].type =BOOTMOD_RAMDISK ; + bi->mods[initrdidx].kind =BOOTMOD_RAMDISK ; bi->domains[0 ].module = &bi->mods[initrdidx];if (first_boot_module_index (bi,BOOTMOD_UNKNOWN ) <MAX_NR_BOOTMODS ) printk(XENLOG_WARNINGxen/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 v3 05/14] x86: Replace arch-specific boot_module with common one
Quoted 7 lines · Stefano Stabellini
Quoted 6 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.
Quoted 6 lines
Quoted 3 lines
No functional change intended.
Signed-off-by Alejandro Vallejo <[email protected]>Hi Alejandro, this patch doesn't apply to staging anymore, it conflict with
3998da124.
Ugh, I'll rebase it and re-send after the existing discussions are sorted.
Cheers,
Alejandro
Re: [PATCH v3 05/14] x86: Replace arch-specific boot_module with common one
In reply to Stefano StabelliniQuoted 14 lines · Stefano Stabellini
xen/arch/x86/hvm/dom0_build.c static int __init pvh_load_kernel( · line 651
Quoted 10 lines · Alejandro Vallejo
xen/arch/x86/hvm/dom0_build.c +1
-1@@ -648,9 +648,9 @@ 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;It looks like struct
boot_domainis still calling its member "module" at this point
Bah, yes. Way too many lines in the diff.
What's _really_ fun is that the pipeline passed. Including the job to build each commit.
https://gitlab.com/xen-project/people/agvallejo/xen/-/pipelines/1868636712
I'll have to look into what the hell happened.
Cheers,
Alejandro
PATCH v3 6/14 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.
---
v3:
* s/bootdomain/boot_domain/
--- 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 ) {
@@ -1386,7 +1386,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" );
@@ -1398,7 +1398,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] =
@@ -1447,7 +1447,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" );
@@ -1455,9 +1455,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;
@@ -1906,7 +1906,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 )
@@ -1918,7 +1918,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 )
@@ -331,23 +331,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;
@@ -363,7 +363,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" );
@@ -386,12 +386,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 v3 06/14] xen: Refactor kernel_info to have a header like boot_domain
Quoted 7 lines · Alejandro Vallejo
Create a struct header within
kernel_infowith the contents common tokernel_infoandboot_domain, and define that header in common code. This enables x86 to use that header as-is and drop x86'sboot_domain.Not a functional change.
Signed-off-by Alejandro Vallejo <[email protected]>
Re: [PATCH v3 06/14] xen: Refactor kernel_info to have a header like boot_domain
In reply to Alejandro VallejoQuoted 3 lines · Alejandro Vallejo
Create a struct header within
kernel_infowith the contents common tokernel_infoandboot_domain, and define that header in common code. This enables x86 to use that header as-is and drop x86'sboot_domain
IMHO kernel_info is an extremely poor name for this structure and hyperlauch attempt to resolve some of these less than optimal choices is being undone.
v/r,
dps
Re: [PATCH v3 06/14] xen: Refactor kernel_info to have a header like boot_domain
Quoted 6 lines · Daniel P. Smith
Quoted 3 lines · Alejandro Vallejo
Create a struct header within
kernel_infowith the contents common tokernel_infoandboot_domain, and define that header in common code. This enables x86 to use that header as-is and drop x86'sboot_domain
Quoted 6 lines
IMHO
kernel_infois an extremely poor name for this structure and hyperlauch attempt to resolve some of these less than optimal choices is being undone.v/r,
dps
kernel_info is a big misnomer, which is why I originally typedeff'd it to bootdomain_t. Note however that at no point (in v3) does kernel_info reach x86. The header is effectively what was already in boot_domain, except it's common code now so the domid field (not yet included in dom0less) goes on an "arch" subfield. And x86 only uses that header and doesn't know or care about the rest.
Cheers,
Alejandro
PATCH v3 7/14 x86: Replace arch-specific boot_domain common one bootdomain
In reply to Alejandro VallejoAdd the single arch-specific field in an "arch" subfield defined in asm/bootfdt.h.
No functional change intended.
---
v3:
* Avoid the bootdomain/boot_domain renames.
--- 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/setup.c | 12 ++++++---- xen/include/xen/bootfdt.h | 4 ++++ 5 files changed, 17 insertions(+), 39 deletions(-) delete mode 100644 xen/arch/x86/include/asm/boot-domain.h
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/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. *
@@ -1039,11 +1041,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);
@@ -2162,7 +2164,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 v3 07/14] x86: Replace arch-specific boot_domain common one bootdomain
Quoted 63 lines · Alejandro Vallejo
Add the single arch-specific field in an "arch" subfield defined in
asm/bootfdt.h.No functional change intended.
Signed-off-by Alejandro Vallejo <[email protected]>---
v3:
* Avoid the bootdomain/boot_domain renames.--- 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/setup.c | 12 ++++++---- xen/include/xen/bootfdt.h | 4 ++++ 5 files changed, 17 insertions(+), 39 deletions(-) delete mode 100644 xen/arch/x86/include/asm/boot-domain.hxen/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 +0
-0
xen/arch/x86/include/asm/bootfdt.h line 11
Quoted 9 lines
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; +};
With the understanding from your previous reply that it is best not to use d->domain_id:
Quoted 2 lines
xen/arch/x86/include/asm/bootfdt.h +0
-0struct arch_boot_module {
PATCH v3 8/14 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.
---
v3:
* Avoid mutations during code motion
--- xen/include/xen/bootfdt.h | 62 +++++++++++++++++++++++++++++++++++ xen/include/xen/device_tree.h | 40 +--------------------- 2 files changed, 63 insertions(+), 39 deletions(-)
xen/include/xen/bootfdt.h +62 -0
@@ -2,6 +2,7 @@#ifndef XEN_BOOTFDT_H #define XEN_BOOTFDT_H +#include <xen/byteorder.h> #include <xen/types.h> #include <xen/kernel.h> #include <xen/macros.h>
@@ -16,8 +17,53 @@#define NR_MEM_BANKS 256#define NR_SHMEM_BANKS 32 +/* Default #address and #size cells */ +#define DT_ROOT_NODE_ADDR_CELLS_DEFAULT 2 +#define DT_ROOT_NODE_SIZE_CELLS_DEFAULT 1 +#define MAX_MODULES 32/* Current maximum useful modules */ +#define DEVICE_TREE_MAX_DEPTH 16 + +/* Helper to read a big number; size is in cells (not bytes) */ +static inline u64 dt_read_number (const __be32 *cell,int size) +{ +u64 r =0 ; + +while ( size-- ) + r = (r <<32 ) |be32_to_cpu (*(cell++)); +return r; +} + +static inline u64 dt_next_cell (int s,const __be32 **cellp) +{ +const __be32 *p = *cellp; + + *cellp = p + s; +return dt_read_number (p, s); +} + +typedef int (*device_tree_node_func )(const void *fdt, +int node,const char *name,int depth, +u32 address_cells,u32 size_cells, +void *data); + +/** +* device_tree_for_each_node - iterate over all device tree sub-nodes +* @fdt: flat device tree. +* @node: parent node to start the search from +* @func: function to call for each sub-node. +* @data: data to pass to @func. +* +* Any nodes nested at DEVICE_TREE_MAX_DEPTH or deeper are ignored. +* +* Returns 0 if all nodes were iterated over successfully. If @func +* returns a value different from 0, that value is returned immediately. +*/ +int device_tree_for_each_node (const void *fdt,int node, +device_tree_node_func func, +void *data); + typedef enum { BOOTMOD_XEN, BOOTMOD_FDT,
@@ -260,4 +306,20 @@ static inline struct membanks *membanks_xzalloc(unsigned int nr, return banks; } +/* +* Interpret the property `prop_name` of `node` as a u32. +* +* Returns the property value on success; otherwise returns `dflt`. +*/ +u32 device_tree_get_u32 (const void *fdt,int node, +const char *prop_name,u32 dflt); + +/* +* Interpret the property `prop_name` of `node` as a "reg". +* +* Returns outputs in `start` and `size`. +*/ +void device_tree_get_reg (const __be32 **cell,uint32_t address_cells, +uint32_t size_cells,paddr_t *start,paddr_t *size); +#endif /* XEN_BOOTFDT_H */
xen/include/xen/device_tree.h +1 -39
@@ -10,6 +10,7 @@#ifndef __XEN_DEVICE_TREE_H__#define __XEN_DEVICE_TREE_H__ +#include <xen/bootfdt.h> #include <xen/byteorder.h> #include <asm/device.h>
@@ -22,8 +23,6 @@#include <xen/list.h> #include <xen/rwlock.h> -#define DEVICE_TREE_MAX_DEPTH 16 -/* * Struct used for matching a device */
@@ -164,17 +163,8 @@ struct dt_raw_irq {u32 specifier[DT_MAX_IRQ_SPEC ]; }; -typedef int (*device_tree_node_func )(const void *fdt, -int node,const char *name,int depth, -u32 address_cells,u32 size_cells, -void *data); -extern const void *device_tree_flattened; -int device_tree_for_each_node (const void *fdt,int node, -device_tree_node_func func, -void *data); -/** * dt_unflatten_host_device_tree - Unflatten the host device tree *
@@ -245,10 +235,6 @@ void intc_dt_preinit(void);#define dt_node_cmp (s1, s2) strcasecmp((s1), (s2))#define dt_compat_cmp (s1, s2) strcasecmp((s1), (s2)) -/* Default #address and #size cells */ -#define DT_ROOT_NODE_ADDR_CELLS_DEFAULT 2 -#define DT_ROOT_NODE_SIZE_CELLS_DEFAULT 1 -#define dt_for_each_property_node (dn, pp) \ for ( pp = (dn)->properties; (pp) != NULL; pp = (pp)->next )
@@ -258,16 +244,6 @@ void intc_dt_preinit(void);#define dt_for_each_child_node (dt, dn) \ for ( dn = (dt)->child; (dn) != NULL; dn = (dn)->sibling ) -/* Helper to read a big number; size is in cells (not bytes) */ -static inline u64 dt_read_number (const __be32 *cell,int size) -{ -u64 r =0 ; - -while ( size-- ) - r = (r <<32 ) |be32_to_cpu (*(cell++)); -return r; -} -/* Wrapper for dt_read_number() to return paddr_t (instead of uint64_t) */ static inline paddr_t dt_read_paddr (const __be32 *cell,int size) {
@@ -307,14 +283,6 @@ static inline int dt_size_to_cells(int bytes)return (bytes /sizeof (u32)); } -static inline u64 dt_next_cell (int s,const __be32 **cellp) -{ -const __be32 *p = *cellp; - - *cellp = p + s; -return dt_read_number (p, s); -} -static inline const char *dt_node_full_name (const struct dt_device_node *np) {return (np && np->full_name) ? np->full_name :"<no-node>" ;
@@ -949,12 +917,6 @@ int dt_get_pci_domain_nr(struct dt_device_node *node);struct dt_device_node *dt_find_node_by_phandle (dt_phandle handle); -void device_tree_get_reg (const __be32 **cell,uint32_t address_cells, -uint32_t size_cells,paddr_t *start,paddr_t *size); - -u32 device_tree_get_u32 (const void *fdt,int node, -const char *prop_name,u32 dflt); -#ifdef CONFIG_DEVICE_TREE_DEBUG #define dt_dprintk(fmt, args...) \ printk(XENLOG_DEBUG fmt, ## args)
Signature · 1 line
2.43.0
Re: [PATCH v3 08/14] xen/dt: Move bootfdt functions to xen/bootfdt.h
Quoted 109 lines · Alejandro Vallejo
Part 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.hand arm'ssetup.hontobootfdt.hDeclaration motion only. Not a functional change.
Signed-off-by Alejandro Vallejo <[email protected]>---
v3:
* Avoid mutations during code motion--- xen/include/xen/bootfdt.h | 62 +++++++++++++++++++++++++++++++++++ xen/include/xen/device_tree.h | 40 +--------------------- 2 files changed, 63 insertions(+), 39 deletions(-)xen/include/xen/bootfdt.h +62
-0@@ -2,6 +2,7 @@#ifndef XEN_BOOTFDT_H #define XEN_BOOTFDT_H +#include <xen/byteorder.h> #include <xen/types.h> #include <xen/kernel.h> #include <xen/macros.h> @@ -16,8 +17,53 @@#define NR_MEM_BANKS 256#define NR_SHMEM_BANKS 32 +/* Default #address and #size cells */ +#define DT_ROOT_NODE_ADDR_CELLS_DEFAULT 2 +#define DT_ROOT_NODE_SIZE_CELLS_DEFAULT 1 +#define MAX_MODULES 32/* Current maximum useful modules */ +#define DEVICE_TREE_MAX_DEPTH 16 + +/* Helper to read a big number; size is in cells (not bytes) */ +static inline u64 dt_read_number (const __be32 *cell,int size) +{ +u64 r =0 ; + +while ( size-- ) + r = (r <<32 ) |be32_to_cpu (*(cell++)); +return r; +} + +static inline u64 dt_next_cell (int s,const __be32 **cellp) +{ +const __be32 *p = *cellp; + + *cellp = p + s; +return dt_read_number (p, s); +} + +typedef int (*device_tree_node_func )(const void *fdt, +int node,const char *name,int depth, +u32 address_cells,u32 size_cells, +void *data); + +/** +* device_tree_for_each_node - iterate over all device tree sub-nodes +* @fdt: flat device tree. +* @node: parent node to start the search from +* @func: function to call for each sub-node. +* @data: data to pass to @func. +* +* Any nodes nested at DEVICE_TREE_MAX_DEPTH or deeper are ignored. +* +* Returns 0 if all nodes were iterated over successfully. If @func +* returns a value different from 0, that value is returned immediately. +*/ +int device_tree_for_each_node (const void *fdt,int node, +device_tree_node_func func, +void *data); + typedef enum { BOOTMOD_XEN, BOOTMOD_FDT,@@ -260,4 +306,20 @@ static inline struct membanks *membanks_xzalloc(unsigned int nr, return banks; } +/* +* Interpret the property `prop_name` of `node` as a u32. +* +* Returns the property value on success; otherwise returns `dflt`. +*/ +u32 device_tree_get_u32 (const void *fdt,int node, +const char *prop_name,u32 dflt); + +/* +* Interpret the property `prop_name` of `node` as a "reg". +* +* Returns outputs in `start` and `size`. +*/ +void device_tree_get_reg (const __be32 **cell,uint32_t address_cells, +uint32_t size_cells,paddr_t *start,paddr_t *size); +#endif /* XEN_BOOTFDT_H */ xen/include/xen/device_tree.h +0
-0
xen/include/xen/device_tree.h line 14
Quoted 5 lines
xen/include/xen/device_tree.h +1
-0@@ -10,6 +10,7 @@#ifndef __XEN_DEVICE_TREE_H__#define __XEN_DEVICE_TREE_H__ +#include <xen/bootfdt.h> #include <xen/byteorder.h>
This should not be needed?
Quoted 87 lines
xen/include/xen/device_tree.h +0
-39#include <asm/device.h> @@ -22,8 +23,6 @@#include <xen/list.h> #include <xen/rwlock.h> -#define DEVICE_TREE_MAX_DEPTH 16 -/* * Struct used for matching a device */ @@ -164,17 +163,8 @@ struct dt_raw_irq {u32 specifier[DT_MAX_IRQ_SPEC ]; }; -typedef int (*device_tree_node_func )(const void *fdt, -int node,const char *name,int depth, -u32 address_cells,u32 size_cells, -void *data); -extern const void *device_tree_flattened; -int device_tree_for_each_node (const void *fdt,int node, -device_tree_node_func func, -void *data); -/** * dt_unflatten_host_device_tree - Unflatten the host device tree * @@ -245,10 +235,6 @@ void intc_dt_preinit(void);#define dt_node_cmp (s1, s2) strcasecmp((s1), (s2))#define dt_compat_cmp (s1, s2) strcasecmp((s1), (s2)) -/* Default #address and #size cells */ -#define DT_ROOT_NODE_ADDR_CELLS_DEFAULT 2 -#define DT_ROOT_NODE_SIZE_CELLS_DEFAULT 1 -#define dt_for_each_property_node (dn, pp) \ for ( pp = (dn)->properties; (pp) != NULL; pp = (pp)->next )@@ -258,16 +244,6 @@ void intc_dt_preinit(void);#define dt_for_each_child_node (dt, dn) \ for ( dn = (dt)->child; (dn) != NULL; dn = (dn)->sibling ) -/* Helper to read a big number; size is in cells (not bytes) */ -static inline u64 dt_read_number (const __be32 *cell,int size) -{ -u64 r =0 ; - -while ( size-- ) - r = (r <<32 ) |be32_to_cpu (*(cell++)); -return r; -} -/* Wrapper for dt_read_number() to return paddr_t (instead of uint64_t) */ static inline paddr_t dt_read_paddr (const __be32 *cell,int size) {@@ -307,14 +283,6 @@ static inline int dt_size_to_cells(int bytes)return (bytes /sizeof (u32)); } -static inline u64 dt_next_cell (int s,const __be32 **cellp) -{ -const __be32 *p = *cellp; - - *cellp = p + s; -return dt_read_number (p, s); -} -static inline const char *dt_node_full_name (const struct dt_device_node *np) {return (np && np->full_name) ? np->full_name :"<no-node>" ;@@ -949,12 +917,6 @@ int dt_get_pci_domain_nr(struct dt_device_node *node);struct dt_device_node *dt_find_node_by_phandle (dt_phandle handle); -void device_tree_get_reg (const __be32 **cell,uint32_t address_cells, -uint32_t size_cells,paddr_t *start,paddr_t *size); - -u32 device_tree_get_u32 (const void *fdt,int node, -const char *prop_name,u32 dflt); -#ifdef CONFIG_DEVICE_TREE_DEBUG #define dt_dprintk(fmt, args...) \ printk(XENLOG_DEBUG fmt, ## args)Signature · 1 line
2.43.0
Re: [PATCH v3 08/14] xen/dt: Move bootfdt functions to xen/bootfdt.h
Quoted 113 lines · Stefano Stabellini
Quoted 112 lines · Alejandro Vallejo
Part 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.hand arm'ssetup.hontobootfdt.hDeclaration motion only. Not a functional change.
Signed-off-by Alejandro Vallejo <[email protected]>---
v3:
* Avoid mutations during code motion--- xen/include/xen/bootfdt.h | 62 +++++++++++++++++++++++++++++++++++ xen/include/xen/device_tree.h | 40 +--------------------- 2 files changed, 63 insertions(+), 39 deletions(-)xen/include/xen/bootfdt.h +62
-0@@ -2,6 +2,7 @@#ifndef XEN_BOOTFDT_H #define XEN_BOOTFDT_H +#include <xen/byteorder.h> #include <xen/types.h> #include <xen/kernel.h> #include <xen/macros.h> @@ -16,8 +17,53 @@#define NR_MEM_BANKS 256#define NR_SHMEM_BANKS 32 +/* Default #address and #size cells */ +#define DT_ROOT_NODE_ADDR_CELLS_DEFAULT 2 +#define DT_ROOT_NODE_SIZE_CELLS_DEFAULT 1 +#define MAX_MODULES 32/* Current maximum useful modules */ +#define DEVICE_TREE_MAX_DEPTH 16 + +/* Helper to read a big number; size is in cells (not bytes) */ +static inline u64 dt_read_number (const __be32 *cell,int size) +{ +u64 r =0 ; + +while ( size-- ) + r = (r <<32 ) |be32_to_cpu (*(cell++)); +return r; +} + +static inline u64 dt_next_cell (int s,const __be32 **cellp) +{ +const __be32 *p = *cellp; + + *cellp = p + s; +return dt_read_number (p, s); +} + +typedef int (*device_tree_node_func )(const void *fdt, +int node,const char *name,int depth, +u32 address_cells,u32 size_cells, +void *data); + +/** +* device_tree_for_each_node - iterate over all device tree sub-nodes +* @fdt: flat device tree. +* @node: parent node to start the search from +* @func: function to call for each sub-node. +* @data: data to pass to @func. +* +* Any nodes nested at DEVICE_TREE_MAX_DEPTH or deeper are ignored. +* +* Returns 0 if all nodes were iterated over successfully. If @func +* returns a value different from 0, that value is returned immediately. +*/ +int device_tree_for_each_node (const void *fdt,int node, +device_tree_node_func func, +void *data); + typedef enum { BOOTMOD_XEN, BOOTMOD_FDT,@@ -260,4 +306,20 @@ static inline struct membanks *membanks_xzalloc(unsigned int nr, return banks; } +/* +* Interpret the property `prop_name` of `node` as a u32. +* +* Returns the property value on success; otherwise returns `dflt`. +*/ +u32 device_tree_get_u32 (const void *fdt,int node, +const char *prop_name,u32 dflt); + +/* +* Interpret the property `prop_name` of `node` as a "reg". +* +* Returns outputs in `start` and `size`. +*/ +void device_tree_get_reg (const __be32 **cell,uint32_t address_cells, +uint32_t size_cells,paddr_t *start,paddr_t *size); +#endif /* XEN_BOOTFDT_H */ xen/include/xen/device_tree.h +0
-0@@ -10,6 +10,7 @@#ifndef __XEN_DEVICE_TREE_H__#define __XEN_DEVICE_TREE_H__
Quoted 4 lines
xen/include/xen/device_tree.h line 14
Quoted 2 lines
xen/include/xen/device_tree.h +1
-0+#include <xen/bootfdt.h> #include <xen/byteorder.h> This should not be needed?
I wanted to avoid having to touch include sites. Let me check how many affected places there are and fix up accordingly if any needs adjusting.
Cheers,
Alejandro
Re: [PATCH v3 08/14] xen/dt: Move bootfdt functions to xen/bootfdt.h
In reply to Stefano StabelliniHi,
Quoted 9 lines · Stefano Stabellini
Quoted 8 lines · Alejandro Vallejo
xen/include/xen/device_tree.h +0
-0@@ -10,6 +10,7 @@#ifndef __XEN_DEVICE_TREE_H__#define __XEN_DEVICE_TREE_H__
Quoted 4 lines
xen/include/xen/device_tree.h line 14
Quoted 2 lines
xen/include/xen/device_tree.h +1
-0+#include <xen/bootfdt.h> #include <xen/byteorder.h> This should not be needed?
dt_read_number() is still needed in dt_read_paddr() in device_tree.h
I can move that helper too (makes sense, as it's strictly a wrapper) and add includes in whatever .c files require it (tentatively it looks like only static-evtchn.c. Then that include can be dropped.
Cheers,
Alejandro
Re: [PATCH v3 08/14] xen/dt: Move bootfdt functions to xen/bootfdt.h
Quoted 17 lines · Alejandro Vallejo
Hi,
Quoted 9 lines · Stefano Stabellini
Quoted 8 lines · Alejandro Vallejo
xen/include/xen/device_tree.h +0
-0@@ -10,6 +10,7 @@#ifndef __XEN_DEVICE_TREE_H__#define __XEN_DEVICE_TREE_H__Quoted 4 lines
xen/include/xen/device_tree.h line 14
Quoted 2 lines
xen/include/xen/device_tree.h +1
-0+#include <xen/bootfdt.h> #include <xen/byteorder.h> This should not be needed?
Quoted 5 lines
dt_read_number()is still needed indt_read_paddr()indevice_tree.hI can move that helper too (makes sense, as it's strictly a wrapper) and add includes in whatever .c files require it (tentatively it looks like only
static-evtchn.c. Then that include can be dropped.
Procede as you think is best. I thought it was unneeded by code inspection, then I tried to remove it and Xen compiled okay. So I wrote that comment. If it is needed it is also OK to keep it.
PATCH v3 9/14 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.
---
v3:
* Remove spurious include for bootinfo.h in mmu/mm.c
--- xen/arch/arm/domain_build.c | 1 + 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/device_tree.h | 2 +- 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/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/init.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
236 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/device_tree.h +1 -1
@@ -10,7 +10,7 @@#ifndef __XEN_DEVICE_TREE_H__#define __XEN_DEVICE_TREE_H__ -#include <xen/bootfdt.h> +#include <xen/bootinfo.h> #include <xen/byteorder.h> #include <asm/device.h>
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
Re: [PATCH v3 09/14] xen/dt: Move bootinfo functions to a new bootinfo.h
Quoted 9 lines · Alejandro Vallejo
Part of an unpicking process to extract bootfdt contents independent of bootinfo to a separate file for x86 to take.
With this,
bootfdt.hcan be cleanly included from x86. A later patch extracts the definitions so the functions may be called too.Not a functional change.
Signed-off-by Alejandro Vallejo <[email protected]>
PATCH v3 10/14 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 v3 11/14 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
@@ -114,4 +114,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 v3 12/14 xen/dt: ifdef out DEV_DT-related bits from device_tree.{c,h}
In reply to Alejandro Vallejo... which means, device-tree.c stops requiring strictly CONFIG_HAS_DEVICE_TREE and may function without it.
Not a functional change on architectures that currently use these files, as they already select CONFIG_HAS_DEVICE_TREE.
--- 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
@@ -2028,9 +2028,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 /* Generic device initialization */ np->dev.type =DEV_DT ; np->dev.of_node = np; +#endif /* CONFIG_HAS_DEVICE_TREE */ } }if ( allnextpp )
xen/include/xen/device_tree.h +4 -0
@@ -109,9 +109,12 @@ struct dt_device_node {*/ struct list_head domain_list; +#ifdef CONFIG_HAS_DEVICE_TREE struct device dev; +#endif /* CONFIG_HAS_DEVICE_TREE */ }; +#ifdef CONFIG_HAS_DEVICE_TREE #define dt_to_dev (dt_node) (&(dt_node)->dev)static inline struct dt_device_node *dev_to_dt (struct device *dev)
@@ -120,6 +123,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 */ #define MAX_PHANDLE_ARGS 16struct dt_phandle_args {
Signature · 1 line
2.43.0
Re: [PATCH v3 12/14] xen/dt: ifdef out DEV_DT-related bits from device_tree.{c,h}
Quoted 7 lines · Alejandro Vallejo
... which means,
device-tree.cstops requiring strictlyCONFIG_HAS_DEVICE_TREEand may function without it.Not a functional change on architectures that currently use these files, as they already select
CONFIG_HAS_DEVICE_TREE.Signed-off-by Alejandro Vallejo <[email protected]>
Re: [PATCH v3 12/14] xen/dt: ifdef out DEV_DT-related bits from device_tree.{c,h}
In reply to Alejandro VallejoQuoted 2 lines · Alejandro Vallejo
... which means,
device-tree.cstops requiring strictlyCONFIG_HAS_DEVICE_TREEand may function without it.
See my reply to patch 14. I consider it outright wrong (as being overly misleading) to build device tree code without HAS_DEVICE_TREE=y.
Jan
Re: [PATCH v3 12/14] xen/dt: ifdef out DEV_DT-related bits from device_tree.{c,h}
Hi,
Quoted 6 lines · Jan Beulich
Quoted 2 lines · Alejandro Vallejo
... which means,
device-tree.cstops requiring strictlyCONFIG_HAS_DEVICE_TREEand may function without it.See my reply to patch 14. I consider it outright wrong (as being overly misleading) to build device tree code without HAS_DEVICE_TREE=y.
FWIW +1.
Cheers,
Signature · 1 line
Julien Grall
PATCH v3 13/14 xen/dt: Allow CONFIG_DOM0LESS_BOOT to include device-tree/
In reply to Alejandro Vallejo... without CONFIG_HAS_DEVICE_TREE
--- xen/common/Kconfig | 1 + xen/common/Makefile | 2 +- xen/common/device-tree/Makefile | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-)
xen/common/Kconfig +1 -0
@@ -14,6 +14,7 @@ config CORE_PARKING config DOM0LESS_BOOT bool "Dom0less boot support" if EXPERT + select LIBFDT depends on HAS_DOM0LESS && HAS_DEVICE_TREE && DOMAIN_BUILD_HELPERS default y help
xen/common/Makefile +1 -1
@@ -8,7 +8,7 @@ obj-y += cpu.o obj-$(CONFIG_DEBUG_TRACE) += debugtrace.o obj-$(CONFIG_HAS_DEVICE_TREE) += device.o obj-$(filter-out $(CONFIG_X86),$(CONFIG_ACPI)) += device.o -obj-$(CONFIG_HAS_DEVICE_TREE) += device-tree/ +obj-$(firstword $(CONFIG_HAS_DEVICE_TREE) $(CONFIG_DOM0LESS_BOOT)) += device-tree/ obj-$(CONFIG_IOREQ_SERVER) += dm.o obj-y += domain.o obj-y += event_2l.o
xen/common/device-tree/Makefile +4 -4
@@ -1,11 +1,11 @@ obj-y += bootfdt.init.o -obj-y += bootinfo-fdt.init.o -obj-y += bootinfo.init.o -obj-y += device-tree.o +obj-$(CONFIG_HAS_DEVICE_TREE) += bootinfo-fdt.init.o +obj-$(CONFIG_HAS_DEVICE_TREE) += bootinfo.init.o +obj-$(CONFIG_HAS_DEVICE_TREE) += 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) += 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
Re: [PATCH v3 13/14] xen/dt: Allow CONFIG_DOM0LESS_BOOT to include device-tree/
Quoted 3 lines · Alejandro Vallejo
... without
CONFIG_HAS_DEVICE_TREESigned-off-by Alejandro Vallejo <[email protected]>
Quoted 54 lines
--- xen/common/Kconfig | 1 + xen/common/Makefile | 2 +- xen/common/device-tree/Makefile | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-)xen/common/Kconfig +1
-0@@ -14,6 +14,7 @@ config CORE_PARKING config DOM0LESS_BOOT bool "Dom0less boot support" if EXPERT + select LIBFDT depends on HAS_DOM0LESS && HAS_DEVICE_TREE && DOMAIN_BUILD_HELPERS default y helpxen/common/Makefile +1
-1@@ -8,7 +8,7 @@ obj-y += cpu.o obj-$(CONFIG_DEBUG_TRACE) += debugtrace.o obj-$(CONFIG_HAS_DEVICE_TREE) += device.o obj-$(filter-out $(CONFIG_X86),$(CONFIG_ACPI)) += device.o -obj-$(CONFIG_HAS_DEVICE_TREE) += device-tree/ +obj-$(firstword $(CONFIG_HAS_DEVICE_TREE) $(CONFIG_DOM0LESS_BOOT)) += device-tree/ obj-$(CONFIG_IOREQ_SERVER) += dm.o obj-y += domain.o obj-y += event_2l.oxen/common/device-tree/Makefile +4
-4@@ -1,11 +1,11 @@ obj-y += bootfdt.init.o -obj-y += bootinfo-fdt.init.o -obj-y += bootinfo.init.o -obj-y += device-tree.o +obj-$(CONFIG_HAS_DEVICE_TREE) += bootinfo-fdt.init.o +obj-$(CONFIG_HAS_DEVICE_TREE) += bootinfo.init.o +obj-$(CONFIG_HAS_DEVICE_TREE) += 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) += intc.o obj-$(CONFIG_DOMAIN_BUILD_HELPERS) += kernel.o obj-$(CONFIG_STATIC_EVTCHN) += static-evtchn.init.o obj-$(CONFIG_STATIC_MEMORY) += static-memory.init.oSignature · 1 line
2.43.0
Re: [PATCH v3 13/14] xen/dt: Allow CONFIG_DOM0LESS_BOOT to include device-tree/
In reply to Alejandro Vallejoxen/common/Kconfig config CORE_PARKING · line 20
Quoted 10 lines · Alejandro Vallejo
xen/common/Kconfig +1
-0@@ -14,6 +14,7 @@ config CORE_PARKING config DOM0LESS_BOOT bool "Dom0less boot support" if EXPERT + select LIBFDT depends on HAS_DOM0LESS && HAS_DEVICE_TREE && DOMAIN_BUILD_HELPERS default y help
Nit: Imo it is good practice to have the select-s after the "depends on", and perhaps also after any default(s).
xen/common/Makefile obj-y += cpu.o · line 11
Quoted 8 lines
xen/common/Makefile +1
-1@@ -8,7 +8,7 @@ obj-y += cpu.o obj-$(CONFIG_DEBUG_TRACE) += debugtrace.o obj-$(CONFIG_HAS_DEVICE_TREE) += device.o obj-$(filter-out $(CONFIG_X86),$(CONFIG_ACPI)) += device.o -obj-$(CONFIG_HAS_DEVICE_TREE) += device-tree/ +obj-$(firstword $(CONFIG_HAS_DEVICE_TREE) $(CONFIG_DOM0LESS_BOOT)) += device-tree/
Why not
obj-$(CONFIG_HAS_DEVICE_TREE) += device-tree/
obj-$(CONFIG_DOM0LESS_BOOT) += device-tree/
as we have it in a few similar situations?
And why would the duplication be needed in the first place? Shouldn't DOM0LESS_BOOT imply HAS_DEVICE_TREE? Sadly the description once again only says what is intended, but not why. And the dependency is actually visible in patch context above, in the hunk altering xen/common/Kconfig.
Jan
Re: [PATCH v3 13/14] xen/dt: Allow CONFIG_DOM0LESS_BOOT to include device-tree/
Quoted 26 lines · Jan Beulich
xen/common/Kconfig config CORE_PARKING · line 20
Quoted 10 lines · Alejandro Vallejo
xen/common/Kconfig +1
-0@@ -14,6 +14,7 @@ config CORE_PARKING config DOM0LESS_BOOT bool "Dom0less boot support" if EXPERT + select LIBFDT depends on HAS_DOM0LESS && HAS_DEVICE_TREE && DOMAIN_BUILD_HELPERS default y helpNit: Imo it is good practice to have the select-s after the "depends on", and perhaps also after any default(s).
xen/common/Makefile obj-y += cpu.o · line 11
Quoted 8 lines
xen/common/Makefile +1
-1@@ -8,7 +8,7 @@ obj-y += cpu.o obj-$(CONFIG_DEBUG_TRACE) += debugtrace.o obj-$(CONFIG_HAS_DEVICE_TREE) += device.o obj-$(filter-out $(CONFIG_X86),$(CONFIG_ACPI)) += device.o -obj-$(CONFIG_HAS_DEVICE_TREE) += device-tree/ +obj-$(firstword $(CONFIG_HAS_DEVICE_TREE) $(CONFIG_DOM0LESS_BOOT)) += device-tree/Why not
Quoted 4 lines
obj-$(CONFIG_HAS_DEVICE_TREE) += device-tree/
obj-$(CONFIG_DOM0LESS_BOOT) += device-tree/as we have it in a few similar situations?
Because I wasn't sure the build system would swallow it. If you claim it does, sure. I think the "firstword" version is clearer, but I don't mind.
Quoted 7 lines
And why would the duplication be needed in the first place? Shouldn't
DOM0LESS_BOOTimplyHAS_DEVICE_TREE? Sadly the description once again only says what is intended, but not why. And the dependency is actually visible in patch context above, in the hunk altering xen/common/Kconfig.Jan
After this series the idea is that CONFIG_HAS_DEVICE_TREE means a platform in which platform resources (memory, devices, etc) are described on DTs.
While x86 ends up understanding DTs to the extent that it's able to parse and extract "xen,domain" nodes, it's not capable of much more than that. The distinction is important because making x86 understand general DT (devices, IRQs and memory) would be far too invasive and not very helpful.
I can rename it to CONFIG_HAS_PLATFORM_DT or CONFIG_HAS_DT_DEVICES, or anything else if you (or anyone else) have any ideas.
TL;DR: It's to still be able to compile-out the bits x86 cannot use in the DT machinery.
Cheers,
Alejandro
Re: [PATCH v3 13/14] xen/dt: Allow CONFIG_DOM0LESS_BOOT to include device-tree/
Quoted 51 lines · Alejandro Vallejo
Quoted 26 lines · Jan Beulich
xen/common/Kconfig config CORE_PARKING · line 20
Quoted 10 lines · Alejandro Vallejo
xen/common/Kconfig +1
-0@@ -14,6 +14,7 @@ config CORE_PARKING config DOM0LESS_BOOT bool "Dom0less boot support" if EXPERT + select LIBFDT depends on HAS_DOM0LESS && HAS_DEVICE_TREE && DOMAIN_BUILD_HELPERS default y helpNit: Imo it is good practice to have the select-s after the "depends on", and perhaps also after any default(s).
xen/common/Makefile obj-y += cpu.o · line 11
Quoted 8 lines
xen/common/Makefile +1
-1@@ -8,7 +8,7 @@ obj-y += cpu.o obj-$(CONFIG_DEBUG_TRACE) += debugtrace.o obj-$(CONFIG_HAS_DEVICE_TREE) += device.o obj-$(filter-out $(CONFIG_X86),$(CONFIG_ACPI)) += device.o -obj-$(CONFIG_HAS_DEVICE_TREE) += device-tree/ +obj-$(firstword $(CONFIG_HAS_DEVICE_TREE) $(CONFIG_DOM0LESS_BOOT)) += device-tree/Why not
Quoted 4 lines
obj-$(CONFIG_HAS_DEVICE_TREE) += device-tree/
obj-$(CONFIG_DOM0LESS_BOOT) += device-tree/as we have it in a few similar situations?
Because I wasn't sure the build system would swallow it. If you claim it does, sure. I think the "firstword" version is clearer, but I don't mind.
Quoted 7 lines
And why would the duplication be needed in the first place? Shouldn't
DOM0LESS_BOOTimplyHAS_DEVICE_TREE? Sadly the description once again only says what is intended, but not why. And the dependency is actually visible in patch context above, in the hunk altering xen/common/Kconfig.Jan
After this series the idea is that
CONFIG_HAS_DEVICE_TREEmeans a platform in which platform resources (memory, devices, etc) are described on DTs.While x86 ends up understanding DTs to the extent that it's able to parse and extract "xen,domain" nodes, it's not capable of much more than that. The distinction is important because making x86 understand general DT (devices, IRQs and memory) would be far too invasive and not very helpful.
Quoted 5 lines
I can rename it to
CONFIG_HAS_PLATFORM_DTorCONFIG_HAS_DT_DEVICES, or anything else if you (or anyone else) have any ideas.TL;DR: It's to still be able to compile-out the bits x86 cannot use in the DT machinery.
Yeah, as it looks like not introducing HAS_DEVICE_TREE on x86 is causing confusion, maybe it is better to add HAS_DEVICE_TREE to all arches and use a different kconfig to say "this architecture supports device discovery via DT", such as CONFIG_HAS_DT_DEVICES or CONFIG_DT_DEVICE_DISCOVERY.
PATCH v3 14/14 kconfig: Allow x86 to pick CONFIG_DOM0LESS_BOOT
In reply to Alejandro VallejoWithout picking CONFIG_HAS_DEVICE_TREE.
In order to do that. Allow CONFIG_DOM0LESS_BOOT to enable a subset of the common/device-tree/ directory. x86 doesn't want dom0less-build.c, as that's tightly integrated still to the ARM way of building domains.
Requires "unsupported" for the time being until all required patches make it through.
--- xen/arch/x86/Kconfig | 1 + xen/common/Kconfig | 12 +++++++----- xen/common/device-tree/Makefile | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-)
xen/arch/x86/Kconfig +1 -0
@@ -18,6 +18,7 @@ config X86 select HAS_COMPAT select HAS_CPUFREQ select HAS_DIT + select HAS_DOM0LESS select HAS_EHCI select HAS_EX_TABLE select HAS_FAST_MULTIPLY
xen/common/Kconfig +7 -5
@@ -13,15 +13,17 @@ config CORE_PARKING depends on NR_CPUS > 1 config DOM0LESS_BOOT - bool "Dom0less boot support" if EXPERT + bool "Dom0less boot support" if EXPERT && (!X86 || UNSUPPORTED) select LIBFDT - depends on HAS_DOM0LESS && HAS_DEVICE_TREE && DOMAIN_BUILD_HELPERS - default y + depends on HAS_DOM0LESS && (X86 || (HAS_DEVICE_TREE && DOMAIN_BUILD_HELPERS)) + default y if !X86 help Dom0less boot support enables Xen to create and start domU guests during Xen boot without the need of a control domain (Dom0), which could be present anyway. + If unsure on x86, say N. + config DOMAIN_BUILD_HELPERS bool
@@ -155,7 +157,7 @@ config NUMA config STATIC_MEMORY bool "Static Allocation Support (UNSUPPORTED)" if UNSUPPORTED - depends on DOM0LESS_BOOT + depends on HAS_DEVICE_TREE && DOM0LESS_BOOT help Static Allocation refers to system or sub-system(domains) for which memory areas are pre-defined by configuration using physical
@@ -174,7 +176,7 @@ config STATIC_SHM config STATIC_EVTCHN bool "Static event channel support on a dom0less system" - depends on DOM0LESS_BOOT + depends on HAS_DEVICE_TREE && DOM0LESS_BOOT default y help This option enables establishing static event channel communication
xen/common/device-tree/Makefile +1 -1
@@ -3,7 +3,7 @@ obj-$(CONFIG_HAS_DEVICE_TREE) += bootinfo-fdt.init.o obj-$(CONFIG_HAS_DEVICE_TREE) += bootinfo.init.o obj-$(CONFIG_HAS_DEVICE_TREE) += device-tree.o obj-$(CONFIG_DOMAIN_BUILD_HELPERS) += domain-build.init.o -obj-$(CONFIG_DOM0LESS_BOOT) += dom0less-build.init.o +obj-$(filter-out $(CONFIG_X86),$(CONFIG_DOM0LESS_BOOT)) += dom0less-build.init.o obj-$(CONFIG_OVERLAY_DTB) += dt-overlay.o obj-$(CONFIG_HAS_DEVICE_TREE) += intc.o obj-$(CONFIG_DOMAIN_BUILD_HELPERS) += kernel.o
Signature · 1 line
2.43.0
Re: [PATCH v3 14/14] kconfig: Allow x86 to pick CONFIG_DOM0LESS_BOOT
Quoted 10 lines · Alejandro Vallejo
Without picking
CONFIG_HAS_DEVICE_TREE.In order to do that. Allow
CONFIG_DOM0LESS_BOOTto enable a subset of the common/device-tree/ directory. x86 doesn't wantdom0less-build.c, as that's tightly integrated still to the ARM way of building domains.Requires "unsupported" for the time being until all required patches make it through.
Signed-off-by Alejandro Vallejo <[email protected]>
Re: [PATCH v3 14/14] kconfig: Allow x86 to pick CONFIG_DOM0LESS_BOOT
In reply to Alejandro VallejoQuoted 5 lines · Alejandro Vallejo
Without picking
CONFIG_HAS_DEVICE_TREE.In order to do that. Allow
CONFIG_DOM0LESS_BOOTto enable a subset of the common/device-tree/ directory. x86 doesn't wantdom0less-build.c, as that's tightly integrated still to the ARM way of building domains.
Which then is grossly misleading: x86 also ought to select HAS_DEVICE_TREE if it wants to use that machinery. Instead of theis an the previous patch, I think what we need is a new Kconfig setting to control the use of dom0less-build.c.
Jan
Re: [PATCH v3 14/14] kconfig: Allow x86 to pick CONFIG_DOM0LESS_BOOT
Quoted 9 lines · Jan Beulich
Quoted 5 lines · Alejandro Vallejo
Without picking
CONFIG_HAS_DEVICE_TREE.In order to do that. Allow
CONFIG_DOM0LESS_BOOTto enable a subset of the common/device-tree/ directory. x86 doesn't wantdom0less-build.c, as that's tightly integrated still to the ARM way of building domains.Which then is grossly misleading: x86 also ought to select
HAS_DEVICE_TREEif it wants to use that machinery. Instead of theis an the previous patch,
It wants to use a _subset_. I can't use the full machinery.
Quoted 4 lines
I think what we need is a new
Kconfigsetting to control the use ofdom0less-build.c.Jan
It's not just dom0less-build.c. It's critical to avoid parsing device_t's during the unflatten procedure (which is the few lines compiled out with ifdef CONFIG_DEVICE_TREE).
Renaming CONFIG_HAS_DEVICE_TREE to CONFIG_HAS_PLATFORM_DT (with a suitable help message for clarity, even though it would always be enabled) should help clarify things.
Does that sound reasonable?
Cheers,
Alejandro
Re: [PATCH v3 14/14] kconfig: Allow x86 to pick CONFIG_DOM0LESS_BOOT
Quoted 20 lines · Alejandro Vallejo
Quoted 9 lines · Jan Beulich
Quoted 5 lines · Alejandro Vallejo
Without picking
CONFIG_HAS_DEVICE_TREE.In order to do that. Allow
CONFIG_DOM0LESS_BOOTto enable a subset of the common/device-tree/ directory. x86 doesn't wantdom0less-build.c, as that's tightly integrated still to the ARM way of building domains.Which then is grossly misleading: x86 also ought to select
HAS_DEVICE_TREEif it wants to use that machinery. Instead of theis an the previous patch,It wants to use a _subset_. I can't use the full machinery.
Quoted 2 lines
I think what we need is a new
Kconfigsetting to control the use ofdom0less-build.c.It's not just
dom0less-build.c. It's critical to avoid parsing device_t's during the unflatten procedure (which is the few lines compiled out with ifdefCONFIG_DEVICE_TREE).
Quoted 5 lines
Renaming
CONFIG_HAS_DEVICE_TREEtoCONFIG_HAS_PLATFORM_DT(with a suitablehelpmessage for clarity, even though it would always be enabled) should help clarify things.Does that sound reasonable?
Perhaps. The main input has to come from DT maintainers, though.
Jan
Re: [PATCH v3 14/14] kconfig: Allow x86 to pick CONFIG_DOM0LESS_BOOT
In reply to Alejandro VallejoHi,
Quoted 5 lines · Alejandro Vallejo
Without picking
CONFIG_HAS_DEVICE_TREE.In order to do that. Allow
CONFIG_DOM0LESS_BOOTto enable a subset
of the common/device-tree/ directory.
x86 doesn't wantdom0less-build.c,> as that's tightly integrated still to the ARM way of building domains.
I don't understand this argument. dom0less-build.c was moved to common and it will soon be used by RISC-V. This raises the question what's so special with x86?
Note I don't particularly care if you don't want to use it on x86. However, the argument provided is lacking some details... This will be useful in the future if someone thinks about consolidating the two.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v3 14/14] kconfig: Allow x86 to pick CONFIG_DOM0LESS_BOOT
Quoted 5 lines · Julien Grall
Hi,
Quoted 2 lines · Alejandro Vallejo
Without picking
CONFIG_HAS_DEVICE_TREE.
Quoted 8 lines
Quoted 3 lines
In order to do that. Allow
CONFIG_DOM0LESS_BOOTto enable a subset of the common/device-tree/ directory.
x86 doesn't wantdom0less-build.c,> as that's tightly integratedstill to the ARM way of building domains.
I don't understand this argument.
dom0less-build.cwas moved to common and it will soon be used by RISC-V. This raises the question what's so special with x86?
That's 2 separate matters:
1. dom0less-build.c not being compiled in.
2. CONFIG_DOM0LESS_BOOT enabling use of DT code without CONFIG_HAS_DEVICE_TREE.
(1) is a matter of not wanting to boil the ocean upfront. The way x86 and everyone else build domains is just different and duplicated in non-trivially consolidable ways. The goal here is to enable the domain builders in any arch to use the same backbone. I don't want to go the extra mile just yet to unify domain construction (though in time I will want to).
(2) has to do with compiling OUT things I really cannot have around. Anything involving devices described in a DT must not exist on x86, because it has no concept of a "struct device".
My intent is/was to repurpose CONFIG_HAS_DEVICE_TREE to mean "this hypervisor goes on a platform that gives a platform-describing DT". On x86 that's given by DSDT/SSDTs with ACPI.
Quoted 4 lines
Note I don't particularly care if you don't want to use it on x86. However, the argument provided is lacking some details... This will be useful in the future if someone thinks about consolidating the two.
I very definitely will want it all unified, but I'm working one elephant at a time.
Cheers,
Alejandro
Re: [PATCH v3 14/14] kconfig: Allow x86 to pick CONFIG_DOM0LESS_BOOT
Quoted 26 lines · Alejandro Vallejo
Quoted 5 lines · Julien Grall
Hi,
Quoted 2 lines · Alejandro Vallejo
Without picking
CONFIG_HAS_DEVICE_TREE.Quoted 8 lines
Quoted 3 lines
In order to do that. Allow
CONFIG_DOM0LESS_BOOTto enable a subset of the common/device-tree/ directory.
x86 doesn't wantdom0less-build.c,> as that's tightly integratedstill to the ARM way of building domains.
I don't understand this argument.
dom0less-build.cwas moved to common and it will soon be used by RISC-V. This raises the question what's so special with x86?That's 2 separate matters:
1.
dom0less-build.cnot being compiled in.
2.CONFIG_DOM0LESS_BOOTenabling use of DT code withoutCONFIG_HAS_DEVICE_TREE.(1) is a matter of not wanting to boil the ocean upfront. The way x86 and everyone else build domains is just different and duplicated in non-trivially consolidable ways. The goal here is to enable the domain builders in any arch to use the same backbone. I don't want to go the extra mile just yet to unify domain construction (though in time I will want to).
Quoted 7 lines
(2) has to do with compiling OUT things I really cannot have around. Anything involving devices described in a DT must not exist on x86, because it has no concept of a "struct device".
My intent is/was to repurpose
CONFIG_HAS_DEVICE_TREEto mean "this hypervisor goes on a platform that gives a platform-describing DT". On x86 that's given by DSDT/SSDTs with ACPI.
Alejandro is suggesting two levels of Device Tree support:
- full DT support, including device discovery via DT
- minimal DT support, for the dom0less/hyperlaunch configuration
Reading this series, it looks reasonable to me, at least as a stepping stone. I think it is expected that the kind of DT support needed by an architecture like ARM or RISC-V is different from the one needed by an architecture like x86. Of course we might be able to align things even more in the future but as of today I think it is reasonable to distinguish between the two.
That said, we might want to consider renaming or changing the kconfig options. For instance:
- CONFIG_HAS_DEVICE_TREE -> enable minimal DT support
- CONFIG_DT_DEVICE_DISCOVERY -> device discovery via DT
In this model, all architectures would have CONFIG_HAS_DEVICE_TREE, but only ARM and RISC-V would have CONFIG_DT_DEVICE_DISCOVERY.
Quoted 6 lines
Quoted 3 lines
Note I don't particularly care if you don't want to use it on x86. However, the argument provided is lacking some details... This will be useful in the future if someone thinks about consolidating the two.
I very definitely will want it all unified, but I'm working one elephant at a time.
+1
Re: [PATCH v3 14/14] kconfig: Allow x86 to pick CONFIG_DOM0LESS_BOOT
Quoted 47 lines · Stefano Stabellini
Quoted 26 lines · Alejandro Vallejo
Quoted 5 lines · Julien Grall
Hi,
Quoted 2 lines · Alejandro Vallejo
Without picking
CONFIG_HAS_DEVICE_TREE.Quoted 8 lines
Quoted 3 lines
In order to do that. Allow
CONFIG_DOM0LESS_BOOTto enable a subset of the common/device-tree/ directory.
x86 doesn't wantdom0less-build.c,> as that's tightly integratedstill to the ARM way of building domains.
I don't understand this argument.
dom0less-build.cwas moved to common and it will soon be used by RISC-V. This raises the question what's so special with x86?That's 2 separate matters:
1.
dom0less-build.cnot being compiled in.
2.CONFIG_DOM0LESS_BOOTenabling use of DT code withoutCONFIG_HAS_DEVICE_TREE.(1) is a matter of not wanting to boil the ocean upfront. The way x86 and everyone else build domains is just different and duplicated in non-trivially consolidable ways. The goal here is to enable the domain builders in any arch to use the same backbone. I don't want to go the extra mile just yet to unify domain construction (though in time I will want to).
Quoted 7 lines
(2) has to do with compiling OUT things I really cannot have around. Anything involving devices described in a DT must not exist on x86, because it has no concept of a "struct device".
My intent is/was to repurpose
CONFIG_HAS_DEVICE_TREEto mean "this hypervisor goes on a platform that gives a platform-describing DT". On x86 that's given by DSDT/SSDTs with ACPI.Alejandro is suggesting two levels of Device Tree support:
- full DT support, including device discovery via DT
- minimal DT support, for the dom0less/hyperlaunch configurationReading this series, it looks reasonable to me, at least as a stepping stone. I think it is expected that the kind of DT support needed by an architecture like ARM or RISC-V is different from the one needed by an architecture like x86. Of course we might be able to align things even more in the future but as of today I think it is reasonable to distinguish between the two.
Quoted 5 lines
That said, we might want to consider renaming or changing the kconfig options. For instance:
-
CONFIG_HAS_DEVICE_TREE-> enable minimal DT support
-CONFIG_DT_DEVICE_DISCOVERY-> device discovery via DT
Perhaps, shorter name like CONFIG_DT will be satisfactory? (instead of CONFIG_DT_DEVICE_DISCOVERY and 'similar' convention to existing CONFIG_ACPI)
Quoted 14 lines
In this model, all architectures would have
CONFIG_HAS_DEVICE_TREE, but only ARM and RISC-V would haveCONFIG_DT_DEVICE_DISCOVERY.Quoted 6 lines
Quoted 3 lines
Note I don't particularly care if you don't want to use it on x86. However, the argument provided is lacking some details... This will be useful in the future if someone thinks about consolidating the two.
I very definitely will want it all unified, but I'm working one elephant at a time.
+1
Re: [PATCH v3 14/14] kconfig: Allow x86 to pick CONFIG_DOM0LESS_BOOT
In reply to Stefano StabelliniQuoted 47 lines · Stefano Stabellini
Quoted 26 lines · Alejandro Vallejo
Quoted 5 lines · Julien Grall
Hi,
Quoted 2 lines · Alejandro Vallejo
Without picking
CONFIG_HAS_DEVICE_TREE.Quoted 8 lines
Quoted 3 lines
In order to do that. Allow
CONFIG_DOM0LESS_BOOTto enable a subset of the common/device-tree/ directory.
x86 doesn't wantdom0less-build.c,> as that's tightly integratedstill to the ARM way of building domains.
I don't understand this argument.
dom0less-build.cwas moved to common and it will soon be used by RISC-V. This raises the question what's so special with x86?That's 2 separate matters:
1.
dom0less-build.cnot being compiled in.
2.CONFIG_DOM0LESS_BOOTenabling use of DT code withoutCONFIG_HAS_DEVICE_TREE.(1) is a matter of not wanting to boil the ocean upfront. The way x86 and everyone else build domains is just different and duplicated in non-trivially consolidable ways. The goal here is to enable the domain builders in any arch to use the same backbone. I don't want to go the extra mile just yet to unify domain construction (though in time I will want to).
Quoted 7 lines
(2) has to do with compiling OUT things I really cannot have around. Anything involving devices described in a DT must not exist on x86, because it has no concept of a "struct device".
My intent is/was to repurpose
CONFIG_HAS_DEVICE_TREEto mean "this hypervisor goes on a platform that gives a platform-describing DT". On x86 that's given by DSDT/SSDTs with ACPI.Alejandro is suggesting two levels of Device Tree support:
- full DT support, including device discovery via DT
- minimal DT support, for the dom0less/hyperlaunch configurationReading this series, it looks reasonable to me, at least as a stepping stone. I think it is expected that the kind of DT support needed by an architecture like ARM or RISC-V is different from the one needed by an architecture like x86. Of course we might be able to align things even more in the future but as of today I think it is reasonable to distinguish between the two.
Quoted 7 lines
That said, we might want to consider renaming or changing the kconfig options. For instance:
-
CONFIG_HAS_DEVICE_TREE-> enable minimal DT support
-CONFIG_DT_DEVICE_DISCOVERY-> device discovery via DTIn this model, all architectures would have
CONFIG_HAS_DEVICE_TREE,
In which case - do we still need HAS_DEVICE_TREE?
Jan
Quoted 2 lines
but
only ARM and RISC-V would haveCONFIG_DT_DEVICE_DISCOVERY.
Bah, ought to be 00/14. Missed during copy.
Cheers,
Alejandro