From patchwork Mon Mar 24 17:18:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 26939 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f198.google.com (mail-ob0-f198.google.com [209.85.214.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 448DD20062 for ; Mon, 24 Mar 2014 17:18:42 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id wn1sf23764037obc.9 for ; Mon, 24 Mar 2014 10:18: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:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version: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:content-type :content-transfer-encoding; bh=VG/jwVK6yn7XO9mXRGe/z72rxFiXyk3Bj6G8wo0r9r4=; b=h3s/gmbRU2VZIfnwZQT6rhoV20pnhSjimRbUgUXVM0O5UOWAe9JQn7p+Up3VH2dnc1 L8tRaGhjzheIpDIUCMVZL6o2SAbMWPkQrUTU4ovLeH7BwF1oB/yy0fmP3o/oV7O5A6H1 NeAplQqn94wtB+WXh876JbLwx4e8NrgEVjV/sT5/ifx92iLcqv6qTExcrzUAnG1C1zHt vpIfYv7Ktlb8CAegRUWXzntc8i5VdeVA/RADNtJ7aG6wCXFiSRC9GchQynFZwyuoHrYm xZLnTVDtNpDwZZrkKTg/F77NmlxdpASD9GWJO9p1vbPEGnfUyzpD1kuz3nb1F4FD73W7 6Qdw== X-Gm-Message-State: ALoCoQnaO3ezD7SE5DPSu7+MFBXJV9Ro0yVFuEYMdT3/q1R5djAGIMKBzUzIEuj5oxc+iGBa3hQy X-Received: by 10.182.43.137 with SMTP id w9mr6761571obl.29.1395681521800; Mon, 24 Mar 2014 10:18:41 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.104.163 with SMTP id a32ls947481qgf.73.gmail; Mon, 24 Mar 2014 10:18:41 -0700 (PDT) X-Received: by 10.220.103.141 with SMTP id k13mr2329373vco.25.1395681521631; Mon, 24 Mar 2014 10:18:41 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id wy9si1896190vdc.37.2014.03.24.10.18.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Mar 2014 10:18:41 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id hu19so6171752vcb.15 for ; Mon, 24 Mar 2014 10:18:41 -0700 (PDT) X-Received: by 10.58.229.167 with SMTP id sr7mr49737399vec.7.1395681521550; Mon, 24 Mar 2014 10:18: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.220.78.9 with SMTP id i9csp239707vck; Mon, 24 Mar 2014 10:18:41 -0700 (PDT) X-Received: by 10.140.25.104 with SMTP id 95mr66592535qgs.39.1395681520769; Mon, 24 Mar 2014 10:18:40 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d8si6219370qao.92.2014.03.24.10.18.40 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 24 Mar 2014 10:18:40 -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]:37662 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WS8WG-0003Xw-7h for patch@linaro.org; Mon, 24 Mar 2014 13:18:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54679) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WS8Vp-0003HB-Tb for qemu-devel@nongnu.org; Mon, 24 Mar 2014 13:18:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WS8Vo-0003xS-FQ for qemu-devel@nongnu.org; Mon, 24 Mar 2014 13:18:13 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:47138) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WS8Vo-0003x7-8J for qemu-devel@nongnu.org; Mon, 24 Mar 2014 13:18:12 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1WS8Vl-0007jI-B0; Mon, 24 Mar 2014 17:18:09 +0000 From: Peter Maydell To: Anthony Liguori Date: Mon, 24 Mar 2014 17:18:09 +0000 Message-Id: <1395681489-29679-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1395681489-29679-1-git-send-email-peter.maydell@linaro.org> References: <1395681489-29679-1-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Cc: Blue Swirl , qemu-devel@nongnu.org, Aurelien Jarno Subject: [Qemu-devel] [PULL 2/2] target-arm: Load ELF images with the correct machine type for CPU 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: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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 When trying to load an ELF file specified via -kernel, we need to pass load_elf() the ELF machine type corresponding to the CPU we're booting with, not the one corresponding to the softmmu binary we happen to be running. (The two are different in the case of loading a 32-bit ARM ELF file into a 32 bit CPU being emulated by qemu-system aarch64.) This was causing us to incorrectly fail to load ELF images in this situation. Signed-off-by: Peter Maydell Reviewed-by: Andreas Färber Message-id: 1395427476-25546-1-git-send-email-peter.maydell@linaro.org --- hw/arm/boot.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index dc62918..3d1f4a2 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -448,6 +448,7 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) int initrd_size; int is_linux = 0; uint64_t elf_entry; + int elf_machine; hwaddr entry, kernel_load_offset; int big_endian; static const ARMInsnFixup *primary_loader; @@ -463,9 +464,11 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { primary_loader = bootloader_aarch64; kernel_load_offset = KERNEL64_LOAD_ADDR; + elf_machine = EM_AARCH64; } else { primary_loader = bootloader; kernel_load_offset = KERNEL_LOAD_ADDR; + elf_machine = EM_ARM; } info->dtb_filename = qemu_opt_get(qemu_get_machine_opts(), "dtb"); @@ -501,7 +504,7 @@ 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); + NULL, NULL, big_endian, elf_machine, 1); entry = elf_entry; if (kernel_size < 0) { kernel_size = load_uimage(info->kernel_filename, &entry, NULL,