* [PATCH v2 1/8] linux/arm: fix ARM Linux header layout
@ 2021-03-11 11:44 Dimitri John Ledkov
2021-03-11 15:32 ` Dimitri John Ledkov
2021-03-11 15:43 ` Paul Menzel
0 siblings, 2 replies; 8+ messages in thread
From: Dimitri John Ledkov @ 2021-03-11 11:44 UTC (permalink / raw)
To: ard.biesheuvel, The development of GNU GRUB, Daniel Kiper,
Javier Martinez Canillas, Peter Jones, Leif Lindholm
The patch from https://lists.gnu.org/archive/html/grub-devel/2020-10/msg00122.html
Is still not applied, and yet it is required to boot armhf linux
kernel in qemu OVMF with grub.
It is applied in rhboot/grub2
https://src.fedoraproject.org/rpms/grub2/blob/rawhide/f/0143-Make-linux_arm_kernel_header.hdr_offset-be-at-the-ri.patch
And it is applied in OpenSUSE too
https://build.opensuse.org/package/view_file/openSUSE:Factory/grub2/0005-Make-linux_arm_kernel_header.hdr_offset-be-at-the-ri.patch?expand=1
I want to apply it in Ubuntu too.
It is still not present in grub2 mainline, and applies cleanly.
Can it please be applied?
--
Regards,
Dimitri.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/8] linux/arm: fix ARM Linux header layout
2021-03-11 11:44 [PATCH v2 1/8] linux/arm: fix ARM Linux header layout Dimitri John Ledkov
@ 2021-03-11 15:32 ` Dimitri John Ledkov
2021-03-11 15:43 ` Paul Menzel
1 sibling, 0 replies; 8+ messages in thread
From: Dimitri John Ledkov @ 2021-03-11 15:32 UTC (permalink / raw)
To: ard.biesheuvel, The development of GNU GRUB, Daniel Kiper,
Javier Martinez Canillas, Peter Jones
On Thu, Mar 11, 2021 at 11:44 AM Dimitri John Ledkov
<dimitri.ledkov@canonical.com> wrote:
>
> The patch from https://lists.gnu.org/archive/html/grub-devel/2020-10/msg00122.html
>
> Is still not applied, and yet it is required to boot armhf linux
> kernel in qemu OVMF with grub.
>
> It is applied in rhboot/grub2
> https://src.fedoraproject.org/rpms/grub2/blob/rawhide/f/0143-Make-linux_arm_kernel_header.hdr_offset-be-at-the-ri.patch
>
> And it is applied in OpenSUSE too
> https://build.opensuse.org/package/view_file/openSUSE:Factory/grub2/0005-Make-linux_arm_kernel_header.hdr_offset-be-at-the-ri.patch?expand=1
>
> I want to apply it in Ubuntu too.
>
> It is still not present in grub2 mainline, and applies cleanly.
>
> Can it please be applied?
And to respond to
https://lists.gnu.org/archive/html/grub-devel/2020-11/msg00014.html
All of the above mentioned distros carry further patches to use
LoadImage api to boot on armhf just like arm64 loader does, and then
hdr_header/offset are being accessed and things blow up. So the header
is wrong, doesn't blow up in upstream configuration, but will once
LoadImage is used on armhf upstream too.
Please fix the header. Even when not used, it should not be a lie.
--
Regards,
Dimitri.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/8] linux/arm: fix ARM Linux header layout
2021-03-11 11:44 [PATCH v2 1/8] linux/arm: fix ARM Linux header layout Dimitri John Ledkov
2021-03-11 15:32 ` Dimitri John Ledkov
@ 2021-03-11 15:43 ` Paul Menzel
1 sibling, 0 replies; 8+ messages in thread
From: Paul Menzel @ 2021-03-11 15:43 UTC (permalink / raw)
To: Dimitri John Ledkov, ard.biesheuvel, Daniel Kiper,
Javier Martinez Canillas, Peter Jones, Leif Lindholm
Cc: grub-devel
Dear Dimitri,
Am 11.03.21 um 12:44 schrieb Dimitri John Ledkov:
> The patch from https://lists.gnu.org/archive/html/grub-devel/2020-10/msg00122.html
>
> Is still not applied, and yet it is required to boot armhf linux
> kernel in qemu OVMF with grub.
Please give the example command line, and maybe even add a test.
> It is applied in rhboot/grub2
> https://src.fedoraproject.org/rpms/grub2/blob/rawhide/f/0143-Make-linux_arm_kernel_header.hdr_offset-be-at-the-ri.patch
>
> And it is applied in OpenSUSE too
> https://build.opensuse.org/package/view_file/openSUSE:Factory/grub2/0005-Make-linux_arm_kernel_header.hdr_offset-be-at-the-ri.patch?expand=1
>
> I want to apply it in Ubuntu too.
>
> It is still not present in grub2 mainline, and applies cleanly.
>
> Can it please be applied?
I guess you could have sent v3, or kept the threading. ;-)
Kind regards,
Paul
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 0/8] linux: implement LoadFile2 initrd loading
@ 2020-10-25 13:49 Ard Biesheuvel
2020-10-25 13:49 ` [PATCH v2 1/8] linux/arm: fix ARM Linux header layout Ard Biesheuvel
0 siblings, 1 reply; 8+ messages in thread
From: Ard Biesheuvel @ 2020-10-25 13:49 UTC (permalink / raw)
To: linux-efi; +Cc: Ard Biesheuvel, grub-devel, daniel.kiper, leif
This implements the LoadFile2 initrd loading protocol, which is
essentially a callback face into the bootloader to load the initrd
data into a caller provided buffer. This means the bootloader no
longer has to contain any policy regarding where to load the initrd
(which differs between architectures and kernel versions) and no
longer has to manipulate arch specific data structures such as DT
or struct bootparams to inform the OS where the initrd resides in
memory.
Sample output from booting a recent Linux/arm64 kernel:
grub> insmod part_msdos
grub> linux (hd0,msdos1)/Image
grub> initrd (hd0,msdos1)/initrd.img
grub> boot
EFI stub: Booting Linux Kernel...
EFI stub: EFI_RNG_PROTOCOL unavailable, KASLR will be disabled
EFI stub: Generating empty DTB
EFI stub: Loaded initrd from LINUX_EFI_INITRD_MEDIA_GUID device path
EFI stub: Exiting boot services and installing virtual address map...
[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x411fd070]
Cc: grub-devel@gnu.org
Cc: daniel.kiper@oracle.com
Cc: leif@nuviainc.com
Changes since v1:
- add Leif's ack to #2, #6 and #8
- add patch #1 to fix the ARM Linux image header definition
- add patches #3, #4 and #5 to unify and reuse the COFF header loading routines
from Xen (and the absence of which from v1 was causing garbage to be read and
interpreted as the image major version)
Ard Biesheuvel (8):
linux/arm: fix ARM Linux header layout
loader/linux: permit NULL argument for argv[] in grub_initrd_load()
efi: move MS-DOS stub out of generic PE header definition
linux/arm: unify ARM/arm64 vs Xen PE/COFF header handling
linux/arm: account for COFF headers appearing at unexpected offsets
efi: add definition of LoadFile2 protocol
efi: implement LoadFile2 initrd loading protocol for Linux
linux: ignore FDT unless we need to modify it
grub-core/commands/efi/lsefi.c | 1 +
grub-core/kern/efi/efi.c | 5 +-
grub-core/loader/arm64/linux.c | 158 +++++++++++++++++---
grub-core/loader/arm64/xen_boot.c | 23 +--
grub-core/loader/efi/fdt.c | 7 +-
grub-core/loader/linux.c | 2 +-
include/grub/arm/linux.h | 8 +-
include/grub/arm64/linux.h | 4 +
include/grub/efi/api.h | 15 ++
include/grub/efi/efi.h | 4 +-
include/grub/efi/pe32.h | 5 +-
11 files changed, 185 insertions(+), 47 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/8] linux/arm: fix ARM Linux header layout
2020-10-25 13:49 [PATCH v2 0/8] linux: implement LoadFile2 initrd loading Ard Biesheuvel
@ 2020-10-25 13:49 ` Ard Biesheuvel
2020-11-04 12:11 ` Leif Lindholm
2021-03-11 16:18 ` Daniel Kiper
0 siblings, 2 replies; 8+ messages in thread
From: Ard Biesheuvel @ 2020-10-25 13:49 UTC (permalink / raw)
To: linux-efi; +Cc: Ard Biesheuvel, grub-devel, daniel.kiper, leif
The hdr_offset member of the ARM Linux image header appears at
offset 0x3c, matching the PE/COFF spec's placement of the COFF
header offset in the MS-DOS header. We're currently off by four,
so fix that.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
---
include/grub/arm/linux.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h
index 2e98a6689696..bcd5a7eb186e 100644
--- a/include/grub/arm/linux.h
+++ b/include/grub/arm/linux.h
@@ -30,7 +30,7 @@ struct linux_arm_kernel_header {
grub_uint32_t magic;
grub_uint32_t start; /* _start */
grub_uint32_t end; /* _edata */
- grub_uint32_t reserved2[4];
+ grub_uint32_t reserved2[3];
grub_uint32_t hdr_offset;
};
--
2.17.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/8] linux/arm: fix ARM Linux header layout
2020-10-25 13:49 ` [PATCH v2 1/8] linux/arm: fix ARM Linux header layout Ard Biesheuvel
@ 2020-11-04 12:11 ` Leif Lindholm
2020-11-04 12:19 ` Ard Biesheuvel
2021-03-11 16:18 ` Daniel Kiper
1 sibling, 1 reply; 8+ messages in thread
From: Leif Lindholm @ 2020-11-04 12:11 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: linux-efi, grub-devel, daniel.kiper
On Sun, Oct 25, 2020 at 14:49:34 +0100, Ard Biesheuvel wrote:
> The hdr_offset member of the ARM Linux image header appears at
> offset 0x3c, matching the PE/COFF spec's placement of the COFF
> header offset in the MS-DOS header. We're currently off by four,
> so fix that.
>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
> ---
> include/grub/arm/linux.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h
> index 2e98a6689696..bcd5a7eb186e 100644
> --- a/include/grub/arm/linux.h
> +++ b/include/grub/arm/linux.h
> @@ -30,7 +30,7 @@ struct linux_arm_kernel_header {
> grub_uint32_t magic;
> grub_uint32_t start; /* _start */
> grub_uint32_t end; /* _edata */
> - grub_uint32_t reserved2[4];
> + grub_uint32_t reserved2[3];
> grub_uint32_t hdr_offset;
How did this ever work?
/
Leif
> };
>
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/8] linux/arm: fix ARM Linux header layout
2020-11-04 12:11 ` Leif Lindholm
@ 2020-11-04 12:19 ` Ard Biesheuvel
2020-11-04 12:31 ` Leif Lindholm
0 siblings, 1 reply; 8+ messages in thread
From: Ard Biesheuvel @ 2020-11-04 12:19 UTC (permalink / raw)
To: Leif Lindholm
Cc: Ard Biesheuvel, linux-efi, The development of GNU GRUB, Daniel Kiper
On Wed, 4 Nov 2020 at 13:11, Leif Lindholm <leif@nuviainc.com> wrote:
>
> On Sun, Oct 25, 2020 at 14:49:34 +0100, Ard Biesheuvel wrote:
> > The hdr_offset member of the ARM Linux image header appears at
> > offset 0x3c, matching the PE/COFF spec's placement of the COFF
> > header offset in the MS-DOS header. We're currently off by four,
> > so fix that.
> >
> > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
> > ---
> > include/grub/arm/linux.h | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h
> > index 2e98a6689696..bcd5a7eb186e 100644
> > --- a/include/grub/arm/linux.h
> > +++ b/include/grub/arm/linux.h
> > @@ -30,7 +30,7 @@ struct linux_arm_kernel_header {
> > grub_uint32_t magic;
> > grub_uint32_t start; /* _start */
> > grub_uint32_t end; /* _edata */
> > - grub_uint32_t reserved2[4];
> > + grub_uint32_t reserved2[3];
> > grub_uint32_t hdr_offset;
>
> How did this ever work?
>
By ignoring the value of hdr_offset entirely everywhere else
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/8] linux/arm: fix ARM Linux header layout
2020-11-04 12:19 ` Ard Biesheuvel
@ 2020-11-04 12:31 ` Leif Lindholm
0 siblings, 0 replies; 8+ messages in thread
From: Leif Lindholm @ 2020-11-04 12:31 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: Ard Biesheuvel, linux-efi, The development of GNU GRUB, Daniel Kiper
On Wed, Nov 04, 2020 at 13:19:47 +0100, Ard Biesheuvel wrote:
> On Wed, 4 Nov 2020 at 13:11, Leif Lindholm <leif@nuviainc.com> wrote:
> >
> > On Sun, Oct 25, 2020 at 14:49:34 +0100, Ard Biesheuvel wrote:
> > > The hdr_offset member of the ARM Linux image header appears at
> > > offset 0x3c, matching the PE/COFF spec's placement of the COFF
> > > header offset in the MS-DOS header. We're currently off by four,
> > > so fix that.
> > >
> > > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
> > > ---
> > > include/grub/arm/linux.h | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h
> > > index 2e98a6689696..bcd5a7eb186e 100644
> > > --- a/include/grub/arm/linux.h
> > > +++ b/include/grub/arm/linux.h
> > > @@ -30,7 +30,7 @@ struct linux_arm_kernel_header {
> > > grub_uint32_t magic;
> > > grub_uint32_t start; /* _start */
> > > grub_uint32_t end; /* _edata */
> > > - grub_uint32_t reserved2[4];
> > > + grub_uint32_t reserved2[3];
> > > grub_uint32_t hdr_offset;
> >
> > How did this ever work?
> >
>
> By ignoring the value of hdr_offset entirely everywhere else
Oh, right - we only bother checking magic, doh!
/
Leif
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/8] linux/arm: fix ARM Linux header layout
2020-10-25 13:49 ` [PATCH v2 1/8] linux/arm: fix ARM Linux header layout Ard Biesheuvel
2020-11-04 12:11 ` Leif Lindholm
@ 2021-03-11 16:18 ` Daniel Kiper
1 sibling, 0 replies; 8+ messages in thread
From: Daniel Kiper @ 2021-03-11 16:18 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: linux-efi, grub-devel, leif, javierm, pjones, pmenzel, dimitri.ledkov
On Sun, Oct 25, 2020 at 02:49:34PM +0100, Ard Biesheuvel wrote:
> The hdr_offset member of the ARM Linux image header appears at
> offset 0x3c, matching the PE/COFF spec's placement of the COFF
> header offset in the MS-DOS header. We're currently off by four,
> so fix that.
>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
I was asked by Dimitri to take this patch. I double checked it. It
looks that it impacts only one grub_file_read() and one grub_dprintf().
So, there is no or minimal risk at this point and no big advantage
for upstream. Though, due to low risk, I will take it for downstream
advantage.
So, Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Until I hear any objections in an hour or so...
Daniel
> ---
> include/grub/arm/linux.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/grub/arm/linux.h b/include/grub/arm/linux.h
> index 2e98a6689696..bcd5a7eb186e 100644
> --- a/include/grub/arm/linux.h
> +++ b/include/grub/arm/linux.h
> @@ -30,7 +30,7 @@ struct linux_arm_kernel_header {
> grub_uint32_t magic;
> grub_uint32_t start; /* _start */
> grub_uint32_t end; /* _edata */
> - grub_uint32_t reserved2[4];
> + grub_uint32_t reserved2[3];
> grub_uint32_t hdr_offset;
> };
>
> --
> 2.17.1
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-03-11 16:19 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11 11:44 [PATCH v2 1/8] linux/arm: fix ARM Linux header layout Dimitri John Ledkov
2021-03-11 15:32 ` Dimitri John Ledkov
2021-03-11 15:43 ` Paul Menzel
-- strict thread matches above, loose matches on Subject: below --
2020-10-25 13:49 [PATCH v2 0/8] linux: implement LoadFile2 initrd loading Ard Biesheuvel
2020-10-25 13:49 ` [PATCH v2 1/8] linux/arm: fix ARM Linux header layout Ard Biesheuvel
2020-11-04 12:11 ` Leif Lindholm
2020-11-04 12:19 ` Ard Biesheuvel
2020-11-04 12:31 ` Leif Lindholm
2021-03-11 16:18 ` Daniel Kiper
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.