qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 6/6] hw/arm/boot: enable DTB support when bootin


From: Ard Biesheuvel
Subject: Re: [Qemu-devel] [PATCH 6/6] hw/arm/boot: enable DTB support when booting ELF images
Date: Fri, 5 Sep 2014 18:42:27 +0200


> On 5 sep. 2014, at 17:15, Ard Biesheuvel <address@hidden> wrote:
> 
> Add support for loading DTB images when booting ELF images via -kernel.
> The DTB image is located at the next 4 KB boundary above the highest address
> covered by the loaded ELF image.
> 

Apologies, this commit message is out of date: the DTB is put at base of RAM, 
bur only if it does not conflict with any of the ELF segments, otherwise we 
abort

> Signed-off-by: Ard Biesheuvel <address@hidden>
> ---
> hw/arm/boot.c | 18 ++++++++++++++++--
> 1 file changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/arm/boot.c b/hw/arm/boot.c
> index 8d8653978dfe..60c4f6af7884 100644
> --- a/hw/arm/boot.c
> +++ b/hw/arm/boot.c
> @@ -458,7 +458,7 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info 
> *info)
>     int kernel_size;
>     int initrd_size;
>     int is_linux = 0;
> -    uint64_t elf_entry;
> +    uint64_t elf_entry, elf_low_addr;
>     int elf_machine;
>     hwaddr entry, kernel_load_offset;
>     int big_endian;
> @@ -529,7 +529,21 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info 
> *info)
> 
>     /* Assume that raw images are linux kernels, and ELF images are not.  */
>     kernel_size = load_elf(info->kernel_filename, NULL, NULL, &elf_entry,
> -                           NULL, NULL, big_endian, elf_machine, 1);
> +                           &elf_low_addr, NULL, big_endian, elf_machine, 1);
> +    if (kernel_size > 0 && have_dtb(info)) {
> +        /* If we have a DTB in combination with an ELF executable image,
> +         * put the DTB at the base of RAM like we do for bootloaders.
> +         */
> +        uint32_t dtb_size;
> +
> +        if (load_dtb(info->loader_start, info, &dtb_size)) {
> +            exit(1);
> +        }
> +        if (info->loader_start + dtb_size > elf_low_addr) {
> +            fprintf(stderr, "Image %s overlaps DTB\n", 
> info->kernel_filename);
> +            exit(1);
> +        }
> +    }
>     entry = elf_entry;
>     if (kernel_size < 0) {
>         kernel_size = load_uimage(info->kernel_filename, &entry, NULL,
> -- 
> 1.8.3.2
> 



reply via email to

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