Merge ~xypron/grub:disable_lf2 into ~ubuntu-core-dev/grub/+git/ubuntu:ubuntu

Proposed by Heinrich Schuchardt
Status: Merged
Merged at revision: c411c65c28035c4b7a6e5e25f04376513dd039a8
Proposed branch: ~xypron/grub:disable_lf2
Merge into: ~ubuntu-core-dev/grub/+git/ubuntu:ubuntu
Diff against target: 78 lines (+64/-0)
2 files modified
debian/patches/series (+1/-0)
debian/patches/ubuntu-disable-LOAD-FILE2-protocol-for-initrd-on-ARM.patch (+63/-0)
Reviewer Review Type Date Requested Status
dann frazier Approve
Review via email: mp+419407@code.launchpad.net

Commit message

Disable LOAD FILE2 protocol for initrd on ARM

RISC-V cannot load the initrd without the LOAD FILE2 protocol.

Currently the LOAD FILE2 protocol does not work with PXE due to a preboot
hook invoking grub_net_fini_hw().

So let's disable this for ARM until a solution has been agreed on with

To post a comment you must log in.
Revision history for this message
Julian Andres Klode (juliank) wrote :

I can't see this from the patch itself, but is the variable initialized at the declaration? Because it is set explicitly to 0 later if kernel not new enough, so I am wondering

Revision history for this message
Heinrich Schuchardt (xypron) wrote :

The variable is static. Thus it is initialized to 0.

grub-core/loader/efi/linux.c:56:
static int initrd_use_loadfile2;

Revision history for this message
dann frazier (dannf) wrote :
Download full text (11.2 KiB)

Thanks @xypron, unfortunately it isn't avoiding the arm64 issue for me (see below). I'll debug locally.

script/lexer.c:336: token 288 text [setparams]
script/script.c:50: malloc 0x401fffdd4b40
script/script.c:50: malloc 0x401fffdd4b00
script/script.c:163: arglist
script/script.c:50: malloc 0x401fffdd4aa0
script/lexer.c:336: token 289 text []
script/script.c:50: malloc 0x401fffdd48c0
script/script.c:50: malloc 0x401fffdd4880
script/lexer.c:336: token 289 text [Try or Install Ubuntu Server]
script/script.c:50: malloc 0x401fffdd4820
script/script.c:50: malloc 0x401fffdd47c0
script/lexer.c:336: token 289 text []
script/script.c:50: malloc 0x401fffdd4760
script/script.c:50: malloc 0x401fffdd4720
script/script.c:163: arglist
script/script.c:50: malloc 0x401fffdd46c0
script/lexer.c:336: token 259 text [
]
script/script.c:50: malloc 0x401fffdd4660
script/script.c:50: malloc 0x401fffdd4620
script/script.c:198: cmdline
script/script.c:50: malloc 0x401fffdd45c0
script/lexer.c:336: token 0 text []
script/script.c:50: malloc 0x401fffdd4c40
script/script.c:50: malloc 0x401fffdd4c00
script/script.c:294: append command
script/script.c:50: malloc 0x401fffdd44a0
kern/verifiers.c:214: string: setparams Try or Install Ubuntu Server, type: 2
script/script.c:65: free 0x401fffdd44a0
script/script.c:65: free 0x401fffdd4c00
script/script.c:65: free 0x401fffdd4c40
script/script.c:65: free 0x401fffdd45c0
script/script.c:65: free 0x401fffdd4620
script/script.c:65: free 0x401fffdd4660
script/script.c:65: free 0x401fffdd46c0
script/script.c:65: free 0x401fffdd4720
script/script.c:65: free 0x401fffdd4760
script/script.c:65: free 0x401fffdd47c0
script/script.c:65: free 0x401fffdd4820
script/script.c:65: free 0x401fffdd4880
script/script.c:65: free 0x401fffdd48c0
script/script.c:65: free 0x401fffdd4aa0
script/script.c:65: free 0x401fffdd4b00
script/script.c:65: free 0x401fffdd4b40
script/lexer.c:336: token 259 text [
]
script/script.c:50: malloc 0x401fffdd4b60
script/script.c:50: malloc 0x401fffdd4b20
script/lexer.c:336: token 0 text []
script/script.c:50: malloc 0x401fffdd4c40
script/script.c:50: malloc 0x401fffdd4ae0
script/script.c:65: free 0x401fffdd4ae0
script/script.c:65: free 0x401fffdd4c40
script/script.c:65: free 0x401fffdd4b20
script/script.c:65: free 0x401fffdd4b60
script/lexer.c:336: token 288 text [set]
script/script.c:50: malloc 0x401fffdd4b60
script/script.c:50: malloc 0x401fffdd4b20
script/script.c:163: arglist
script/script.c:50: malloc 0x401fffdd4ac0
script/lexer.c:336: token 289 text [gfxpayload=keep]
script/script.c:50: malloc 0x401fffdd48e0
script/script.c:50: malloc 0x401fffdd48a0
script/script.c:163: arglist
script/script.c:50: malloc 0x401fffdd4840
script/lexer.c:336: token 259 text [
]
script/script.c:50: malloc 0x401fffdd47e0
script/script.c:50: malloc 0x401fffdd47a0
script/script.c:198: cmdline
script/script.c:50: malloc 0x401fffdd4740
script/lexer.c:336: token 0 text []
script/script.c:50: malloc 0x401fffdd4c40
script/script.c:50: malloc 0x401fffdd4c00
script/script.c:294: append command
script/script.c:50: malloc 0x401fffdd4700
kern/verifiers.c:214: string: set gfxpayload=keep, type: 2
script/script.c:65: free 0x401fffdd4700
script/script.c:65: ...

review: Disapprove
Revision history for this message
dann frazier (dannf) wrote :

Sorry, it helps if I quilt push the patch. Retrying...

Revision history for this message
dann frazier (dannf) wrote :

OK, after wiping the egg off of my face, I can confirm it works :)

Let me know if you'd like me to merge/upload, or if Foundations already plans to do so. (I don't know, for example, if there are other fixes for known bugs that should be applied at the same time).

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/patches/series b/debian/patches/series
2index 24509f9..e8cf74c 100644
3--- a/debian/patches/series
4+++ b/debian/patches/series
5@@ -125,3 +125,4 @@ efivar-check-that-efivarfs-is-writeable.patch
6 linuxefi-do-not-validate-kernels-twice.patch
7 fdt-add-debug-output-to-devicetree-command.patch
8 efi-EFI-Device-Tree-Fixup-Protocol.patch
9+ubuntu-disable-LOAD-FILE2-protocol-for-initrd-on-ARM.patch
10diff --git a/debian/patches/ubuntu-disable-LOAD-FILE2-protocol-for-initrd-on-ARM.patch b/debian/patches/ubuntu-disable-LOAD-FILE2-protocol-for-initrd-on-ARM.patch
11new file mode 100644
12index 0000000..b7f7f23
13--- /dev/null
14+++ b/debian/patches/ubuntu-disable-LOAD-FILE2-protocol-for-initrd-on-ARM.patch
15@@ -0,0 +1,63 @@
16+From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
17+Date: Wed, 13 Apr 2022 18:51:37 +0200
18+Subject: ubuntu: disable LOAD FILE2 protocol for initrd on ARM
19+
20+RISC-V cannot load the initrd without the LOAD FILE2 protocol.
21+
22+Currently the LOAD FILE2 protocol does not work with PXE due to a preboot
23+hook invoking grub_net_fini_hw().
24+
25+So let's disable this for ARM until a solution has been agreed on with
26+upstream.
27+
28+Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
29+---
30+ grub-core/loader/efi/linux.c | 18 +++++++++++++++---
31+ 1 file changed, 15 insertions(+), 3 deletions(-)
32+
33+diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c
34+index 24abc0c0b..6dd31966d 100644
35+--- a/grub-core/loader/efi/linux.c
36++++ b/grub-core/loader/efi/linux.c
37+@@ -67,8 +67,10 @@ struct grub_arm64_linux_pe_header
38+ grub_err_t
39+ grub_arch_efi_linux_check_image (struct linux_arch_kernel_header * lh)
40+ {
41++#ifdef __riscv
42+ struct grub_pe32_coff_header *coff_header;
43+ struct grub_pe32_optional_header *optional_header;
44++#endif
45+
46+ if (lh->magic != GRUB_LINUX_ARCH_MAGIC_SIGNATURE)
47+ return grub_error(GRUB_ERR_BAD_OS, "invalid magic number");
48+@@ -80,17 +82,27 @@ grub_arch_efi_linux_check_image (struct linux_arch_kernel_header * lh)
49+ grub_dprintf ("linux", "UEFI stub kernel:\n");
50+ grub_dprintf ("linux", "PE/COFF header @ %08x\n", lh->hdr_offset);
51+
52+- coff_header = (struct grub_pe32_coff_header *)((unsigned long)lh + lh->hdr_offset);
53+- optional_header = (struct grub_pe32_optional_header *)(coff_header + 1);
54+-
55+ /*
56+ * Linux kernels built for any architecture are guaranteed to support the
57+ * LoadFile2 based initrd loading protocol if the image version is >= 1.
58+ */
59++#ifdef __riscv
60++ /*
61++ * RISC-V cannot load the initrd without the LOAD FILE2 protocol.
62++ *
63++ * Currently the LOAD FILE2 protocol does not work with PXE due to a preboot
64++ * hook invoking grub_net_fini_hw().
65++ *
66++ * TODO: clarify if the preboot hook is needed
67++ */
68++ coff_header = (struct grub_pe32_coff_header *)((unsigned long)lh + lh->hdr_offset);
69++ optional_header = (struct grub_pe32_optional_header *)(coff_header + 1);
70++
71+ if (optional_header->major_image_version >= 1)
72+ initrd_use_loadfile2 = 1;
73+ else
74+ initrd_use_loadfile2 = 0;
75++#endif
76+
77+ grub_dprintf ("linux", "LoadFile2 initrd loading %sabled\n",
78+ initrd_use_loadfile2 ? "en" : "dis");

Subscribers

People subscribed via source and target branches