2018-07-12 14:56:34 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2016-03-04 18:32:29 +00:00
|
|
|
From: Peter Jones <pjones@redhat.com>
|
|
|
|
Date: Mon, 7 Dec 2015 14:20:49 -0500
|
2018-07-10 18:39:10 +00:00
|
|
|
Subject: [PATCH] Make efi machines load an env block from a variable
|
2016-03-04 18:32:29 +00:00
|
|
|
|
|
|
|
Signed-off-by: Peter Jones <pjones@redhat.com>
|
|
|
|
---
|
|
|
|
grub-core/Makefile.core.def | 1 +
|
2024-08-01 23:56:47 +00:00
|
|
|
grub-core/kern/efi/init.c | 34 ++++++++++++++++++++++++++++++++++
|
|
|
|
2 files changed, 35 insertions(+)
|
2016-03-04 18:32:29 +00:00
|
|
|
|
|
|
|
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
|
2024-08-01 23:56:47 +00:00
|
|
|
index 1571421d7e8..0bffbfea917 100644
|
2016-03-04 18:32:29 +00:00
|
|
|
--- a/grub-core/Makefile.core.def
|
|
|
|
+++ b/grub-core/Makefile.core.def
|
2024-08-01 23:56:47 +00:00
|
|
|
@@ -219,6 +219,7 @@ kernel = {
|
2016-03-04 18:32:29 +00:00
|
|
|
efi = kern/efi/acpi.c;
|
2021-03-12 21:54:28 +00:00
|
|
|
efi = kern/efi/sb.c;
|
|
|
|
efi = kern/lockdown.c;
|
2016-03-04 18:32:29 +00:00
|
|
|
+ efi = lib/envblk.c;
|
|
|
|
i386_coreboot = kern/i386/pc/acpi.c;
|
|
|
|
i386_multiboot = kern/i386/pc/acpi.c;
|
|
|
|
i386_coreboot = kern/acpi.c;
|
|
|
|
diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c
|
2024-08-01 23:56:47 +00:00
|
|
|
index 6c54af6e79e..b5201974a76 100644
|
2016-03-04 18:32:29 +00:00
|
|
|
--- a/grub-core/kern/efi/init.c
|
|
|
|
+++ b/grub-core/kern/efi/init.c
|
2024-08-01 23:56:47 +00:00
|
|
|
@@ -28,8 +28,11 @@
|
2016-03-04 18:32:29 +00:00
|
|
|
#include <grub/env.h>
|
|
|
|
#include <grub/mm.h>
|
|
|
|
#include <grub/kernel.h>
|
2021-03-12 21:54:28 +00:00
|
|
|
+
|
|
|
|
#include <grub/stack_protector.h>
|
|
|
|
|
2016-03-04 18:32:29 +00:00
|
|
|
+#include <grub/lib/envblk.h>
|
2021-03-12 21:54:28 +00:00
|
|
|
+
|
|
|
|
#ifdef GRUB_STACK_PROTECTOR
|
|
|
|
|
2024-08-01 23:56:47 +00:00
|
|
|
static grub_efi_char16_t stack_chk_fail_msg[] =
|
|
|
|
@@ -103,6 +106,36 @@ stack_protector_init (void)
|
2016-03-04 18:32:29 +00:00
|
|
|
|
|
|
|
grub_addr_t grub_modbase;
|
|
|
|
|
|
|
|
+#define GRUB_EFI_GRUB_VARIABLE_GUID \
|
|
|
|
+ { 0x91376aff, 0xcba6, 0x42be, \
|
|
|
|
+ { 0x94, 0x9d, 0x06, 0xfd, 0xe8, 0x11, 0x28, 0xe8 } \
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+/* Helper for grub_efi_env_init */
|
|
|
|
+static int
|
|
|
|
+set_var (const char *name, const char *value,
|
|
|
|
+ void *whitelist __attribute__((__unused__)))
|
|
|
|
+{
|
|
|
|
+ grub_env_set (name, value);
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void
|
|
|
|
+grub_efi_env_init (void)
|
|
|
|
+{
|
2024-08-01 23:56:47 +00:00
|
|
|
+ grub_guid_t efi_grub_guid = GRUB_EFI_GRUB_VARIABLE_GUID;
|
2016-03-04 18:32:29 +00:00
|
|
|
+ struct grub_envblk envblk_s = { NULL, 0 };
|
|
|
|
+ grub_envblk_t envblk = &envblk_s;
|
|
|
|
+
|
2021-03-12 21:54:28 +00:00
|
|
|
+ grub_efi_get_variable ("GRUB_ENV", &efi_grub_guid, &envblk_s.size,
|
|
|
|
+ (void **) &envblk_s.buf);
|
2016-03-04 18:32:29 +00:00
|
|
|
+ if (!envblk_s.buf || envblk_s.size < 1)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ grub_envblk_iterate (envblk, NULL, set_var);
|
|
|
|
+ grub_free (envblk_s.buf);
|
|
|
|
+}
|
|
|
|
+
|
2024-08-01 23:56:47 +00:00
|
|
|
__attribute__ ((__optimize__ ("-fno-stack-protector"))) void
|
2016-03-04 18:32:29 +00:00
|
|
|
grub_efi_init (void)
|
|
|
|
{
|
2024-08-01 23:56:47 +00:00
|
|
|
@@ -128,6 +161,7 @@ grub_efi_init (void)
|
|
|
|
|
|
|
|
grub_efi_system_table->boot_services->set_watchdog_timer (0, 0, 0, NULL);
|
2016-03-04 18:32:29 +00:00
|
|
|
|
|
|
|
+ grub_efi_env_init ();
|
|
|
|
grub_efidisk_init ();
|
|
|
|
|
2024-08-01 23:56:47 +00:00
|
|
|
grub_efi_register_debug_commands ();
|