From patchwork Mon Jan 19 22:30:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Bellows X-Patchwork-Id: 43337 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f197.google.com (mail-we0-f197.google.com [74.125.82.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A75022034D for ; Mon, 19 Jan 2015 22:33:59 +0000 (UTC) Received: by mail-we0-f197.google.com with SMTP id l61sf3886802wev.0 for ; Mon, 19 Jan 2015 14:33:58 -0800 (PST) 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=gBnXQZIKAdXhHB8FKoKr8yLQU6MQee33dI3I9/ZVuHE=; b=F206GGCom9TnCkCHLUe89IAbAypyNE/utMDi40LIIFS3goqV/7iuKgt2cM0+GrjSKc OWs1EjgOhyJb2OrZ/6yCtY5x6eqbK19fDX2wOV+FEAzRB2ug2YtEY3YHeIizl9k57EW3 5qFfmJA2gE6a9HeHwe10l8oi5oBL7wqA6vntLPUvhQAIju5b5evoox2DtEhtrN/Tz/ZF 4CCMHBIIk8qxxE6Mjmu7qM07Yh7o56Gfu/uyLJvdhVNIROSChQ+jCMuIDhtPRqGUWc6r zyUn/k0LLmSeWTaLvvdXngIILWwV+SzfP545To+4/4mA6uBCid/kbv04ojYNQa40GDUn t/hQ== X-Gm-Message-State: ALoCoQnH0NeeTAos0LJBLTkTAndwS5XQX+BDA/up53bhDOHYdQSxgqsQKy66XXoFtJZNMayqG3Cv X-Received: by 10.194.241.163 with SMTP id wj3mr289wjc.5.1421706838873; Mon, 19 Jan 2015 14:33:58 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.71 with SMTP id z7ls26055lag.92.gmail; Mon, 19 Jan 2015 14:33:58 -0800 (PST) X-Received: by 10.112.12.65 with SMTP id w1mr34580321lbb.68.1421706838535; Mon, 19 Jan 2015 14:33:58 -0800 (PST) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id q13si7720945lal.79.2015.01.19.14.33.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 Jan 2015 14:33:58 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by mail-la0-f47.google.com with SMTP id hv19so3825085lab.6 for ; Mon, 19 Jan 2015 14:33:58 -0800 (PST) X-Received: by 10.112.98.99 with SMTP id eh3mr34159984lbb.32.1421706838388; Mon, 19 Jan 2015 14:33:58 -0800 (PST) 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.112.9.200 with SMTP id c8csp1229428lbb; Mon, 19 Jan 2015 14:33:57 -0800 (PST) X-Received: by 10.140.42.194 with SMTP id c60mr5226620qga.61.1421706837144; Mon, 19 Jan 2015 14:33:57 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i6si19580667qan.53.2015.01.19.14.33.56 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 19 Jan 2015 14:33:57 -0800 (PST) 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]:40090 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDKtQ-0007d0-4p for patch@linaro.org; Mon, 19 Jan 2015 17:33:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58203) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDKrO-0004lb-HY for qemu-devel@nongnu.org; Mon, 19 Jan 2015 17:31:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDKrI-0003eA-M7 for qemu-devel@nongnu.org; Mon, 19 Jan 2015 17:31:50 -0500 Received: from mail-pd0-f179.google.com ([209.85.192.179]:64989) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDKrI-0003e5-H1 for qemu-devel@nongnu.org; Mon, 19 Jan 2015 17:31:44 -0500 Received: by mail-pd0-f179.google.com with SMTP id v10so20721449pde.10 for ; Mon, 19 Jan 2015 14:31:44 -0800 (PST) X-Received: by 10.66.249.39 with SMTP id yr7mr21138226pac.43.1421706704041; Mon, 19 Jan 2015 14:31:44 -0800 (PST) Received: from gbellows-linaro.qualcomm.com (rrcs-67-52-129-61.west.biz.rr.com. [67.52.129.61]) by mx.google.com with ESMTPSA id rl10sm985994pbb.67.2015.01.19.14.31.42 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 Jan 2015 14:31:43 -0800 (PST) From: Greg Bellows To: qemu-devel@nongnu.org, peter.maydell@linaro.org, christoffer.dall@linaro.org Date: Mon, 19 Jan 2015 16:30:21 -0600 Message-Id: <1421706621-23731-6-git-send-email-greg.bellows@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1421706621-23731-1-git-send-email-greg.bellows@linaro.org> References: <1421706621-23731-1-git-send-email-greg.bellows@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.192.179 Cc: Greg Bellows Subject: [Qemu-devel] [PATCH 5/5] target-arm: Adjust kernel load address for Image 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: greg.bellows@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.215.47 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 Adjust the kernel load offset by 0x8000 if not a zImage. Signed-off-by: Pranavkumar Sawargaonkar Signed-off-by: Greg Bellows --- hw/arm/boot.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 52ebd8b..b581cea 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -537,6 +537,32 @@ static void load_image_to_fw_cfg(FWCfgState *fw_cfg, uint16_t size_key, fw_cfg_add_bytes(fw_cfg, data_key, data, size); } +static int check_load_zimage(const char *filename) +{ + int fd; + uint8_t buf[40]; + uint32_t *p = (uint32_t *) &buf[36]; + + fd = open(filename, O_RDONLY | O_BINARY); + if (fd < 0) { + perror(filename); + return -1; + } + + memset(buf, 0, sizeof(buf)); + if (read(fd, buf, sizeof(buf)) != sizeof(buf)) { + close(fd); + return -1; + } + + /* Check for zImage magic number */ + if (*p == 0x016F2818) { + return 1; + } + + return 0; +} + void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) { CPUState *cs; @@ -613,7 +639,12 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) primary_loader = bootloader; kernel_load_offset = KERNEL_LOAD_ADDR; elf_machine = EM_ARM; - } + + if (!check_load_zimage(info->kernel_filename)) { + /* Assuming we are loading Image hence aligning it to 0x8000 */ + kernel_load_offset -= 0x8000; + } + } info->dtb_filename = qemu_opt_get(qemu_get_machine_opts(), "dtb");