ppc64le: update signed media fixes

Signed-off-by: Robbie Harwood <rharwood@redhat.com>
This commit is contained in:
Robbie Harwood 2023-01-27 18:59:45 +00:00
parent ac206cb17b
commit 3ce59ed7e1
6 changed files with 108 additions and 115 deletions

View file

@ -1,58 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Robbie Harwood <rharwood@redhat.com>
Date: Thu, 12 Jan 2023 16:03:03 -0500
Subject: [PATCH] Skip diskfilter on powerpc CDs
Prior to this change, on ppc64le with part_msdos and the mdraid* modules
enabled, we see:
disk/diskfilter.c:191: scanning ieee1275/cdrom
kern/disk.c:196: Opening `ieee1275/cdrom'...
disk/ieee1275/ofdisk.c:477: Opening `cdrom'.
disk/ieee1275/ofdisk.c:502: MAX_RETRIES set to 20
kern/disk.c:288: Opening `ieee1275/cdrom' succeeded.
disk/diskfilter.c:136: Scanning for DISKFILTER devices on disk ieee1275/cdrom
partmap/msdos.c:184: partition 0: flag 0x80, type 0x96, start 0x0, len
0x6a5d70
disk/diskfilter.c:136: Scanning for DISKFILTER devices on disk ieee1275/cdrom
SCSI-DISK: Access beyond end of device !
SCSI-DISK: Access beyond end of device !
SCSI-DISK: Access beyond end of device !
SCSI-DISK: Access beyond end of device !
SCSI-DISK: Access beyond end of device !
disk/ieee1275/ofdisk.c:578: MAX_RETRIES set to 20
These latter two lines repeat many times, eventually ending in:
kern/disk.c:388: ieee1275/cdrom read failed
error: ../../grub-core/disk/ieee1275/ofdisk.c:608:failure reading sector
0x1a9720 from `ieee1275/cdrom'.
and the system drops to a "grub>" prompt.
The firmware and the iso image appear to diagree on the blocksize (512
vs. 2048), and the diskfilter RAID probing is too much for it. We won't
be seeing RAID on bootable CDs, so just turn it off.
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
(cherry picked from commit 35614da6ef0296d1a2d1583ae23822230c25a334)
---
grub-core/disk/diskfilter.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c
index 7cdffe3ebd..f9140f7493 100644
--- a/grub-core/disk/diskfilter.c
+++ b/grub-core/disk/diskfilter.c
@@ -133,6 +133,11 @@ scan_disk_partition_iter (grub_disk_t disk, grub_partition_t p, void *data)
struct grub_diskfilter_pv_id id;
grub_diskfilter_t diskfilter;
+#ifdef __powerpc__
+ if (!grub_strcmp (name, "ieee1275/cdrom"))
+ return 0;
+#endif
+
grub_dprintf ("diskfilter", "Scanning for DISKFILTER devices on disk %s\n",
name);
#ifdef GRUB_UTIL

View file

@ -0,0 +1,102 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Robbie Harwood <rharwood@redhat.com>
Date: Wed, 25 Jan 2023 16:10:58 -0500
Subject: [PATCH] ppc64le: signed boot media changes
Skip diskfilter on isos since mdraid* can't even
Prior to this change, on ppc64le with part_msdos and the mdraid* modules
enabled, we see:
disk/diskfilter.c:191: scanning ieee1275/cdrom
kern/disk.c:196: Opening `ieee1275/cdrom'...
disk/ieee1275/ofdisk.c:477: Opening `cdrom'.
disk/ieee1275/ofdisk.c:502: MAX_RETRIES set to 20
kern/disk.c:288: Opening `ieee1275/cdrom' succeeded.
disk/diskfilter.c:136: Scanning for DISKFILTER devices on disk ieee1275/cdrom
partmap/msdos.c:184: partition 0: flag 0x80, type 0x96, start 0x0, len
0x6a5d70
disk/diskfilter.c:136: Scanning for DISKFILTER devices on disk ieee1275/cdrom
SCSI-DISK: Access beyond end of device !
SCSI-DISK: Access beyond end of device !
SCSI-DISK: Access beyond end of device !
SCSI-DISK: Access beyond end of device !
SCSI-DISK: Access beyond end of device !
disk/ieee1275/ofdisk.c:578: MAX_RETRIES set to 20
These latter two lines repeat many times, eventually ending in:
kern/disk.c:388: ieee1275/cdrom read failed
error: ../../grub-core/disk/ieee1275/ofdisk.c:608:failure reading sector
0x1a9720 from `ieee1275/cdrom'.
and the system drops to a "grub>" prompt.
The firmware and the iso image appear to diagree on the blocksize (512
vs. 2048), and the diskfilter RAID probing is too much for it. We won't
be seeing RAID on bootable CDs, so just turn it off.
Fix detection of root.
Try the chrp path as a fallback if the built prefix doesn't work.
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
---
grub-core/disk/diskfilter.c | 6 ++++++
grub-core/kern/ieee1275/openfw.c | 2 +-
grub-core/normal/main.c | 5 +++++
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c
index 7cdffe3ebd..27fbca903f 100644
--- a/grub-core/disk/diskfilter.c
+++ b/grub-core/disk/diskfilter.c
@@ -139,6 +139,12 @@ scan_disk_partition_iter (grub_disk_t disk, grub_partition_t p, void *data)
grub_util_info ("Scanning for DISKFILTER devices on disk %s", name);
#endif
+ if (p->parent == NULL || p->parent->len == 0)
+ {
+ grub_dprintf ("diskfilter", "skipping %s due to unknown parent partition length", name);
+ return 0;
+ }
+
disk->partition = p;
for (arr = array_list; arr != NULL; arr = arr->next)
diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c
index 3a6689abb1..0278054c61 100644
--- a/grub-core/kern/ieee1275/openfw.c
+++ b/grub-core/kern/ieee1275/openfw.c
@@ -499,7 +499,7 @@ grub_ieee1275_encode_devname (const char *path)
*optr++ ='\\';
*optr++ = *iptr++;
}
- if (partition && partition[0])
+ if (partition && partition[0] >= '0' && partition[0] <= '9')
{
unsigned int partno = grub_strtoul (partition, 0, 0);
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
index 8f5fd81003..d59145f861 100644
--- a/grub-core/normal/main.c
+++ b/grub-core/normal/main.c
@@ -372,6 +372,7 @@ grub_try_normal_prefix (const char *prefix)
file = grub_file_open (config, GRUB_FILE_TYPE_CONFIG);
if (file)
{
+ grub_env_set ("prefix", prefix);
grub_file_close (file);
err = GRUB_ERR_NONE;
}
@@ -447,6 +448,10 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),
err = grub_try_normal ("fw_path");
if (err == GRUB_ERR_FILE_NOT_FOUND)
err = grub_try_normal ("prefix");
+#ifdef __powerpc__
+ if (err == GRUB_ERR_FILE_NOT_FOUND)
+ err = grub_try_normal_prefix ("/boot/grub");
+#endif
if (err == GRUB_ERR_FILE_NOT_FOUND)
err = grub_try_normal_discover ();
if (err == GRUB_ERR_FILE_NOT_FOUND)

View file

@ -1,53 +0,0 @@
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);

View file

@ -23,7 +23,7 @@
-e 's/-fplugin=annobin//g' \\\
-e 's,-specs=[[:alnum:]/_-]*annobin[[:alnum:]_-]*,,g' \\\
-e 's/-fstack-protector[[:alpha:]-]\\+//g' \\\
-e 's/-Wp,-D_FORTIFY_SOURCE=[[:digit:]]\\+//g' \\\
-e 's/-[^ ]*D_FORTIFY_SOURCE=[[:digit:]][^ ]*\\+//g' \\\
-e 's/--param=ssp-buffer-size=4//g' \\\
-e 's/-mregparm=3/-mregparm=4/g' \\\
-e 's/-fexceptions//g' \\\

View file

@ -315,5 +315,4 @@ Patch0314: 0314-kern-efi-mm-Pass-up-errors-from-add_memory_regions.patch
Patch0315: 0315-kern-efi-mm-Implement-runtime-addition-of-pages.patch
Patch0316: 0316-efi-Increase-default-memory-allocation-to-32-MiB.patch
Patch0317: 0317-mm-Try-invalidate-disk-caches-last-when-out-of-memor.patch
Patch0318: 0318-Skip-diskfilter-on-powerpc-CDs.patch
Patch0319: 0319-Fix-prefix-and-root-on-ppc64le-CDs.patch
Patch0318: 0318-ppc64le-signed-boot-media-changes.patch

View file

@ -17,7 +17,7 @@
Name: grub2
Epoch: 1
Version: 2.06
Release: 76%{?dist}
Release: 77%{?dist}
Summary: Bootloader with support for Linux, Multiboot and more
License: GPLv3+
URL: http://www.gnu.org/software/grub/
@ -544,6 +544,9 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg
%endif
%changelog
* Fri Jan 27 2023 Robbie Harwood <rharwood@redhat.com> - 2.06-77
- ppc64le: update signed media fixes
* Fri Jan 13 2023 Robbie Harwood <rharwood@redhat.com> - 2.06-76
- ppc64le: fix issues using core.elf on boot media