All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/2] arm: s5p4418: fix relocation
@ 2023-11-12 14:38 Stefan Bosch
  2023-11-12 14:38 ` [PATCH v1 1/2] common: board_f: change calculation of gd->mon_len to fix s5p4418 reloc Stefan Bosch
  2023-11-12 14:38 ` [PATCH v1 2/2] arm: s5p4418: fix relocation of vectors Stefan Bosch
  0 siblings, 2 replies; 4+ messages in thread
From: Stefan Bosch @ 2023-11-12 14:38 UTC (permalink / raw)
  To: Tom Rini; +Cc: u-boot, Stefan Bosch


Fix relocation of u-boot for s5p4418-SoC. I.e. use __image_copy_start
instead of _start to calculate the monitor length. Furthermore use an
adapted version of relocate_vectors for the s5p4418-SoC. Background:
The header (NSIH) used by the 2nd-bootloader (included at the begin of
u-boot.bin) is not loaded into RAM. Therefore _start has to be after
the header and therefore is not equal to __image_copy_start which is
at the begin of the header.


Stefan Bosch (2):
  common: board_f: change calculation of gd->mon_len to fix s5p4418
    reloc
  arm: s5p4418: fix relocation of vectors

 arch/arm/cpu/armv7/s5p4418/Makefile   |  3 +++
 arch/arm/cpu/armv7/s5p4418/relocate.S | 24 ++++++++++++++++++++++++
 common/board_f.c                      |  2 +-
 3 files changed, 28 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/cpu/armv7/s5p4418/relocate.S

-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v1 1/2] common: board_f: change calculation of gd->mon_len to fix s5p4418 reloc
  2023-11-12 14:38 [PATCH v1 0/2] arm: s5p4418: fix relocation Stefan Bosch
@ 2023-11-12 14:38 ` Stefan Bosch
  2023-11-12 20:01   ` Simon Glass
  2023-11-12 14:38 ` [PATCH v1 2/2] arm: s5p4418: fix relocation of vectors Stefan Bosch
  1 sibling, 1 reply; 4+ messages in thread
From: Stefan Bosch @ 2023-11-12 14:38 UTC (permalink / raw)
  To: Tom Rini; +Cc: u-boot, Stefan Bosch

ARM and MICROBLAZE: Change calculation of monitor length (gd->mon_len)
to fix relocation at boards with s5p4418-SoC. At s5p4418, _start is
after the header (NSIH) therefore the monitor length has to be
calculated using __image_copy_start instead of _start in order the hole
monitor code is relocated.

Signed-off-by: Stefan Bosch <stefan_b@posteo.net>
---

 common/board_f.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/board_f.c b/common/board_f.c
index d4d7d01f8f..d2e4d9eae2 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -283,7 +283,7 @@ static int init_func_i2c(void)
 static int setup_mon_len(void)
 {
 #if defined(__ARM__) || defined(__MICROBLAZE__)
-	gd->mon_len = (ulong)__bss_end - (ulong)_start;
+	gd->mon_len = (ulong)__bss_end - (ulong)__image_copy_start;
 #elif defined(CONFIG_SANDBOX) && !defined(__riscv)
 	gd->mon_len = (ulong)_end - (ulong)_init;
 #elif defined(CONFIG_SANDBOX)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v1 2/2] arm: s5p4418: fix relocation of vectors
  2023-11-12 14:38 [PATCH v1 0/2] arm: s5p4418: fix relocation Stefan Bosch
  2023-11-12 14:38 ` [PATCH v1 1/2] common: board_f: change calculation of gd->mon_len to fix s5p4418 reloc Stefan Bosch
@ 2023-11-12 14:38 ` Stefan Bosch
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Bosch @ 2023-11-12 14:38 UTC (permalink / raw)
  To: Tom Rini; +Cc: u-boot, Stefan Bosch

The header (NSIH) used for the s5p4418-SoC is not loaded into RAM by the
2nd-bootloader, see boot0.h. Therefore, use an adapted version of
relocate_vectors which relocates the vectors after the header (at _start)
instead of the 'dummy'-vectors at the start of the header (at
__image_copy_start).

Signed-off-by: Stefan Bosch <stefan_b@posteo.net>
---

 arch/arm/cpu/armv7/s5p4418/Makefile   |  3 +++
 arch/arm/cpu/armv7/s5p4418/relocate.S | 24 ++++++++++++++++++++++++
 2 files changed, 27 insertions(+)
 create mode 100644 arch/arm/cpu/armv7/s5p4418/relocate.S

diff --git a/arch/arm/cpu/armv7/s5p4418/Makefile b/arch/arm/cpu/armv7/s5p4418/Makefile
index 321b257b6d..58042581c4 100644
--- a/arch/arm/cpu/armv7/s5p4418/Makefile
+++ b/arch/arm/cpu/armv7/s5p4418/Makefile
@@ -2,5 +2,8 @@
 #
 # (C) Copyright 2016 Nexell
 # Hyunseok, Jung <hsjung@nexell.co.kr>
+#
+# Copyright (C) 2023  Stefan Bosch <stefan_b@posteo.net>
 
 obj-y += cpu.o
+obj-y += relocate.o
diff --git a/arch/arm/cpu/armv7/s5p4418/relocate.S b/arch/arm/cpu/armv7/s5p4418/relocate.S
new file mode 100644
index 0000000000..d6e76adceb
--- /dev/null
+++ b/arch/arm/cpu/armv7/s5p4418/relocate.S
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ *  relocate - S5P4418 specific relocation for ARM U-Boot
+ *
+ *  Copyright (c) 2013  Albert ARIBAUD <albert.u.boot@aribaud.net>
+ *  Copyright (C) 2023  Stefan Bosch <stefan_b@posteo.net>
+ */
+
+#include <asm-offsets.h>
+#include <asm/assembler.h>
+#include <linux/linkage.h>
+
+ENTRY(relocate_vectors)
+
+	/*
+	 * The s5p4418 SoC has the security extensions, so use VBAR to relocate
+	 * the exception vectors.
+	 */
+	ldr	r0, [r9, #GD_RELOCADDR]	/* r0 = gd->relocaddr */
+	add	r0, #0x400			/* vectors are after NSIH + 0x200 */
+	mcr	p15, 0, r0, c12, c0, 0	/* Set VBAR */
+	ret	lr
+
+ENDPROC(relocate_vectors)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 1/2] common: board_f: change calculation of gd->mon_len to fix s5p4418 reloc
  2023-11-12 14:38 ` [PATCH v1 1/2] common: board_f: change calculation of gd->mon_len to fix s5p4418 reloc Stefan Bosch
@ 2023-11-12 20:01   ` Simon Glass
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Glass @ 2023-11-12 20:01 UTC (permalink / raw)
  To: Stefan Bosch; +Cc: Tom Rini, u-boot

On Sun, 12 Nov 2023 at 07:40, Stefan Bosch <stefan_b@posteo.net> wrote:
>
> ARM and MICROBLAZE: Change calculation of monitor length (gd->mon_len)
> to fix relocation at boards with s5p4418-SoC. At s5p4418, _start is
> after the header (NSIH) therefore the monitor length has to be
> calculated using __image_copy_start instead of _start in order the hole

whole

> monitor code is relocated.
>
> Signed-off-by: Stefan Bosch <stefan_b@posteo.net>Reviewed-by: Simon Glass <sjg@chromium.org>
> ---
>
>  common/board_f.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>


>
> diff --git a/common/board_f.c b/common/board_f.c
> index d4d7d01f8f..d2e4d9eae2 100644
> --- a/common/board_f.c
> +++ b/common/board_f.c
> @@ -283,7 +283,7 @@ static int init_func_i2c(void)
>  static int setup_mon_len(void)
>  {
>  #if defined(__ARM__) || defined(__MICROBLAZE__)
> -       gd->mon_len = (ulong)__bss_end - (ulong)_start;
> +       gd->mon_len = (ulong)__bss_end - (ulong)__image_copy_start;
>  #elif defined(CONFIG_SANDBOX) && !defined(__riscv)
>         gd->mon_len = (ulong)_end - (ulong)_init;
>  #elif defined(CONFIG_SANDBOX)
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-11-12 20:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-12 14:38 [PATCH v1 0/2] arm: s5p4418: fix relocation Stefan Bosch
2023-11-12 14:38 ` [PATCH v1 1/2] common: board_f: change calculation of gd->mon_len to fix s5p4418 reloc Stefan Bosch
2023-11-12 20:01   ` Simon Glass
2023-11-12 14:38 ` [PATCH v1 2/2] arm: s5p4418: fix relocation of vectors Stefan Bosch

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.