mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86/efi: Handle EFI_UNACCEPTED_MEMORY in do_add_efi_memmap()
@ 2026-11-25 17:33 Kiryl Shutsemau (Meta)
  0 siblings, 0 replies; only message in thread
From: Kiryl Shutsemau (Meta) @ 2026-11-25 17:33 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Kiryl Shutsemau (Meta),
	Ilias Apalodimas, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin, Mike Rapoport, Tom Lendacky,
	Rick Edgecombe, Pankaj Gupta, linux-efi, linux-coco,
	linux-kernel, kernel-team, stable

The EFI stub reports unaccepted memory to the kernel as E820 RAM.
do_add_efi_memmap() has no case for EFI_UNACCEPTED_MEMORY and adds the
same range again as E820_TYPE_RESERVED. e820__update_table() resolves
the overlap in favour of the reserved type, so the kernel never uses
the range.

do_add_efi_memmap() runs when soft reservation is enabled and the
firmware marks any conventional memory EFI_MEMORY_SP; that takes no
command-line option. It also runs with the add_efi_memmap boot
parameter. A TDX or SEV-SNP guest booted either way loses the memory the
firmware left unaccepted, and it does not show up in MemTotal.

Add unaccepted memory as RAM, as the stub does. Without
CONFIG_UNACCEPTED_MEMORY the kernel cannot accept it, so keep it
reserved there.

Fixes: 745e3ed85f71 ("efi/libstub: Implement support for unaccepted memory")
Reported-by: Mike Rapoport <rppt@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
---
Build-tested only, with and without CONFIG_UNACCEPTED_MEMORY.

 arch/x86/platform/efi/efi.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 5eb96c17883e..f03d5e984f2f 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -150,6 +150,12 @@ static void __init do_add_efi_memmap(void)
 		case EFI_PERSISTENT_MEMORY:
 			e820_type = E820_TYPE_PMEM;
 			break;
+		case EFI_UNACCEPTED_MEMORY:
+			if (IS_ENABLED(CONFIG_UNACCEPTED_MEMORY))
+				e820_type = E820_TYPE_RAM;
+			else
+				e820_type = E820_TYPE_RESERVED;
+			break;
 		default:
 			/*
 			 * EFI_RESERVED_TYPE EFI_RUNTIME_SERVICES_CODE

base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
-- 
2.54.0


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

only message in thread, other threads:[~2026-11-25 17:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 17:33 [PATCH] x86/efi: Handle EFI_UNACCEPTED_MEMORY in do_add_efi_memmap() Kiryl Shutsemau (Meta)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®