* [PATCH RFC 1/3] x86/e820: Ignore memmap= in confidential guests
2026-11-24 13:32 [PATCH RFC 0/3] x86/e820: Ignore memmap= and mem= in confidential guests Pankaj Gupta
@ 2026-11-24 13:32 ` Pankaj Gupta
2026-11-24 13:32 ` [PATCH RFC 2/3] x86/e820: Allow memmap= in a kdump kernel " Pankaj Gupta
` (2 subsequent siblings)
3 siblings, 0 replies; 11+ messages in thread
From: Pankaj Gupta @ 2026-11-24 13:32 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86
Cc: H . Peter Anvin, Tom Lendacky, Ard Biesheuvel, Kiryl Shutsemau,
Ilias Apalodimas, linux-kernel, Mike Rapoport, linux-mm,
linux-efi, Pankaj.gupta.linux, Pankaj Gupta
In a confidential guest the memory layout, including the EFI unaccepted
memory bitmap, is set up by the firmware and the EFI stub before the
command line is parsed. memmap= only edits the E820 table afterwards, so
the two no longer match.
The bitmap has one bit per unit and a unit cannot be partly accepted. A
memmap= hole that does not start and end on unit boundaries splits a unit.
Accepting that unit touches the hole, which faults early in boot on
SEV-SNP. A kexec kernel gets an E820 table in which the hole is still RAM.
Ard suggested to avoid such command line hacks in confidential VMs, as the
firmware's view of memory should be in sync with the OS [1]. The
discussion of the unaccepted memory fix [2] showed that the bitmap
cannot represent this case.
Warn and ignore memmap= in confidential guests.
[1] https://lore.kernel.org/all/deb5ea81-70bd-463d-8d98-ed51c316cf75@app.fastmail.com/
[2] https://lore.kernel.org/all/20261113105554.199912-1-pankaj.gupta@amd.com/
Suggested-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
---
arch/x86/kernel/e820.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 0967b485f38b..142657be690d 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -15,6 +15,7 @@
#include <linux/firmware-map.h>
#include <linux/sort.h>
#include <linux/kvm_types.h>
+#include <linux/cc_platform.h>
#include <asm/e820/api.h>
#include <asm/setup.h>
@@ -905,6 +906,15 @@ __init unsigned long e820__end_of_low_ram_pfn(void)
__initdata static int userdef;
+__init static bool cc_ignore_cmdline_mem(const char *opt)
+{
+ if (!cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
+ return false;
+
+ pr_warn("%s= is not supported in confidential guests, ignoring\n", opt);
+ return true;
+}
+
/* The "mem=nopentium" boot option disables 4MB page tables on 32-bit kernels: */
__init static int parse_memopt(char *p)
{
@@ -997,6 +1007,9 @@ __init static int parse_memmap_one(char *p)
__init static int parse_memmap_opt(char *str)
{
+ if (cc_ignore_cmdline_mem("memmap"))
+ return 0;
+
while (str) {
char *k = strchr(str, ',');
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH RFC 2/3] x86/e820: Allow memmap= in a kdump kernel in confidential guests
2026-11-24 13:32 [PATCH RFC 0/3] x86/e820: Ignore memmap= and mem= in confidential guests Pankaj Gupta
2026-11-24 13:32 ` [PATCH RFC 1/3] x86/e820: Ignore memmap= " Pankaj Gupta
@ 2026-11-24 13:32 ` Pankaj Gupta
2026-11-24 13:32 ` [PATCH RFC 3/3] x86/e820: Ignore mem= " Pankaj Gupta
2026-11-24 15:09 ` [PATCH RFC 0/3] x86/e820: Ignore memmap= and " Dave Hansen
3 siblings, 0 replies; 11+ messages in thread
From: Pankaj Gupta @ 2026-11-24 13:32 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86
Cc: H . Peter Anvin, Tom Lendacky, Ard Biesheuvel, Kiryl Shutsemau,
Ilias Apalodimas, linux-kernel, Mike Rapoport, linux-mm,
linux-efi, Pankaj.gupta.linux, Pankaj Gupta
A kdump kernel can get memmap= on its command line, e.g. from kexec_load,
to restrict the memory it may use to its reserved region. Ignoring it
would let the kdump kernel use the memory of the crashed kernel.
Do not ignore memmap= when elfcorehdr= is on the command line, which marks
a kdump kernel.
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
---
arch/x86/kernel/e820.c | 7 +++++++
1 file changed, 6 insertions(+)
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 142657be690d..9c206ad4369c 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -17,6 +17,7 @@
#include <linux/kvm_types.h>
#include <linux/cc_platform.h>
+#include <asm/cmdline.h>
#include <asm/e820/api.h>
#include <asm/setup.h>
@@ -908,9 +909,14 @@ __initdata static int userdef;
__init static bool cc_ignore_cmdline_mem(const char *opt)
{
+ char buf[32];
+
if (!cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
return false;
+ if (cmdline_find_option(boot_command_line, "elfcorehdr", buf, sizeof(buf)) >= 0)
+ return false;
+
pr_warn("%s= is not supported in confidential guests, ignoring\n", opt);
return true;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH RFC 3/3] x86/e820: Ignore mem= in confidential guests
2026-11-24 13:32 [PATCH RFC 0/3] x86/e820: Ignore memmap= and mem= in confidential guests Pankaj Gupta
2026-11-24 13:32 ` [PATCH RFC 1/3] x86/e820: Ignore memmap= " Pankaj Gupta
2026-11-24 13:32 ` [PATCH RFC 2/3] x86/e820: Allow memmap= in a kdump kernel " Pankaj Gupta
@ 2026-11-24 13:32 ` Pankaj Gupta
2026-11-24 15:09 ` [PATCH RFC 0/3] x86/e820: Ignore memmap= and " Dave Hansen
3 siblings, 0 replies; 11+ messages in thread
From: Pankaj Gupta @ 2026-11-24 13:32 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86
Cc: H . Peter Anvin, Tom Lendacky, Ard Biesheuvel, Kiryl Shutsemau,
Ilias Apalodimas, linux-kernel, Mike Rapoport, linux-mm,
linux-efi, Pankaj.gupta.linux, Pankaj Gupta
mem= also only edits the E820 table, after the firmware and the EFI stub
have set up the unaccepted memory bitmap. It removes the RAM above the
given limit, but the bitmap bits for it stay set.
accept_memory() accepts whole units, and one more unit when the range ends
on a unit boundary. Memory below the limit can therefore pull in a unit
that is no longer in the E820 table. On SEV-SNP that memory is not mapped
and PVALIDATE faults.
Warn and ignore mem= in confidential guests, for the same reason as
memmap=.
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
---
arch/x86/kernel/e820.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 9c206ad4369c..c7b86267a480 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -940,6 +940,9 @@ __init static int parse_memopt(char *p)
#endif
}
+ if (cc_ignore_cmdline_mem("mem"))
+ return 0;
+
userdef = 1;
mem_size = memparse(p, &p);
--
2.34.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH RFC 0/3] x86/e820: Ignore memmap= and mem= in confidential guests
2026-11-24 13:32 [PATCH RFC 0/3] x86/e820: Ignore memmap= and mem= in confidential guests Pankaj Gupta
` (2 preceding siblings ...)
2026-11-24 13:32 ` [PATCH RFC 3/3] x86/e820: Ignore mem= " Pankaj Gupta
@ 2026-11-24 15:09 ` Dave Hansen
2026-11-24 15:56 ` Mike Rapoport
3 siblings, 1 reply; 11+ messages in thread
From: Dave Hansen @ 2026-11-24 15:09 UTC (permalink / raw)
To: Pankaj Gupta, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, x86
Cc: H . Peter Anvin, Tom Lendacky, Ard Biesheuvel, Kiryl Shutsemau,
Ilias Apalodimas, linux-kernel, Mike Rapoport, linux-mm,
linux-efi, Pankaj.gupta.linux
On 11/24/26 05:32, Pankaj Gupta wrote:
> In a confidential guest (SEV-SNP, TDX) the EFI stub builds the unaccepted
> memory bitmap before the command line is parsed. memmap= and mem= edit
> e820_table only afterwards.
memmap= and mem= are debugging tools, right? If you use them, you get to
keep the pieces. Why add complexity for this?
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH RFC 0/3] x86/e820: Ignore memmap= and mem= in confidential guests
2026-11-24 15:09 ` [PATCH RFC 0/3] x86/e820: Ignore memmap= and " Dave Hansen
@ 2026-11-24 15:56 ` Mike Rapoport
2026-11-24 15:58 ` Dave Hansen
0 siblings, 1 reply; 11+ messages in thread
From: Mike Rapoport @ 2026-11-24 15:56 UTC (permalink / raw)
To: Dave Hansen
Cc: Pankaj Gupta, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, x86, H . Peter Anvin, Tom Lendacky, Ard Biesheuvel,
Kiryl Shutsemau, Ilias Apalodimas, linux-kernel, linux-mm,
linux-efi, Pankaj.gupta.linux
On Tue, Nov 24, 2026 at 07:09:42AM -0800, Dave Hansen wrote:
> On 11/24/26 05:32, Pankaj Gupta wrote:
> > In a confidential guest (SEV-SNP, TDX) the EFI stub builds the unaccepted
> > memory bitmap before the command line is parsed. memmap= and mem= edit
> > e820_table only afterwards.
>
> memmap= and mem= are debugging tools, right?
I wish they were :)
But AFAIU they are used to carve out "pmem" or PFN-mapped memory.
> If you use them, you get to keep the pieces. Why add complexity for this?
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH RFC 0/3] x86/e820: Ignore memmap= and mem= in confidential guests
2026-11-24 15:56 ` Mike Rapoport
@ 2026-11-24 15:58 ` Dave Hansen
2026-11-24 16:14 ` Mike Rapoport
0 siblings, 1 reply; 11+ messages in thread
From: Dave Hansen @ 2026-11-24 15:58 UTC (permalink / raw)
To: Mike Rapoport
Cc: Pankaj Gupta, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, x86, H . Peter Anvin, Tom Lendacky, Ard Biesheuvel,
Kiryl Shutsemau, Ilias Apalodimas, linux-kernel, linux-mm,
linux-efi, Pankaj.gupta.linux
On 11/24/26 07:56, Mike Rapoport wrote:
> On Tue, Nov 24, 2026 at 07:09:42AM -0800, Dave Hansen wrote:
>> On 11/24/26 05:32, Pankaj Gupta wrote:
>>> In a confidential guest (SEV-SNP, TDX) the EFI stub builds the unaccepted
>>> memory bitmap before the command line is parsed. memmap= and mem= edit
>>> e820_table only afterwards.
>> memmap= and mem= are debugging tools, right?
> I wish they were 🙂
> But AFAIU they are used to carve out "pmem" or PFN-mapped memory.
I've used them that way for development, but production pmem systems
always had persistent memory in their BIOS-provided memory maps.
How are folks depending on these in production in confidential guests?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH RFC 0/3] x86/e820: Ignore memmap= and mem= in confidential guests
2026-11-24 15:58 ` Dave Hansen
@ 2026-11-24 16:14 ` Mike Rapoport
2026-11-24 16:26 ` Ard Biesheuvel
0 siblings, 1 reply; 11+ messages in thread
From: Mike Rapoport @ 2026-11-24 16:14 UTC (permalink / raw)
To: Dave Hansen
Cc: Pankaj Gupta, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, x86, H . Peter Anvin, Tom Lendacky, Ard Biesheuvel,
Kiryl Shutsemau, Ilias Apalodimas, linux-kernel, linux-mm,
linux-efi, Pankaj.gupta.linux
On Tue, Nov 24, 2026 at 07:58:31AM -0800, Dave Hansen wrote:
> On 11/24/26 07:56, Mike Rapoport wrote:
> > On Tue, Nov 24, 2026 at 07:09:42AM -0800, Dave Hansen wrote:
> >> On 11/24/26 05:32, Pankaj Gupta wrote:
> >>> In a confidential guest (SEV-SNP, TDX) the EFI stub builds the unaccepted
> >>> memory bitmap before the command line is parsed. memmap= and mem= edit
> >>> e820_table only afterwards.
> >> memmap= and mem= are debugging tools, right?
> > I wish they were 🙂
> > But AFAIU they are used to carve out "pmem" or PFN-mapped memory.
>
> I've used them that way for development, but production pmem systems
> always had persistent memory in their BIOS-provided memory maps.
>
> How are folks depending on these in production in confidential guests?
They shouldn't but you can't guarantee that.
But I don't mind letting them crash if they do :)
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH RFC 0/3] x86/e820: Ignore memmap= and mem= in confidential guests
2026-11-24 16:14 ` Mike Rapoport
@ 2026-11-24 16:26 ` Ard Biesheuvel
2026-11-24 16:32 ` Dave Hansen
2026-11-24 17:27 ` Gupta, Pankaj
0 siblings, 2 replies; 11+ messages in thread
From: Ard Biesheuvel @ 2026-11-24 16:26 UTC (permalink / raw)
To: Mike Rapoport, Dave Hansen
Cc: Pankaj Gupta, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, x86, H . Peter Anvin, Tom Lendacky,
Kiryl Shutsemau (Meta), Ilias Apalodimas, linux-kernel, linux-mm,
linux-efi, Pankaj.gupta.linux
On Tue, 24 Nov 2026, at 17:14, Mike Rapoport wrote:
> On Tue, Nov 24, 2026 at 07:58:31AM -0800, Dave Hansen wrote:
>> On 11/24/26 07:56, Mike Rapoport wrote:
>> > On Tue, Nov 24, 2026 at 07:09:42AM -0800, Dave Hansen wrote:
>> >> On 11/24/26 05:32, Pankaj Gupta wrote:
>> >>> In a confidential guest (SEV-SNP, TDX) the EFI stub builds the unaccepted
>> >>> memory bitmap before the command line is parsed. memmap= and mem= edit
>> >>> e820_table only afterwards.
>> >> memmap= and mem= are debugging tools, right?
>> > I wish they were 🙂
>> > But AFAIU they are used to carve out "pmem" or PFN-mapped memory.
>>
>> I've used them that way for development, but production pmem systems
>> always had persistent memory in their BIOS-provided memory maps.
>>
>> How are folks depending on these in production in confidential guests?
>
> They shouldn't but you can't guarantee that.
>
> But I don't mind letting them crash if they do :)
>
I'm fine with either approach (i.e. disallowing it or doing nothing
at all), as long as we don't pretend that this is something that is
expected to work.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH RFC 0/3] x86/e820: Ignore memmap= and mem= in confidential guests
2026-11-24 16:26 ` Ard Biesheuvel
@ 2026-11-24 16:32 ` Dave Hansen
2026-11-24 17:27 ` Gupta, Pankaj
1 sibling, 0 replies; 11+ messages in thread
From: Dave Hansen @ 2026-11-24 16:32 UTC (permalink / raw)
To: Ard Biesheuvel, Mike Rapoport
Cc: Pankaj Gupta, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, x86, H . Peter Anvin, Tom Lendacky,
Kiryl Shutsemau (Meta), Ilias Apalodimas, linux-kernel, linux-mm,
linux-efi, Pankaj.gupta.linux
On 11/24/26 08:26, Ard Biesheuvel wrote:
>> They shouldn't but you can't guarantee that.
>>
>> But I don't mind letting them crash if they do 🙂
>>
> I'm fine with either approach (i.e. disallowing it or doing nothing
> at all), as long as we don't pretend that this is something that is
> expected to work.
Yeah, it's not supposed to work. I'd rather document "don't poke the
sharp stick in your eye" versus trying to make the stick less sharp.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH RFC 0/3] x86/e820: Ignore memmap= and mem= in confidential guests
2026-11-24 16:26 ` Ard Biesheuvel
2026-11-24 16:32 ` Dave Hansen
@ 2026-11-24 17:27 ` Gupta, Pankaj
1 sibling, 0 replies; 11+ messages in thread
From: Gupta, Pankaj @ 2026-11-24 17:27 UTC (permalink / raw)
To: Ard Biesheuvel, Mike Rapoport, Dave Hansen
Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H . Peter Anvin, Tom Lendacky, Kiryl Shutsemau (Meta),
Ilias Apalodimas, linux-kernel, linux-mm, linux-efi,
Pankaj.gupta.linux
>>>>>> In a confidential guest (SEV-SNP, TDX) the EFI stub builds the unaccepted
>>>>>> memory bitmap before the command line is parsed. memmap= and mem= edit
>>>>>> e820_table only afterwards.
>>>>> memmap= and mem= are debugging tools, right?
>>>> I wish they were 🙂
>>>> But AFAIU they are used to carve out "pmem" or PFN-mapped memory.
>>> I've used them that way for development, but production pmem systems
>>> always had persistent memory in their BIOS-provided memory maps.
>>>
>>> How are folks depending on these in production in confidential guests?
>> They shouldn't but you can't guarantee that.
>>
>> But I don't mind letting them crash if they do :)
>>
> I'm fine with either approach (i.e. disallowing it or doing nothing
> at all), as long as we don't pretend that this is something that is
> expected to work.
Yes, it is confusing for a user who expects it to work. I hit this
myself and spent time finding the cause: a memmap= hole consistently
crashes a confidential guest (SEV-SNP) early in boot.
I tried to fix it [1], but a bitmap unit cannot be half accepted when the
hole is not 2 MiB aligned. Also, a TDX guest does accept such holes.
So we are left with the following options:
- disallow the memmap= options with a clear warning, as this series
does,
- add similar handling for TDX, so that holes are not accepted there
either, as done for SEV-SNP in [1]; memmap= holes that are not
2 MiB aligned would still be unhandled, or
- only print a warning and leave the options applied, in which case
memmap= holes still crash SEV-SNP guests.
Which of these do you prefer, or is there a better way to handle it?
[1]
https://lore.kernel.org/all/20261113105554.199912-1-pankaj.gupta@amd.com/
Thanks,
Pankaj
^ permalink raw reply [flat|nested] 11+ messages in thread