[U-Boot] [PATCH 02/11] x86: bios: Synchronize stack between real and protected mode

Bin Meng bmeng.cn at gmail.com
Thu Jul 2 02:05:40 CEST 2015


Hi Simon,

On Wed, Jul 1, 2015 at 10:58 PM, Simon Glass <sjg at chromium.org> wrote:
> 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?
>

Will add a comment in v2.

>> +       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
>> --

Regards,
Bin


More information about the U-Boot mailing list