diff mbox series

[v3,30/43] x86: Allow logging to be used in SPL reliably

Message ID 20230504165823.v3.30.I3ff4f57cec46d4068d7790792b6373bae7c28c0e@changeid
State Superseded
Delegated to: Bin Meng
Headers show
Series x86: Use qemu-x86_64 to boot EFI installers | expand

Commit Message

Simon Glass May 4, 2023, 10:58 p.m. UTC
When global_data is relocated, log_head moves in memory, meaning that
the items in that list point to the wrong place.

Disable logging when making the change, then reenable it afterwards, so
that logging works normally.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 arch/x86/lib/spl.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff mbox series

Patch

diff --git a/arch/x86/lib/spl.c b/arch/x86/lib/spl.c
index 8d57f98f6c1..090fa718dbf 100644
--- a/arch/x86/lib/spl.c
+++ b/arch/x86/lib/spl.c
@@ -139,9 +139,22 @@  static int x86_spl_init(void)
 	 */
 	gd->new_gd = (struct global_data *)ptr;
 	memcpy(gd->new_gd, gd, sizeof(*gd));
+
+	/*
+	 * Make sure logging is disabled when we switch, since the log system
+	 * list head will move
+	 */
+	gd->new_gd->flags &= ~GD_FLG_LOG_READY;
 	arch_setup_gd(gd->new_gd);
 	gd->start_addr_sp = (ulong)ptr;
 
+	/* start up logging again, with the new list-head location */
+	ret = log_init();
+	if (ret) {
+		log_debug("Log setup failed (err=%d)\n", ret);
+		return ret;
+	}
+
 	if (_LOG_DEBUG) {
 		ret = mtrr_list(mtrr_get_var_count(), MP_SELECT_BSP);
 		if (ret)