From nobody Sun May 5 02:47:03 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543523063395718.162029099022; Thu, 29 Nov 2018 12:24:23 -0800 (PST) Received: from localhost ([::1]:56234 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSSqr-0001jW-Cr for importer@patchew.org; Thu, 29 Nov 2018 15:23:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSSpw-0000j5-1i for qemu-devel@nongnu.org; Thu, 29 Nov 2018 15:23:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSSpu-0006Du-7f for qemu-devel@nongnu.org; Thu, 29 Nov 2018 15:22:59 -0500 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:43540) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gSSpq-0006Ap-Ni; Thu, 29 Nov 2018 15:22:54 -0500 Received: by mail-wr1-x441.google.com with SMTP id r10so3178289wrs.10; Thu, 29 Nov 2018 12:22:54 -0800 (PST) Received: from ?IPv6:2a02:c7d:860f:7601:7503:9d7c:2958:5e7d? ([2a02:c7d:860f:7601:7503:9d7c:2958:5e7d]) by smtp.gmail.com with ESMTPSA id n9sm3214924wrx.80.2018.11.29.12.22.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 12:22:52 -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-language:content-transfer-encoding; bh=f0qLraRY151DnldRikjh/w7Z322fEPljgTfbEOlyjV4=; b=nXGZFFF+CfKujVGpC71C0B2pwV4CnrnYM0OhFUuhXp93hzhRuUWJGlRRhYYiwWc9nU STzgY5HE11CJHi3D+EjDIh33i8UquggINZ6fQfL66MSPcahYruZ0lwSshgJoKLpmjLWM cDWWGQ+nu9IvONqTiJdpOOLK9YzkZh3VRXOPTFNhvX/MaRnZhrBntcgi7qoTNnw4meS/ NFDV/ytpBnAQmdAdi3BtC9ZtYDJPpSYq62qyKy3i2e7eittW9UEuIS6yarRsyncifbFH Ub4UG338t948MuBXAUPRALWpolgnguuMd8d5rMzhwb9XY+rVwqMgZUI5f4LOYSshI4xm n+0A== 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-language:content-transfer-encoding; bh=f0qLraRY151DnldRikjh/w7Z322fEPljgTfbEOlyjV4=; b=S/uurB3O49rzVfzqhTO1Vn15A/hA1tz+huDqjz7VHSGz4EzzUuXRrmPH/K7uzVjUdC 0iY1WOvIhkXQGgdyGVvBBbqpoDw/c6ug1H6WUDzqkJfQx48IUeuvZD1nmvolXEkhzmgI bHgIeaGa4KmW+V315guyckKlXzOo/GWB8S+YBu89NW/dZ1T4nPMLUupDQN6zkxf/46FT mKB1prNen2V2Vkq6UlCwk78TPnKhN8utpV3PzYJVdShkajKeZFuoUn5uZHrbu36iQF8h 7QGwWa5y9h3XTetL/A35QW//3/PkiK5qVDw9GvLYBUdIDTDhXq5b9SCQd9NOuwuliq43 V7mg== X-Gm-Message-State: AA+aEWZSX6Zbtkvvzda/aVjWntcBCKrmtJAUJO5oXdh4GYXPLwlzcvHj k/Km48tDIKAiMdmaV0FQh5M= X-Google-Smtp-Source: AFSGD/W2cSgWMRmoG81+FlbBniVKdgP2DcIYqGdD1Ae5jP3dW2bQ9xYIhmhkuDuY+EI+3YyeS81sew== X-Received: by 2002:a5d:5182:: with SMTP id k2mr2640240wrv.121.1543522973113; Thu, 29 Nov 2018 12:22:53 -0800 (PST) From: Nick Hudson X-Google-Original-From: Nick Hudson To: qemu-devel@nongnu.org Message-ID: Date: Thu, 29 Nov 2018 20:22:47 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 Content-Language: en-GB Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PATCH v2] 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@linaro.org, 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) Content-Type: text/plain; charset="utf-8" noload kernels are loaded with the u-boot image header and as a result the header size needs adding to the entry point. Fake up a hdr so the kernel image is loaded at the right address and the entry point is adjusted appropriately. The bootloader fits in the space that the uboot header would have occupied. Update the load_uimage API to allow passing of load address when an image doesn't specify one. Signed-off-by: Nick Hudson --- hw/arm/boot.c | 8 +++++--- hw/core/loader.c | 15 ++++++++++++--- hw/core/uboot_image.h | 1 + include/hw/loader.h | 3 ++- 4 files changed, 20 insertions(+), 7 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 @@ * Documentation/arm/Booting and Documentation/arm64/booting.txt * They have different preferred image load offsets from system RAM base. */ -#define KERNEL_ARGS_ADDR 0x100 -#define KERNEL_LOAD_ADDR 0x00010000 +#define KERNEL_ARGS_ADDR 0x100 +#define KERNEL_NOLOAD_ADDR 0x00000000 +#define KERNEL_LOAD_ADDR 0x00010000 #define KERNEL64_LOAD_ADDR 0x00080000 #define ARM64_TEXT_OFFSET_OFFSET 8 @@ -1078,7 +1079,8 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_inf= o *info) } entry =3D elf_entry; if (kernel_size < 0) { - kernel_size =3D load_uimage_as(info->kernel_filename, &entry, NULL, + uint64_t loadaddr =3D info->loader_start + KERNEL_NOLOAD_ADDR; + kernel_size =3D load_uimage_as(info->kernel_filename, &entry, &loa= daddr, &is_linux, NULL, NULL, as); } 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..5537e88817 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -638,13 +638,22 @@ static int load_uboot_image(const char *filename, hwa= ddr *ep, hwaddr *loadaddr, goto out; if (hdr->ih_type !=3D image_type) { - fprintf(stderr, "Wrong image type %d, expected %d\n", hdr->ih_type, - image_type); - goto out; + if (image_type !=3D IH_TYPE_KERNEL && hdr->ih_type !=3D IH_TYPE_KE= RNEL_NOLOAD) { + fprintf(stderr, "Wrong image type %d, expected %d\n", hdr->ih_= type, + image_type); + goto out; + } } /* TODO: Implement other image types. */ switch (hdr->ih_type) { + case IH_TYPE_KERNEL_NOLOAD: + if (loadaddr =3D=3D NULL) + goto out; + + hdr->ih_load =3D *loadaddr + sizeof(*hdr); + hdr->ih_ep +=3D hdr->ih_load; + /* fall through */ case IH_TYPE_KERNEL: address =3D hdr->ih_load; 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 @@ #define IH_TYPE_SCRIPT 6 /* Script file */ #define IH_TYPE_FILESYSTEM 7 /* Filesystem Image (any type) */ #define IH_TYPE_FLATDT 8 /* Binary Flat Device Tree Blob */ +#define IH_TYPE_KERNEL_NOLOAD 14 /* OS Kernel Image (noload) */ /* * Compression Types diff --git a/include/hw/loader.h b/include/hw/loader.h index 67a0af84ac..10ff0ff76d 100644 --- a/include/hw/loader.h +++ b/include/hw/loader.h @@ -163,7 +163,8 @@ int load_aout(const char *filename, hwaddr addr, int ma= x_sz, /** load_uimage_as: * @filename: Path of uimage file * @ep: Populated with program entry point. Ignored if NULL. - * @loadaddr: Populated with the load address. Ignored if NULL. + * @loadaddr: load address if none specified in the image. Populated with = the + * load address. Ignored if NULL. * @is_linux: Is set to true if the image loaded is Linux. Ignored if NULL. * @translate_fn: optional function to translate load addresses * @translate_opaque: opaque data passed to @translate_fn -- 2.17.1