* [PATCH] x86/efi: Handle EFI_UNACCEPTED_MEMORY in do_add_efi_memmap()
@ 2026-11-25 17:33 Kiryl Shutsemau (Meta)
2026-11-26 11:27 ` Gupta, Pankaj
2026-11-26 11:29 ` Ard Biesheuvel
0 siblings, 2 replies; 4+ messages 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 related [flat|nested] 4+ messages in thread* Re: [PATCH] x86/efi: Handle EFI_UNACCEPTED_MEMORY in do_add_efi_memmap()
2026-11-25 17:33 [PATCH] x86/efi: Handle EFI_UNACCEPTED_MEMORY in do_add_efi_memmap() Kiryl Shutsemau (Meta)
@ 2026-11-26 11:27 ` Gupta, Pankaj
2026-11-26 11:29 ` Ard Biesheuvel
1 sibling, 0 replies; 4+ messages in thread
From: Gupta, Pankaj @ 2026-11-26 11:27 UTC (permalink / raw)
To: Kiryl Shutsemau (Meta), Ard Biesheuvel
Cc: Ilias Apalodimas, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, x86, H. Peter Anvin, Mike Rapoport, Tom Lendacky,
Rick Edgecombe, 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>
Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>
Tested-by: Pankaj Gupta <pankaj.gupta@amd.com>
Tested on SEV-SNP with CONFIG_UNACCEPTED_MEMORY=y
Best regards,
Pankaj
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] x86/efi: Handle EFI_UNACCEPTED_MEMORY in do_add_efi_memmap()
2026-11-25 17:33 [PATCH] x86/efi: Handle EFI_UNACCEPTED_MEMORY in do_add_efi_memmap() Kiryl Shutsemau (Meta)
2026-11-26 11:27 ` Gupta, Pankaj
@ 2026-11-26 11:29 ` Ard Biesheuvel
2026-11-26 12:06 ` Kiryl Shutsemau (Meta)
1 sibling, 1 reply; 4+ messages in thread
From: Ard Biesheuvel @ 2026-11-26 11:29 UTC (permalink / raw)
To: Kiryl Shutsemau (Meta)
Cc: 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
On Wed, 25 Nov 2026, at 18:33, Kiryl Shutsemau (Meta) wrote:
> 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(+)
>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
I can take this via efi/urgent if desired.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] x86/efi: Handle EFI_UNACCEPTED_MEMORY in do_add_efi_memmap()
2026-11-26 11:29 ` Ard Biesheuvel
@ 2026-11-26 12:06 ` Kiryl Shutsemau (Meta)
0 siblings, 0 replies; 4+ messages in thread
From: Kiryl Shutsemau (Meta) @ 2026-11-26 12:06 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: 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
On Thu, Nov 26, 2026 at 12:29:30PM +0100, Ard Biesheuvel wrote:
>
>
> On Wed, 25 Nov 2026, at 18:33, Kiryl Shutsemau (Meta) wrote:
> > 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(+)
> >
>
> Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
>
> I can take this via efi/urgent if desired.
It is not urgent on my part. It can wait the next merge window, unless
someone else needs it now.
--
Kiryl Shutsemau / Kirill A. Shutemov
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-26 12:06 UTC | newest]
Thread overview: 4+ messages (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)
2026-11-26 11:27 ` Gupta, Pankaj
2026-11-26 11:29 ` Ard Biesheuvel
2026-11-26 12:06 ` 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