From patchwork Wed Sep 10 10:59:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 37196 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f199.google.com (mail-yk0-f199.google.com [209.85.160.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 17FA620491 for ; Wed, 10 Sep 2014 11:07:13 +0000 (UTC) Received: by mail-yk0-f199.google.com with SMTP id 19sf9725049ykq.6 for ; Wed, 10 Sep 2014 04:07:12 -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=xb9Bgz3CZrnOM0TtSO9vUSN3pUWh92j9LpfjA9l6vuo=; b=JO918a98lACbGHPJX6liVQV0elwbCzgk4rdb4DRMZ/AaYAy8/zEPWl5u1M2m/amBne QE6FKE9Yt4OZIZH1TA6QkJaNJ8M80aZnTlL+inCZ0FdAM3OO2L4q1k5diMki3giGwONj fkclOwjv2cUnqgVUJu/CLSRnJ4Z+bcz+oPC8cEbwH1QvwhlN9QJNooMi9i/OCt7DYO5b ir6RA1HwrDBCbQO51GbAmggu1WJzvKqRVcMmZTmDLiCpIqvT0SRM9Ob+Kpaiqw3bnadn D6cJmSsF7ERItTyKFfDbK4uTCF7XPsI7Ulqn90icyx695IWHSfnu4JnwTyBe6zEeYM2b FJZg== X-Gm-Message-State: ALoCoQmEfYs0uPUP9VwUKfNPiR5ZWLpWsXmweElDr5hAxjkS/S1bz8Bcr46DPwUd8e0/YbCxdQbQ X-Received: by 10.236.19.52 with SMTP id m40mr25018034yhm.35.1410347232935; Wed, 10 Sep 2014 04:07:12 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.88.203 with SMTP id t69ls2600054qgd.30.gmail; Wed, 10 Sep 2014 04:07:12 -0700 (PDT) X-Received: by 10.220.105.201 with SMTP id u9mr35634045vco.11.1410347232848; Wed, 10 Sep 2014 04:07:12 -0700 (PDT) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id 20si6201123vcd.22.2014.09.10.04.07.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 10 Sep 2014 04:07:12 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.176 as permitted sender) client-ip=209.85.220.176; Received: by mail-vc0-f176.google.com with SMTP id la4so2272939vcb.21 for ; Wed, 10 Sep 2014 04:07:12 -0700 (PDT) X-Received: by 10.52.156.100 with SMTP id wd4mr16766621vdb.39.1410347232761; Wed, 10 Sep 2014 04:07:12 -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 uj3csp419846vcb; Wed, 10 Sep 2014 04:07:12 -0700 (PDT) X-Received: by 10.140.42.77 with SMTP id b71mr639329qga.52.1410347232065; Wed, 10 Sep 2014 04:07:12 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z34si18397857qge.6.2014.09.10.04.07.11 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 10 Sep 2014 04:07:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:55197 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRfjz-0002G7-Jt for patch@linaro.org; Wed, 10 Sep 2014 07:07:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39501) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRfdF-00077i-NC for qemu-devel@nongnu.org; Wed, 10 Sep 2014 07:00:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XRfd8-0003Go-Bb for qemu-devel@nongnu.org; Wed, 10 Sep 2014 07:00:13 -0400 Received: from mail-we0-f169.google.com ([74.125.82.169]:33794) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRfd7-0003Dn-Sj for qemu-devel@nongnu.org; Wed, 10 Sep 2014 07:00:06 -0400 Received: by mail-we0-f169.google.com with SMTP id w61so3577824wes.0 for ; Wed, 10 Sep 2014 04:00:05 -0700 (PDT) X-Received: by 10.180.78.226 with SMTP id e2mr16662992wix.68.1410346805085; Wed, 10 Sep 2014 04:00:05 -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 wr10sm18127240wjc.10.2014.09.10.04.00.03 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 10 Sep 2014 04:00:04 -0700 (PDT) From: Ard Biesheuvel To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Wed, 10 Sep 2014 12:59:50 +0200 Message-Id: <1410346790-31743-5-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1410346790-31743-1-git-send-email-ard.biesheuvel@linaro.org> References: <1410346790-31743-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.169 Cc: christoffer.dall@linaro.org, Ard Biesheuvel Subject: [Qemu-devel] [PATCH v2 4/4] 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.176 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 using -kernel. If there are no conflicts with the placement of the ELF segments, the DTB image is loaded at the base of RAM. Signed-off-by: Ard Biesheuvel --- hw/arm/boot.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 1f73614d8843..3878cbd97aad 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -464,7 +464,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; @@ -531,7 +531,19 @@ 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 there is still some room left between the base of RAM and the + * low end of the ELF image we just loaded, try and put the DTB at the + * base of RAM like we do for bootloaders. Just ignore the potential 0 + * return value of load_dtb() which indicates that the dtb didn't fit, + * in that case we just proceed without it. + */ + if (elf_low_addr > info->loader_start && + load_dtb(info->loader_start, info, elf_low_addr) < 0) { + exit(1); + } + } entry = elf_entry; if (kernel_size < 0) { kernel_size = load_uimage(info->kernel_filename, &entry, NULL,