[PATCH v4 09/45] x86: Correct get_sp() implementation for 64-bit

Bin Meng bmeng.cn at gmail.com
Wed Jul 12 16:02:20 CEST 2023


Hi Simon,

On Mon, Jun 19, 2023 at 8:01 PM Simon Glass <sjg at chromium.org> wrote:
>
> Use an assembler implementation as is done for i386, so that the results
> are equivalent.

The commit message is confusing. It says "Correct the implementation
..." and here it says "the results are equivalent", but what was
changed here in this path does not make an equivalent change, as the
original codes returns "gd->start_addr_sp" which is not the current
stack pointer (your new code returns).

>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
> (no changes since v1)
>
>  arch/x86/lib/bootm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/lib/bootm.c b/arch/x86/lib/bootm.c
> index 61cb7bc61168..3196f9ddc2c8 100644
> --- a/arch/x86/lib/bootm.c
> +++ b/arch/x86/lib/bootm.c
> @@ -258,7 +258,7 @@ static ulong get_sp(void)
>         ulong ret;
>
>  #if CONFIG_IS_ENABLED(X86_64)
> -       ret = gd->start_addr_sp;
> +       asm("mov %%rsp, %0" : "=r"(ret) : );
>  #else
>         asm("mov %%esp, %0" : "=r"(ret) : );
>  #endif
> --

Regards,
Bin


More information about the U-Boot mailing list