Skip to contentSkip to conversation

efi: Override runtime supported mask from a EFI variable if present

PATCH In review Ard Biesheuvel 2 participants 3 messages Nov 9, 2022 – Nov 11, 2022 EFI

lore
Share & tools
lore

Ard Biesheuvel

author maintainer
#0 lore raw

PATCH 1/1 efi: Override runtime supported mask from a EFI variable if present

For debugging purposes, allow the runtime override mask to be set from a EFI variable if one exists. For instance, the RT supported mask can be set to 0xfffd to disable the SetTime() runtime service, and enable all others:

  echo -ne "\x7\0\0\0\xfd\xff" \
    > /sys/firmware/efi/efivars/LinuxRtMaskOverride-eb66918a-7eef-402a-842e-931d21c38ae9
---
 drivers/firmware/efi/efi.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/firmware/efi/efi.c +11 -1
index a46df5d1d0942751..faed1ef78c044924 100644
@@ -367,7 +367,17 @@ static int __init efisubsys_init(void)
 		}
 	}
 
-	if (efi_rt_services_supported(EFI_RT_SUPPORTED_TIME_SERVICES))
+	if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE)) {
+		unsigned long size = sizeof(efi.runtime_supported_mask);
+
+		if (efi.get_variable(L"LinuxRtMaskOverride",
+				     &EFI_RT_PROPERTIES_TABLE_GUID, NULL, &size,
+				     &efi.runtime_supported_mask) == EFI_SUCCESS)
+			pr_info("Overriding runtime_supported_mask to 0x%x\n",
+				efi.runtime_supported_mask);
+	}
+
+	if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_TIME))
 		platform_device_register_simple("rtc-efi", 0, NULL, 0);
 
 	/* We register the efi directory at /sys/firmware/efi */
Signature · 1 line
2.35.1
#1 lore raw

Hi,

Quoted 7 lines · Ard Biesheuvel

For debugging purposes, allow the runtime override mask to be set from a EFI variable if one exists. For instance, the RT supported mask can be set to 0xfffd to disable the SetTime() runtime service, and enable all others:

  echo -ne "\x7\0\0\0\xfd\xff" \
    > /sys/firmware/efi/efivars/LinuxRtMaskOverride-eb66918a-7eef-402a-842e-931d21c38ae9

I'm really sorry, I applied this patch, but I couldn't find the file (LinuxRtMaskOverride*) under efivars, and couldn't find another way of setting the variable.

Thanks,
Alex

Quoted 32 lines
---
 drivers/firmware/efi/efi.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/firmware/efi/efi.c +11 -1
index a46df5d1d0942751..faed1ef78c044924 100644
@@ -367,7 +367,17 @@ static int __init efisubsys_init(void)
 		}
 	}
 
-	if (efi_rt_services_supported(EFI_RT_SUPPORTED_TIME_SERVICES))
+	if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE)) {
+		unsigned long size = sizeof(efi.runtime_supported_mask);
+
+		if (efi.get_variable(L"LinuxRtMaskOverride",
+				     &EFI_RT_PROPERTIES_TABLE_GUID, NULL, &size,
+				     &efi.runtime_supported_mask) == EFI_SUCCESS)
+			pr_info("Overriding runtime_supported_mask to 0x%x\n",
+				efi.runtime_supported_mask);
+	}
+
+	if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_TIME))
 		platform_device_register_simple("rtc-efi", 0, NULL, 0);
 
 	/* We register the efi directory at /sys/firmware/efi */
Signature · 1 line
2.35.1
author maintainer
#2 lore raw
Quoted 9 lines · Alexandru Elisei

Hi,

Quoted 5 lines · Ard Biesheuvel

For debugging purposes, allow the runtime override mask to be set from a EFI variable if one exists. For instance, the RT supported mask can be set to 0xfffd to disable the SetTime() runtime service, and enable all others:

Quoted 7 lines
Quoted 2 lines
  echo -ne "\x7\0\0\0\xfd\xff" \
    > /sys/firmware/efi/efivars/LinuxRtMaskOverride-eb66918a-7eef-402a-842e-931d21c38ae9

I'm really sorry, I applied this patch, but I couldn't find the file (LinuxRtMaskOverride*) under efivars, and couldn't find another way of setting the variable.

The variable will be created by writing to the file.

But no worries, I think we have enough context now. I've queued up the patch that checks the SMBIOS record for Altra machines.

Quoted 32 lines
Quoted 32 lines
---
 drivers/firmware/efi/efi.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/firmware/efi/efi.c +11 -2
index a46df5d1d0942751..faed1ef78c044924 100644
@@ -367,7 +367,17 @@ static int __init efisubsys_init(void)
              }
      }
 
-     if (efi_rt_services_supported(EFI_RT_SUPPORTED_TIME_SERVICES))
+     if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE)) {
+             unsigned long size = sizeof(efi.runtime_supported_mask);
+
+             if (efi.get_variable(L"LinuxRtMaskOverride",
+                                  &EFI_RT_PROPERTIES_TABLE_GUID, NULL, &size,
+                                  &efi.runtime_supported_mask) == EFI_SUCCESS)
+                     pr_info("Overriding runtime_supported_mask to 0x%x\n",
+                             efi.runtime_supported_mask);
+     }
+
+     if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_TIME))
              platform_device_register_simple("rtc-efi", 0, NULL, 0);
 
      /* We register the efi directory at /sys/firmware/efi */
--

2.35.1