Skip to contentSkip to conversation

efi/x86: Disable buggy QueryVariableInfo() on HP ProBook x360

PATCH New Ard Biesheuvel 1 participant 1 message Sep 11, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efi/x86: Disable buggy QueryVariableInfo() on HP ProBook x360

From: Ard Biesheuvel <[email protected]>

Some HP ProBook x360 machines appear to have a buggy UEFI implementation that crashes in the firmware when QueryVariableInfo() is invoked. So add a DMI based quirk that marks this runtime service as unavailable on those machines.

---
DodoLedev,

Please check whether this patch gives you a working efibootmgr when applied onto 6.4 or earlier. There is another patch [0] under discussion that will combine with this one to fix the 6.5 regression as well.

[0] https://lore.kernel.org/all/[email protected]/

 arch/x86/platform/efi/quirks.c | 31 ++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)
arch/x86/platform/efi/quirks.c +29 -2
index f0cc00032751..7103bec7bc86 100644
@@ -162,8 +162,9 @@ efi_status_t efi_query_variable_store(u32 attributes, unsigned long size,
 	efi_status_t status;
 	u64 storage_size, remaining_size, max_size;
 
-	if (!(attributes & EFI_VARIABLE_NON_VOLATILE))
-		return 0;
+	if (!(attributes & EFI_VARIABLE_NON_VOLATILE) ||
+	    !efi_rt_services_supported(EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO))
+		return EFI_SUCCESS;
 
 	if (nonblocking)
 		return query_variable_store_nonblocking(attributes, size);
@@ -779,3 +780,29 @@ void efi_crash_gracefully_on_page_fault(unsigned long phys_addr)
 		schedule();
 	}
 }
+
+static int __init
+disable_buggy_query_variable_info(const struct dmi_system_id *id)
+{
+	pr_info("Detected %s machine, disabling EFI QueryVariableInfo()\n",
+		id->ident);
+	efi.runtime_supported_mask &= ~EFI_RT_SUPPORTED_QUERY_VARIABLE_INFO;
+	return 1;
+}
+
+static int __init efi_dmi_check(void)
+{
+	static const struct dmi_system_id dmi_ids[] __initconst = {
+		{
+			.callback = disable_buggy_query_variable_info,
+			.ident = "HP ProBook x360",
+			.matches = {
+				DMI_MATCH(DMI_SYS_VENDOR, "HP"),
+				DMI_MATCH(DMI_PRODUCT_NAME, "HP ProBook x360 11 G1 EE"),
+			},
+		},
+		{ }	/* terminating entry */
+	};
+	return dmi_check_system(dmi_ids);
+}
+subsys_initcall(efi_dmi_check);
Signature · 1 line
2.42.0.283.g2d96d420d3-goog