Skip to content

Commit

Permalink
avoid EFIv2 runtime services on Apple x86 machines
Browse files Browse the repository at this point in the history
Signed-off-by: Eduard Acatrinei <eduard.acatrinei@certussoftware.ro>
  • Loading branch information
eduardacatrinei committed Sep 3, 2024
1 parent e064e7d commit 54c3e30
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion mok.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,20 @@ 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 BOOLEAN is_apple_firmware_vendor(void)
{
CHAR16 *vendor = ST->FirmwareVendor;
if (!vendor)
return FALSE;

dprint(L"FirmwareVendor: \"%s\"\n", vendor);

if (StrnCmp(vendor, L"Apple", 5) == 0)
return TRUE;

return FALSE;
}

static EFI_STATUS
get_max_var_sz(UINT32 attrs, SIZE_T *max_var_szp)
{
Expand All @@ -226,7 +240,7 @@ get_max_var_sz(UINT32 attrs, SIZE_T *max_var_szp)
uint64_t max_var_sz = 0;

*max_var_szp = 0;
if (EFI_MAJOR_VERSION(RT) < 2) {
if (EFI_MAJOR_VERSION(RT) < 2 || is_apple_firmware_vendor()) {
dprint(L"EFI %d.%d; no RT->QueryVariableInfo(). Using 1024!\n",
EFI_MAJOR_VERSION(RT), EFI_MINOR_VERSION(RT));
max_var_sz = remaining_sz = max_storage_sz = 1024;
Expand Down

0 comments on commit 54c3e30

Please sign in to comment.