nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0309-ppc64le-signed-boot-media-changes.patch

b35c50
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
b35c50
From: Robbie Harwood <rharwood@redhat.com>
b35c50
Date: Wed, 25 Jan 2023 16:10:58 -0500
b35c50
Subject: [PATCH] ppc64le: signed boot media changes
b35c50
b35c50
Skip mdraid < 1.1 on isos since mdraid* can't even
b35c50
b35c50
Prior to this change, on ppc64le with part_msdos and the mdraid* modules
b35c50
enabled, we see:
b35c50
b35c50
    disk/diskfilter.c:191: scanning ieee1275/cdrom
b35c50
    kern/disk.c:196: Opening `ieee1275/cdrom'...
b35c50
    disk/ieee1275/ofdisk.c:477: Opening `cdrom'.
b35c50
    disk/ieee1275/ofdisk.c:502: MAX_RETRIES set to 20
b35c50
    kern/disk.c:288: Opening `ieee1275/cdrom' succeeded.
b35c50
    disk/diskfilter.c:136: Scanning for DISKFILTER devices on disk ieee1275/cdrom
b35c50
    partmap/msdos.c:184: partition 0: flag 0x80, type 0x96, start 0x0, len
b35c50
    0x6a5d70
b35c50
    disk/diskfilter.c:136: Scanning for DISKFILTER devices on disk ieee1275/cdrom
b35c50
    SCSI-DISK: Access beyond end of device !
b35c50
    SCSI-DISK: Access beyond end of device !
b35c50
    SCSI-DISK: Access beyond end of device !
b35c50
    SCSI-DISK: Access beyond end of device !
b35c50
    SCSI-DISK: Access beyond end of device !
b35c50
    disk/ieee1275/ofdisk.c:578: MAX_RETRIES set to 20
b35c50
b35c50
These latter two lines repeat many times, eventually ending in:
b35c50
b35c50
    kern/disk.c:388: ieee1275/cdrom read failed
b35c50
    error: ../../grub-core/disk/ieee1275/ofdisk.c:608:failure reading sector
b35c50
    0x1a9720 from `ieee1275/cdrom'.
b35c50
b35c50
and the system drops to a "grub>" prompt.
b35c50
b35c50
Prior to 1.1, mdraid stored the superblock offset from the end of the
b35c50
disk, and the firmware really doesn't like reads there.  Best guess was
b35c50
that the firmware and the iso image appear to diagree on the blocksize
b35c50
(512 vs. 2048), and the diskfilter RAID probing is too much for it.
b35c50
It's tempting to just skip probing for cdroms, but unfortunately isos
b35c50
can be virtualized elsewhere - such as regular disks.
b35c50
b35c50
Also fix detection of root, and try the chrp path as a fallback if the
b35c50
built prefix doesn't work.
b35c50
b35c50
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
b35c50
b35c50
wip
b35c50
---
b35c50
 grub-core/disk/mdraid1x_linux.c  | 8 +++++++-
b35c50
 grub-core/disk/mdraid_linux.c    | 5 +++++
b35c50
 grub-core/kern/ieee1275/openfw.c | 2 +-
b35c50
 grub-core/normal/main.c          | 5 +++++
b35c50
 4 files changed, 18 insertions(+), 2 deletions(-)
b35c50
b35c50
diff --git a/grub-core/disk/mdraid1x_linux.c b/grub-core/disk/mdraid1x_linux.c
b35c50
index 38444b02c7..08c57ae16e 100644
b35c50
--- a/grub-core/disk/mdraid1x_linux.c
b35c50
+++ b/grub-core/disk/mdraid1x_linux.c
b35c50
@@ -129,7 +129,13 @@ grub_mdraid_detect (grub_disk_t disk,
b35c50
       grub_uint32_t level;
b35c50
       struct grub_diskfilter_vg *array;
b35c50
       char *uuid;
b35c50
-	
b35c50
+
b35c50
+#ifdef __powerpc__
b35c50
+      /* Firmware will yell at us for reading too far. */
b35c50
+      if (minor_version == 0)
b35c50
+        continue;
b35c50
+#endif
b35c50
+
b35c50
       if (size == GRUB_DISK_SIZE_UNKNOWN && minor_version == 0)
b35c50
 	continue;
b35c50
 	
b35c50
diff --git a/grub-core/disk/mdraid_linux.c b/grub-core/disk/mdraid_linux.c
b35c50
index e40216f511..98fcfb1be6 100644
b35c50
--- a/grub-core/disk/mdraid_linux.c
b35c50
+++ b/grub-core/disk/mdraid_linux.c
b35c50
@@ -189,6 +189,11 @@ grub_mdraid_detect (grub_disk_t disk,
b35c50
   grub_uint32_t level;
b35c50
   struct grub_diskfilter_vg *ret;
b35c50
 
b35c50
+#ifdef __powerpc__
b35c50
+  /* Firmware will yell at us for reading too far. */
b35c50
+  return NULL;
b35c50
+#endif
b35c50
+
b35c50
   /* The sector where the mdraid 0.90 superblock is stored, if available.  */
b35c50
   size = grub_disk_native_sectors (disk);
b35c50
   if (size == GRUB_DISK_SIZE_UNKNOWN)
b35c50
diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c
b35c50
index 3a6689abb1..0278054c61 100644
b35c50
--- a/grub-core/kern/ieee1275/openfw.c
b35c50
+++ b/grub-core/kern/ieee1275/openfw.c
b35c50
@@ -499,7 +499,7 @@ grub_ieee1275_encode_devname (const char *path)
b35c50
 	*optr++ ='\\';
b35c50
       *optr++ = *iptr++;
b35c50
     }
b35c50
-  if (partition && partition[0])
b35c50
+  if (partition && partition[0] >= '0' && partition[0] <= '9')
b35c50
     {
b35c50
       unsigned int partno = grub_strtoul (partition, 0, 0);
b35c50
 
b35c50
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
b35c50
index 8f5fd81003..d59145f861 100644
b35c50
--- a/grub-core/normal/main.c
b35c50
+++ b/grub-core/normal/main.c
b35c50
@@ -372,6 +372,7 @@ grub_try_normal_prefix (const char *prefix)
b35c50
            file = grub_file_open (config, GRUB_FILE_TYPE_CONFIG);
b35c50
            if (file)
b35c50
              {
b35c50
+               grub_env_set ("prefix", prefix);
b35c50
                grub_file_close (file);
b35c50
                err = GRUB_ERR_NONE;
b35c50
              }
b35c50
@@ -447,6 +448,10 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),
b35c50
       err = grub_try_normal ("fw_path");
b35c50
       if (err == GRUB_ERR_FILE_NOT_FOUND)
b35c50
         err = grub_try_normal ("prefix");
b35c50
+#ifdef __powerpc__
b35c50
+      if (err == GRUB_ERR_FILE_NOT_FOUND)
b35c50
+        err = grub_try_normal_prefix ("/boot/grub");
b35c50
+#endif
b35c50
       if (err == GRUB_ERR_FILE_NOT_FOUND)
b35c50
         err = grub_try_normal_discover ();
b35c50
       if (err == GRUB_ERR_FILE_NOT_FOUND)