diff --git a/ChangeLog b/ChangeLog index 4b1ccafd3..a12035634 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2010-09-02 Colin Watson + + Zero %ebp and %edi when entering Linux's 32-bit entry point, as + required by the boot protocol. + + * include/grub/i386/relocator.h (struct grub_relocator32_state): Add + ebp and edi members. + * grub-core/lib/i386/relocator.c (grub_relocator_boot): Handle + state.ebp and state.edi. + * grub-core/lib/i386/relocator32.S (grub_relocator32_start): Set + %ebp and %edi according to grub_relocator32_ebp and + grub_relocator32_edi respectively. + * grub-core/loader/i386/linux.c (grub_linux_boot): Zero state.ebp + and state.edi. + 2010-09-02 Vladimir Serbinenko Add i386-pc-pxe image target. diff --git a/grub-core/lib/i386/relocator.c b/grub-core/lib/i386/relocator.c index f06a6ef86..1bc4240c3 100644 --- a/grub-core/lib/i386/relocator.c +++ b/grub-core/lib/i386/relocator.c @@ -59,7 +59,9 @@ extern grub_uint32_t grub_relocator32_ecx; extern grub_uint32_t grub_relocator32_edx; extern grub_uint32_t grub_relocator32_eip; extern grub_uint32_t grub_relocator32_esp; +extern grub_uint32_t grub_relocator32_ebp; extern grub_uint32_t grub_relocator32_esi; +extern grub_uint32_t grub_relocator32_edi; extern grub_uint8_t grub_relocator64_start; extern grub_uint8_t grub_relocator64_end; @@ -165,7 +167,9 @@ grub_relocator32_boot (struct grub_relocator *rel, grub_relocator32_edx = state.edx; grub_relocator32_eip = state.eip; grub_relocator32_esp = state.esp; + grub_relocator32_ebp = state.ebp; grub_relocator32_esi = state.esi; + grub_relocator32_edi = state.edi; grub_memmove (get_virtual_current_address (ch), &grub_relocator32_start, RELOCATOR_SIZEOF (32)); diff --git a/grub-core/lib/i386/relocator32.S b/grub-core/lib/i386/relocator32.S index b581305a5..09ce56ad0 100644 --- a/grub-core/lib/i386/relocator32.S +++ b/grub-core/lib/i386/relocator32.S @@ -65,13 +65,27 @@ VARIABLE(grub_relocator32_esp) movl %eax, %esp + /* mov imm32, %eax */ + .byte 0xb8 +VARIABLE(grub_relocator32_ebp) + .long 0 + + movl %eax, %ebp + /* mov imm32, %eax */ .byte 0xb8 VARIABLE(grub_relocator32_esi) .long 0 movl %eax, %esi - + + /* mov imm32, %eax */ + .byte 0xb8 +VARIABLE(grub_relocator32_edi) + .long 0 + + movl %eax, %edi + /* mov imm32, %eax */ .byte 0xb8 VARIABLE(grub_relocator32_eax) diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index debcdb71f..9cb26a0c2 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -716,7 +716,7 @@ grub_linux_boot (void) /* FIXME. */ /* asm volatile ("lidt %0" : : "m" (idt_desc)); */ - state.ebx = 0; + state.ebp = state.edi = state.ebx = 0; state.esi = real_mode_target; state.esp = real_mode_target; state.eip = params->code32_start; diff --git a/include/grub/i386/relocator.h b/include/grub/i386/relocator.h index 891235f9b..6ff5c6631 100644 --- a/include/grub/i386/relocator.h +++ b/include/grub/i386/relocator.h @@ -26,12 +26,14 @@ struct grub_relocator32_state { grub_uint32_t esp; + grub_uint32_t ebp; grub_uint32_t eax; grub_uint32_t ebx; grub_uint32_t ecx; grub_uint32_t edx; grub_uint32_t eip; grub_uint32_t esi; + grub_uint32_t edi; }; struct grub_relocator16_state