[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Multiboot 2 Header Alignment: implementation contradicts specificati
From: |
Hans Ulrich Niedermann |
Subject: |
Re: Multiboot 2 Header Alignment: implementation contradicts specification |
Date: |
Sat, 23 May 2020 22:26:46 +0200 |
On Sat, 23 May 2020 21:24:32 +0200
Jacob Paul via Grub-devel <address@hidden> wrote:
> On 2020-05-23 20:33, Hans Ulrich Niedermann wrote:
> > The comment is valid for MB1, but not for MB2. Both regarding the
> > alignment and regarding the size. And regarding the size, this
> > actually means there is a bug in the code here: An MB2 header is at
> > least 16 bytes for the header magic plus at least 8 bytes for the
> > mb2 header termination tag. That adds up to 24 bytes for MB2, not
> > 12 bytes as it did for MB1.
>
> I see, so there is at least that. Might be a good idea to fix it.
See separate patch:
Subject: [PATCH] mb2 loader: Fix header size, alignment for Multiboot 2
> > I fear you have missed that bytes and grub_uint32_t array elements
> > are not the same size.
>
> I unfortunately did not notice the (grub_uint32_t *), I apologize for
> assuming that it increments by 2 bytes and not u32's. Wouldn't it be
> a lot cleaner if it just incremented it in bytes instead, since you
> could then also remove the division by 4 and the cast? It wouldn't
> make any difference runtime wise, just a bit easier to read.
And it could be the same code as is in use elsewhere, namely in the
Multiboot 1 loader.
I have put that into a separate RFC patch:
Subject: [PATCH RFC] mb2 loader: Use the same iteration code for MB2 as for MB1