|
|
98a0ca |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
98a0ca |
From: Daniel Axtens <dja@axtens.net>
|
|
|
98a0ca |
Date: Mon, 19 Jul 2021 14:35:55 +1000
|
|
|
98a0ca |
Subject: [PATCH] powerpc: adjust setting of prefix for signed binary case
|
|
|
98a0ca |
|
|
|
98a0ca |
On RHEL-signed powerpc grub, we sign a grub with -p /grub2 and expect
|
|
|
98a0ca |
that there's a boot partition.
|
|
|
98a0ca |
|
|
|
98a0ca |
Unfortunately grub_set_prefix_and_root tries to convert this to
|
|
|
98a0ca |
($fwdevice)/grub2. This ends up being (ieee1275/disk)/grub2 and that
|
|
|
98a0ca |
falls apart pretty quickly - there's no file-system on ieee1275/disk,
|
|
|
98a0ca |
and it makes the search routine try things like
|
|
|
98a0ca |
(ieee1275/disk,msdos2)(ieee1275/disk)/grub2 which also doesn't work.
|
|
|
98a0ca |
|
|
|
98a0ca |
Detect if we would be about to create (ieee1275/disk)/path and don't:
|
|
|
98a0ca |
preserve a prefix of /path instead and hope the search later finds us.
|
|
|
98a0ca |
|
|
|
98a0ca |
Related: rhbz#1899864
|
|
|
98a0ca |
|
|
|
98a0ca |
Signed-off-by: Daniel Axtens <dja@axtens.net>
|
|
|
98a0ca |
---
|
|
|
98a0ca |
grub-core/kern/main.c | 38 +++++++++++++++++++++++++++++++++-----
|
|
|
98a0ca |
1 file changed, 33 insertions(+), 5 deletions(-)
|
|
|
98a0ca |
|
|
|
98a0ca |
diff --git a/grub-core/kern/main.c b/grub-core/kern/main.c
|
|
|
09e3cc |
index 9bf6a8b23..25dbcfef1 100644
|
|
|
98a0ca |
--- a/grub-core/kern/main.c
|
|
|
98a0ca |
+++ b/grub-core/kern/main.c
|
|
|
98a0ca |
@@ -215,13 +215,41 @@ grub_set_prefix_and_root (void)
|
|
|
98a0ca |
if (device)
|
|
|
98a0ca |
{
|
|
|
98a0ca |
char *prefix_set;
|
|
|
98a0ca |
-
|
|
|
98a0ca |
- prefix_set = grub_xasprintf ("(%s)%s", device, path ? : "");
|
|
|
98a0ca |
- if (prefix_set)
|
|
|
98a0ca |
+
|
|
|
98a0ca |
+#ifdef __powerpc__
|
|
|
98a0ca |
+ /* We have to be careful here on powerpc-ieee1275 + signed grub. We
|
|
|
98a0ca |
+ will have signed something with a prefix that doesn't have a device
|
|
|
98a0ca |
+ because we cannot know in advance what partition we're on.
|
|
|
98a0ca |
+
|
|
|
98a0ca |
+ We will have had !device earlier, so we will have set device=fwdevice
|
|
|
98a0ca |
+ However, we want to make sure we do not end up setting prefix to be
|
|
|
98a0ca |
+ ($fwdevice)/path, because we will then end up trying to boot or search
|
|
|
98a0ca |
+ based on a prefix of (ieee1275/disk)/path, which will not work because
|
|
|
98a0ca |
+ it's missing a partition.
|
|
|
98a0ca |
+
|
|
|
98a0ca |
+ Also:
|
|
|
98a0ca |
+ - You can end up with a device with an FS directly on it, without
|
|
|
98a0ca |
+ a partition, e.g. ieee1275/cdrom.
|
|
|
98a0ca |
+
|
|
|
98a0ca |
+ - powerpc-ieee1275 + grub-install sets e.g. prefix=(,gpt2)/path,
|
|
|
98a0ca |
+ which will have now been extended to device=$fwdisk,partition
|
|
|
98a0ca |
+ and path=/path
|
|
|
98a0ca |
+
|
|
|
98a0ca |
+ So we only need to act if device = ieee1275/disk exactly.
|
|
|
98a0ca |
+ */
|
|
|
98a0ca |
+ if (grub_strncmp (device, "ieee1275/disk", 14) == 0)
|
|
|
98a0ca |
+ grub_env_set ("prefix", path);
|
|
|
98a0ca |
+ else
|
|
|
98a0ca |
+#endif
|
|
|
98a0ca |
{
|
|
|
98a0ca |
- grub_env_set ("prefix", prefix_set);
|
|
|
98a0ca |
- grub_free (prefix_set);
|
|
|
98a0ca |
+ prefix_set = grub_xasprintf ("(%s)%s", device, path ? : "");
|
|
|
98a0ca |
+ if (prefix_set)
|
|
|
98a0ca |
+ {
|
|
|
98a0ca |
+ grub_env_set ("prefix", prefix_set);
|
|
|
98a0ca |
+ grub_free (prefix_set);
|
|
|
98a0ca |
+ }
|
|
|
98a0ca |
}
|
|
|
98a0ca |
+
|
|
|
98a0ca |
grub_env_set ("root", device);
|
|
|
98a0ca |
}
|
|
|
98a0ca |
|