[PATCH RFC 1/3] x86/e820: Ignore memmap= in confidential guests

From: Pankaj Gupta

Date: Tue Nov 24 2026 - 08:32:58 EST


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@xxxxxxxxxxxxxxxx/
[2] https://lore.kernel.org/all/20261113105554.199912-1-pankaj.gupta@xxxxxxx/

Suggested-by: Ard Biesheuvel <ardb@xxxxxxxxxx>
Signed-off-by: Pankaj Gupta <pankaj.gupta@xxxxxxx>
---
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