[PATCH 02/16] mips: add support to restore exception vector base before booting linux

Weijie Gao weijie.gao at mediatek.com
Thu Jan 9 09:28:16 CET 2020


On Wed, 2020-01-08 at 15:29 +0100, Daniel Schwierzeck wrote:
> 
> Am 08.01.20 um 04:00 schrieb Weijie Gao:
> > In U-Boot the exception vector base will be moved to top of memory, to be
> > used to display register dump when exception occurs.
> > 
> > But some old linux kernel does not honor the base set in CP0_EBASE. A
> > modified exception vector base will cause kernel crash.
> > 
> > This patch adds an option to enable reset exception vector base to
> > 0x80000000 before booting linux kernel.
> > 
> > Signed-off-by: Weijie Gao <weijie.gao at mediatek.com>
> > ---
> >  arch/mips/Kconfig     | 13 +++++++++++++
> >  arch/mips/lib/bootm.c |  9 +++++++++
> >  2 files changed, 22 insertions(+)
> > 
> > diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> > index a3ae603044..4688717593 100644
> > --- a/arch/mips/Kconfig
> > +++ b/arch/mips/Kconfig
> > @@ -287,6 +287,19 @@ config MIPS_RELOCATION_TABLE_SIZE
> >  
> >  	  If unsure, leave at the default value.
> >  
> > +config RESTORE_EXCEPTION_VECTOR_BASE
> > +	bool "Restore exception vector base before booting linux kernel"
> > +	default n
> > +	help
> > +	  In U-Boot the exception vector base will be moved to top of memory,
> > +	  to be used to display register dump when exception occurs.
> > +	  But some old linux kernel does not honor the base set in CP0_EBASE.
> > +	  A modified exception vector base will cause kernel crash.
> > +
> > +	  This option will set exception vector base to 0x80000000.
> 
> Does it make sense to make the base address configurable and let it
> default to 0x80000000?
> 
> > +
> > +	  If unsure, say N.
> > +
> >  endmenu
> >  
> >  menu "OS boot interface"
> > diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
> > index 8c0d7672f2..86ea082fd0 100644
> > --- a/arch/mips/lib/bootm.c
> > +++ b/arch/mips/lib/bootm.c
> > @@ -294,6 +294,15 @@ static void boot_jump_linux(bootm_headers_t *images)
> >  	bootstage_report();
> >  #endif
> >  
> > +#ifdef CONFIG_RESTORE_EXCEPTION_VECTOR_BASE
> > +	/* Restore EBASE for compatibility */
> > +	set_c0_status(ST0_BEV);
> > +	execution_hazard_barrier();
> > +	write_c0_ebase(KSEG0);
> > +	clear_c0_status(ST0_BEV);
> > +	execution_hazard_barrier();
> > +#endif
> > +
> 
> could you move this to a function trap_restore() in arch/mips/lib/traps.c?
> 
> Also prefer the following over #ifdef:
> 
>     if (CONFIG_IS_ENABLED(RESTORE_EXCEPTION_VECTOR_BASE))
>         trap_restore();
> 
> Alternatively you could simply define trap_restore() as empty static
> inline function if RESTORE_EXCEPTION_VECTOR_BASE is disabled.
> 
> >  	if (images->ft_len)
> >  		kernel(-2, (ulong)images->ft_addr, 0, 0);
> >  	else
> > 
> 

Hi Daniel,

0x80000000 is the power-on value of EBASE. I think there is no need to
change it to a different value.

For the rest parts, I'll take your advice.

Best Regards,

Weijie



More information about the U-Boot mailing list