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.
This commit is contained in:
Colin Watson 2010-09-02 22:36:09 +01:00
parent 529cc99acf
commit 9056cbf38e
5 changed files with 37 additions and 2 deletions

View File

@ -1,3 +1,18 @@
2010-09-02 Colin Watson <cjwatson@ubuntu.com>
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 <phcoder@gmail.com>
Add i386-pc-pxe image target.

View File

@ -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));

View File

@ -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)

View File

@ -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;

View File

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