Skip to contentSkip to conversation

arm64: add pmem module for kernel update

PATCH In review Zhuling 2 participants 2 messages Dec 31, 2020 – Jan 5, 2021

Subsystems (5)
lore
Share & tools
lore

Zhuling

author
#0 lore raw

PATCH 1/1 arm64: add pmem module for kernel update

Category: feature
Bugzilla: NA
CVE: NA

Use reserved memory to create a pmem device to store the processes information that dumped before kernel update. When you want to use this feature you need to declare by "pmemmem=pmem_size:pmem_phystart" in cmdline. (exp: pmemmem=100M:0x202000000000)

---
 arch/arm64/kernel/setup.c |   5 +++
 arch/arm64/mm/init.c      |  90 +++++++++++++++++++++++++++++++++++++++
 drivers/nvdimm/Kconfig    |  11 +++++
 drivers/nvdimm/Makefile   |   3 ++
 drivers/nvdimm/kup_pmem.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/ioport.h    |   1 +
 include/linux/mm.h        |   4 ++
 lib/Kconfig               |   6 +++
 8 files changed, 226 insertions(+)
 create mode 100644 drivers/nvdimm/kup_pmem.c
arch/arm64/kernel/setup.c +5 -0
index 133257f..0bd9429 100644
@@ -237,6 +237,11 @@ static void __init request_standard_resources(void)
 		if (kernel_data.start >= res->start &&
 		    kernel_data.end <= res->end)
 			request_resource(res, &kernel_data);
+#ifdef CONFIG_KUP_PMEM_MEMORY
+	if (pmem_res.end)
+		insert_resource(&iomem_resource, &pmem_res);
+#endif
+
 #ifdef CONFIG_KEXEC_CORE
 		/* Userspace will find "Crash kernel" region in /proc/iomem. */
 		if (crashk_res.end && crashk_res.start >= res->start &&
arch/arm64/mm/init.c +90 -0

108 lines not on this page · raw message

drivers/nvdimm/Kconfig +11 -0
index b7d1eb3..7f5fa22 100644
@@ -119,6 +119,17 @@ config NVDIMM_KEYS
 	depends on ENCRYPTED_KEYS
 	depends on (LIBNVDIMM=ENCRYPTED_KEYS) || LIBNVDIMM=m
 
+config KUP_PMEM
+	tristate "Persistent memory for kernel update"
+	depends on LIBNVDIMM
+	depends on KUP_PMEM_MEMORY
+	default LIBNVDIMM
+	help
+	  Allows regions of persistent memory to be described in the
+	  device-tree.
+
+	  Select Y if unsure.
+
 config NVDIMM_TEST_BUILD
 	tristate "Build the unit test core"
 	depends on m
drivers/nvdimm/Makefile +3 -0
index 29203f3..39fabc3 100644
@@ -6,6 +6,7 @@ obj-$(CONFIG_ND_BLK) += nd_blk.o
 obj-$(CONFIG_X86_PMEM_LEGACY) += nd_e820.o
 obj-$(CONFIG_OF_PMEM) += of_pmem.o
 obj-$(CONFIG_VIRTIO_PMEM) += virtio_pmem.o nd_virtio.o
+obj-$(CONFIG_KUP_PMEM) += nd_kup_pmem.o
 
 nd_pmem-y := pmem.o
 
@@ -15,6 +16,8 @@ nd_blk-y := blk.o
 
 nd_e820-y := e820.o
 
+nd_kup_pmem-y := kup_pmem.o
+
 libnvdimm-y := core.o
 libnvdimm-y += bus.o
 libnvdimm-y += dimm_devs.o
drivers/nvdimm/kup_pmem.c new file +106 -0

106 lines not on this page · raw message

include/linux/ioport.h +1 -0
index 5135d4b..bba36f2 100644
@@ -139,6 +139,7 @@ enum {
 	IORES_DESC_DEVICE_PRIVATE_MEMORY	= 6,
 	IORES_DESC_RESERVED			= 7,
 	IORES_DESC_SOFT_RESERVED		= 8,
+	IORES_DESC_KPMEM_DEV			= 9,
 };
 
 /*
include/linux/mm.h +4 -0
index db6ae4d..2b2a94c 100644
@@ -45,6 +45,10 @@ extern int sysctl_page_lock_unfairness;
 
 void init_mm_internals(void);
 
+#ifdef CONFIG_KUP_PMEM_MEMORY
+extern struct resource pmem_res;
+#endif
+
 #ifndef CONFIG_NEED_MULTIPLE_NODES	/* Don't use mapnrs, do it properly */
 extern unsigned long max_mapnr;
 
lib/Kconfig +6 -0
index b46a9fd..ff5677c 100644
@@ -689,3 +689,9 @@ config GENERIC_LIB_UCMPDI2
 config PLDMFW
 	bool
 	default n
+
+config KUP_PMEM_MEMORY
+	bool "reserve memory for kup pmem to store image"
+	default y
+	help
+	  Say y here to enable this feature

--
2.9.5
_______________________________________________
Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]

#1 lore raw

Hi Zhuling,

Quoted 4 lines · Zhuling

Category: feature
Bugzilla: NA
CVE: NA

These tags can be dropped.

Quoted 7 lines

Use reserved memory to create a pmem device to store the processes information that dumped before kernel update. When you want to use this feature you need to declare by "pmemmem=pmem_size:pmem_phystart" in cmdline. (exp: pmemmem=100M:0x202000000000)

Interesting. I like the feature, but it's not clear to me that a new command line based configuration scheme is needed. There is the existing memmap= parameter that on x86 describes a IORES_DESC_PERSISTENT_MEMORY_LEGACY range. The driver/nvdimm/e820.c driver could be reworked to attach to the same thing on ARM64.

Then as far as assigning memory to different kernel usages there is the existing capability in libnvdimm to attach a "personality" to an nvdimm namespace. I imagine you could write a special signature to the namespace that libnvdimm would recognize as a KUP reservation namespace and work generically across any arch.