grub2/0319-Fix-prefix-and-root-on-ppc64le-CDs.patch
Robbie Harwood ac206cb17b ppc64le: fix issues using core.elf on boot media
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
2023-01-13 20:28:48 +00:00

54 lines
2.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Robbie Harwood <rharwood@redhat.com>
Date: Fri, 13 Jan 2023 12:36:29 -0500
Subject: [PATCH] Fix prefix and root on ppc64le CDs
CHRP requires grub at /boot/grub. On CDs, this means any other prefix
will be invalid. In particular, a distro grub might prefer /grub2 - but
prefix is hardcoded into the signed core.elf, and will always be wrong
here.
Also work around a conflict between OF naming and that used by
part_msdos: on CDs, we always want the raw device. This fixes an issue
where grub would successfully load the menu from an image, but then
produce the error:
error: ../../grub-core/net/net.c:1552:disk `ieee1275/cdrom,0' not found.
and fail to boot further.
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
(cherry picked from commit 68e5981a5e808a32350aca4a2414717fa4605ca0)
---
grub-core/kern/main.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c
index e94a2f78fb..ab06033534 100644
--- a/grub-core/kern/main.c
+++ b/grub-core/kern/main.c
@@ -278,6 +278,23 @@ grub_set_prefix_and_root (void)
}
grub_env_set ("root", device);
+
+#ifdef __powerpc__
+ /* When booting from a CD, if part_msdos is enabled, grub will detect
+ and create access points starting at (ieee1275/cdrom,msdos1).
+ However, the device detection and OF name transformation will produce
+ a device named (ieee1275/cdrom,0) - i.e., missing the msdos and also
+ differently indexed. Furthermore, CHRP mandates boot/grub as prefix,
+ but our signed images are built with /grub2 to reflect installed
+ systems. Just ignore both messes.
+ */
+ if (!grub_strncmp (device[0] == '(' ? device + 1 : device,
+ "ieee1275/cdrom", grub_strlen ("ieee1275/cdrom")))
+ {
+ grub_env_set ("prefix", "/boot/grub");
+ grub_env_set ("root", "ieee1275/cdrom");
+ }
+#endif
}
grub_free (device);