All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yoshinori K. Okuji" <okuji@enbug.org>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: loader modules jumping back to kernel
Date: Sun, 20 Jul 2008 11:09:02 +0200	[thread overview]
Message-ID: <200807201109.03173.okuji@enbug.org> (raw)
In-Reply-To: <20080719230622.GA17043@thorin>

On Sunday 20 July 2008 01:06:22 Robert Millan wrote:
> Anyone recalls the reason our loaders had to jump back to kernel
> (startup.S) to do the final part of the load?

Not all of them should do that, but it might be more convenient. I look at one 
by one:

- The chainloader needs to get back the original state (e.g. A20 disabled), so 
the final code must be located at below 1MB. Since the address of the startup 
code is well known, it is easier to use.

- The linux loader does not have to overwrite the startup code, but other 
regions can be. So it is easier to use.

- The multiboot loader had, historically speaking, a limitation that it may 
not load an OS image below 1MB. So it was easier to use. But I don't remember 
if this limitation is still present in the current implementation.

> IIRC this causes trouble when the loadee chose an address that precisely
> overwrites the loader, which is garanteed to happen when GRUB is loading
> itself, AFAICT.

Sure. My recommendation is, in case where you might overwrite that part, that 
you should write relocatable code (which is rather easy for simple code on 
i386) at anywhere (it could be in the startup), find out a safe region when 
loading an OS image, copy the code to the safe region, and finalize the 
bootstrap in that code (e.g. relocating the OS image, initializing registers, 
and jumping to it). On i386, we have a reserved region to temporarily load an 
OS image for the very reason, so this is not difficult.

Regards,
Okuji



  parent reply	other threads:[~2008-07-20  9:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-19 23:06 loader modules jumping back to kernel Robert Millan
2008-07-20  3:26 ` Bean
2008-07-20  9:09 ` Yoshinori K. Okuji [this message]
2008-07-27 21:39   ` Robert Millan
2008-07-30 19:15     ` loadee relocation (Re: loader modules jumping back to kernel) Robert Millan
2008-07-31 23:45       ` Robert Millan
2008-08-01 16:16         ` Robert Millan
2008-08-01 22:45           ` Robert Millan
2008-08-02 12:11             ` Robert Millan

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=200807201109.03173.okuji@enbug.org \
    --to=okuji@enbug.org \
    --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 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.