[U-Boot] [PATCH] arm: fix exception vectors

Albert ARIBAUD albert.u.boot at aribaud.net
Mon Jan 19 11:28:20 CET 2015


Hello Luca,

On Mon, 19 Jan 2015 11:11:34 +0100, Luca Ellero
<luca.ellero at brickedbrain.com> wrote:
> Hi Albert,
> 
> On 17/01/2015 07:40, Albert ARIBAUD wrote:
> > Hello Luca,
> >
> > On Mon, 29 Dec 2014 16:10:53 +0100, Luca Ellero
> > <luca.ellero at brickedbrain.com> wrote:
> >> After relocation, exception vectors still point to the old code (not relocated).
> >> This patch fixes them.
> >>
> >> Signed-off-by: Luca Ellero <luca.ellero at brickedbrain.com>
> >> ---
> >>   arch/arm/lib/relocate.S |   15 +++++++++++++++
> >>   1 file changed, 15 insertions(+)
> >>
> >> diff --git a/arch/arm/lib/relocate.S b/arch/arm/lib/relocate.S
> >> index 92f5314..4186344 100644
> >> --- a/arch/arm/lib/relocate.S
> >> +++ b/arch/arm/lib/relocate.S
> >> @@ -76,6 +76,21 @@ copy_loop:
> >>   	blo	copy_loop
> >>
> >>   	/*
> >> +	 * fix exception vectors
> >> +	 */
> >> +	ldr r2, =_undefined_instruction
> >> +	ldr r3, =_fiq
> >> +	add	r2, r2, r4
> >> +	add	r3, r3, r4
> >> +fix_exceptions:
> >> +	ldr r0, [r2]
> >> +	add	r0, r0, r4
> >> +	str	r0, [r2]
> >> +	cmp r2,r3
> >> +	add r2, #4
> >> +	blo fix_exceptions
> >> +
> >> +	/*
> >>   	 * fix .rel.dyn relocations
> >>   	 */
> >>   	ldr	r2, =__rel_dyn_start	/* r2 <- SRC &__rel_dyn_start */
> >> --
> >> 1.7.10.4
> >>
> >
> > There is already a mechanism to relocate vectors (do a git grep for
> > 'relocate_vectors' which takes into account various ISA and SoC cases.
> >
> > Can you describe the use case which you are encountering?
> 
> As far as I can see the mechanism to relocate vectors is implemented 
> only on iMX25/27 and involves high vectors address (0xFFFFxxxx).

You are correct that the mechanism is /used/ only by mx25 and mx27.

However, it has been introduced to support /all/ SoCs (or even boards),
not only mx25, mx27, and /all/ exception vector handling scenarios, not
only high vectors addresses.

Actually, the standard high and low address is handled by default,
and mx25 and mx27 are cases where this default is overriden /because/
high or low vector addresses are *unapplicable* for them due to their
memory mapping.

> The problem is that, after relocation, U-Boot doesn't fix the vector 
> table addresses, they still point to the old addresses (before relocation).
> This is wrong and this patch fixes them to point to the new addresses.

You are right about the problem, and this problem is exactly what the
relocate_vectors mechanism is here to fix -- exactly the same problem
mx25 and mx27 had before we fixed it (quite recently actually, as it
was done mid-November, between 2015.01-rc1 and 2015.01-rc1 rc2).

> I had to use this patch trying to implement IRQ support for a Freescale 
> iMX6 board. iMX6 does not provide RAM at the high vectors address and 
> trying to access them leads to errors, so I couldn't use them.

This is *exactly* the case where you should define your own version of
relocate_vectors (probably at SoC level). 

> Regards
> 
> -- 
> Luca Ellero

Amicalement,
-- 
Albert.


More information about the U-Boot mailing list