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