Blame SOURCES/0214-Make-efi-machines-load-an-env-block-from-a-variable.patch

f725e3
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
f725e3
From: Peter Jones <pjones@redhat.com>
f725e3
Date: Mon, 7 Dec 2015 14:20:49 -0500
f725e3
Subject: [PATCH] Make efi machines load an env block from a variable
f725e3
f725e3
Signed-off-by: Peter Jones <pjones@redhat.com>
f725e3
---
f725e3
 grub-core/Makefile.core.def |  1 +
f725e3
 grub-core/kern/efi/init.c   | 34 +++++++++++++++++++++++++++++++++-
f725e3
 2 files changed, 34 insertions(+), 1 deletion(-)
f725e3
f725e3
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
f725e3
index d73ea6f6c51..4fc74393335 100644
f725e3
--- a/grub-core/Makefile.core.def
f725e3
+++ b/grub-core/Makefile.core.def
f725e3
@@ -173,6 +173,7 @@ kernel = {
f725e3
   efi = kern/efi/init.c;
f725e3
   efi = kern/efi/mm.c;
f725e3
   efi = term/efi/console.c;
f725e3
+  efi = lib/envblk.c;
f725e3
 
f725e3
   x86 = kern/i386/tsc.c;
f725e3
 
f725e3
diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c
f725e3
index c391df48236..c5d8a76144a 100644
f725e3
--- a/grub-core/kern/efi/init.c
f725e3
+++ b/grub-core/kern/efi/init.c
f725e3
@@ -25,9 +25,40 @@
f725e3
 #include <grub/env.h>
f725e3
 #include <grub/mm.h>
f725e3
 #include <grub/kernel.h>
f725e3
+#include <grub/lib/envblk.h>
f725e3
 
f725e3
 grub_addr_t grub_modbase;
f725e3
 
f725e3
+#define GRUB_EFI_GRUB_VARIABLE_GUID \
f725e3
+  { 0x91376aff, 0xcba6, 0x42be, \
f725e3
+    { 0x94, 0x9d, 0x06, 0xfd, 0xe8, 0x11, 0x28, 0xe8 } \
f725e3
+  }
f725e3
+
f725e3
+/* Helper for grub_efi_env_init */
f725e3
+static int
f725e3
+set_var (const char *name, const char *value,
f725e3
+	 void *whitelist __attribute__((__unused__)))
f725e3
+{
f725e3
+  grub_env_set (name, value);
f725e3
+  return 0;
f725e3
+}
f725e3
+
f725e3
+static void
f725e3
+grub_efi_env_init (void)
f725e3
+{
f725e3
+  grub_efi_guid_t efi_grub_guid = GRUB_EFI_GRUB_VARIABLE_GUID;
f725e3
+  struct grub_envblk envblk_s = { NULL, 0 };
f725e3
+  grub_envblk_t envblk = &envblk_s;
f725e3
+
f725e3
+  envblk_s.buf = grub_efi_get_variable ("GRUB_ENV", &efi_grub_guid,
f725e3
+					&envblk_s.size);
f725e3
+  if (!envblk_s.buf || envblk_s.size < 1)
f725e3
+    return;
f725e3
+
f725e3
+  grub_envblk_iterate (envblk, NULL, set_var);
f725e3
+  grub_free (envblk_s.buf);
f725e3
+}
f725e3
+
f725e3
 void
f725e3
 grub_efi_init (void)
f725e3
 {
f725e3
@@ -42,10 +73,11 @@ grub_efi_init (void)
f725e3
   efi_call_4 (grub_efi_system_table->boot_services->set_watchdog_timer,
f725e3
 	      0, 0, 0, NULL);
f725e3
 
f725e3
+  grub_efi_env_init ();
f725e3
   grub_efidisk_init ();
f725e3
 }
f725e3
 
f725e3
-void (*grub_efi_net_config) (grub_efi_handle_t hnd, 
f725e3
+void (*grub_efi_net_config) (grub_efi_handle_t hnd,
f725e3
 			     char **device,
f725e3
 			     char **path);
f725e3