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

Weijie Gao weijie.gao at mediatek.com
Wed Jan 8 04:00:55 CET 2020


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.
+
+	  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
-- 
2.17.1


More information about the U-Boot mailing list