From patchwork Tue Apr 6 07:50:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitaly Wool X-Patchwork-Id: 1462848 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.a=rsa-sha256 header.s=google header.b=jKgqIblV; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FF7WC3wJ9z9sTD for ; Tue, 6 Apr 2021 23:23:03 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 024748168B; Tue, 6 Apr 2021 15:22:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="jKgqIblV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ABA4681DC5; Tue, 6 Apr 2021 09:50:43 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6F0C881DC9 for ; Tue, 6 Apr 2021 09:50:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=vitaly.wool@konsulko.com Received: by mail-wr1-x431.google.com with SMTP id v11so13078258wro.7 for ; Tue, 06 Apr 2021 00:50:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nZY2fesIA3MnruS5sV9ZxjwwZKL3pYnEYuzwpDBdNOI=; b=jKgqIblV9Xq3W54n1mqApnK9QMFrSUeJTWOY1t7/s9QdSKJTJlj3jURd/FmwaMp9kF A2NobrP3pAEubvizGGvStFtnVX54cjx6NpEII0AIe7Dh0bLbADwWnkNCapi1272IUYO1 VKZRpoZ1Yaqc1YoNig294XYAg/yTvRuVvAbzE= 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:mime-version :content-transfer-encoding; bh=nZY2fesIA3MnruS5sV9ZxjwwZKL3pYnEYuzwpDBdNOI=; b=pETDJPf7arjA+oftplX1co7Gv6+uQuhPDO7Re+zZMJrGR21A2mbcUJS8v3JqMj8krk CyjebRDEnojImFQkdCgKUqkR9gReoDL0Op9JM2Bgs9gdCmO1vryeuVr8uaYXw56GoA65 IYGtF8eIhcFds7cRX9AxjntbCIcTuFpy1/GKqkKVlfoNsGdg1tUkrI1DlkKHSjdmntgp e9O4Y5YQWE8cMLnUdQuHFAoaiQrJMGMWdRET97JyUUMzrtCj2R2xKwJDOL9iwb31l6M2 WJc9TA1hW646eFA0GS6pkeq3VyQtC+a5jeCWTlE9DwJTT6XRkOc4WbrpJylLW5UIoLJb XArg== X-Gm-Message-State: AOAM531OXLHrVhNxN8r5VzzWmfHYfJFVUNuqkDf3kSOVU0/LA1oYuLlg VnfTcgz4vd1678MF19kC2Na279ytHgGlCLfu X-Google-Smtp-Source: ABdhPJxAOHBPRrSQc7i4YqGoGyedQFSe2EJWVgqqP99rPXQducUSFFQtHoQEbFUq7UhYdGnQiWMApA== X-Received: by 2002:a5d:604d:: with SMTP id j13mr7261453wrt.161.1617695438825; Tue, 06 Apr 2021 00:50:38 -0700 (PDT) Received: from lootbox.konsulko.bg (lan.nucleusys.com. [92.247.61.126]) by smtp.gmail.com with ESMTPSA id a6sm2124516wmm.0.2021.04.06.00.50.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 00:50:38 -0700 (PDT) From: Vitaly Wool To: u-boot@lists.denx.de Cc: Anup Patel , trini@konsulko.com, Alex Ghiti , Bin Meng , Vitaly Wool Subject: [PATCH] riscv: booti: do not force relocation if force_reloc is not set Date: Tue, 6 Apr 2021 10:50:16 +0300 Message-Id: <20210406075016.32429-1-vitaly.wool@konsulko.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 06 Apr 2021 15:22:23 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean If force_reloc flag is not set and booti is called for an address ouside RAM (i. e. QSPI NOR flash), we should honor that and not try to force relocation in a bogus fashion. Signed-off-by: Vitaly Wool Reviewed-by: Leo Yu-Chi Liang --- arch/riscv/lib/image.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/riscv/lib/image.c b/arch/riscv/lib/image.c index 7357d3b07d..2032c2c399 100644 --- a/arch/riscv/lib/image.c +++ b/arch/riscv/lib/image.c @@ -48,7 +48,12 @@ int booti_setup(ulong image, ulong *relocated_addr, ulong *size, return -EINVAL; } *size = lhdr->image_size; - *relocated_addr = gd->ram_base + lhdr->text_offset; + if (force_reloc || + (gd->ram_base <= image && image < gd->ram_base + gd->ram_size)) { + *relocated_addr = gd->ram_base + lhdr->text_offset; + } else { + *relocated_addr = image; + } unmap_sysmem(lhdr);