linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] efi/x86: Disable buggy QueryVariableInfo() on HP ProBook x360
@ 2023-09-11  8:10 Ard Biesheuvel
  0 siblings, 0 replies; only message in thread
From: Ard Biesheuvel @ 2023-09-11  8:10 UTC (permalink / raw)
  To: linux-efi
  Cc: N3verG0nnaGiveYouUp+LinuxKernel, Ard Biesheuvel, Ilias Apalodimas,
	Heinrich Schuchardt

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 --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);
-- 
2.42.0.283.g2d96d420d3-goog


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-11  8:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-11  8:10 [PATCH] efi/x86: Disable buggy QueryVariableInfo() on HP ProBook x360 Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).