ppc64le: fix issues using core.elf on boot media

Resolves: #2143420
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
This commit is contained in:
Robbie Harwood 2023-01-13 20:30:06 +00:00
parent 1395eb50d1
commit 80718e98fa
4 changed files with 120 additions and 1 deletions

View File

@ -0,0 +1,59 @@
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)
(cherry picked from commit e908b38eabd5011865b3bfe0873b053ee82de217)
---
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,54 @@
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)
(cherry picked from commit 19c45257cc29845adedc3931eed577e97534f8f1)
---
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 4c4e6912f9..6989da5618 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

@ -305,3 +305,5 @@ Patch0304: 0304-font-Harden-grub_font_blit_glyph-and-grub_font_blit_.patch
Patch0305: 0305-font-Assign-null_font-to-glyphs-in-ascii_font_glyph.patch
Patch0306: 0306-normal-charset-Fix-an-integer-overflow-in-grub_unico.patch
Patch0307: 0307-Correction-in-vector-5-values.patch
Patch0308: 0308-Skip-diskfilter-on-powerpc-CDs.patch
Patch0309: 0309-Fix-prefix-and-root-on-ppc64le-CDs.patch

View File

@ -14,7 +14,7 @@
Name: grub2
Epoch: 1
Version: 2.06
Release: 52%{?dist}
Release: 53%{?dist}
Summary: Bootloader with support for Linux, Multiboot and more
License: GPLv3+
URL: http://www.gnu.org/software/grub/
@ -532,6 +532,10 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg
%endif
%changelog
* Fri Jan 13 2023 Robbie Harwood <rharwood@redhat.com> - 2.06-53
- ppc64le: fix issues using core.elf on boot media
- Resolves: #2143420
* Wed Dec 14 2022 Robbie Harwood <rharwood@redhat.com> - 2.06-52
- ppc64le: fix lpar cas5
- Resolves: #2153071