grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/2] Ensure nvram is available and functional on IEEE1275


From: Ismael Luceno
Subject: [PATCH 2/2] Ensure nvram is available and functional on IEEE1275
Date: Wed, 24 Aug 2022 18:03:11 +0200

Otherwise the installation will fail, and the system will be left in an
unbootable state.

On ppc64le, 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>

Signed-off-by: Ismael Luceno <iluceno@suse.de>
---
 grub-core/osdep/unix/platform.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/grub-core/osdep/unix/platform.c b/grub-core/osdep/unix/platform.c
index a5bf064b7cf5..fd23176e58a0 100644
--- a/grub-core/osdep/unix/platform.c
+++ b/grub-core/osdep/unix/platform.c
@@ -192,12 +192,30 @@ grub_install_register_efi (grub_device_t efidir_grub_dev,
   return ret;
 }
 
+static void
+linux_ensure_nvram (void)
+{
+  int fd;
+#ifndef __linux__
+  return 0;
+#endif
+  if (linux_kmod_load("nvram"))
+    grub_util_error (_("%s: kernel module not found"), "nvram");
+  fd = open ("/dev/nvram", O_RDWR);
+  if (fd == -1)
+    grub_util_error ("/dev/nvram: %s", strerror(errno));
+  close (fd);
+}
+
 void
 grub_install_register_ieee1275 (int is_prep, const char *install_device,
                                int partno, const char *relpath)
 {
   char *boot_device;
 
+  /* On Linux, ensure nvram is available and functional.  */
+  linux_ensure_nvram ();
+
   if (grub_util_exec_redirect_null ((const char * []){ "ofpathname", 
"--version", NULL }))
     {
       /* TRANSLATORS: This message is shown when required executable `%s'
-- 
2.37.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]