Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1OnusN-0003hl-3m for mharc-grub-devel@gnu.org; Tue, 24 Aug 2010 10:53:23 -0400 Received: from [140.186.70.92] (port=50877 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OnusJ-0003fU-HL for grub-devel@gnu.org; Tue, 24 Aug 2010 10:53:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OnusI-0004Yk-F4 for grub-devel@gnu.org; Tue, 24 Aug 2010 10:53:19 -0400 Received: from smarthost01.mail.zen.net.uk ([212.23.3.140]:35089) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OnusI-0004Yb-3Z for grub-devel@gnu.org; Tue, 24 Aug 2010 10:53:18 -0400 Received: from [82.69.40.219] (helo=riva.pelham.vpn.ucam.org) by smarthost01.mail.zen.net.uk with esmtp (Exim 4.63) (envelope-from ) id 1OnusF-0000ff-Us for grub-devel@gnu.org; Tue, 24 Aug 2010 14:53:16 +0000 Received: from cjwatson by riva.pelham.vpn.ucam.org with local (Exim 3.36 #1 (Debian)) for grub-devel@gnu.org id 1OnusE-0001I9-00; Tue, 24 Aug 2010 15:53:14 +0100 Date: Tue, 24 Aug 2010 15:53:14 +0100 From: Colin Watson To: grub-devel@gnu.org Message-ID: <20100824145314.GN12396@riva.ucam.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-Originating-Smarthost01-IP: [82.69.40.219] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: [PATCH] Zero some registers in linux_trampoline X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2010 14:53:20 -0000 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 * 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]