From patchwork Wed Jan 8 03:00:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weijie Gao X-Patchwork-Id: 239231 List-Id: U-Boot discussion From: weijie.gao at mediatek.com (Weijie Gao) Date: Wed, 8 Jan 2020 11:00:55 +0800 Subject: [PATCH 02/16] mips: add support to restore exception vector base before booting linux Message-ID: <1578452455-6761-1-git-send-email-weijie.gao@mediatek.com> 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 --- 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. + + 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 + if (images->ft_len) kernel(-2, (ulong)images->ft_addr, 0, 0); else