From: walt <wa1ter@myrealbox.com>
To: grub-devel@gnu.org
Subject: Re: multiboot2 vs. grub2 implementation
Date: Tue, 05 Feb 2008 17:23:44 -0800 [thread overview]
Message-ID: <1202261023.460.4.camel@k9.localnet> (raw)
In-Reply-To: <20080205202322.GL1756@kirkkit.kollasch.net>
[-- Attachment #1: Type: text/plain, Size: 1302 bytes --]
On Tue, 2008-02-05 at 14:23 -0600, jakllsch@kollasch.net wrote:
> On Sun, Feb 03, 2008 at 09:11:23AM -0800, walt wrote:
> > jakllsch@kollasch.net wrote:
> >> Hi,
> >>
> >> In the course of actually trying to use the MultibootDraft, I've
> >> discovered
> >> some places where the draft and the grub2 implementation differ...
> >
> > Hi Jonathan,
> >
> > Are you using grub2/cvs with or without Bean's latest multiboot patch?
>
> I tend not to be aware of these things. I'm using stock sources.
>
> > It still hasn't been committed, and I was about to ask about it anyway.
> > Without that patch, multiboot doesn't work.
>
> Hmm.
Agreed :o) Bean's patch had some whitespace corruption anyway, so here
it is again, diffed against today's latest cvs grub2:
========================================================================
this is the patch, problems found:
1, the mbi structure is not initialized to all zeros, this means some
important member, like mods_count, will contain trash.
2, the entry point in the header is virtual address, we need to
translate it to physical address.
* loader/i386/pc/multiboot.c (grub_multiboot_load_elf32): Get
physical
address of entry.
(grub_multiboot_load_elf64): Likewise.
(grub_multiboot): Initialize mbi structure.
[-- Attachment #2: multiboot.patch --]
[-- Type: text/x-patch, Size: 1713 bytes --]
Index: loader/i386/pc/multiboot.c
===================================================================
RCS file: /sources/grub/grub2/loader/i386/pc/multiboot.c,v
retrieving revision 1.15
diff -u -r1.15 multiboot.c
--- loader/i386/pc/multiboot.c 2 Jan 2008 11:55:23 -0000 1.15
+++ loader/i386/pc/multiboot.c 6 Feb 2008 01:16:26 -0000
@@ -96,6 +96,7 @@
{
Elf32_Ehdr *ehdr = (Elf32_Ehdr *) buffer;
Elf32_Phdr *phdr;
+ grub_addr_t real_entry = 0;
int i;
if (ehdr->e_ident[EI_CLASS] != ELFCLASS32)
@@ -144,9 +145,16 @@
if (phdr->p_filesz < phdr->p_memsz)
grub_memset ((char *) phdr->p_paddr + phdr->p_filesz, 0,
phdr->p_memsz - phdr->p_filesz);
+
+ if ((entry >= phdr->p_vaddr) &&
+ (entry < phdr->p_vaddr + phdr->p_memsz))
+ real_entry = entry + phdr->p_paddr - phdr->p_vaddr;
}
}
-
+
+ if (real_entry)
+ entry = real_entry;
+
return grub_errno;
}
@@ -164,6 +172,7 @@
{
Elf64_Ehdr *ehdr = (Elf64_Ehdr *) buffer;
Elf64_Phdr *phdr;
+ grub_addr_t real_entry = 0;
int i;
if (ehdr->e_ident[EI_CLASS] != ELFCLASS64)
@@ -226,9 +235,16 @@
+ phdr->p_filesz),
0,
phdr->p_memsz - phdr->p_filesz);
+
+ if ((entry >= phdr->p_vaddr) &&
+ (entry < phdr->p_vaddr + phdr->p_memsz))
+ real_entry = entry + phdr->p_paddr - phdr->p_vaddr;
}
}
-
+
+ if (real_entry)
+ entry = real_entry;
+
return grub_errno;
}
@@ -306,6 +322,8 @@
if (! mbi)
goto fail;
+ grub_memset (mbi, 0, sizeof (struct grub_multiboot_info));
+
mbi->flags = MULTIBOOT_INFO_MEMORY;
/* Convert from bytes to kilobytes. */
next prev parent reply other threads:[~2008-02-06 1:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-03 16:39 multiboot2 vs. grub2 implementation jakllsch
2008-02-03 17:11 ` walt
2008-02-05 20:23 ` jakllsch
2008-02-06 1:23 ` walt [this message]
2008-02-06 12:14 ` Robert Millan
2008-02-06 15:18 ` Bean
2008-02-06 15:33 ` Robert Millan
2008-02-06 16:48 ` 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=1202261023.460.4.camel@k9.localnet \
--to=wa1ter@myrealbox.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 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.