grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v1 2/2] Fix prefix and root on ppc64le CDs


From: Robbie Harwood
Subject: [PATCH v1 2/2] Fix prefix and root on ppc64le CDs
Date: Fri, 13 Jan 2023 15:26:51 -0500

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>
---
 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 731c07c290..0a24fe38e4 100644
--- a/grub-core/kern/main.c
+++ b/grub-core/kern/main.c
@@ -216,6 +216,23 @@ grub_set_prefix_and_root (void)
          grub_free (prefix_set);
        }
       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);
-- 
2.39.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]