Skip to contentSkip to conversation

Fix installation issues on ppc64le

PATCH In review Ismael Luceno 2 participants 4 messages Sep 5, 2022 – Nov 24, 2022

lore
Share & tools
lore
#0 lore raw

v3 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>

Introduce a point of no return after embedding grub in the PReP partition, and make sure /dev/nvram is functional or fail early.

Ismael Luceno (2):
grub-install: Ensure a functional /dev/nvram
grub-install: Add point of no return for IEEE1275 on powerpc

 util/grub-install.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

Changes since v2:
* Removed point of no return for i386
* Check for update_nvram before opening /dev/nvarm Changes since v1:
* Check /dev/nvram early
* Removed loading of the nvram module
* Added points of no return

Signature · 1 line
2.37.3
#1 lore raw

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

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 | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
util/grub-install.c +24 -0
index 7b04bd3c534b..da50bd58b73b 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,20 @@ 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_.  */
+      if (update_nvram)
+        try_open ("/dev/nvram");
+#endif
+      break;
+    default:
+      break;
+    }
+
   /* Find the EFI System Partition.  */
 
   if (is_efi)
Signature · 1 line
2.37.3
#2 lore raw

PATCH v3 2/2 grub-install: Add point of no return for IEEE1275 on powerpc

In reply to Ismael Luceno
---
 util/grub-install.c | 1 +
 1 file changed, 1 insertion(+)
util/grub-install.c +1 -0
index da50bd58b73b..45f549c25867 100644
@@ -1859,6 +1859,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
 	    {
Signature · 1 line
2.37.3
Reviewed-by on the v3 series
#3 lore raw
In reply to Ismael Luceno
Quoted 13 lines · Ismael Luceno

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>

Quoted 6 lines

Introduce a point of no return after embedding grub in the PReP partition, and make sure /dev/nvram is functional or fail early.

Ismael Luceno (2):
grub-install: Ensure a functional /dev/nvram
grub-install: Add point of no return for IEEE1275 on powerpc

Daniel