Skip to contentSkip to conversation

Fix installation issues on ppc64le

PATCH Superseded Ismael Luceno 2 participants 5 messages Aug 29, 2022 – Sep 5, 2022

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Fix installation issues on ppc64le

If the nvram device is non-functional, e.g. because the nvram module isn't loaded and it's file been removed from the filesystem, thus can't be loaded, the installation will be attempted but the system will be left in an unbootable state.

The boot process shows:

Welcome to GRUB!

error: ../../grub-core/kern/dl.c:380:symbol `grub_disk_get_size' not found. Entering rescue mode...
grub rescue>

The patches in this series introduce a couple of points of no return before updating the nvram, and make sure /dev/nvram is functional or fail early.

Ismael Luceno (2):
grub-install: Add missing points of no return for IEEE1275 on

    i386/powerpc

grub-install: Ensure a functional /dev/nvram

 util/grub-install.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
Signature · 1 line
2.37.1
#1 lore raw

PATCH v2 1/2 grub-install: Add missing points of no return for IEEE1275 on i386/powerpc

---
 util/grub-install.c | 2 ++
 1 file changed, 2 insertions(+)
util/grub-install.c +2 -0
index 7b04bd3c534b..527b85e27aa7 100644
@@ -1835,6 +1835,7 @@ main (int argc, char *argv[])
 	    {
 	      if (write_to_disk (ins_dev, imgfile))
 		grub_util_error ("%s", _("failed to copy Grub to the PReP partition"));
+	      grub_set_install_backup_ponr ();
 	    }
 	  else
 	    {
@@ -1859,6 +1860,7 @@ main (int argc, char *argv[])
 	  partno = grub_dev->disk->partition
 	    ? grub_dev->disk->partition->number + 1 : 0;
 	  dev = grub_util_get_os_disk (grub_devices[0]);
+	  grub_set_install_backup_ponr ();
 	  grub_install_register_ieee1275 (0, dev,
 					  partno, relpath);
 	}
Signature · 1 line
2.37.1
#2 lore raw

Re: [PATCH v2 1/2] grub-install: Add missing points of no return for IEEE1275 on i386/powerpc

Quoted 10 lines · Ismael Luceno
---
 util/grub-install.c | 2 ++
 1 file changed, 2 insertions(+)
util/grub-install.c +0 -0
index 7b04bd3c534b..527b85e27aa7 100644

util/grub-install.c main (int argc, char *argv[]) · line 1838

Quoted 4 lines
util/grub-install.c +1 -0
@@ -1835,6 +1835,7 @@ main (int argc, char *argv[])
 	    {
 	      if (write_to_disk (ins_dev, imgfile))
 		grub_util_error ("%s", _("failed to copy Grub to the PReP partition"));
+	      grub_set_install_backup_ponr ();

This looks good to me.

util/grub-install.c main (int argc, char *argv[]) · line 1863

Quoted 8 lines
util/grub-install.c +1 -0
 	    }
 	  else
 	    {
@@ -1859,6 +1860,7 @@ main (int argc, char *argv[])
 	  partno = grub_dev->disk->partition
 	    ? grub_dev->disk->partition->number + 1 : 0;
 	  dev = grub_util_get_os_disk (grub_devices[0]);
+	  grub_set_install_backup_ponr ();

This should be moved way up, given failure may occur at grub_make_system_path_relative_to_its_root or even earlier.

But in the first place the attempt may have been wrong, given the image is installed as file in the platform directory, there we should not be botherd to set grub_set_install_backup_ponr as file should be able to be backup and restored thus is covered. On the other hand, the grub_set_install_backup_ponr looked like a workaround to me to deal with raw images embedded in partition that has no good way to restore it.

That is for i386-ieee1275, /boot/grub2/i386-ieee1275/grub should be added to the list of backup and restore to get it to work in failure recovery path.

Thanks,
Michael

Quoted 11 lines
util/grub-install.c +0 -0
 	  grub_install_register_ieee1275 (0, dev,
 					  partno, relpath);
 	}
Signature · 7 lines
2.37.1


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#3 lore raw

PATCH v2 2/2 grub-install: Ensure a functional /dev/nvram

In reply to Ismael Luceno

This enables an early failure; for i386-ieee1275 and powerpc-ieee1275 on Linux, without /dev/nvram the system may be left in an unbootable state.

---
 util/grub-install.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
util/grub-install.c +23 -0
index 527b85e27aa7..c84a2fb0526f 100644
@@ -827,6 +827,16 @@ fill_core_services (const char *core_services)
   free (sysv_plist);
 }
 
+static void
+try_open (const char *path)
+{
+  FILE *f;
+  f = grub_util_fopen (path, "r+");
+  if (!f)
+    grub_util_error (_("Unable to open %s: %s"), path, strerror(errno));
+  fclose (f);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -1026,6 +1036,19 @@ main (int argc, char *argv[])
       break;
     }
 
+  switch (platform)
+    {
+    case GRUB_INSTALL_PLATFORM_I386_IEEE1275:
+    case GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275:
+#ifdef __linux__
+      /* On Linux, ensure /dev/nvram is _functional_.  */
+      try_open ("/dev/nvram");
+#endif
+      break;
+    default:
+      break;
+    }
+
   /* Find the EFI System Partition.  */
 
   if (is_efi)
Signature · 1 line
2.37.1
#4 lore raw

Re: [PATCH v2 2/2] grub-install: Ensure a functional /dev/nvram

Quoted 30 lines · Ismael Luceno

This enables an early failure; for i386-ieee1275 and powerpc-ieee1275 on Linux, without /dev/nvram the system may be left in an unbootable state.

---
 util/grub-install.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
util/grub-install.c +10 -0
index 527b85e27aa7..c84a2fb0526f 100644
@@ -827,6 +827,16 @@ fill_core_services (const char *core_services)
   free (sysv_plist);
 }
 
+static void
+try_open (const char *path)
+{
+  FILE *f;
+  f = grub_util_fopen (path, "r+");
+  if (!f)
+    grub_util_error (_("Unable to open %s: %s"), path, strerror(errno));
+  fclose (f);
+}
+
 int
 main (int argc, char *argv[])
 {

util/grub-install.c main (int argc, char *argv[]) · line 1045

Quoted 10 lines
util/grub-install.c +7 -0
@@ -1026,6 +1036,19 @@ main (int argc, char *argv[])
       break;
     }
 
+  switch (platform)
+    {
+    case GRUB_INSTALL_PLATFORM_I386_IEEE1275:
+    case GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275:
+#ifdef __linux__
+      /* On Linux, ensure /dev/nvram is _functional_.  */
+      try_open ("/dev/nvram");

The update_nvram variable should be tested in case user has skipped it.

Thanks,
Michael

Quoted 17 lines
util/grub-install.c +6 -0
+#endif
+      break;
+    default:
+      break;
+    }
+
   /* Find the EFI System Partition.  */
 
   if (is_efi)
Signature · 7 lines
2.37.1


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel