diff mbox series

Regression: ef/x86: Remove EfiMemoryMappedIO from E820 map

Message ID c3796ac1-521f-4cba-9c74-3eb92072bb85@iam.tj
State New
Headers show
Series Regression: ef/x86: Remove EfiMemoryMappedIO from E820 map | expand

Commit Message

Tj April 11, 2024, 12:02 p.m. UTC
Lenovo Legion 9i fails to set up e820 EFI MMIO regions since v6.2 due to
commit 07eab0901ede8b75 "efi/x86: Remove EfiMemoryMappedIO from E820 map"

Mateusz Kaduk bisected v6.1..v6.2 and pinpointed this on his Legion 9i and confirms this patch fixes all the reported issues.

https://bugzilla.kernel.org/show_bug.cgi?id=218444

This patch is more of a proof of cause since it is quite coarse; it simply disables the effects of 07eab0901ede8b75 with "keep_efi_e820" on command-line; maybe there is a better way than arbitrarily
removing mappings larger than 256KiB? I wonder if the removal should be done later once the regions
have been read, or if there is some inherent metadata in the regions to describe what range(s) need
to be retained.
diff mbox series

Patch

From 8156a7560be93ce563f45b3ce1f643f63f9e2126 Mon Sep 17 00:00:00 2001
From: Tj <linux@iam.tj>
Date: Thu, 11 Apr 2024 12:37:46 +0100
Subject: [PATCH] efi/x86: add param keep_efi_e820

Add a command-line option to retain all e820 mappings.

Commit 07eab0901ede8b in v6.2 added logic to remove e820 EFI MMIO
regions larger than 256KiB. This caused a regression that affects
Lenovo Legion 9i and possibly others.

Fixes: 07eab0901ede8b ("efi/x86: Remove EfiMemoryMappedIO from E820
map")
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218444
Signed-off-by: Tj <linux@iam.tj>
Tested-by: Mateusz Kaduk <mateusz.kaduk@gmail.com>
---
 arch/x86/platform/efi/efi.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index f090ec972d7b..9410182942bd 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -103,6 +103,14 @@  static const unsigned long * const efi_tables[] = {
 
 u64 efi_setup;		/* efi setup_data physical address */
 
+static int keep_efi_e820 __initdata;
+static int __init setup_keep_efi_e820(char *arg)
+{
+	keep_efi_e820 = 1;
+	return 0;
+}
+early_param("keep_efi_e820", setup_keep_efi_e820);
+
 static int add_efi_memmap __initdata;
 static int __init setup_add_efi_memmap(char *arg)
 {
@@ -333,6 +341,9 @@  static void __init efi_remove_e820_mmio(void)
 	u64 size, start, end;
 	int i = 0;
 
+	if (keep_efi_e820)
+		return;
+
 	for_each_efi_memory_desc(md) {
 		if (md->type == EFI_MEMORY_MAPPED_IO) {
 			size = md->num_pages << EFI_PAGE_SHIFT;
-- 
2.39.2