From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53501) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPwar-0004cZ-9d for qemu-devel@nongnu.org; Fri, 05 Sep 2014 12:42:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XPwal-0007YQ-B6 for qemu-devel@nongnu.org; Fri, 05 Sep 2014 12:42:37 -0400 Received: from mail-we0-f174.google.com ([74.125.82.174]:60262) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPwal-0007YM-4y for qemu-devel@nongnu.org; Fri, 05 Sep 2014 12:42:31 -0400 Received: by mail-we0-f174.google.com with SMTP id w61so591848wes.19 for ; Fri, 05 Sep 2014 09:42:30 -0700 (PDT) References: <1409930126-28449-1-git-send-email-ard.biesheuvel@linaro.org> <1409930126-28449-7-git-send-email-ard.biesheuvel@linaro.org> Mime-Version: 1.0 (1.0) In-Reply-To: <1409930126-28449-7-git-send-email-ard.biesheuvel@linaro.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Message-Id: <793AD66A-7E9F-4E31-814F-FEDFB278E6F8@linaro.org> From: Ard Biesheuvel Date: Fri, 5 Sep 2014 18:42:27 +0200 Subject: Re: [Qemu-devel] [PATCH 6/6] hw/arm/boot: enable DTB support when booting ELF images List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "peter.maydell@linaro.org" , "qemu-devel@nongnu.org" Cc: "fu.wei@linaro.org" , "christoffer.dall@linaro.org" > On 5 sep. 2014, at 17:15, Ard Biesheuvel wrote= : >=20 > 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 addre= ss > covered by the loaded ELF image. >=20 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 w= e abort > Signed-off-by: Ard Biesheuvel > --- > hw/arm/boot.c | 18 ++++++++++++++++-- > 1 file changed, 16 insertions(+), 2 deletions(-) >=20 > 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 =3D 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_inf= o *info) >=20 > /* Assume that raw images are linux kernels, and ELF images are not. *= / > kernel_size =3D 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_filen= ame); > + exit(1); > + } > + } > entry =3D elf_entry; > if (kernel_size < 0) { > kernel_size =3D load_uimage(info->kernel_filename, &entry, NULL, > --=20 > 1.8.3.2 >=20