From: Colin Watson <cjwatson@ubuntu.com>
To: grub-devel@gnu.org
Subject: Re: Where in GRUB2 source code is the handover/jump to kernel code on x86?
Date: Thu, 3 Sep 2015 18:24:36 +0100 [thread overview]
Message-ID: <20150903172436.GA26838@riva.ucam.org> (raw)
In-Reply-To: <trinity-de97546c-0cce-49aa-8b77-d0a45f60d9b8-1441284585418@3capp-gmx-bs12>
On Thu, Sep 03, 2015 at 02:49:45PM +0200, deffo@gmx.de wrote:
> <html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>
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]
prev parent reply other threads:[~2015-09-03 17:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-03 12:49 Where in GRUB2 source code is the handover/jump to kernel code on x86? deffo
2015-09-03 17:24 ` Colin Watson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150903172436.GA26838@riva.ucam.org \
--to=cjwatson@ubuntu.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).