diff mbox series

riscv: booti: do not force relocation if force_reloc is not set

Message ID 20210406075016.32429-1-vitaly.wool@konsulko.com
State Accepted
Commit 6ba8eeb6f17c08a7a7fd97683161330d01a8ef2e
Delegated to: Andes
Headers show
Series riscv: booti: do not force relocation if force_reloc is not set | expand

Commit Message

Vitaly Wool April 6, 2021, 7:50 a.m. UTC
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 <vitaly.wool@konsulko.com>
---
 arch/riscv/lib/image.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Leo Liang July 15, 2021, 9:09 a.m. UTC | #1
On Tue, Apr 06, 2021 at 10:50:16AM +0300, Vitaly Wool wrote:
> 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 <vitaly.wool@konsulko.com>
> ---
>  arch/riscv/lib/image.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)

Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
diff mbox series

Patch

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);