All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Zero some registers in linux_trampoline
@ 2010-08-24 14:53 Colin Watson
  0 siblings, 0 replies; only message in thread
From: Colin Watson @ 2010-08-24 14:53 UTC (permalink / raw)
  To: grub-devel

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  <cjwatson@ubuntu.com>

	* 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                                       [cjwatson@ubuntu.com]


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-08-24 14:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-24 14:53 [PATCH] Zero some registers in linux_trampoline Colin Watson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.