Subject: Re: Adding Multiboot support (or not)
To: Jason Thorpe <thorpej@shagadelic.org>
From: Julio M. Merino Vidal <jmmv84@gmail.com>
List: tech-kern
Date: 02/11/2006 10:11:40
On Saturday 11 February 2006 05:08, you wrote:
> On Feb 10, 2006, at 4:51 PM, Pavel Cahyna wrote:
> > I think this bug
> > (https://savannah.gnu.org/bugs/?func=detailitem&item_id=15590) is
> > more a
> > deficiency in NetBSD. The ELF format has the ability to tell the boot
> > loader where the program should be loaded (the p_paddr field, see
> > PhysAddr
> > in the output of readelf). But the NetBSD kernel has this field set
> > to the
> > virtual address, which is incorrect. Instead of using a not very well
> > defined feature of the multiboot specification, why not use a standard
> > way? If the paddr fields are set correctly, unpatched grub (from
> > Debian
> > 3.1) can load a multiboot NetBSD kernel.
>
> Yes, I think we should use the "phys addr" field in the ELF headers
> properly.  It would allow us to get rid of a great deal of evil with
> loadfile() in libsa, too.

I was talking the other day to a friend who has messed with linker scripts
and GRUB and he faced a similar problem (he wrote a little OS kernel that
remaps itself to 0x0c000000, just as NetBSD/i386 does).

What he did was to split the code in two parts, one mapped to physical
addresses and the other mapped to virtual addresses.  This way, when the
kernel starts and before it relocates itself, all addresses are physical,
so there is no need to use that RELOC macro to relocate them.  After he
set up the page mappings, he just jumped to the second part of the code
which was properly mapped to the virtual addresses.

Maybe we'd do this to simplify the whole thing?  (I mean, to make the
startup code simpler and also to fix this issue as a side effect.)

-- 
Julio M. Merino Vidal <jmmv84@gmail.com>
The Julipedia - http://julipedia.blogspot.com/