From 41e885947e4f48aae0866df9e5fee657afb7c1cc Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Fri, 14 May 2021 15:43:00 -0700 Subject: [PATCH] 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 --- arch/x86/core/prep_c.c | 2 +- tests/arch/x86/info/CMakeLists.txt | 2 +- tests/arch/x86/info/prj.conf | 1 + tests/arch/x86/info/src/main.c | 5 +++++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/x86/core/prep_c.c b/arch/x86/core/prep_c.c index 630a9735c08..5fca80069cf 100644 --- a/arch/x86/core/prep_c.c +++ b/arch/x86/core/prep_c.c @@ -39,7 +39,7 @@ FUNC_NORETURN void z_x86_prep_c(void *arg) 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 a6c41c64c9f..3c0718d389a 100644 --- a/tests/arch/x86/info/CMakeLists.txt +++ b/tests/arch/x86/info/CMakeLists.txt @@ -8,6 +8,6 @@ project(x86_info) 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 1cf566c6016..c867855a08e 100644 --- a/tests/arch/x86/info/prj.conf +++ b/tests/arch/x86/info/prj.conf @@ -4,3 +4,4 @@ CONFIG_MULTIBOOT_MEMMAP=y 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 b5ac0186e3c..7fb52e01f5d 100644 --- a/tests/arch/x86/info/src/main.c +++ b/tests/arch/x86/info/src/main.c @@ -11,6 +11,11 @@ __weak void multiboot(void) 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");