Skip to contentSkip to conversation

arm: bugfix: Move vector table before jumping relocated code

PATCH New Tetsuyuki Kobayashi 5 participants 11 messages Jun 25, 2012 – Dec 26, 2012 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: bugfix: Move vector table before jumping relocated code

Interrupts and exceptions doesn't work in relocated code. It badly use IRQ_STACK_START_IN in rom area as interrupt stack. It is because the vecotr table is not moved to ram area. This patch moves vector table before jumping relocated code.

---
 arch/arm/cpu/armv7/start.S |   12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm/cpu/armv7/start.S +12 -0
index 52f7f6e..5098f7b 100644
@@ -277,6 +277,18 @@ jump_2_ram:
 	mcr     p15, 0, r0, c7, c10, 4	@ DSB
 	mcr     p15, 0, r0, c7, c5, 4	@ ISB
 #endif
+/*
+ * Move vector table
+ */
+#if !defined(CONFIG_TEGRA2)
+#if !(defined(CONFIG_OMAP44XX) && defined(CONFIG_SPL_BUILD))
+	/* Set vector address in CP15 VBAR register */
+	ldr     r0, =_start
+	add     r0, r0, r9
+	mcr     p15, 0, r0, c12, c0, 0  @Set VBAR
+#endif
+#endif /* !Tegra2 */
+	
 	ldr	r0, _board_init_r_ofs
 	adr	r1, _start
 	add	lr, r0, r1
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 arm: bugfix: Move vector table before jumping relocated code

Quoted 6 lines · Tetsuyuki Kobayashi

Interrupts and exceptions doesn't work in relocated code. It badly use IRQ_STACK_START_IN in rom area as interrupt stack. It is because the vecotr table is not moved to ram area. This patch moves vector table before jumping relocated code.

CC'ing in some Tegra people.

Tetsuyuki, you probably want to CC some OMAP people too.

Quoted 27 lines
---
 arch/arm/cpu/armv7/start.S |   12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm/cpu/armv7/start.S +12 -0
index 52f7f6e..5098f7b 100644
@@ -277,6 +277,18 @@ jump_2_ram:
 	mcr     p15, 0, r0, c7, c10, 4	@ DSB
 	mcr     p15, 0, r0, c7, c5, 4	@ ISB
 #endif
+/*
+ * Move vector table
+ */
+#if !defined(CONFIG_TEGRA2)
+#if !(defined(CONFIG_OMAP44XX) && defined(CONFIG_SPL_BUILD))
+	/* Set vector address in CP15 VBAR register */
+	ldr     r0, =_start
+	add     r0, r0, r9
+	mcr     p15, 0, r0, c12, c0, 0  @Set VBAR
+#endif
+#endif /* !Tegra2 */
+	
 	ldr	r0, _board_init_r_ofs
 	adr	r1, _start
 	add	lr, r0, r1
#2 lore raw

PATCH 1/1 arm: bugfix: Move vector table before jumping relocated code

Hello,

Quoted 11 lines · Stephen Warren
Quoted 6 lines · Tetsuyuki Kobayashi

Interrupts and exceptions doesn't work in relocated code. It badly use IRQ_STACK_START_IN in rom area as interrupt stack. It is because the vecotr table is not moved to ram area. This patch moves vector table before jumping relocated code.

CC'ing in some Tegra people.

Tetsuyuki, you probably want to CC some OMAP people too.

Thank you.
I don't know proper person to CC because I am very new in this ML. I need some help ..

'#if condition' in my patch is the same as the code setting VBAR right after reset. (in file arch/arm/cpu/armv7/start.S)

Quoted 30 lines
Quoted 28 lines
---
 arch/arm/cpu/armv7/start.S |   12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm/cpu/armv7/start.S +12 -0
index 52f7f6e..5098f7b 100644
@@ -277,6 +277,18 @@ jump_2_ram:
 	mcr     p15, 0, r0, c7, c10, 4	@ DSB
 	mcr     p15, 0, r0, c7, c5, 4	@ ISB
 #endif
+/*
+ * Move vector table
+ */
+#if !defined(CONFIG_TEGRA2)
+#if !(defined(CONFIG_OMAP44XX) && defined(CONFIG_SPL_BUILD))
+	/* Set vector address in CP15 VBAR register */
+	ldr     r0, =_start
+	add     r0, r0, r9
+	mcr     p15, 0, r0, c12, c0, 0  @Set VBAR
+#endif
+#endif /* !Tegra2 */
+	
 	ldr	r0, _board_init_r_ofs
 	adr	r1, _start
 	add	lr, r0, r1
#3 lore raw

PATCH 1/1 arm: bugfix: Move vector table before jumping relocated code

Quoted 13 lines · Tetsuyuki Kobayashi

Hello,

Quoted 10 lines · Stephen Warren
Quoted 6 lines · Tetsuyuki Kobayashi

Interrupts and exceptions doesn't work in relocated code. It badly use IRQ_STACK_START_IN in rom area as interrupt stack. It is because the vecotr table is not moved to ram area. This patch moves vector table before jumping relocated code.

CC'ing in some Tegra people.

Quoted 8 lines
Quoted 1 line

Tetsuyuki, you probably want to CC some OMAP people too.

Thank you.
I don't know proper person to CC because I am very new in this ML. I need some help ..

'#if condition' in my patch is the same as the code setting VBAR right after reset. (in file arch/arm/cpu/armv7/start.S)

I imagine the primary ARM custodian and the TI ARM sub-arch custodian (both now CC'd) would be a good place to start. You'd need to CC them anyway in order to get this patch checked in.

Quoted 31 lines
Quoted 29 lines
Quoted 27 lines
---
 arch/arm/cpu/armv7/start.S |   12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm/cpu/armv7/start.S +12 -0
index 52f7f6e..5098f7b 100644
@@ -277,6 +277,18 @@ jump_2_ram:
 	mcr     p15, 0, r0, c7, c10, 4	@ DSB
 	mcr     p15, 0, r0, c7, c5, 4	@ ISB
 #endif
+/*
+ * Move vector table
+ */
+#if !defined(CONFIG_TEGRA2)
+#if !(defined(CONFIG_OMAP44XX) && defined(CONFIG_SPL_BUILD))
+	/* Set vector address in CP15 VBAR register */
+	ldr     r0, =_start
+	add     r0, r0, r9
+	mcr     p15, 0, r0, c12, c0, 0  @Set VBAR
+#endif
+#endif /* !Tegra2 */
+	
 	ldr	r0, _board_init_r_ofs
 	adr	r1, _start
 	add	lr, r0, r1
#4 lore raw

PATCH 1/1 arm: bugfix: Move vector table before jumping relocated code

Hi Tetsuyuki, Stephen,

Quoted 20 lines · Stephen Warren
Quoted 19 lines · Tetsuyuki Kobayashi

Hello,

Quoted 11 lines · Stephen Warren
Quoted 6 lines · Tetsuyuki Kobayashi

Interrupts and exceptions doesn't work in relocated code. It badly use IRQ_STACK_START_IN in rom area as interrupt stack. It is because the vecotr table is not moved to ram area. This patch moves vector table before jumping relocated code.

CC'ing in some Tegra people.

Tetsuyuki, you probably want to CC some OMAP people too.

Thank you.
I don't know proper person to CC because I am very new in this ML. I need some help ..

Quoted 6 lines
Quoted 2 lines

'#if condition' in my patch is the same as the code setting VBAR right after reset. (in file arch/arm/cpu/armv7/start.S)

I imagine the primary ARM custodian and the TI ARM sub-arch custodian (both now CC'd) would be a good place to start. You'd need to CC them anyway in order to get this patch checked in.

I'll pull this in as soon as atmel and marvell pull reqs are in.

Amicalement,

Signature · 1 line
Albert.
#5 lore raw

PATCH 1/1 arm: bugfix: Move vector table before jumping relocated code

In reply to Tetsuyuki Kobayashi
Quoted 23 lines · Tetsuyuki Kobayashi

Interrupts and exceptions doesn't work in relocated code. It badly use IRQ_STACK_START_IN in rom area as interrupt stack. It is because the vecotr table is not moved to ram area. This patch moves vector table before jumping relocated code.

---
 arch/arm/cpu/armv7/start.S |   12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm/cpu/armv7/start.S +5 -0
index 52f7f6e..5098f7b 100644
@@ -277,6 +277,18 @@ jump_2_ram:
 	mcr     p15, 0, r0, c7, c10, 4	@ DSB
 	mcr     p15, 0, r0, c7, c5, 4	@ ISB
 #endif
+/*
+ * Move vector table
+ */
+#if !defined(CONFIG_TEGRA2)
+#if !(defined(CONFIG_OMAP44XX) && defined(CONFIG_SPL_BUILD))

arch/arm/cpu/armv7/start.S jump_2_ram: · line 294

Quoted 10 lines
arch/arm/cpu/armv7/start.S +7 -0
+	/* Set vector address in CP15 VBAR register */
+	ldr     r0, =_start
+	add     r0, r0, r9
+	mcr     p15, 0, r0, c12, c0, 0  @Set VBAR
+#endif
+#endif /* !Tegra2 */
+	
 	ldr	r0, _board_init_r_ofs
 	adr	r1, _start
 	add	lr, r0, r1

I think this code should get boot tested on a few platforms to make sure it's OK. As such, I've tried on am335x and omap3 and they're still fine.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120627/3f0f19cb/attachment.pgp>
#6 lore raw

PATCH 1/1 arm: bugfix: Move vector table before jumping relocated code

Hi Tom and all,

Quoted 40 lines · Tom Rini
Quoted 23 lines · Tetsuyuki Kobayashi

Interrupts and exceptions doesn't work in relocated code. It badly use IRQ_STACK_START_IN in rom area as interrupt stack. It is because the vecotr table is not moved to ram area. This patch moves vector table before jumping relocated code.

---
  arch/arm/cpu/armv7/start.S |   12 ++++++++++++
  1 file changed, 12 insertions(+)
arch/arm/cpu/armv7/start.S +5 -0
index 52f7f6e..5098f7b 100644
@@ -277,6 +277,18 @@ jump_2_ram:
  	mcr     p15, 0, r0, c7, c10, 4	@ DSB
  	mcr     p15, 0, r0, c7, c5, 4	@ ISB
  #endif
+/*
+ * Move vector table
+ */
+#if !defined(CONFIG_TEGRA2)
+#if !(defined(CONFIG_OMAP44XX)&&  defined(CONFIG_SPL_BUILD))

arch/arm/cpu/armv7/start.S jump_2_ram: · line 294

Quoted 10 lines
arch/arm/cpu/armv7/start.S +7 -0
+	/* Set vector address in CP15 VBAR register */
+	ldr     r0, =_start
+	add     r0, r0, r9
+	mcr     p15, 0, r0, c12, c0, 0  @Set VBAR
+#endif
+#endif /* !Tegra2 */
+	
  	ldr	r0, _board_init_r_ofs
  	adr	r1, _start
  	add	lr, r0, r1

I think this code should get boot tested on a few platforms to make sure it's OK. As such, I've tried on am335x and omap3 and they're still fine.

Quoted 2 lines

Tom, thank you for testing.

Easy way to test this patch.
Jump any bad address using go command on U-boot prompt.

Good restult:

Quoted 1 line

go 0x0badc0de

## Starting application at 0x0BADC0DE ...
undefined instruction

pc : [<0badc0e0>]          lr : [<5ff91354>]

sp : 5feefb98 ip : 0000001c fp : 5feefbdd
r10: 00000002 r9 : 5feefbdd r8 : 5feeff68
r7 : 5feeff14 r6 : 0badc0de r5 : 5feefed4 r4 : 00000002
r3 : 0badc0de r2 : 5feefed4 r1 : 5feefed4 r0 : 00000001
Flags: nZCv IRQs off FIQs off Mode SVC_32
Resetting CPU ...

resetting ...

Bad result:

Quoted 1 line

go 0x0badc0de

(.. hang up without any crash dump.)

#7 lore raw

PATCH 1/1 arm: bugfix: Move vector table before jumping relocated code

Hi Tesuyuki and friends,

I had a question with this patch.

Quoted 21 lines · Tetsuyuki Kobayashi
Quoted 21 lines
Quoted 21 lines

This patch moves vector table before jumping relocated code.

---
  arch/arm/cpu/armv7/start.S |   12 ++++++++++++
  1 file changed, 12 insertions(+)
arch/arm/cpu/armv7/start.S +5 -0
index 52f7f6e..5098f7b 100644
@@ -277,6 +277,18 @@ jump_2_ram:
        mcr     p15, 0, r0, c7, c10, 4  @ DSB
        mcr     p15, 0, r0, c7, c5, 4   @ ISB
  #endif
+/*
+ * Move vector table
+ */
+#if !defined(CONFIG_TEGRA2)
+#if !(defined(CONFIG_OMAP44XX)&&  defined(CONFIG_SPL_BUILD))
 
Quoted 5 lines
Quoted 5 lines

arch/arm/cpu/armv7/start.S jump_2_ram: · line 289

Quoted 5 lines
arch/arm/cpu/armv7/start.S +5 -0
+       /* Set vector address in CP15 VBAR register */
+       ldr     r0, =_start
+       add     r0, r0, r9
+       mcr     p15, 0, r0, c12, c0, 0  @Set VBAR
+#endif

Why is c12 (VBAR) setup only for SPL builds? Because main u-boot does relocation too, shouldn't we setup c12 to point to new table addr after relocation?

Also how do interrupts (irq/fiq) work at all in U-boot if c12 is not setup to point to the new vector table address after relocation?

Thanks,
Joel

#8 lore raw

PATCH 1/1 arm: bugfix: Move vector table before jumping relocated code

Hello, Joel

Quoted 26 lines · Joel A Fernandes

Hi Tesuyuki and friends,

I had a question with this patch.

Quoted 21 lines · Tetsuyuki Kobayashi
Quoted 21 lines
Quoted 21 lines

This patch moves vector table before jumping relocated code.

---
   arch/arm/cpu/armv7/start.S |   12 ++++++++++++
   1 file changed, 12 insertions(+)
arch/arm/cpu/armv7/start.S +5 -0
index 52f7f6e..5098f7b 100644
@@ -277,6 +277,18 @@ jump_2_ram:
         mcr     p15, 0, r0, c7, c10, 4  @ DSB
         mcr     p15, 0, r0, c7, c5, 4   @ ISB
   #endif
+/*
+ * Move vector table
+ */
+#if !defined(CONFIG_TEGRA2)
+#if !(defined(CONFIG_OMAP44XX)&&  defined(CONFIG_SPL_BUILD))
 
Quoted 9 lines
Quoted 5 lines
Quoted 5 lines

arch/arm/cpu/armv7/start.S jump_2_ram: · line 289

Quoted 5 lines
arch/arm/cpu/armv7/start.S +5 -0
+       /* Set vector address in CP15 VBAR register */
+       ldr     r0, =_start
+       add     r0, r0, r9
+       mcr     p15, 0, r0, c12, c0, 0  @Set VBAR
+#endif

Why is c12 (VBAR) setup only for SPL builds? Because main u-boot does relocation too, shouldn't we setup c12 to point to new table addr after relocation?

You may mis-understand. ! means NOT.

#9 lore raw

PATCH 1/1 arm: bugfix: Move vector table before jumping relocated code

Quoted 45 lines · Tetsuyuki Kobayashi

Hello, Joel

Quoted 29 lines · Joel A Fernandes

Hi Tesuyuki and friends,

I had a question with this patch.

Quoted 22 lines · Tetsuyuki Kobayashi
Quoted 22 lines
Quoted 22 lines

This patch moves vector table before jumping relocated code.

---
   arch/arm/cpu/armv7/start.S |   12 ++++++++++++
   1 file changed, 12 insertions(+)
arch/arm/cpu/armv7/start.S +5 -0
index 52f7f6e..5098f7b 100644
@@ -277,6 +277,18 @@ jump_2_ram:
         mcr     p15, 0, r0, c7, c10, 4  @ DSB
         mcr     p15, 0, r0, c7, c5, 4   @ ISB
   #endif
+/*
+ * Move vector table
+ */
+#if !defined(CONFIG_TEGRA2)
+#if !(defined(CONFIG_OMAP44XX)&&  defined(CONFIG_SPL_BUILD))
 
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines

arch/arm/cpu/armv7/start.S jump_2_ram: · line 289

Quoted 5 lines
arch/arm/cpu/armv7/start.S +5 -0
+       /* Set vector address in CP15 VBAR register */
+       ldr     r0, =_start
+       add     r0, r0, r9
+       mcr     p15, 0, r0, c12, c0, 0  @Set VBAR
+#endif

Why is c12 (VBAR) setup only for SPL builds? Because main u-boot does relocation too, shouldn't we setup c12 to point to new table addr after relocation?

Quoted 1 line

You may mis-understand. ! means NOT.

Yes! Thanks for pointing it out.

Regards,
Joel

#10 lore raw

PATCH 1/1 arm: bugfix: Move vector table before jumping relocated code

In reply to Tetsuyuki Kobayashi

Hi Tetsuyuki,

Quoted 9 lines · Tetsuyuki Kobayashi

Interrupts and exceptions doesn't work in relocated code. It badly use IRQ_STACK_START_IN in rom area as interrupt stack. It is because the vecotr table is not moved to ram area. This patch moves vector table before jumping relocated code.

---
 arch/arm/cpu/armv7/start.S |   12 ++++++++++++
 1 file changed, 12 insertions(+)

Applied to u-boot-arm/master, thanks.

Amicalement,

Signature · 1 line
Albert.