From: Suseendran Bhaskaran <suseendranb@google.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Mike Rapoport <rppt@kernel.org>, Dan Williams <djbw@kernel.org>,
David Hildenbrand <david@kernel.org>
Cc: Alexander Graf <graf@amazon.com>,
Alison Schofield <alison.schofield@intel.com>,
Andy Lutomirski <luto@kernel.org>,
Borislav Petkov <bp@alien8.de>,
Catalin Marinas <catalin.marinas@arm.com>,
Changyuan Lyu <changyuanl@google.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
Dave Jiang <dave.jiang@intel.com>,
David Rientjes <rientjes@google.com>,
Frank van der Linden <fvdl@google.com>,
"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@redhat.com>,
Ira Weiny <iweiny@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
"Liam R. Howlett" <liam@infradead.org>,
Mark Rutland <mark.rutland@arm.com>,
Michal Hocko <mhocko@suse.com>,
Oscar Salvador <osalvador@suse.de>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
Peter Zijlstra <peterz@infradead.org>,
Pratyush Yadav <pratyush@kernel.org>,
Randy Dunlap <rdunlap@infradead.org>,
Shuah Khan <skhan@linuxfoundation.org>,
Thomas Gleixner <tglx@kernel.org>,
Vishal Verma <vishal.l.verma@intel.com>,
Vlastimil Babka <vbabka@kernel.org>,
Will Deacon <will@kernel.org>,
kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org,
linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
nvdimm@lists.linux.dev, x86@kernel.org,
Suseendran Bhaskaran <suseendranb@google.com>
Subject: [RFC PATCH 11/11] mm/extmem: preserve carved regions across KHO kexec
Date: Wed, 2 Dec 2026 00:19:46 +0000 [thread overview]
Message-ID: <20261202001946.1226273-12-suseendranb@google.com> (raw)
In-Reply-To: <20261202001946.1226273-1-suseendranb@google.com>
Across a Kexec HandOver (KHO) live update, ZONE_DEVICE DAX regions
backing guest VMs must keep the same physical ranges, alignments, and
contents without tracking payload pages in KHO's preserved-page radix
tree (extmem ranges are removed from memblock.memory and have no boot
struct page arrays).
Add KHO preservation in mm/extmem_kho.c and document the "extmem" subtree
ABI in include/linux/kho/abi/extmem.h:
- At late_initcall, reclaim any incoming preserved descriptor folio via
kho_restore_free(), then save each carved region's base, size, NUMA
node ID, and alignment shift into a kho_extmem_ser descriptor table
registered with kho_add_subtree().
- Add kho_early_has_subtree() using early_memremap() so arm64 map_mem()
enables boot carveout handling on KHO boots only when an "extmem"
subtree is present.
- Before kho_memory_init_early() runs kho_discover_noprsrv(), validate
the preserved table against mappable RAM and each region's bounds
against mappable RAM above 4 GiB, then remove revived ranges from
memblock via extmem_commit_regions().
- Ignore extmem= with a warning on KHO boots that have no preserved
"extmem" subtree instead of carving out of KHO bootmem or failing
under kho_noprsrv_only.
Signed-off-by: Suseendran Bhaskaran <suseendranb@google.com>
---
.../admin-guide/kernel-parameters.txt | 2 +
Documentation/core-api/kho/abi.rst | 5 +
MAINTAINERS | 3 +-
arch/arm64/mm/mmu.c | 4 +-
include/linux/extmem.h | 8 +
include/linux/kexec_handover.h | 6 +
include/linux/kho/abi/extmem.h | 55 +++++
kernel/liveupdate/kexec_handover.c | 31 +++
mm/Kconfig | 3 +-
mm/Makefile | 3 +
mm/extmem.c | 33 +--
mm/extmem.h | 29 +++
mm/extmem_kho.c | 188 ++++++++++++++++++
13 files changed, 353 insertions(+), 17 deletions(-)
create mode 100644 include/linux/kho/abi/extmem.h
create mode 100644 mm/extmem.h
create mode 100644 mm/extmem_kho.c
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index d25265bb0095..6c1738c3828d 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1713,6 +1713,8 @@ Kernel parameters
"max" carves all aligned memory above <keep_size> and
4 GiB (or all memory above 4 GiB on an explicit
secondary node <nid> > 0).
+ When CONFIG_KEXEC_HANDOVER=y is active, carved regions
+ and alignments are preserved across KHO kexec.
failslab=
fail_usercopy=
diff --git a/Documentation/core-api/kho/abi.rst b/Documentation/core-api/kho/abi.rst
index edeb5b311963..e05e3eab8869 100644
--- a/Documentation/core-api/kho/abi.rst
+++ b/Documentation/core-api/kho/abi.rst
@@ -33,6 +33,11 @@ KHO serialization block ABI
.. kernel-doc:: include/linux/kho/abi/block.h
+extmem preservation ABI
+=======================
+
+.. kernel-doc:: include/linux/kho/abi/extmem.h
+
See Also
========
diff --git a/MAINTAINERS b/MAINTAINERS
index 306707fdfd68..3cf834dc15ed 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -17567,7 +17567,8 @@ M: Suseendran Bhaskaran <suseendranb@google.com>
L: linux-mm@kvack.org
S: Maintained
F: include/linux/extmem.h
-F: mm/extmem.c
+F: include/linux/kho/abi/extmem.h
+F: mm/extmem*
MEMORY MANAGEMENT - GUP (GET USER PAGES)
M: David Hildenbrand <david@kernel.org>
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index e99c8b21f603..5e6acfee1994 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -10,6 +10,7 @@
#include <linux/export.h>
#include <linux/kernel.h>
#include <linux/errno.h>
+#include <linux/extmem.h>
#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/kexec.h>
@@ -1209,7 +1210,8 @@ static void __init map_mem(void)
linear_map_requires_bbml3 = !force_pte_mapping() && can_set_direct_map();
if (force_pte_mapping() ||
- (linear_map_boot_unmap && !cpu_supports_bbml3()))
+ ((linear_map_boot_unmap || extmem_kho_early_active()) &&
+ !cpu_supports_bbml3()))
flags |= NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS;
/*
diff --git a/include/linux/extmem.h b/include/linux/extmem.h
index 88fde6f26e64..32e8f852e89b 100644
--- a/include/linux/extmem.h
+++ b/include/linux/extmem.h
@@ -2,6 +2,8 @@
#ifndef _LINUX_EXTMEM_H
#define _LINUX_EXTMEM_H
+#include <linux/types.h>
+
#ifdef CONFIG_EXTMEM
void extmem_init(void);
void extmem_unmap_regions(void);
@@ -10,4 +12,10 @@ static inline void extmem_init(void) { }
static inline void extmem_unmap_regions(void) { }
#endif
+#if defined(CONFIG_EXTMEM) && defined(CONFIG_KEXEC_HANDOVER)
+bool extmem_kho_early_active(void);
+#else
+static inline bool extmem_kho_early_active(void) { return false; }
+#endif
+
#endif /* _LINUX_EXTMEM_H */
diff --git a/include/linux/kexec_handover.h b/include/linux/kexec_handover.h
index ef2b188c8ed0..692a159d1b1c 100644
--- a/include/linux/kexec_handover.h
+++ b/include/linux/kexec_handover.h
@@ -32,6 +32,7 @@ void *kho_restore_vmalloc(const struct kho_vmalloc *preservation);
int kho_add_subtree(const char *name, void *blob, size_t size);
void kho_remove_subtree(void *blob);
int kho_retrieve_subtree(const char *name, phys_addr_t *phys, size_t *size);
+bool kho_early_has_subtree(const char *name);
void kho_memory_init(void);
void kho_memory_init_early(void);
@@ -118,6 +119,11 @@ static inline int kho_retrieve_subtree(const char *name, phys_addr_t *phys,
return -EOPNOTSUPP;
}
+static inline bool kho_early_has_subtree(const char *name)
+{
+ return false;
+}
+
static inline void kho_memory_init(void) { }
static inline void kho_memory_init_early(void) { }
diff --git a/include/linux/kho/abi/extmem.h b/include/linux/kho/abi/extmem.h
new file mode 100644
index 000000000000..513db284897a
--- /dev/null
+++ b/include/linux/kho/abi/extmem.h
@@ -0,0 +1,55 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2026, Google LLC.
+ */
+
+#ifndef _LINUX_KHO_ABI_EXTMEM_H
+#define _LINUX_KHO_ABI_EXTMEM_H
+
+#include <linux/build_bug.h>
+#include <linux/types.h>
+
+/**
+ * DOC: extmem kexec handover ABI
+ *
+ * The "extmem" KHO subtree preserves boot-carved external memory ranges across
+ * kexec so the target kernel removes the same physical ranges from memblock
+ * before page-allocator setup. Payload memory is omitted from KHO's preserved
+ * page radix tree; only &struct kho_extmem_ser is preserved. Any incompatible
+ * layout change requires bumping %KHO_EXTMEM_VERSION.
+ */
+
+#define EXTMEM_KHO_ENTRY_NAME "extmem"
+#define KHO_EXTMEM_VERSION 1
+
+/**
+ * struct kho_extmem_region_ser - Serialized descriptor for one extmem region
+ * @base: Physical start address
+ * @size: Size in bytes
+ * @nid: Target NUMA node ID
+ * @align_shift: Base-2 logarithm of region alignment in bytes
+ */
+struct kho_extmem_region_ser {
+ u64 base;
+ u64 size;
+ s32 nid;
+ u32 align_shift;
+};
+
+static_assert(sizeof(struct kho_extmem_region_ser) == 24);
+
+/**
+ * struct kho_extmem_ser - Root header for the "extmem" KHO subtree
+ * @version: ABI version (%KHO_EXTMEM_VERSION)
+ * @nr_regions: Number of entries in @regions
+ * @regions: Serialized region descriptors
+ */
+struct kho_extmem_ser {
+ u32 version;
+ u32 nr_regions;
+ struct kho_extmem_region_ser regions[];
+};
+
+static_assert(sizeof(struct kho_extmem_ser) == 8);
+
+#endif /* _LINUX_KHO_ABI_EXTMEM_H */
diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
index 42c6609a1766..9eb78e994d93 100644
--- a/kernel/liveupdate/kexec_handover.c
+++ b/kernel/liveupdate/kexec_handover.c
@@ -98,6 +98,7 @@ static struct kho_out kho_out = {
struct kho_in {
phys_addr_t fdt_phys;
+ u64 fdt_len;
phys_addr_t bootmem_phys;
char previous_release[__NEW_UTS_LEN + 1];
u32 kexec_count;
@@ -1694,6 +1695,35 @@ int kho_retrieve_subtree(const char *name, phys_addr_t *phys, size_t *size)
}
EXPORT_SYMBOL_GPL(kho_retrieve_subtree);
+/**
+ * kho_early_has_subtree - check if a preserved sub-blob exists early
+ * @name: the name of the sub-blob passed to kho_add_subtree().
+ *
+ * Inspects the incoming KHO FDT via early_memremap() before the linear map is
+ * established. May only be called after kho_populate() while early_memremap()
+ * is active.
+ *
+ * Return: true if a subnode named @name exists in the KHO FDT, false otherwise
+ */
+bool __init kho_early_has_subtree(const char *name)
+{
+ void *fdt;
+ int offset = -ENOENT;
+
+ if (!is_kho_boot() || kho_in.fdt_len < sizeof(struct fdt_header))
+ return false;
+
+ fdt = early_memremap(kho_in.fdt_phys, kho_in.fdt_len);
+ if (!fdt)
+ return false;
+
+ if (fdt_totalsize(fdt) <= kho_in.fdt_len)
+ offset = fdt_subnode_offset(fdt, 0, name);
+ early_memunmap(fdt, kho_in.fdt_len);
+
+ return offset >= 0;
+}
+
static void __init kho_mem_retrieve(void)
{
const struct kho_radix_walk_cb cb = {
@@ -2034,6 +2064,7 @@ void __init kho_populate(phys_addr_t fdt_phys, u64 fdt_len,
memblock_set_kho_noprsrv_only();
kho_in.fdt_phys = fdt_phys;
+ kho_in.fdt_len = fdt_len;
kho_in.bootmem_phys = bootmem_phys;
kho_bootmem_cnt = bootmem_cnt;
diff --git a/mm/Kconfig b/mm/Kconfig
index 95dfdd192909..3f4c0cc536fe 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -1546,6 +1546,7 @@ config EXTMEM
Allow carving out NUMA-aware, section- or huge-page-aligned
physical memory regions at boot via the "extmem=" kernel command
line parameter and exposing them as "extmem" platform devices
- carrying memory-region metadata and IORESOURCE_MEM resources.
+ carrying memory-region metadata and IORESOURCE_MEM resources,
+ with Kexec HandOver (KHO) preservation across kexec.
endmenu
diff --git a/mm/Makefile b/mm/Makefile
index 0542953db072..98ed50761d7a 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -152,3 +152,6 @@ obj-$(CONFIG_LAZY_MMU_MODE_KUNIT_TEST) += tests/lazy_mmu_mode_kunit.o
obj-$(CONFIG_VMSTAT_KUNIT_TEST) += tests/vmstat_kunit.o
obj-$(CONFIG_MEM_ALLOC_PROFILING) += alloc_tag.o
obj-$(CONFIG_EXTMEM) += extmem.o
+ifdef CONFIG_EXTMEM
+obj-$(CONFIG_KEXEC_HANDOVER) += extmem_kho.o
+endif
diff --git a/mm/extmem.c b/mm/extmem.c
index e5be9fcb6bbd..7e1bd3d2a511 100644
--- a/mm/extmem.c
+++ b/mm/extmem.c
@@ -13,6 +13,7 @@
#include <linux/extmem.h>
#include <linux/init.h>
#include <linux/ioport.h>
+#include <linux/kexec_handover.h>
#include <linux/kernel.h>
#include <linux/limits.h>
#include <linux/log2.h>
@@ -29,10 +30,10 @@
#include <linux/sizes.h>
#include <linux/string.h>
+#include "extmem.h"
#include "mm_init.h"
#define EXTMEM_MAX_RANGES 8
-#define EXTMEM_MAX_REGIONS 64
#define EXTMEM_MIN_ALIGN BIT_ULL(SECTION_SIZE_BITS)
#define EXTMEM_ALL_NODES MAX_NUMNODES
@@ -43,18 +44,11 @@ struct extmem_rule {
phys_addr_t keep;
};
-struct extmem_region {
- phys_addr_t base;
- phys_addr_t size;
- phys_addr_t align;
- int nid;
-};
-
static struct extmem_rule extmem_rules[EXTMEM_MAX_REGIONS] __initdata;
static unsigned int extmem_nr_rules __initdata;
-static struct extmem_region extmem_regions[EXTMEM_MAX_REGIONS] __initdata;
-static unsigned int extmem_nr_regions __initdata;
+struct extmem_region extmem_regions[EXTMEM_MAX_REGIONS] __initdata;
+unsigned int extmem_nr_regions __initdata;
/*
* Parse [<nid>|all:]<size|max>[:<align>][:keep=<keep_size>]
@@ -158,7 +152,7 @@ static int __init early_extmem(char *p)
* so early page tables stay in low RAM rather than fragmenting the
* top of a NUMA node before extmem_init() runs.
*/
- if (extmem_nr_rules) {
+ if (extmem_nr_rules && !is_kho_boot()) {
memblock_set_bottom_up(true);
arch_boot_carveout_enable();
}
@@ -185,7 +179,7 @@ static int __init extmem_find_keep_end(int nid, phys_addr_t keep,
return -ENOSPC;
}
-static int __init extmem_commit_regions(unsigned int nr, const char *verb)
+int __init extmem_commit_regions(unsigned int nr, const char *verb)
{
struct extmem_region *regs = &extmem_regions[extmem_nr_regions];
struct memblock_region *r;
@@ -294,14 +288,24 @@ static void __init extmem_carve_node(int nid, const struct extmem_rule *rule)
void __init extmem_init(void)
{
- unsigned long orig_end_pfn, new_end_pfn;
+ unsigned long orig_end_pfn = PFN_DOWN(memblock_end_of_DRAM());
+ unsigned long new_end_pfn;
unsigned int i, j;
int nid;
+ /*
+ * Must run before kho_memory_init_early() so revived extmem regions
+ * are removed from memblock before kho_discover_noprsrv() scans it.
+ */
+ if (is_kho_boot()) {
+ if (extmem_kho_revive() == -ENOENT && extmem_nr_rules)
+ pr_warn("ignoring extmem= on KHO boot without preserved state\n");
+ goto refresh_end;
+ }
+
if (!extmem_nr_rules)
return;
- orig_end_pfn = PFN_DOWN(memblock_end_of_DRAM());
memblock_set_bottom_up(false);
for (i = 0; i < extmem_nr_rules; i++) {
@@ -329,6 +333,7 @@ void __init extmem_init(void)
}
}
+refresh_end:
if (!extmem_nr_regions)
return;
new_end_pfn = PFN_DOWN(memblock_end_of_DRAM());
diff --git a/mm/extmem.h b/mm/extmem.h
new file mode 100644
index 000000000000..d73f3729745f
--- /dev/null
+++ b/mm/extmem.h
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __MM_EXTMEM_INTERNAL_H
+#define __MM_EXTMEM_INTERNAL_H
+
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/types.h>
+
+#define EXTMEM_MAX_REGIONS 64
+
+struct extmem_region {
+ phys_addr_t base;
+ phys_addr_t size;
+ phys_addr_t align;
+ int nid;
+};
+
+extern struct extmem_region extmem_regions[EXTMEM_MAX_REGIONS] __initdata;
+extern unsigned int extmem_nr_regions __initdata;
+
+int extmem_commit_regions(unsigned int nr, const char *verb);
+
+#ifdef CONFIG_KEXEC_HANDOVER
+int extmem_kho_revive(void);
+#else
+static inline int extmem_kho_revive(void) { return -EOPNOTSUPP; }
+#endif
+
+#endif /* __MM_EXTMEM_INTERNAL_H */
diff --git a/mm/extmem_kho.c b/mm/extmem_kho.c
new file mode 100644
index 000000000000..53d83fd8b84c
--- /dev/null
+++ b/mm/extmem_kho.c
@@ -0,0 +1,188 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Kexec HandOver (KHO) preservation for external memory (extmem) regions.
+ */
+
+#define pr_fmt(fmt) "extmem: " fmt
+
+#include <linux/align.h>
+#include <linux/bits.h>
+#include <linux/err.h>
+#include <linux/extmem.h>
+#include <linux/init.h>
+#include <linux/kexec_handover.h>
+#include <linux/kho/abi/extmem.h>
+#include <linux/log2.h>
+#include <linux/memblock.h>
+#include <linux/mm.h>
+#include <linux/mmzone.h>
+#include <linux/numa.h>
+#include <linux/overflow.h>
+#include <linux/printk.h>
+#include <linux/sizes.h>
+
+#include "extmem.h"
+
+static_assert(struct_size_t(struct kho_extmem_ser, regions,
+ EXTMEM_MAX_REGIONS) <= PAGE_SIZE);
+
+static phys_addr_t extmem_kho_in_ser_phys __initdata;
+
+bool __init extmem_kho_early_active(void)
+{
+ return kho_early_has_subtree(EXTMEM_KHO_ENTRY_NAME);
+}
+
+static bool __init extmem_kho_is_ram(phys_addr_t base, phys_addr_t size)
+{
+ phys_addr_t end, rstart, rend;
+ u64 i;
+
+ if (!size || check_add_overflow(base, size, &end))
+ return false;
+
+ __for_each_mem_range(i, &memblock.memory, NULL, NUMA_NO_NODE,
+ MEMBLOCK_HOTPLUG, &rstart, &rend, NULL) {
+ if (rstart > base)
+ break;
+ base = max(base, rend);
+ if (base >= end)
+ return true;
+ }
+
+ return false;
+}
+
+static int __init extmem_kho_validate_region(const struct kho_extmem_ser *ser,
+ unsigned int idx,
+ phys_addr_t ser_phys)
+{
+ const struct kho_extmem_region_ser *r = &ser->regions[idx];
+ u64 base = r->base, size = r->size;
+ unsigned int j;
+
+ if (r->align_shift < SECTION_SIZE_BITS ||
+ r->align_shift >= sizeof(phys_addr_t) * BITS_PER_BYTE ||
+ (r->nid != NUMA_NO_NODE && (r->nid < 0 || r->nid >= MAX_NUMNODES)))
+ return -EINVAL;
+
+ if (base < SZ_4G || !IS_ALIGNED(base | size, BIT_ULL(r->align_shift)) ||
+ !extmem_kho_is_ram(base, size))
+ return -EINVAL;
+ if (memblock_addrs_overlap(base, size, ser_phys, PAGE_SIZE) ||
+ memblock_is_region_reserved(base, size))
+ return -EBUSY;
+
+ for (j = 0; j < idx; j++) {
+ if (memblock_addrs_overlap(base, size, ser->regions[j].base,
+ ser->regions[j].size))
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+/*
+ * Runs before kho_memory_init_early() -> kho_discover_noprsrv() so revived
+ * extmem ranges are removed from memblock before KHO marks unpreserved RAM as
+ * MEMBLOCK_KHO_NOPRSRV.
+ */
+int __init extmem_kho_revive(void)
+{
+ const struct kho_extmem_ser *ser;
+ phys_addr_t ser_phys;
+ size_t blob_size;
+ unsigned int i;
+ int err;
+
+ err = kho_retrieve_subtree(EXTMEM_KHO_ENTRY_NAME, &ser_phys,
+ &blob_size);
+ if (err == -ENOENT)
+ return -ENOENT;
+ if (err) {
+ pr_warn_once("failed to retrieve KHO subtree: %pe\n",
+ ERR_PTR(err));
+ return err;
+ }
+
+ if (!ser_phys || !PAGE_ALIGNED(ser_phys) || blob_size < sizeof(*ser) ||
+ blob_size > struct_size(ser, regions, EXTMEM_MAX_REGIONS) ||
+ !extmem_kho_is_ram(ser_phys, PAGE_SIZE)) {
+ err = -EINVAL;
+ goto err_warn;
+ }
+
+ ser = phys_to_virt(ser_phys);
+ if (ser->version != KHO_EXTMEM_VERSION || !ser->nr_regions ||
+ blob_size != struct_size(ser, regions, ser->nr_regions)) {
+ err = -EINVAL;
+ goto err_warn;
+ }
+
+ extmem_kho_in_ser_phys = ser_phys;
+
+ for (i = 0; i < ser->nr_regions; i++) {
+ err = extmem_kho_validate_region(ser, i, ser_phys);
+ if (err)
+ goto err_warn;
+
+ extmem_regions[i] = (struct extmem_region) {
+ .base = ser->regions[i].base,
+ .size = ser->regions[i].size,
+ .align = BIT_ULL(ser->regions[i].align_shift),
+ .nid = ser->regions[i].nid,
+ };
+ }
+
+ err = extmem_commit_regions(ser->nr_regions, "KHO revived");
+ if (err)
+ goto err_warn;
+
+ return 0;
+
+err_warn:
+ pr_warn_once("invalid KHO subtree: %pe\n", ERR_PTR(err));
+ return err;
+}
+
+static int __init extmem_kho_init(void)
+{
+ struct kho_extmem_ser *ser;
+ unsigned int i;
+ size_t size;
+ int err;
+
+ if (extmem_kho_in_ser_phys && is_kho_boot())
+ kho_restore_free(phys_to_virt(extmem_kho_in_ser_phys));
+
+ if (!kho_is_enabled() || !extmem_nr_regions)
+ return 0;
+
+ size = struct_size(ser, regions, extmem_nr_regions);
+ ser = kho_alloc_preserve(size);
+ if (IS_ERR(ser)) {
+ pr_err("failed to allocate KHO buffer: %pe\n", ser);
+ return PTR_ERR(ser);
+ }
+
+ ser->version = KHO_EXTMEM_VERSION;
+ ser->nr_regions = extmem_nr_regions;
+ for (i = 0; i < extmem_nr_regions; i++) {
+ ser->regions[i] = (struct kho_extmem_region_ser) {
+ .base = extmem_regions[i].base,
+ .size = extmem_regions[i].size,
+ .nid = extmem_regions[i].nid,
+ .align_shift = ilog2(extmem_regions[i].align),
+ };
+ }
+
+ err = kho_add_subtree(EXTMEM_KHO_ENTRY_NAME, ser, size);
+ if (err) {
+ pr_err("failed to register KHO subtree: %pe\n", ERR_PTR(err));
+ kho_unpreserve_free(ser);
+ return err;
+ }
+
+ return 0;
+}
+late_initcall(extmem_kho_init);
prev parent reply other threads:[~2026-12-02 0:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 0:19 [RFC PATCH 00/11] mm: NUMA-aware boot memory carving (extmem) Suseendran Bhaskaran
2026-12-02 0:19 ` [RFC PATCH 01/11] mm/cma: clamp multi-range search to 4G and honor memblock flags Suseendran Bhaskaran
2026-12-02 0:19 ` [RFC PATCH 02/11] mm/memblock: factor out multi-range contiguous reservation helper from CMA Suseendran Bhaskaran
2026-12-02 0:19 ` [RFC PATCH 03/11] x86/mm: add early direct-map unmap helpers for boot carveouts Suseendran Bhaskaran
2026-12-02 0:19 ` [RFC PATCH 04/11] arm64/mm: support unmapping boot carveouts from the linear map Suseendran Bhaskaran
2026-12-02 0:19 ` [RFC PATCH 05/11] mm/extmem: add architecture-neutral external memory subsystem Suseendran Bhaskaran
2026-12-02 0:19 ` [RFC PATCH 06/11] dax/hmem: bind extmem platform devices with per-region alignment Suseendran Bhaskaran
2026-12-02 0:19 ` [RFC PATCH 07/11] nvdimm/ramdax: manage bus and DIMM allocations with devres Suseendran Bhaskaran
2026-12-02 0:19 ` [RFC PATCH 08/11] nvdimm/ramdax: harden probe checks and select NUMA_KEEP_MEMINFO Suseendran Bhaskaran
2026-12-02 0:19 ` [RFC PATCH 09/11] nvdimm/ramdax: support binding extmem platform devices Suseendran Bhaskaran
2026-12-02 0:19 ` [RFC PATCH 10/11] x86/kaslr: avoid placing kernel in carvable high memory when extmem= is set Suseendran Bhaskaran
2026-12-02 0:19 ` Suseendran Bhaskaran [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=20261202001946.1226273-12-suseendranb@google.com \
--to=suseendranb@google.com \
--cc=akpm@linux-foundation.org \
--cc=alison.schofield@intel.com \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=changyuanl@google.com \
--cc=corbet@lwn.net \
--cc=dave.hansen@linux.intel.com \
--cc=dave.jiang@intel.com \
--cc=david@kernel.org \
--cc=djbw@kernel.org \
--cc=fvdl@google.com \
--cc=graf@amazon.com \
--cc=hpa@zytor.com \
--cc=iweiny@kernel.org \
--cc=kexec@lists.infradead.org \
--cc=liam@infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@kernel.org \
--cc=mark.rutland@arm.com \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=nvdimm@lists.linux.dev \
--cc=osalvador@suse.de \
--cc=pasha.tatashin@soleen.com \
--cc=peterz@infradead.org \
--cc=pratyush@kernel.org \
--cc=rdunlap@infradead.org \
--cc=rientjes@google.com \
--cc=rppt@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=tglx@kernel.org \
--cc=vbabka@kernel.org \
--cc=vishal.l.verma@intel.com \
--cc=will@kernel.org \
--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
all inboxes | Powered by JetHome®