The current implementation of make_chosen_node() does not contain any architecture-specific logic. Therefore, move it from arch-specific files to common code.
At this stage, there is no need to introduce an arch_make_chosen_node(), as no architecture-specific customization is required. This change avoids duplication and simplifies future maintenance for architectures like RISC-V and ARM. Signed-off-by: Oleksii Kurochko <[email protected]> --- Changes in v2: - Rebase the patch on top of current staging: s/struct bootmodule/struct boot_module s/kinfo->cmdline/kinfo->bd.cmdline s/kinfo->initrd_bootmodule/kinfo->bd.initrd - Update the comment above make_chosen_node: ... on ACPI systems (on platform where CONFIG_ACPI=y) ... - Move make_chosen_node() to common/domain-build.c as it could be used not only for dom0less. - Based on the previous review it should be added: Reviewed-by: Michal Orzel <[email protected] but I decided not to add it as I've changed a place where make_chosen_node() leaves. - Link to v1: https://lore.kernel.org/xen-devel/9c87738225d48bd1ee9bba6e8d4e018dfecabccd.1747145897.git.oleksii.kuroc...@gmail.com/ --- xen/arch/arm/domain_build.c | 46 --------------------------- xen/common/device-tree/domain-build.c | 46 +++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index fb8fbb1650..6d1c9583b1 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1510,52 +1510,6 @@ int __init make_timer_node(const struct kernel_info *kinfo) return res; } -/* - * This function is used as part of the device tree generation for Dom0 - * on ACPI systems, and DomUs started directly from Xen based on device - * tree information. - */ -int __init make_chosen_node(const struct kernel_info *kinfo) -{ - int res; - const char *bootargs = NULL; - const struct boot_module *initrd = kinfo->bd.initrd; - void *fdt = kinfo->fdt; - - dt_dprintk("Create chosen node\n"); - res = fdt_begin_node(fdt, "chosen"); - if ( res ) - return res; - - if ( kinfo->bd.cmdline && kinfo->bd.cmdline[0] ) - { - bootargs = &kinfo->bd.cmdline[0]; - res = fdt_property(fdt, "bootargs", bootargs, strlen(bootargs) + 1); - if ( res ) - return res; - } - - /* - * If the bootloader provides an initrd, we must create a placeholder - * for the initrd properties. The values will be replaced later. - */ - if ( initrd && initrd->size ) - { - u64 a = 0; - res = fdt_property(kinfo->fdt, "linux,initrd-start", &a, sizeof(a)); - if ( res ) - return res; - - res = fdt_property(kinfo->fdt, "linux,initrd-end", &a, sizeof(a)); - if ( res ) - return res; - } - - res = fdt_end_node(fdt); - - return res; -} - static int __init handle_node(struct domain *d, struct kernel_info *kinfo, struct dt_device_node *node, p2m_type_t p2mt) diff --git a/xen/common/device-tree/domain-build.c b/xen/common/device-tree/domain-build.c index 95b383e00f..774790aab3 100644 --- a/xen/common/device-tree/domain-build.c +++ b/xen/common/device-tree/domain-build.c @@ -405,6 +405,52 @@ void __init initrd_load(struct kernel_info *kinfo, iounmap(initrd); } +/* + * This function is used as part of the device tree generation for Dom0 + * on ACPI systems (on platform where CONFIG_ACPI=y), and DomUs started + * directly from Xen based on device tree information. + */ +int __init make_chosen_node(const struct kernel_info *kinfo) +{ + int res; + const char *bootargs = NULL; + const struct boot_module *initrd = kinfo->bd.initrd; + void *fdt = kinfo->fdt; + + dt_dprintk("Create chosen node\n"); + res = fdt_begin_node(fdt, "chosen"); + if ( res ) + return res; + + if ( kinfo->bd.cmdline && kinfo->bd.cmdline[0] ) + { + bootargs = &kinfo->bd.cmdline[0]; + res = fdt_property(fdt, "bootargs", bootargs, strlen(bootargs) + 1); + if ( res ) + return res; + } + + /* + * If the bootloader provides an initrd, we must create a placeholder + * for the initrd properties. The values will be replaced later. + */ + if ( initrd && initrd->size ) + { + u64 a = 0; + res = fdt_property(kinfo->fdt, "linux,initrd-start", &a, sizeof(a)); + if ( res ) + return res; + + res = fdt_property(kinfo->fdt, "linux,initrd-end", &a, sizeof(a)); + if ( res ) + return res; + } + + res = fdt_end_node(fdt); + + return res; +} + /* * Local variables: * mode: C -- 2.52.0
