From patchwork Wed Jun 13 04:13:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 928643 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dUALmaA4"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 415D071Q4rz9s3C for ; Wed, 13 Jun 2018 14:13:57 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 22D44C21E29; Wed, 13 Jun 2018 04:13:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 11045C21CB1; Wed, 13 Jun 2018 04:13:48 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 61695C21C93; Wed, 13 Jun 2018 04:13:46 +0000 (UTC) Received: from mail-pg0-f66.google.com (mail-pg0-f66.google.com [74.125.83.66]) by lists.denx.de (Postfix) with ESMTPS id 321B6C21BE5 for ; Wed, 13 Jun 2018 04:13:44 +0000 (UTC) Received: by mail-pg0-f66.google.com with SMTP id z1-v6so597344pgv.12 for ; Tue, 12 Jun 2018 21:13:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=imzbTaDPriUIdk2/mQWj9LsC2alphzHW47gAwL5pvg0=; b=dUALmaA4vhE/jIvSff5DQG8r38WoU1ZFua6bsuIF2TtLiBt1YpBqEHjUwwvDuztdEz vFURUzGnJqVqtpg1+43lpPo2kA+E77Sh1efGHHWfWJWaS2j/yQ8ISlMqzFdnAER2R7QU yD94FdEJaH7yUIzQmuLbPG19MnM2Djbmzd6brouShvgcAXo4OIqMPuYKan4jGa1qby/q /X5aFhSKJSj2o9HIMmcSQ4qDjF3QYTHeTp7VsYk1xeuensWGKhnpdJpzNkqE16AwAAsd PHm6ZNUXrD07CMmPeE2JAKiJWi8lyxLsdHpNcDg7AMZ3c5nkTOkfUr2LSBQ9aEqNCfww d2nA== 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:date:message-id; bh=imzbTaDPriUIdk2/mQWj9LsC2alphzHW47gAwL5pvg0=; b=PbNSZZsJoSpQO17r7qW2Z3aCgG8ymi+UZ3LKMT58F25mltyIEkTM8JSAO40FAuiq7T lFNVU6nFgt7rYGmY3TSZWYuKH2N3yJ8rbLeMH2EwQn+9+vw2d5+54QG+D66v4MURWzZ7 DyYTqMWLhF2MFVl9EBin2zj01uRLgeUSYCPcy6SAdZ9RgTo+XBt366tr+xRwMdwvqWG9 JCMipYRfOWwIOeMHvKjBRU55qkWu4vGKq1P9m+FCFpe+61bRYgNWF2LciU63rl1qyGpY S53ZcshFnOnyGcTMKzWjQOQd4RIt+UZn2s+mv6cUkvYB0pYBjbNgv38xqs3xUh6Ru1IL 2weQ== X-Gm-Message-State: APt69E0IyJuQlk45uJv8B4n5CsL4EVDQiq7SbmP6F70/AIB62HAq9GcV 7EziwZgwFPxgJgwxQJzUUW9eHFwg X-Google-Smtp-Source: ADUXVKJEYj6IwtZXp8Gb23lQeMU6kqdSh2UuVe4WXqf/Hzq62mdHaC3UDVgbOzg7ZwQm07Nkazs9HA== X-Received: by 2002:a63:8b44:: with SMTP id j65-v6mr2723005pge.203.1528863222505; Tue, 12 Jun 2018 21:13:42 -0700 (PDT) Received: from localhost.localdomain ([1.1.125.124]) by smtp.gmail.com with ESMTPSA id v5-v6sm2727444pfd.1.2018.06.12.21.13.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jun 2018 21:13:41 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: u-boot@lists.denx.de Date: Wed, 13 Jun 2018 06:13:32 +0200 Message-Id: <20180613041333.17943-1-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.17.1 Cc: Tom Rini , Marek Vasut Subject: [U-Boot] [PATCH V4 1/2] ARM: image: Add option for ignoring ep bit 3 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add option to the booti_setup() which indicates to it that the caller requires the image to be relocated to the beginning of the RAM and that the information whether the image can be located anywhere in RAM at 2 MiB aligned boundary or not is to be ignored. This is useful ie. in case the Image is wrapped in another envelope, ie. fitImage and not relocating it but moving it would corrupt the envelope. Signed-off-by: Marek Vasut Cc: Bin Chen Cc: Masahiro Yamada Cc: Tom Rini Reviewed-By: Bin Chen --- V2: Rename ignore_ep to force_reloc V3: No change V4: - Add stdbool.h include - Switch force_reloc to bool --- arch/arm/lib/image.c | 5 +++-- cmd/booti.c | 2 +- include/image.h | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/arm/lib/image.c b/arch/arm/lib/image.c index 1a04e2b875..699bf44e70 100644 --- a/arch/arm/lib/image.c +++ b/arch/arm/lib/image.c @@ -26,7 +26,8 @@ struct Image_header { uint32_t res5; }; -int booti_setup(ulong image, ulong *relocated_addr, ulong *size) +int booti_setup(ulong image, ulong *relocated_addr, ulong *size, + bool force_reloc) { struct Image_header *ih; uint64_t dst; @@ -63,7 +64,7 @@ int booti_setup(ulong image, ulong *relocated_addr, ulong *size) * images->ep. Otherwise, relocate the image to the base of RAM * since memory below it is not accessible via the linear mapping. */ - if (le64_to_cpu(ih->flags) & BIT(3)) + if (!force_reloc && (le64_to_cpu(ih->flags) & BIT(3))) dst = image - text_offset; else dst = gd->bd->bi_dram[0].start; diff --git a/cmd/booti.c b/cmd/booti.c index 45fbb99b68..04353b68ec 100644 --- a/cmd/booti.c +++ b/cmd/booti.c @@ -37,7 +37,7 @@ static int booti_start(cmd_tbl_t *cmdtp, int flag, int argc, debug("* kernel: cmdline image address = 0x%08lx\n", ld); } - ret = booti_setup(ld, &relocated_addr, &image_size); + ret = booti_setup(ld, &relocated_addr, &image_size, false); if (ret != 0) return 1; diff --git a/include/image.h b/include/image.h index 95d5934344..420b8ff576 100644 --- a/include/image.h +++ b/include/image.h @@ -17,6 +17,7 @@ #include "compiler.h" #include +#include /* Define this to avoid #ifdefs later on */ struct lmb; @@ -881,9 +882,11 @@ int bootz_setup(ulong image, ulong *start, ulong *end); * @image: Address of image * @start: Returns start address of image * @size : Returns size image + * @force_reloc: Ignore image->ep field, always place image to RAM start * @return 0 if OK, 1 if the image was not recognised */ -int booti_setup(ulong image, ulong *relocated_addr, ulong *size); +int booti_setup(ulong image, ulong *relocated_addr, ulong *size, + bool force_reloc); /*******************************************************************/ /* New uImage format specific code (prefixed with fit_) */ From patchwork Wed Jun 13 04:13:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 928644 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ru6MKktu"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 415D0q4HzGz9s2g for ; Wed, 13 Jun 2018 14:14:35 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 4CA31C21D65; Wed, 13 Jun 2018 04:14:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id C74D1C21DFB; Wed, 13 Jun 2018 04:13:50 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id F06FEC21C93; Wed, 13 Jun 2018 04:13:47 +0000 (UTC) Received: from mail-pg0-f66.google.com (mail-pg0-f66.google.com [74.125.83.66]) by lists.denx.de (Postfix) with ESMTPS id 58169C21BE5 for ; Wed, 13 Jun 2018 04:13:47 +0000 (UTC) Received: by mail-pg0-f66.google.com with SMTP id l65-v6so603372pgl.8 for ; Tue, 12 Jun 2018 21:13:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=G0ga+F6Jhvy+WVyE6GR4vj6fMJW8o6FWkmstqmObls4=; b=ru6MKktuuLdANL7ojVZeRJvTgROncnIjWqGGHetAdOxXVyafI+rClj7pA6VhGcPCAw Ydc5z7S3gvm+/KvE67h7JJ26m1TFBN8YNXJOKuX6nJT5tIcDDfot0YAJ7ZSfa+QDXf31 7YP1iuUVhBTtNPlPeHA4d3VUbQhv4Fxq5mrKBzPUzBEqHU4ThFD32G7RAfycpAvGgKCr i2jU36U6UB97qgU+rmcamBK85VYaRMYG4fo/rDjqv0IS11C7VGkJjdSK9vK0g3MIYY6e PXJmERzUlhzXuHFxPg9V5OEEz9+19q6JniM6yuBf9wM3/2H1cfZyMu1X5xZ/Knwn37gV XPGw== 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:date:message-id:in-reply-to :references; bh=G0ga+F6Jhvy+WVyE6GR4vj6fMJW8o6FWkmstqmObls4=; b=SsxHieE5gVkXrCai9/ZPFBdhFI8uW0J4XIhCCfQ1qXJMCBfP4U6zBQszhtKjF6Q6tk 4lSefVkTG+BByJaESEiAUq+qWWiqU5tbo6YzbrmMa9NHmBkJcyZQtIV9IZC0CAMXT4UU nKUvKJyZjdecW/3V72mk074XDtmI7ah7C5xJI/Q/j51NwNIoSTk+KgeBmX9suvmy4snM q2o6tXzvCYOB5TVfBkuwtYABbD4wvazNlCidvvHVS9ytp8/6D8jcMbhnbkqnorDHM2ai XhPllMYlbevx7PBAh1HF76T/RHxcpJEXMl6pzBc6YyHoVtNUZg1Sw6vdmT2avjXJc9M6 EVeA== X-Gm-Message-State: APt69E2GFKR0NLgI+Xj+J9vThFGIVke/O+6IUHqRa4LVtWOVAo7bQAcp uWw9ZPmbgDQns5F1pd6Xsx1J+nOP X-Google-Smtp-Source: ADUXVKLsY5p/4qzSEAG8KWvt9HWZOHaW1jJCmqLz/zy69aSLdW2SPF1WbVs3wSyd0cc9A8dGoP8o/A== X-Received: by 2002:a65:46cb:: with SMTP id n11-v6mr2603330pgr.193.1528863225764; Tue, 12 Jun 2018 21:13:45 -0700 (PDT) Received: from localhost.localdomain ([1.1.125.124]) by smtp.gmail.com with ESMTPSA id v5-v6sm2727444pfd.1.2018.06.12.21.13.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jun 2018 21:13:45 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: u-boot@lists.denx.de Date: Wed, 13 Jun 2018 06:13:33 +0200 Message-Id: <20180613041333.17943-2-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180613041333.17943-1-marek.vasut+renesas@gmail.com> References: <20180613041333.17943-1-marek.vasut+renesas@gmail.com> Cc: Tom Rini , Marek Vasut Subject: [U-Boot] [PATCH V4 2/2] bootm: Handle kernel_noload on arm64 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The ARM64 has 2 MiB alignment requirement for the kernel. When using fitImage, this requirement may by violated, the kernel will thus be executed from unaligned address and fail to boot. Do what booti does and run booti_setup() for kernel_noload images on arm64 to obtain a suitable aligned address to which the image shall be relocated. Signed-off-by: Marek Vasut Cc: Bin Chen Cc: Masahiro Yamada Cc: Tom Rini --- V2: Protect the ARM64 booti bit with if IS_ENABLED(CMD_BOOTI) V3: Use if() instead of #ifdef V4: Switch force_reloc to bool --- common/bootm.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/common/bootm.c b/common/bootm.c index e789f6818a..e517d9f118 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -202,8 +202,23 @@ static int bootm_find_os(cmd_tbl_t *cmdtp, int flag, int argc, } if (images.os.type == IH_TYPE_KERNEL_NOLOAD) { - images.os.load = images.os.image_start; - images.ep += images.os.load; + if (CONFIG_IS_ENABLED(CMD_BOOTI) && + images.os.arch == IH_ARCH_ARM64) { + ulong image_addr; + ulong image_size; + + ret = booti_setup(images.os.image_start, &image_addr, + &image_size, true); + if (ret != 0) + return 1; + + images.os.type = IH_TYPE_KERNEL; + images.os.load = image_addr; + images.ep = image_addr; + } else { + images.os.load = images.os.image_start; + images.ep += images.os.image_start; + } } images.os.start = map_to_sysmem(os_hdr);