Blame SOURCES/0539-efi-Add-a-function-to-read-EFI-variables-with-attrib.patch

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