linux/Documentation/x86/boot.txt specifies that:

  At entry, the CPU must be in 32-bit protected mode with paging
  disabled; a GDT must be loaded with the descriptors for selectors
  __BOOT_CS(0x10) and __BOOT_DS(0x18); both descriptors must be 4G flat
  segment; __BOOS_CS must have execute/read permission, and __BOOT_DS
  must have read/write permission; CS must be __BOOT_CS and DS, ES, SS
  must be __BOOT_DS; interrupt must be disabled; %esi must hold the base
  address of the struct boot_params; %ebp, %edi and %ebx must be zero.

In the linux_trampoline used in a 64-bit EFI target, we jump to the
contents of %edi, so that at least is certainly non-compliant with the
specification above.  I don't know about %ebp and %ebx but it would be
good to make sure.

How about the following patch?

2010-08-24  Colin Watson  <[email protected]>

        * loader/i386/linux_trampoline.S (cont2): Zero %ebp, %edi, and %ebx
        before jumping to the kernel, per the Linux 32-bit boot protocol
        specification.

=== modified file 'loader/i386/linux_trampoline.S'
--- loader/i386/linux_trampoline.S      2009-06-10 21:04:23 +0000
+++ loader/i386/linux_trampoline.S      2010-08-24 14:50:21 +0000
@@ -93,8 +93,12 @@ cont2:
        .code32
 
        mov %ebx, %esi
+       mov %edi, %ecx
+       xor %ebp, %ebp
+       xor %edi, %edi
+       xor %ebx, %ebx
 
-       jmp *%edi
+       jmp *%ecx
 
        /* GDT. */
        .p2align 4

-- 
Colin Watson                                       [[email protected]]

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to