All of lore.kernel.org
 help / color / mirror / Atom feed
From: Krystian Hebel <krystian.hebel@3mdeb.com>
To: grub-devel@gnu.org
Cc: Norbert Kaminski <norbert.kaminski@3mdeb.com>
Subject: [GRUB PATCH RFC 11/22] efi: Add a function to read EFI variables with attributes
Date: Tue, 10 Nov 2020 15:44:49 +0100	[thread overview]
Message-ID: <20201110144500.31606-12-krystian.hebel@3mdeb.com> (raw)
In-Reply-To: <20201110144500.31606-1-krystian.hebel@3mdeb.com>

From: Norbert Kaminski <norbert.kaminski@3mdeb.com>

It will be used to properly detect and report UEFI Secure Boot status to
the x86 Linux kernel. The functionality will be added by subsequent patches.

Signed-off-by: Ignat Korchagin <ignat@cloudflare.com>
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Norbert Kaminski <norbert.kaminski@3mdeb.com>
---
 grub-core/kern/efi/efi.c | 16 +++++++++++++---
 include/grub/efi/efi.h   |  5 +++++
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
index 9403b12cd780..2942b8e355de 100644
--- a/grub-core/kern/efi/efi.c
+++ b/grub-core/kern/efi/efi.c
@@ -224,8 +224,11 @@ grub_efi_set_variable(const char *var, const grub_efi_guid_t *guid,
 }
 
 grub_efi_status_t
-grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid,
-		       grub_size_t *datasize_out, void **data_out)
+grub_efi_get_variable_with_attributes (const char *var,
+				       const grub_efi_guid_t *guid,
+				       grub_size_t *datasize_out,
+				       void **data_out,
+				       grub_efi_uint32_t *attributes)
 {
   grub_efi_status_t status;
   grub_efi_uintn_t datasize = 0;
@@ -262,7 +265,7 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid,
       return GRUB_EFI_OUT_OF_RESOURCES;
     }
 
-  status = efi_call_5 (r->get_variable, var16, guid, NULL, &datasize, data);
+  status = efi_call_5 (r->get_variable, var16, guid, attributes, &datasize, data);
   grub_free (var16);
 
   if (status == GRUB_EFI_SUCCESS)
@@ -276,6 +279,13 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid,
   return status;
 }
 
+grub_efi_status_t
+grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid,
+		       grub_size_t *datasize_out, void **data_out)
+{
+  return grub_efi_get_variable_with_attributes (var, guid, datasize_out, data_out, NULL);
+}
+
 #pragma GCC diagnostic ignored "-Wcast-align"
 
 /* Search the mods section from the PE32/PE32+ image. This code uses
diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h
index 8b2a0f1f5907..83d958f9945e 100644
--- a/include/grub/efi/efi.h
+++ b/include/grub/efi/efi.h
@@ -74,6 +74,11 @@ grub_err_t EXPORT_FUNC (grub_efi_set_virtual_address_map) (grub_efi_uintn_t memo
 							   grub_efi_uintn_t descriptor_size,
 							   grub_efi_uint32_t descriptor_version,
 							   grub_efi_memory_descriptor_t *virtual_map);
+grub_efi_status_t EXPORT_FUNC (grub_efi_get_variable_with_attributes) (const char *variable,
+								       const grub_efi_guid_t *guid,
+								       grub_size_t *datasize_out,
+								       void **data_out,
+								       grub_efi_uint32_t *attributes);
 grub_efi_status_t EXPORT_FUNC (grub_efi_get_variable) (const char *variable,
 						       const grub_efi_guid_t *guid,
 						       grub_size_t *datasize_out,
-- 
2.17.1



  parent reply	other threads:[~2020-11-10 14:47 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-10 14:44 [GRUB RFC PATCH 00/22] i386: Intel TXT and AMD SKINIT secure launcher Krystian Hebel
2020-11-10 14:44 ` [GRUB PATCH RFC 01/22] i386/msr: Merge rdmsr.h and wrmsr.h into msr.h Krystian Hebel
2020-11-10 14:44 ` [GRUB PATCH RFC 02/22] i386/msr: Rename grub_msr_read() and grub_msr_write() Krystian Hebel
2020-11-10 14:44 ` [GRUB PATCH RFC 03/22] i386/msr: Extract and improve MSR support detection code Krystian Hebel
2020-11-10 14:44 ` [GRUB PATCH RFC 04/22] i386/memory: Rename PAGE_SHIFT to GRUB_PAGE_SHIFT Krystian Hebel
2020-11-10 14:44 ` [GRUB PATCH RFC 05/22] i386/memory: Rename PAGE_SIZE to GRUB_PAGE_SIZE and make it global Krystian Hebel
2020-11-10 14:44 ` [GRUB PATCH RFC 06/22] mmap: Add grub_mmap_get_lowest() and grub_mmap_get_highest() Krystian Hebel
2020-11-10 14:44 ` [GRUB PATCH RFC 07/22] i386/tpm: Rename tpm module to tpm_verifier Krystian Hebel
2020-11-10 14:44 ` [GRUB PATCH RFC 08/22] i386/tpm: Add TPM TIS and CRB driver Krystian Hebel
2020-11-10 14:44 ` [GRUB PATCH RFC 09/22] efi: Make shim_lock GUID and protocol type public Krystian Hebel
2020-11-10 14:44 ` [GRUB PATCH RFC 10/22] efi: Return grub_efi_status_t from grub_efi_get_variable() Krystian Hebel
2020-11-10 14:44 ` Krystian Hebel [this message]
2020-11-10 14:44 ` [GRUB PATCH RFC 12/22] i386/efi: Report UEFI Secure Boot status to the Linux kernel Krystian Hebel
2020-11-10 14:44 ` [GRUB PATCH RFC 13/22] i386/slaunch: Add basic platform support for secure launch Krystian Hebel
2020-11-10 14:44 ` [GRUB PATCH RFC 14/22] i386/txt: Add Intel TXT definitions header file Krystian Hebel
2020-11-10 14:44 ` [GRUB PATCH RFC 15/22] i386/txt: Add Intel TXT core implementation Krystian Hebel
2020-11-10 14:44 ` [GRUB PATCH RFC 16/22] i386/txt: Add Intel TXT ACM module support Krystian Hebel
2020-11-10 14:44 ` [GRUB PATCH RFC 17/22] i386/txt: Add Intel TXT verification routines Krystian Hebel
2020-11-10 14:44 ` [GRUB PATCH RFC 18/22] i386/slaunch: Add secure launch framework and commands Krystian Hebel
2020-11-10 14:44 ` [GRUB PATCH RFC 19/22] i386/slaunch: Add code for searching for DRTM event log in ACPI Krystian Hebel
2020-11-10 14:44 ` [GRUB PATCH RFC 20/22] i386/skinit: Add AMD SKINIT definitions header file Krystian Hebel
2020-11-10 14:44 ` [GRUB PATCH RFC 21/22] i386/skinit: Add AMD SKINIT core implementation Krystian Hebel
2020-11-10 14:45 ` [GRUB PATCH RFC 22/22] i386/slaunch: Add support for AMD SKINIT Krystian Hebel
2020-11-10 22:00 ` [GRUB RFC PATCH 00/22] i386: Intel TXT and AMD SKINIT secure launcher Konrad Rzeszutek Wilk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201110144500.31606-12-krystian.hebel@3mdeb.com \
    --to=krystian.hebel@3mdeb.com \
    --cc=grub-devel@gnu.org \
    --cc=norbert.kaminski@3mdeb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.