Subrata Banik has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/81960?usp=email )
Change subject: arch/x86: Enable long mode entry into payload for x86_64 support ......................................................................
arch/x86: Enable long mode entry into payload for x86_64 support
This patch allows coreboot to enter libpayload in long mode (64-bit) instead of protected mode (32-bit), enabling support for upcoming Intel platforms and payloads requiring access to memory beyond 4GB.
This change ensures compatibility between libpayload and depthcharge, preventing compilation issues and stack misalignment during the transition.
Introduces a new Kconfig named `PAYLOAD_X86_64_SUPPORT` to ensure user can specify the intention to enter into payload in 64-bit without trunking into 32-bit mode.
BUG=b:242829490 TEST=Entered libpayload in long mode, successfully parsed coreboot table.
Change-Id: Ic5e6f0af11c05e8b075b8c20880c012747a1df9b Signed-off-by: Subrata Banik subratabanik@google.com --- M src/arch/x86/Kconfig M src/arch/x86/boot.c 2 files changed, 23 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/60/81960/1
diff --git a/src/arch/x86/Kconfig b/src/arch/x86/Kconfig index 7d25561..aeb2670 100644 --- a/src/arch/x86/Kconfig +++ b/src/arch/x86/Kconfig @@ -81,6 +81,18 @@ usual protected flat (32-bit) mode. 64-bit CPUs and OSes can be used irrespective of whether coreboot runs in 32-bit or 64-bit mode.
+config PAYLOAD_X86_64_SUPPORT + bool + depends on HAVE_X86_64_SUPPORT + help + Enable this option to load and run payloads in 64-bit mode (also known as "long mode"). + + This has the following effects: + * **Libpayload:** Operates in 64-bit mode. + * **Payloads:** Allows the use of 64-bit payloads (e.g., deptcharge requires 64-bit mode). + + If unsure, leave this option disabled (default is 32-bit mode). + config PAGE_TABLES_IN_CBFS bool default n diff --git a/src/arch/x86/boot.c b/src/arch/x86/boot.c index 90af84f..d3ae40a 100644 --- a/src/arch/x86/boot.c +++ b/src/arch/x86/boot.c @@ -22,11 +22,18 @@ void arch_prog_run(struct prog *prog) { #if ENV_RAMSTAGE && ENV_X86_64 - const uint32_t arg = pointer_to_uint32_safe(prog_entry_arg(prog)); - const uint32_t entry = pointer_to_uint32_safe(prog_entry(prog)); + if (CONFIG(PAYLOAD_X86_64_SUPPORT)) { + void (*doit)(void *arg); + doit = prog_entry(prog); + /* coreboot is loading payload in long mode */ + doit(prog_entry_arg(prog)); + } else { + const uint32_t arg = pointer_to_uint32_safe(prog_entry_arg(prog)); + const uint32_t entry = pointer_to_uint32_safe(prog_entry(prog));
- /* On x86 coreboot payloads expect to be called in protected mode */ - protected_mode_jump(entry, arg); + /* On x86 coreboot payloads expect to be called in protected mode */ + protected_mode_jump(entry, arg); + } #else #if ENV_X86_64 void (*doit)(void *arg);