]> git.proxmox.com Git - efi-boot-shim.git/commitdiff
Don't call QueryVariableInfo() on EFI 1.10 machines
authorSteve McIntyre <steve@einval.com>
Tue, 20 Apr 2021 23:25:20 +0000 (00:25 +0100)
committerSteve McIntyre <steve@einval.com>
Tue, 20 Apr 2021 23:25:20 +0000 (00:25 +0100)
New patch from upstream, don't break old Macs

debian/patches/Don-t-call-QueryVariableInfo-on-EFI-1.10-machines.patch [new file with mode: 0644]
debian/patches/series

diff --git a/debian/patches/Don-t-call-QueryVariableInfo-on-EFI-1.10-machines.patch b/debian/patches/Don-t-call-QueryVariableInfo-on-EFI-1.10-machines.patch
new file mode 100644 (file)
index 0000000..74ae9eb
--- /dev/null
@@ -0,0 +1,62 @@
+From 8b59591775a0412863aab9596ab87bdd493a9c1e Mon Sep 17 00:00:00 2001
+From: Peter Jones <pjones@redhat.com>
+Date: Sat, 10 Apr 2021 16:05:23 -0400
+Subject: [PATCH] Don't call QueryVariableInfo() on EFI 1.10 machines
+
+The EFI 1.10 spec (and presumably earlier revisions as well) didn't have
+RT->QueryVariableInfo(), and on Chris Murphy's MacBookPro8,2 , that
+memory appears to be initialized randomly.
+
+This patch changes it to not call RT->QueryVariableInfo() if the
+EFI_RUNTIME_SERVICES table's major revision is less than two, and
+assumes our maximum variable size is 1024 in that case.
+
+Signed-off-by: Peter Jones <pjones@redhat.com>
+---
+ mok.c | 23 ++++++++++++++++++-----
+ 1 file changed, 18 insertions(+), 5 deletions(-)
+
+diff --git a/mok.c b/mok.c
+index 9b8fc2bc..beac0ff6 100644
+--- a/mok.c
++++ b/mok.c
+@@ -261,6 +261,9 @@ static const uint8_t null_sha256[32] = { 0, };
+ typedef UINTN SIZE_T;
++#define EFI_MAJOR_VERSION(tablep) ((UINT16)((((tablep)->Hdr.Revision) >> 16) & 0xfffful))
++#define EFI_MINOR_VERSION(tablep) ((UINT16)(((tablep)->Hdr.Revision) & 0xfffful))
++
+ static EFI_STATUS
+ get_max_var_sz(UINT32 attrs, SIZE_T *max_var_szp)
+ {
+@@ -270,11 +273,21 @@ get_max_var_sz(UINT32 attrs, SIZE_T *max_var_szp)
+       uint64_t max_var_sz = 0;
+       *max_var_szp = 0;
+-      efi_status = gRT->QueryVariableInfo(attrs, &max_storage_sz,
+-                                          &remaining_sz, &max_var_sz);
+-      if (EFI_ERROR(efi_status)) {
+-              perror(L"Could not get variable storage info: %r\n", efi_status);
+-              return efi_status;
++      if (EFI_MAJOR_VERSION(gRT) < 2) {
++              dprint(L"EFI %d.%d; no RT->QueryVariableInfo().  Using 1024!\n",
++                     EFI_MAJOR_VERSION(gRT), EFI_MINOR_VERSION(gRT));
++              max_var_sz = remaining_sz = max_storage_sz = 1024;
++              efi_status = EFI_SUCCESS;
++      } else {
++              dprint(L"calling RT->QueryVariableInfo() at 0x%lx\n",
++                     gRT->QueryVariableInfo);
++              efi_status = gRT->QueryVariableInfo(attrs, &max_storage_sz,
++                                                  &remaining_sz, &max_var_sz);
++              if (EFI_ERROR(efi_status)) {
++                      perror(L"Could not get variable storage info: %r\n",
++                             efi_status);
++                      return efi_status;
++              }
+       }
+       /*
+-- 
+2.20.1
+
index 0ffe2a27524f0f041d686631f4f76f827440bb4b..20e12aa7823732199ed52e4632979d86e061f5c8 100644 (file)
@@ -1,3 +1,4 @@
 fix-import_one_mok_state.patch
 fix-broken-ia32-reloc.patch
 MOK-BootServicesData.patch
+Don-t-call-QueryVariableInfo-on-EFI-1.10-machines.patch