From: Grzegorz Jaszczyk <jaszczyk@chromium.org>
To: tglx@linutronix.de, robh@kernel.org
Cc: mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
x86@kernel.org, hpa@zytor.com, saravanak@google.com,
dmaluka@chromium.org, bgrzesik@google.com, jaszczyk@google.com,
ilpo.jarvinen@linux.intel.com, usamaarif642@gmail.com,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
tnowicki@google.com, mazurekm@google.com, vineethrp@google.com,
rppt@kernel.org, agordeev@linux.ibm.com, dyoung@redhat.com,
myrrhperiwinkle@qtmlabs.xyz, guoweikang.kernel@gmail.com,
kirill.shutemov@linux.intel.com, akpm@linux-foundation.org,
joel.granados@kernel.org, sourabhjain@linux.ibm.com
Subject: [PATCH v4 2/2] x86/e820: reserve corresponding to DT reserved-memory nomap region
Date: Fri, 13 Mar 2026 16:03:47 +0000 [thread overview]
Message-ID: <20260313160347.2843005-3-jaszczyk@google.com> (raw)
In-Reply-To: <20260313160347.2843005-1-jaszczyk@google.com>
The DT reserved-memory nomap region shouldn't be mapped and registered
as an IORESOURCE_SYSTEM_RAM resource. On the x86 platform the resource
tree map is built based on e820 entries (via e820__reserve_resources()).
Consequently memblock reservation originating from DT are not taken into
account by x86 resource management unless they are explicitly injected
into e820 table.
Injecting the corresponding no-map into e820 table as
'E820_TYPE_RESERVED', ensures that the x86 architecture builds an
accurate resource tree. This aligns x86 with how other architectures
(like arm64 in request_standard_resources() during resource tree
creation) protect DT no-map region.
Adding a corresponding e820 entry also allows other parts of x86 early
kernel initialization to rely on it. E.g. e820__setup_pci_gap based on
the gap in the e820 memory table picks space and passes to the PCI
subsystem. Without adding corresponding e820 reserved entry, DT
reserved memory nomap region could conflict with such region assigned
later to PCI subsystem.
Additionally updating e820_table in this stage of the x86 setup seems
safe since it is performed before mentioned e820__reserve_resources and
e820__setup_pci_gap and there are also other functions, which updates
e820 table on the later stage of early x86 setup such as early_quirks()
and efi_arch_mem_reserve() (used by efi_esrt_init).
Signed-off-by: Grzegorz Jaszczyk <jaszczyk@google.com>
---
arch/x86/include/asm/e820/api.h | 1 +
arch/x86/kernel/e820.c | 20 ++++++++++++++++++++
arch/x86/kernel/setup.c | 2 ++
3 files changed, 23 insertions(+)
diff --git a/arch/x86/include/asm/e820/api.h b/arch/x86/include/asm/e820/api.h
index bbe0c8de976c..9568d88e8df8 100644
--- a/arch/x86/include/asm/e820/api.h
+++ b/arch/x86/include/asm/e820/api.h
@@ -27,6 +27,7 @@ extern unsigned long e820__end_of_low_ram_pfn(void);
extern u64 e820__memblock_alloc_reserved(u64 size, u64 align);
extern void e820__memblock_setup(void);
+extern void e820__reserve_nomap_region(void);
extern void e820__finish_early_params(void);
extern void e820__reserve_resources(void);
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 2a9992758933..6f8a65dba7c7 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -1374,3 +1374,23 @@ __init void e820__memblock_setup(void)
memblock_dump_all();
}
+
+void __init e820__reserve_nomap_region(void)
+{
+ struct memblock_region *region;
+ bool updated = false;
+
+ for_each_mem_region(region) {
+ if (memblock_is_nomap(region)) {
+ /*
+ * Add corresponding e820 region and let
+ * e820__update_table sanitize e820 map
+ */
+ e820__range_add(region->base, region->size, E820_TYPE_RESERVED);
+ updated = true;
+ }
+ }
+
+ if (updated)
+ e820__update_table_print();
+}
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index cf6c93f8be1a..cbbc7abdabef 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1078,6 +1078,8 @@ void __init setup_arch(char **cmdline_p)
x86_flattree_get_config();
+ e820__reserve_nomap_region();
+
/*
* Needs to run after memblock setup because it needs the physical
* memory size.
--
2.53.0.851.ga537e3e6e9-goog
prev parent reply other threads:[~2026-03-13 16:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-13 16:03 [PATCH v4 0/2] x86: add support for reserved memory defined by DT Grzegorz Jaszczyk
2026-03-13 16:03 ` [PATCH v4 1/2] x86/of: add early setup of DT reserved-memory nodes Grzegorz Jaszczyk
2026-03-13 16:03 ` Grzegorz Jaszczyk [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260313160347.2843005-3-jaszczyk@google.com \
--to=jaszczyk@chromium.org \
--cc=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=bgrzesik@google.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=devicetree@vger.kernel.org \
--cc=dmaluka@chromium.org \
--cc=dyoung@redhat.com \
--cc=guoweikang.kernel@gmail.com \
--cc=hpa@zytor.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jaszczyk@google.com \
--cc=joel.granados@kernel.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mazurekm@google.com \
--cc=mingo@redhat.com \
--cc=myrrhperiwinkle@qtmlabs.xyz \
--cc=robh@kernel.org \
--cc=rppt@kernel.org \
--cc=saravanak@google.com \
--cc=sourabhjain@linux.ibm.com \
--cc=tglx@linutronix.de \
--cc=tnowicki@google.com \
--cc=usamaarif642@gmail.com \
--cc=vineethrp@google.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox