diff mbox series

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

Message ID 20230911081024.3489875-2-ardb@google.com
State New
Headers show
Series efi/x86: Disable buggy QueryVariableInfo() on HP ProBook x360 | expand

Commit Message

Ard Biesheuvel Sept. 11, 2023, 8:10 a.m. UTC
From: Ard Biesheuvel <ardb@kernel.org>

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.

Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=217898
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
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/20230910045445.41632-1-heinrich.schuchardt@canonical.com/

 arch/x86/platform/efi/quirks.c | 31 ++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
index f0cc00032751..7103bec7bc86 100644
--- a/arch/x86/platform/efi/quirks.c
+++ b/arch/x86/platform/efi/quirks.c
@@ -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);