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