public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH 02/16] mips: add support to restore exception vector base before booting linux
@ 2020-01-08  3:00 Weijie Gao
  2020-01-08 14:29 ` Daniel Schwierzeck
  0 siblings, 1 reply; 3+ messages in thread
From: Weijie Gao @ 2020-01-08  3:00 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-09  8:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox