qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC 1/1] add support of `--initrd` for ELF-ARM kernels


From: Alex Bennée
Subject: Re: [RFC 1/1] add support of `--initrd` for ELF-ARM kernels
Date: Fri, 14 Apr 2023 09:54:50 +0100
User-agent: mu4e 1.10.0; emacs 29.0.90

Stefan Lankes <slankes@eonerc.rwth-aachen.de> writes:

> Currently, the flag `--initrd` is only support for Linux ARM kernels.
> However, also other ELF kernels could depend on an initial ramdisk.
> This PR loads also the initrd for ELF kernels and announce the
> location by the nodes "/chosen/initrd-start" and
> "/chosen/initrd-end" within the device tree.
>
> Signed-off-by: Stefan Lankes <slankes@eonerc.rwth-aachen.de>
> ---
>  hw/arm/boot.c | 106 +++++++++++++++++++++++++++++---------------------
>  1 file changed, 62 insertions(+), 44 deletions(-)
>
> diff --git a/hw/arm/boot.c b/hw/arm/boot.c
> index 54f6a3e0b3..f767a4809e 100644
> --- a/hw/arm/boot.c
> +++ b/hw/arm/boot.c
> @@ -657,20 +657,38 @@ int arm_load_dtb(hwaddr addr, const struct 
> arm_boot_info *binfo,
>      }
>  
>      if (binfo->initrd_size) {
> -        rc = qemu_fdt_setprop_sized_cells(fdt, "/chosen", 
> "linux,initrd-start",
> +        if (binfo->is_linux) {
> +            rc = qemu_fdt_setprop_sized_cells(fdt, "/chosen", 
> "linux,initrd-start",
>                                            acells, binfo->initrd_start);
> -        if (rc < 0) {
> -            fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n");
> -            goto fail;
> -        }
> +            if (rc < 0) {
> +                fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n");
> +                goto fail;
> +            }
>  
> -        rc = qemu_fdt_setprop_sized_cells(fdt, "/chosen", "linux,initrd-end",
> -                                          acells,
> -                                          binfo->initrd_start +
> -                                          binfo->initrd_size);
> -        if (rc < 0) {
> -            fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n");
> -            goto fail;
> +            rc = qemu_fdt_setprop_sized_cells(fdt, "/chosen", 
> "linux,initrd-end",
> +                                              acells,
> +                                              binfo->initrd_start +
> +                                              binfo->initrd_size);
> +            if (rc < 0) {
> +                fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n");
> +                goto fail;
> +            }
> +        } else {
> +            rc = qemu_fdt_setprop_sized_cells(fdt, "/chosen", "initrd-start",
> +                                          acells, binfo->initrd_start);
> +            if (rc < 0) {
> +                fprintf(stderr, "couldn't set /chosen/initrd-start\n");
> +                goto fail;
> +            }
> +
> +            rc = qemu_fdt_setprop_sized_cells(fdt, "/chosen", "initrd-end",
> +                                              acells,
> +                                              binfo->initrd_start +
> +                                              binfo->initrd_size);
> +            if (rc < 0) {
> +                fprintf(stderr, "couldn't set /chosen/initrd-end\n");
> +                goto fail;
> +            }

Where are these DTB nodes documented?

Also could you not achieve the same thing using the guest-loader which
uses the multiboot spec and sets:

        const char *compat[2] = { "multiboot,module", "multiboot,ramdisk" };
        if (qemu_fdt_setprop_string_array(fdt, node, "compatible",
                                          (char **) &compat,
                                          ARRAY_SIZE(compat)) < 0) {
            error_setg(errp, "couldn't set %s/compatible", node);
            return;
        }


-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro



reply via email to

[Prev in Thread] Current Thread [Next in Thread]