arch/x86: Correct multiboot interpretation when building for EFI

When loaded via EFI, we obviously don't have a multiboot info pointer
available (we might have an EFI system table, but zefi doesn't pass
that through yet).  Don't try to parse the "whatever garbage was in
%rbp" as a multiboot table.

The configuration is a little clumsy, as strictly our EFI kconfig just
says we're "building for" EFI but not that we'll boot that way.  And
tests like arch/x86/info are trying to set CONFIG_MULTIBOOT=n
unconditionally, when it really should be something they detect from
devicetree or wherever.

Fixes #33545

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
diff --git a/arch/x86/core/prep_c.c b/arch/x86/core/prep_c.c
index 630a973..5fca800 100644
--- a/arch/x86/core/prep_c.c
+++ b/arch/x86/core/prep_c.c
@@ -39,7 +39,7 @@
 	x86_64_irq_init();
 #endif
 
-#ifdef CONFIG_MULTIBOOT_INFO
+#if defined(CONFIG_MULTIBOOT_INFO) && !defined(CONFIG_BUILD_OUTPUT_EFI)
 	z_multiboot_init(info);
 #else
 	ARG_UNUSED(info);
diff --git a/tests/arch/x86/info/CMakeLists.txt b/tests/arch/x86/info/CMakeLists.txt
index a6c41c6..3c0718d 100644
--- a/tests/arch/x86/info/CMakeLists.txt
+++ b/tests/arch/x86/info/CMakeLists.txt
@@ -8,6 +8,6 @@
 
 target_sources(app PRIVATE src/main.c)
 target_sources(app PRIVATE src/timer.c)
-target_sources(app PRIVATE src/memmap.c)
 target_sources_ifdef(CONFIG_ACPI app PRIVATE src/acpi.c)
 target_sources_ifdef(CONFIG_MULTIBOOT app PRIVATE src/multiboot.c)
+target_sources_ifdef(CONFIG_X86_MEMMAP app PRIVATE src/memmap.c)
diff --git a/tests/arch/x86/info/prj.conf b/tests/arch/x86/info/prj.conf
index 1cf566c..c867855 100644
--- a/tests/arch/x86/info/prj.conf
+++ b/tests/arch/x86/info/prj.conf
@@ -4,3 +4,4 @@
 CONFIG_MULTIBOOT_FRAMEBUF=y
 CONFIG_COUNTER=y
 CONFIG_COUNTER_CMOS=y
+CONFIG_X86_MEMMAP=y
diff --git a/tests/arch/x86/info/src/main.c b/tests/arch/x86/info/src/main.c
index b5ac018..7fb52e0 100644
--- a/tests/arch/x86/info/src/main.c
+++ b/tests/arch/x86/info/src/main.c
@@ -11,6 +11,11 @@
 	printk("MULTIBOOT: Not supported in this build.\n\n");
 }
 
+__weak void memmap(void)
+{
+	printk("MEMMAP: Not supported in this build.\n\n");
+}
+
 __weak void acpi(void)
 {
 	printk("ACPI: Not supported in this build.\n\n");