From patchwork Fri Sep 5 15:15:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 36856 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 378F0202E4 for ; Fri, 5 Sep 2014 15:16:42 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id l13sf55895471iga.10 for ; Fri, 05 Sep 2014 08:16:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=YVzCEmMPjqaYOZVPRry67+lVn7mV2oxavK6Mff8vsqk=; b=bWVxm2HqkIO/zdvZlCuxHHHA5HACEhbNT9SPy7DmEXJdLVsHuv3RdPVShrV6SdEovA BQLrRFYK1G4Cdd//mkdi7oaFV+a7S8g8laDiby3yF1zmSZLU4e751NgxKGzzbpDzRg5v WftKvpWN4CeuZTljZrcBlxIEyIYAgLmeQdLOQrqxdP1rzr9jiirRHR4zx+kEFwvIjrrl khqjg4ELFey6M23DVDWUg/79Oyp4Vwhx+WGc9OQ3FDN+9OKMZQj7UndQrBJ0sLfuKiPP AvbnoLdILHKGI6Sa9ia/zTFl55jQmURLV5KHvTKi5bDdLtWm0PuaZ2QiT9cCiYruLTIt mn6Q== X-Gm-Message-State: ALoCoQlCGbvyyUTxDLRWGB21TSWv0a0G6pWpUotqZSxjmwA4XsbUveBfDTaos3gy/IKYRojt2QCx X-Received: by 10.182.110.130 with SMTP id ia2mr7474221obb.42.1409930201780; Fri, 05 Sep 2014 08:16:41 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.108.230 with SMTP id j93ls849592qgf.31.gmail; Fri, 05 Sep 2014 08:16:41 -0700 (PDT) X-Received: by 10.52.15.36 with SMTP id u4mr1244982vdc.91.1409930201669; Fri, 05 Sep 2014 08:16:41 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id uv6si937590vcb.3.2014.09.05.08.16.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Sep 2014 08:16:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.173 as permitted sender) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id im17so12415560vcb.4 for ; Fri, 05 Sep 2014 08:16:41 -0700 (PDT) X-Received: by 10.220.97.5 with SMTP id j5mr11429970vcn.16.1409930201410; Fri, 05 Sep 2014 08:16:41 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp97563vcb; Fri, 5 Sep 2014 08:16:41 -0700 (PDT) X-Received: by 10.224.137.6 with SMTP id u6mr19094019qat.91.1409930200865; Fri, 05 Sep 2014 08:16:40 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [208.118.235.17]) by mx.google.com with ESMTPS id t98si1900901qge.119.2014.09.05.08.16.40 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 05 Sep 2014 08:16:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; Received: from localhost ([::1]:58412 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPvFg-0004ld-Ag for patch@linaro.org; Fri, 05 Sep 2014 11:16:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60089) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPvEk-0003mv-I8 for qemu-devel@nongnu.org; Fri, 05 Sep 2014 11:15:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XPvEe-0002kp-Km for qemu-devel@nongnu.org; Fri, 05 Sep 2014 11:15:42 -0400 Received: from mail-we0-f178.google.com ([74.125.82.178]:55423) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPvEe-0002kf-F2 for qemu-devel@nongnu.org; Fri, 05 Sep 2014 11:15:36 -0400 Received: by mail-we0-f178.google.com with SMTP id q58so426019wes.37 for ; Fri, 05 Sep 2014 08:15:32 -0700 (PDT) X-Received: by 10.180.105.8 with SMTP id gi8mr4633052wib.46.1409930132875; Fri, 05 Sep 2014 08:15:32 -0700 (PDT) Received: from ards-macbook-pro.local (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by mx.google.com with ESMTPSA id wx3sm1734308wjc.19.2014.09.05.08.15.31 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Sep 2014 08:15:32 -0700 (PDT) From: Ard Biesheuvel To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Fri, 5 Sep 2014 17:15:26 +0200 Message-Id: <1409930126-28449-7-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1409930126-28449-1-git-send-email-ard.biesheuvel@linaro.org> References: <1409930126-28449-1-git-send-email-ard.biesheuvel@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 74.125.82.178 Cc: fu.wei@linaro.org, christoffer.dall@linaro.org, Ard Biesheuvel Subject: [Qemu-devel] [PATCH 6/6] hw/arm/boot: enable DTB support when booting ELF images X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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. Signed-off-by: Ard Biesheuvel --- 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,