From: Weijie Gao <weijie.gao@mediatek.com>
To: u-boot@lists.denx.de
Subject: [PATCH 02/16] mips: add support to restore exception vector base before booting linux
Date: Thu, 9 Jan 2020 16:28:16 +0800 [thread overview]
Message-ID: <1578558496.5535.12.camel@mcddlt001> (raw)
In-Reply-To: <fc8a8098-c3c3-0927-525a-f21956605d9e@gmail.com>
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@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
prev parent reply other threads:[~2020-01-09 8:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-08 3:00 [PATCH 02/16] mips: add support to restore exception vector base before booting linux Weijie Gao
2020-01-08 14:29 ` Daniel Schwierzeck
2020-01-09 8:28 ` Weijie Gao [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1578558496.5535.12.camel@mcddlt001 \
--to=weijie.gao@mediatek.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox