From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZXYFn-00017X-8M for mharc-grub-devel@gnu.org; Thu, 03 Sep 2015 13:24:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXYFk-00014n-Az for grub-devel@gnu.org; Thu, 03 Sep 2015 13:24:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXYFh-0007TH-6J for grub-devel@gnu.org; Thu, 03 Sep 2015 13:24:48 -0400 Received: from b.a.painless.aa.net.uk ([81.187.30.65]:52635) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXYFh-0007T4-0Z for grub-devel@gnu.org; Thu, 03 Sep 2015 13:24:45 -0400 Received: from 3.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.4.1.b.e.2.f.f.b.0.b.8.0.1.0.0.2.ip6.arpa ([2001:8b0:bff2:eb14::3] helo=riva.pelham.vpn.ucam.org) by a.painless.aa.net.uk with esmtps (TLSv1:AES128-SHA:128) (Exim 4.77) (envelope-from ) id 1ZXYFa-0002Fd-Dj for grub-devel@gnu.org; Thu, 03 Sep 2015 18:24:42 +0100 Received: from ns1.pelham.vpn.ucam.org ([172.20.153.2] helo=riva.ucam.org) by riva.pelham.vpn.ucam.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84) (envelope-from ) id 1ZXYFZ-0008Kv-NP for grub-devel@gnu.org; Thu, 03 Sep 2015 18:24:37 +0100 Date: Thu, 3 Sep 2015 18:24:36 +0100 From: Colin Watson To: grub-devel@gnu.org Subject: Re: Where in GRUB2 source code is the handover/jump to kernel code on x86? Message-ID: <20150903172436.GA26838@riva.ucam.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 81.187.30.65 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 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: Thu, 03 Sep 2015 17:24:49 -0000 On Thu, Sep 03, 2015 at 02:49:45PM +0200, deffo@gmx.de wrote: >
Plain-text mail would be appreciated, or at least mail with a text/plain part. > I'm looking for the line of code where GRUB2 finally jumps to kernel > code and thus hands over execution on x86 systems? I guess it's in an > assembler file since this is very low architecture stuff. I looked at > the source files in /grub-core/boot/i386/pc/*.S and found a JMP in > boot.S at line 455 but kernel_address could be the address of the > GRUB2 kernel in memory and not the linux kernel. grub_linux_boot is the top level of this. From there it gets complicated. On x86, it goes from there to grub_relocator32_boot, which (essentially) copies the code from grub-core/lib/i386/relocator32.S into a freshly-allocated area of memory and fills in some details specific to the kernel image it wants to boot. The final bit is: .byte 0xea VARIABLE(grub_relocator32_eip) .long 0 This is a JMP opcode followed by space into which the relocator fills in an instruction pointer. When that's put together, it forms the line of code you're looking for. -- Colin Watson [cjwatson@ubuntu.com]