x86: Switch to protected_mode_call_1arg for correct argument passing

The payload execution process has been updated to utilize
protected_mode_call_1arg in order to guarantee proper handling of
function parameters.

The previous use of protected_mode_jump with a "jmp" instruction did
not allow for proper stack setup for argument passing, as the calling
convention was not aligned with the System V ABI calling convention.

This patch ensures that calling into the libpayload entry point using
protected mode is now aligned with the System V ABI calling convention.

This resolves an issue where retrieving the "pointer to coreboot tables"
from within the libpayload entry point was failing due to incorrect
argument passing.

BUG=b:332759882
TEST=Built and booted 64-bit coreboot with 32-bit payload successfully.

Change-Id: Ibd522544ad1e9deed6a11015b0c0e95265bda8eb
Signed-off-by: Subrata Banik <subratabanik@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/82294
Reviewed-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nick Vaccaro <nvaccaro@google.com>
This commit is contained in:
Subrata Banik 2024-05-12 10:24:14 +00:00 committed by Felix Held
parent 94d50bbe2a
commit 06b25c26a1

View File

@ -4,6 +4,7 @@
#include <arch/cpu.h>
#include <commonlib/helpers.h>
#include <console/console.h>
#include <mode_switch.h>
#include <program_loading.h>
#include <symbols.h>
#include <assert.h>
@ -26,7 +27,7 @@ void arch_prog_run(struct prog *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);
protected_mode_call_1arg((void *)(uintptr_t)entry, arg);
#else
#if ENV_X86_64
void (*doit)(void *arg);