From nobody Sat Apr 27 17:36:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541597784060773.613503412747; Wed, 7 Nov 2018 05:36:24 -0800 (PST) Received: from localhost ([::1]:48395 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKO0M-0000ir-Qd for importer@patchew.org; Wed, 07 Nov 2018 08:36:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKNk8-0001Kb-La for qemu-devel@nongnu.org; Wed, 07 Nov 2018 08:19:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKNk2-0002Xr-VS for qemu-devel@nongnu.org; Wed, 07 Nov 2018 08:19:36 -0500 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:33807) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gKNje-0002Ln-Bg; Wed, 07 Nov 2018 08:19:06 -0500 Received: by mail-wr1-x441.google.com with SMTP id j26-v6so17390629wre.1; Wed, 07 Nov 2018 05:19:06 -0800 (PST) Received: from [192.168.0.45] ([90.200.74.20]) by smtp.gmail.com with ESMTPSA id r14-v6sm929330wro.8.2018.11.07.05.19.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Nov 2018 05:19:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=mADRNCaQxmO9LzgrEcKBqrU6gGW7lSHwsqYZuCquPDM=; b=snPI8WilfHn6w9DQ32BcEn1gZhhbmG/rrNKq8iDr+/+AA2i03VMBpF0dSbousAXFMV BujpGLsDTyF1oQzpt2qgLoU+kPSdWWV/9PsUlPb217PuCvFHa9qtbEZJY3OTw5U5ygG8 T5bJ9IDDLJ7Z/f1QFRx+9XKe4qVFR+Qu78uALjjsHWnPgrH/H3gwNUPbzPwk5oM2GKA5 Eqoh5EGf+8cryEtXrEIauzVP3sVsVQ8BBN00t1iWnsDvxHoaf7jhzyjnOWnTqLEa6gWe vIojMM8lR9hjpxoE8ekYt2CkOTHnxDXMx5zRZLJfhfkR4yqZDeAQmcnJJZcNMhSJQwyo lCQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:message-id:date:user-agent :mime-version:content-transfer-encoding:content-language; bh=mADRNCaQxmO9LzgrEcKBqrU6gGW7lSHwsqYZuCquPDM=; b=seqg2dzfzHy2gJbyEPn95grJx1SMBBdXMzySEKo9cm8FK6J5JXtrYqS6hd1yF7dhJZ QH8EhB8EbyuAJ8IU2b06SMk7i/H4oVHhEXFD1wyK2dxtiZlRA6Tku3bW3Xzzmh7Dd39n w6ug5VxPJnUOIvqyVw2HOZsm70zrshfcTKv9EhS5KjbVmgCBZeb2KYSiUlNSuupTGLSb yFAfJKo7tvWc+h/66/BIBKAH15dQIKQX4VCHH03ww4k0M19Ef8/+de6XO9Je3ySy5aRs WpsxjqFc3VQspA0teNFGx3aHfIwyKCG3t/ySSKJMLJNlTFTuftwAfcTOn9sUhxbQcZsd VbfA== X-Gm-Message-State: AGRZ1gKj4z4uVCi+M7KoZzLqzijtyJbK7Pmi5J7TXNt/m8EnlwUTu264 epDnMl1wO/uwzySQQVTZfaI= X-Google-Smtp-Source: AJdET5fpNUWeJgQ0ikn2j3moKKfRtsU/gq0vaOBHO0mkem1OAFo0LdpzNWbPWe7Mf1Nh+xtJUScn1Q== X-Received: by 2002:a5d:4747:: with SMTP id o7-v6mr181835wrs.256.1541596745094; Wed, 07 Nov 2018 05:19:05 -0800 (PST) From: Nick Hudson X-Google-Original-From: Nick Hudson To: qemu-devel@nongnu.org Message-ID: Date: Wed, 7 Nov 2018 13:19:00 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: quoted-printable Content-Language: en-GB X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-Mailman-Approved-At: Wed, 07 Nov 2018 08:34:54 -0500 Subject: [Qemu-devel] [PATCH] Support u-boot noload images for arm as used by NetBSD/evbarm GENERIC kernel. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) noload kernels are loaded with the u-boot image header and as a result the header size needs adding to the entry point.=C2=A0 Fake up a hdr so the kernel image is loaded at the right address and the entry point is adjusted appropriately Signed-off-by: Nick Hudson --- =C2=A0hw/arm/boot.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2= =A0 8 +++++--- =C2=A0hw/core/loader.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 12 +++++++++--- =C2=A0hw/core/uboot_image.h |=C2=A0 1 + =C2=A03 files changed, 15 insertions(+), 6 deletions(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 586baa9b64..450267566a 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -30,8 +30,9 @@ =C2=A0 * Documentation/arm/Booting and Documentation/arm64/booting.txt =C2=A0 * They have different preferred image load offsets from system RAM = base. =C2=A0 */ -#define KERNEL_ARGS_ADDR 0x100 -#define KERNEL_LOAD_ADDR 0x00010000 +#define KERNEL_ARGS_ADDR=C2=A0=C2=A0 0x100 +#define KERNEL_NOLOAD_ADDR 0x00000000 +#define KERNEL_LOAD_ADDR=C2=A0=C2=A0 0x00010000 =C2=A0#define KERNEL64_LOAD_ADDR 0x00080000 =C2=A0#define ARM64_TEXT_OFFSET_OFFSET=C2=A0=C2=A0=C2=A0 8 @@ -1078,7 +1079,8 @@ void arm_load_kernel(ARMCPU *cpu, struct=20 arm_boot_info *info) =C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 entry =3D elf_entry; =C2=A0=C2=A0=C2=A0=C2=A0 if (kernel_size < 0) { -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 kernel_size =3D load_uimage_as(= info->kernel_filename, &entry, NULL, +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uint64_t loadaddr =3D info->loa= der_start + KERNEL_NOLOAD_ADDR; +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 kernel_size =3D load_uimage_as(= info->kernel_filename, &entry,=20 &loadaddr, =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= &is_linux, NULL, NULL, as); =C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64) &= & kernel_size < 0) { diff --git a/hw/core/loader.c b/hw/core/loader.c index aa0b3fc867..952562c2da 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -638,13 +638,19 @@ static int load_uboot_image(const char *filename,=20 hwaddr *ep, hwaddr *loadaddr, =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto out; =C2=A0=C2=A0=C2=A0=C2=A0 if (hdr->ih_type !=3D image_type) { -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 fprintf(stderr, "Wrong image ty= pe %d, expected %d\n", hdr->ih_type, -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 image_type); -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto out; +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (image_type !=3D IH_TYPE_KER= NEL && hdr->ih_type !=3D=20 IH_TYPE_KERNEL_NOLOAD) { +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 fprintf= (stderr, "Wrong image type %d, expected %d\n",=20 hdr->ih_type, +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 image_type); +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto ou= t; +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 /* TODO: Implement other image types.=C2=A0 */ =C2=A0=C2=A0=C2=A0=C2=A0 switch (hdr->ih_type) { +=C2=A0=C2=A0=C2=A0 case IH_TYPE_KERNEL_NOLOAD: +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 hdr->ih_load =3D *loadaddr + si= zeof(*hdr); +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 hdr->ih_ep +=3D hdr->ih_load; + =C2=A0=C2=A0=C2=A0=C2=A0 case IH_TYPE_KERNEL: =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 address =3D hdr->ih_load; =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (translate_fn) { diff --git a/hw/core/uboot_image.h b/hw/core/uboot_image.h index 34c11a70a6..608022de6e 100644 --- a/hw/core/uboot_image.h +++ b/hw/core/uboot_image.h @@ -124,6 +124,7 @@ =C2=A0#define IH_TYPE_SCRIPT=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 6=C2=A0= =C2=A0=C2=A0 /* Script file=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2= =A0=C2=A0 */ =C2=A0#define IH_TYPE_FILESYSTEM=C2=A0=C2=A0=C2=A0 7=C2=A0=C2=A0=C2=A0 /* = Filesystem Image (any type)=C2=A0=C2=A0=C2=A0 */ =C2=A0#define IH_TYPE_FLATDT=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 8=C2=A0= =C2=A0=C2=A0 /* Binary Flat Device Tree Blob=C2=A0=C2=A0=C2=A0 */ +#define IH_TYPE_KERNEL_NOLOAD=C2=A0 14=C2=A0=C2=A0=C2=A0 /* OS Kernel Imag= e (noload)=C2=A0=C2=A0=C2=A0 */ =C2=A0/* =C2=A0 * Compression Types --=20 2.17.1