On Tue, 2006-10-24 at 22:48 +0200, Johan Rydberg wrote:
> Hollis Blanchard <[EMAIL PROTECTED]> writes:
> 
> >> The idea is very good. But I don't like that loaded areas are always 
> >> allocated 
> >> from the heap. GRUB has a staging area for OS images on i386-pc, and I 
> >> prefer 
> >> to load an image directly instead of consuming the heap.
> >
> > Actually I'm not using the heap, I'm just directly copying wherever
> > phdr->p_paddr says to. That's not a good thing actually; in the future
> > we should add some error checking to make sure we don't clobber GRUB
> > itself.
> 
> Have you looked at how EFI solves this?  
> 
> They keep track of all memory regions, and with each region is a
> "memory type" associated.  Whenever you allocate memory you change the
> type of the region (from "free") to some that makes sense (could be
> "loader data", "disk cache", ...). You can only allocate memory that
> is marked "conventional", meaning it is considered free.  The memory
> region database is later feed to the operating system.  We could do
> the same.
> 
> Is this case we could allocate the regions specified by the ELF image.
> If any of the allocations fail we know there is something already
> loaded there, or the image is faulty.

That's a great point. Doing a "claim" (as described in my reply to
Tristan) will return an error if the area is already claimed, so that
will accomplish the check.

On x86, the load hook will manually check to make sure the address is
within the OS load area.

-Hollis



_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to