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

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