|
|
bf0270 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
bf0270 |
From: Daniel Kiper <daniel.kiper@oracle.com>
|
|
|
bf0270 |
Date: Thu, 3 Dec 2020 16:01:47 +0100
|
|
|
bf0270 |
Subject: [PATCH] efi: Add a function to read EFI variables with attributes
|
|
|
bf0270 |
|
|
|
bf0270 |
It will be used to properly detect and report UEFI Secure Boot status to
|
|
|
bf0270 |
the x86 Linux kernel. The functionality will be added by subsequent patches.
|
|
|
bf0270 |
|
|
|
bf0270 |
Signed-off-by: Ignat Korchagin <ignat@cloudflare.com>
|
|
|
bf0270 |
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
|
bf0270 |
Signed-off-by: Marco A Benatto <mbenatto@redhat.com>
|
|
|
bf0270 |
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
|
|
bf0270 |
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
|
bf0270 |
(cherry picked from commit ac5c9367548750e75ed1e7fc4354a3d20186d733)
|
|
|
bf0270 |
(cherry picked from commit 51b11f8b3ab96c38efb1636d9c53b5a86503f1f2)
|
|
|
bf0270 |
---
|
|
|
bf0270 |
grub-core/kern/efi/efi.c | 16 +++++++++++++---
|
|
|
bf0270 |
include/grub/efi/efi.h | 5 +++++
|
|
|
bf0270 |
2 files changed, 18 insertions(+), 3 deletions(-)
|
|
|
bf0270 |
|
|
|
bf0270 |
diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
|
|
|
bf0270 |
index 335033975d..fccea20a01 100644
|
|
|
bf0270 |
--- a/grub-core/kern/efi/efi.c
|
|
|
bf0270 |
+++ b/grub-core/kern/efi/efi.c
|
|
|
bf0270 |
@@ -242,8 +242,11 @@ grub_efi_set_variable(const char *var, const grub_efi_guid_t *guid,
|
|
|
bf0270 |
}
|
|
|
bf0270 |
|
|
|
bf0270 |
grub_efi_status_t
|
|
|
bf0270 |
-grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid,
|
|
|
bf0270 |
- grub_size_t *datasize_out, void **data_out)
|
|
|
bf0270 |
+grub_efi_get_variable_with_attributes (const char *var,
|
|
|
bf0270 |
+ const grub_efi_guid_t *guid,
|
|
|
bf0270 |
+ grub_size_t *datasize_out,
|
|
|
bf0270 |
+ void **data_out,
|
|
|
bf0270 |
+ grub_efi_uint32_t *attributes)
|
|
|
bf0270 |
{
|
|
|
bf0270 |
grub_efi_status_t status;
|
|
|
bf0270 |
grub_efi_uintn_t datasize = 0;
|
|
|
bf0270 |
@@ -280,7 +283,7 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid,
|
|
|
bf0270 |
return GRUB_EFI_OUT_OF_RESOURCES;
|
|
|
bf0270 |
}
|
|
|
bf0270 |
|
|
|
bf0270 |
- status = efi_call_5 (r->get_variable, var16, guid, NULL, &datasize, data);
|
|
|
bf0270 |
+ status = efi_call_5 (r->get_variable, var16, guid, attributes, &datasize, data);
|
|
|
bf0270 |
grub_free (var16);
|
|
|
bf0270 |
|
|
|
bf0270 |
if (status == GRUB_EFI_SUCCESS)
|
|
|
bf0270 |
@@ -294,6 +297,13 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid,
|
|
|
bf0270 |
return status;
|
|
|
bf0270 |
}
|
|
|
bf0270 |
|
|
|
bf0270 |
+grub_efi_status_t
|
|
|
bf0270 |
+grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid,
|
|
|
bf0270 |
+ grub_size_t *datasize_out, void **data_out)
|
|
|
bf0270 |
+{
|
|
|
bf0270 |
+ return grub_efi_get_variable_with_attributes (var, guid, datasize_out, data_out, NULL);
|
|
|
bf0270 |
+}
|
|
|
bf0270 |
+
|
|
|
bf0270 |
#pragma GCC diagnostic ignored "-Wcast-align"
|
|
|
bf0270 |
|
|
|
bf0270 |
/* Search the mods section from the PE32/PE32+ image. This code uses
|
|
|
bf0270 |
diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
|
|
|
bf0270 |
index 90a85d7d9a..7af979b184 100644
|
|
|
bf0270 |
--- a/include/grub/efi/efi.h
|
|
|
bf0270 |
+++ b/include/grub/efi/efi.h
|
|
|
bf0270 |
@@ -113,6 +113,11 @@ grub_err_t EXPORT_FUNC (grub_efi_set_virtual_address_map) (grub_efi_uintn_t memo
|
|
|
bf0270 |
grub_efi_uintn_t descriptor_size,
|
|
|
bf0270 |
grub_efi_uint32_t descriptor_version,
|
|
|
bf0270 |
grub_efi_memory_descriptor_t *virtual_map);
|
|
|
bf0270 |
+grub_efi_status_t EXPORT_FUNC (grub_efi_get_variable_with_attributes) (const char *variable,
|
|
|
bf0270 |
+ const grub_efi_guid_t *guid,
|
|
|
bf0270 |
+ grub_size_t *datasize_out,
|
|
|
bf0270 |
+ void **data_out,
|
|
|
bf0270 |
+ grub_efi_uint32_t *attributes);
|
|
|
bf0270 |
grub_efi_status_t EXPORT_FUNC (grub_efi_get_variable) (const char *variable,
|
|
|
bf0270 |
const grub_efi_guid_t *guid,
|
|
|
bf0270 |
grub_size_t *datasize_out,
|