[U-Boot] [PATCH 02/11] x86: bios: Synchronize stack between real and protected mode
Simon Glass
sjg at chromium.org
Wed Jul 1 16:58:51 CEST 2015
Hi,
On 1 July 2015 at 02:27, Bin Meng <bmeng.cn at gmail.com> wrote:
> From: Jian Luo <jian.luo4 at boschrexroth.de>
>
> PCI option rom may use different SS during its execution, so it is not
> safe to assume esp pointed to the same location in the protected mode.
>
> Signed-off-by: Jian Luo <jian.luo4 at boschrexroth.de>
> Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
> Tested-by: Bin Meng <bmeng.cn at gmail.com>
> ---
>
> arch/x86/lib/bios_asm.S | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/arch/x86/lib/bios_asm.S b/arch/x86/lib/bios_asm.S
> index 4faa70e..a29fe0e 100644
> --- a/arch/x86/lib/bios_asm.S
> +++ b/arch/x86/lib/bios_asm.S
> @@ -246,6 +246,8 @@ __interrupt_handler_16bit = PTR_TO_REAL_MODE(.)
> push %fs
> push %gs
>
> + movw %ss, %cs:__realmode_ss
> +
> /* Clear DF to not break ABI assumptions */
> cld
>
> @@ -258,12 +260,22 @@ __interrupt_handler_16bit = PTR_TO_REAL_MODE(.)
>
> enter_protected_mode
>
Please can you add a comment here for the next person who changes
this, about what is going on? It looks like it is saving and restoring
the real mode SS register?
> + movzwl %cs:__realmode_ss, %ecx
> + shll $4, %ecx
> + addl %ecx, %esp
> +
> /* Call the C interrupt handler */
> movl $interrupt_handler, %eax
> call *%eax
>
> + movzwl %cs:__realmode_ss, %ecx
> + shll $4, %ecx
> + subl %ecx, %esp
> +
> enter_real_mode
>
> + movw %cs:__realmode_ss, %ss
> +
> /*
> * Restore all registers, including those manipulated by the C
> * handler
> @@ -276,6 +288,9 @@ __interrupt_handler_16bit = PTR_TO_REAL_MODE(.)
> popal
> iret
>
> +__realmode_ss = PTR_TO_REAL_MODE(.)
> + .word 0
> +
> .globl asm_realmode_code_size
> asm_realmode_code_size:
> .long . - asm_realmode_code
> --
> 1.8.2.1
>
Regards,
Simon
More information about the U-Boot
mailing list