Skip to contentSkip to conversation

kexec-tools, x86: E820 memmap pass for kdump

PATCH In review WANG Chao 3 participants 15 messages Apr 22, 2014 – May 8, 2014

Subsystems (2)
lore
Share & tools
lore

WANG Chao

author
#0 lore raw

v7 cover kexec-tools, x86: E820 memmap pass for kdump

Hi, All

This patchset enables passing memory map via E820 map on x86 platform instead of memmap=exactmap. It's a better design and will solve the following problem so far:

- kernel cmdline is limited resource and large machines tend to have many memory ranges that may excceed kernel cmdline limit size.
- kASLR doesn't work with memmap=exactmap, because kASLR happens early than user defined memmap=exactmap takes effect.

Unfortunately, saved_max_pfn still got its user out there (calgry pci, it looks like the only one). So for backward compatibility, I'm introducing a new option --pass-memmap-cmdline to force kexec-tools to pass memmap=exactmap, the old way.

This patchset contains massive updates from the previous one. I take some suggestions from reviewers. I try to split the changes into smaller pieces and keep the whole change as minimal as I can so it wouldn't be too harsh to review the patch.

Any comment is appreciate!

v7->v6:
dyoung/Simon:
- more description for CRASH_MAX_MEMMAP_NR to be 1024

v6->v5:
dyoung:
- use nr_memmap instead of nr_memmap_p
- .end inclusive
Simon:
- more description on some patches

v5->v4:
Dave:
- separate add_setup_data() to another patch.
Vivek:
- adding comments for setup_data.
- store crash memory range info golobally in kexec_info.
me:
-remove dbgprint_mem_range defination, Simon has merged the patch.

v3->v4:
Linn: check return value of malloc (use xmalloc).
me: fix dbgprintf_mem_range.

v2->v3:
Linn:
- do not free sd (setup_data) buffer.
- reuse code in setup_e820 and setup_e820_ext.

v1->v2:
Vivek:
- Use function instead of macro for dbgprint_mem_range
- Do not pass reserved memory range for kdump. It could addressed later separately.

WANG Chao (9):
x86, cleanup: add extra arguments to add_memmap() and delete_memmap() x86, cleanup: add_memmap() only do alignment check on RANGE_RAM x86, cleanup: add other types of memory range for 2nd kernel boot to
memmap_p
x86, cleanup: use dbgprint_mem_range for memory range debugging x86, cleanup: increase CRASH_MAX_MEMMAP_NR up to 1024
x86, cleanup: Store crash memory ranges kexec_info
x86, cleanup: kexec memory range .end to be inclusive
x86: add --pass-memmap-cmdline option
x86: Pass memory range via E820 for kdump

 kexec/arch/i386/crashdump-x86.c        |  69 +++++++--------
 kexec/arch/i386/crashdump-x86.h        |   2 +-
 kexec/arch/i386/include/arch/options.h |   2 +
 kexec/arch/i386/kexec-x86-common.c     |   3 +-
 kexec/arch/i386/kexec-x86.c            |   4 +
 kexec/arch/i386/kexec-x86.h            |   1 +
 kexec/arch/i386/x86-linux-setup.c      | 149 ++++++++++++++++++++++-----------
 kexec/arch/i386/x86-linux-setup.h      |   1 +
 kexec/arch/x86_64/kexec-x86_64.c       |   5 ++
 kexec/firmware_memmap.c                |   1 -
 kexec/kexec.h                          |   2 +
 11 files changed, 147 insertions(+), 92 deletions(-)
Signature · 7 lines
1.9.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
author
#1 lore raw

PATCH v7 1/9 x86, cleanup: add extra arguments to add_memmap() and delete_memmap()

This change will be used later:

add_memmap(.., int *nr_memmap, .., int type);
delete_memmap(.., int *nr_memmap, ..);

memmap_p[] is statically allocated for a certain amount. It will be used later when mapping these memory maps to e820 map.

It's convenient to keep track of the count of memmap_p (nr_memmap) in add_memmap and delete_memmap, because the counting has already been taken care of in these two functions.

The original add_memmap() can only add memory range of RANGE_RAM type. For adding other types of memory range, add another argument for indicating the type.

---
 kexec/arch/i386/crashdump-x86.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
kexec/arch/i386/crashdump-x86.c +13 -9
index 72bce0b..dfcce17 100644
@@ -476,8 +476,8 @@ static int exclude_region(int *nr_ranges, uint64_t start, uint64_t end)
 
 /* Adds a segment from list of memory regions which new kernel can use to
  * boot. Segment start and end should be aligned to 1K boundary. */
-static int add_memmap(struct memory_range *memmap_p, unsigned long long addr,
-								size_t size)
+static int add_memmap(struct memory_range *memmap_p, int *nr_memmap,
+			unsigned long long addr, size_t size, int type)
 {
 	int i, j, nr_entries = 0, tidx = 0, align = 1024;
 	unsigned long long mstart, mend;
@@ -514,6 +514,8 @@ static int add_memmap(struct memory_range *memmap_p, unsigned long long addr,
 		memmap_p[j+1] = memmap_p[j];
 	memmap_p[tidx].start = addr;
 	memmap_p[tidx].end = addr + size - 1;
+	memmap_p[tidx].type = type;
+	*nr_memmap = nr_entries + 1;
 
 	dbgprintf("Memmap after adding segment\n");
 	for (i = 0; i < CRASH_MAX_MEMMAP_NR;  i++) {
@@ -530,8 +532,8 @@ static int add_memmap(struct memory_range *memmap_p, unsigned long long addr,
 
 /* Removes a segment from list of memory regions which new kernel can use to
  * boot. Segment start and end should be aligned to 1K boundary. */
-static int delete_memmap(struct memory_range *memmap_p, unsigned long long addr,
-								size_t size)
+static int delete_memmap(struct memory_range *memmap_p, int *nr_memmap,
+				unsigned long long addr, size_t size)
 {
 	int i, j, nr_entries = 0, tidx = -1, operation = 0, align = 1024;
 	unsigned long long mstart, mend;
@@ -593,12 +595,14 @@ static int delete_memmap(struct memory_range *memmap_p, unsigned long long addr,
 		for (j = nr_entries-1; j > tidx; j--)
 			memmap_p[j+1] = memmap_p[j];
 		memmap_p[tidx+1] = temp_region;
+		*nr_memmap = nr_entries + 1;
 	}
 	if ((operation == -1) && tidx >=0) {
 		/* Delete the exact match memory region. */
 		for (j = i+1; j < CRASH_MAX_MEMMAP_NR; j++)
 			memmap_p[j-1] = memmap_p[j];
 		memmap_p[j-1].start = memmap_p[j-1].end = 0;
+		*nr_memmap = nr_entries - 1;
 	}
 
 	dbgprintf("Memmap after deleting segment\n");
@@ -865,7 +869,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
 {
 	void *tmp;
 	unsigned long sz, bufsz, memsz, elfcorehdr;
-	int nr_ranges = 0, align = 1024, i;
+	int nr_ranges = 0, nr_memmap = 0, align = 1024, i;
 	struct memory_range *mem_range, *memmap_p;
 	struct crash_elf_info elf_info;
 	unsigned kexec_arch;
@@ -941,10 +945,10 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
 	sz = (sizeof(struct memory_range) * CRASH_MAX_MEMMAP_NR);
 	memmap_p = xmalloc(sz);
 	memset(memmap_p, 0, sz);
-	add_memmap(memmap_p, info->backup_src_start, info->backup_src_size);
+	add_memmap(memmap_p, &nr_memmap, info->backup_src_start, info->backup_src_size, RANGE_RAM);
 	for (i = 0; i < crash_reserved_mem_nr; i++) {
 		sz = crash_reserved_mem[i].end - crash_reserved_mem[i].start +1;
-		if (add_memmap(memmap_p, crash_reserved_mem[i].start, sz) < 0)
+		if (add_memmap(memmap_p, &nr_memmap, crash_reserved_mem[i].start, sz, RANGE_RAM) < 0)
 			return ENOCRASHKERNEL;
 	}
 
@@ -957,7 +961,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
 						0, max_addr, -1);
 		dbgprintf("Created backup segment at 0x%lx\n",
 			  info->backup_start);
-		if (delete_memmap(memmap_p, info->backup_start, sz) < 0)
+		if (delete_memmap(memmap_p, &nr_memmap, info->backup_start, sz) < 0)
 			return EFAILED;
 	}
 
@@ -993,7 +997,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
 	elfcorehdr = add_buffer(info, tmp, bufsz, memsz, align, min_base,
 							max_addr, -1);
 	dbgprintf("Created elf header segment at 0x%lx\n", elfcorehdr);
-	if (delete_memmap(memmap_p, elfcorehdr, memsz) < 0)
+	if (delete_memmap(memmap_p, &nr_memmap, elfcorehdr, memsz) < 0)
 		return -1;
 	cmdline_add_memmap(mod_cmdline, memmap_p);
 	if (!bzImage_support_efi_boot)
Signature · 7 lines
1.9.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
author
#2 lore raw

PATCH v7 2/9 x86, cleanup: add_memmap() only do alignment check on RANGE_RAM

In reply to WANG Chao

add_memmap() will also add memory range with type RANGE_ACPI and RANGE_ACPI_NVS (RANGE_RESERVED in the future) besides RANGE_RAM to memmap_p.

Among these types of memory range, only RANGE_RAM needs to be aligned with certain alignment. RANGE_ACPI, RANGE_ACPI_NVS and RANGE_RESERVED doesn't have to be aligned.

---
 kexec/arch/i386/crashdump-x86.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kexec/arch/i386/crashdump-x86.c +2 -2
index dfcce17..6dd2e65 100644
@@ -482,8 +482,8 @@ static int add_memmap(struct memory_range *memmap_p, int *nr_memmap,
 	int i, j, nr_entries = 0, tidx = 0, align = 1024;
 	unsigned long long mstart, mend;
 
-	/* Do alignment check. */
-	if ((addr%align) || (size%align))
+	/* Do alignment check if it's RANGE_RAM */
+	if ((type == RANGE_RAM) && ((addr%align) || (size%align)))
 		return -1;
 
 	/* Make sure at least one entry in list is free. */
Signature · 7 lines
1.9.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
author
#3 lore raw

PATCH v7 3/9 x86, cleanup: add other types of memory range for 2nd kernel boot to memmap_p

In reply to WANG Chao

In load_crashdump_segments(), memmap_p[] is used to contain RANGE_RAM memory range for booting 2nd kernel. Now adding types of RANGE_ACPI and RANGE_ACPI_NVS to memmap_p, so later we can pass all the types of memory range to 2nd kernel. These all types of memory ranges are all stored in memmap_p for later reference.

---
 kexec/arch/i386/crashdump-x86.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
kexec/arch/i386/crashdump-x86.c +4 -1
index 6dd2e65..f97d79a 100644
@@ -1006,12 +1006,15 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
 
 	/* Inform second kernel about the presence of ACPI tables. */
 	for (i = 0; i < CRASH_MAX_MEMORY_RANGES; i++) {
-		unsigned long start, end;
+		unsigned long start, end, size, type;
 		if ( !( mem_range[i].type == RANGE_ACPI
 			|| mem_range[i].type == RANGE_ACPI_NVS) )
 			continue;
 		start = mem_range[i].start;
 		end = mem_range[i].end;
+		type = mem_range[i].type;
+		size = end - start + 1;
+		add_memmap(memmap_p, &nr_memmap, start, size, type);
 		cmdline_add_memmap_acpi(mod_cmdline, start, end);
 	}
 	return 0;
Signature · 7 lines
1.9.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
author
#4 lore raw

PATCH v7 4/9 x86, cleanup: use dbgprint_mem_range for memory range debugging

In reply to WANG Chao
---
 kexec/arch/i386/crashdump-x86.c | 26 +++-----------------------
 1 file changed, 3 insertions(+), 23 deletions(-)
kexec/arch/i386/crashdump-x86.c +3 -23
index f97d79a..39c35ea 100644
@@ -517,15 +517,7 @@ static int add_memmap(struct memory_range *memmap_p, int *nr_memmap,
 	memmap_p[tidx].type = type;
 	*nr_memmap = nr_entries + 1;
 
-	dbgprintf("Memmap after adding segment\n");
-	for (i = 0; i < CRASH_MAX_MEMMAP_NR;  i++) {
-		mstart = memmap_p[i].start;
-		mend = memmap_p[i].end;
-		if (mstart == 0 && mend == 0)
-			break;
-		dbgprintf("%016llx - %016llx\n",
-			mstart, mend);
-	}
+	dbgprint_mem_range("Memmap after adding segment", memmap_p, *nr_memmap);
 
 	return 0;
 }
@@ -605,16 +597,7 @@ static int delete_memmap(struct memory_range *memmap_p, int *nr_memmap,
 		*nr_memmap = nr_entries - 1;
 	}
 
-	dbgprintf("Memmap after deleting segment\n");
-	for (i = 0; i < CRASH_MAX_MEMMAP_NR;  i++) {
-		mstart = memmap_p[i].start;
-		mend = memmap_p[i].end;
-		if (mstart == 0 && mend == 0) {
-			break;
-		}
-		dbgprintf("%016llx - %016llx\n",
-			mstart, mend);
-	}
+	dbgprint_mem_range("Memmap after deleting segment", memmap_p, *nr_memmap);
 
 	return 0;
 }
@@ -913,10 +896,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
 
 	get_backup_area(info, mem_range, nr_ranges);
 
-	dbgprintf("CRASH MEMORY RANGES\n");
-
-	for(i = 0; i < nr_ranges; ++i)
-		dbgprintf("%016Lx-%016Lx\n", mem_range[i].start, mem_range[i].end);
+	dbgprint_mem_range("CRASH MEMORY RANGES", mem_range, nr_ranges);
 
 	/*
 	 * if the core type has not been set on command line, set it here
Signature · 7 lines
1.9.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
author
#5 lore raw

PATCH v7 5/9 x86, cleanup: increase CRASH_MAX_MEMMAP_NR up to 1024

In reply to WANG Chao

CRASH_MAX_MEMMAP_NR is used as the upper boundary of memmap_p. Originally memmap_p was used to store RANGE_RAM only. But now we changed it to store all the types of memory ranges for 2nd kernel, which includes RANGE_RAM, RANGE_ACPI, RANGE_ACPI_NVS (and RANGE_RESERVED in the future).

Currently CRASH_MAX_MEMMAP_NR is defined (KEXEC_MAX_SEGMENTS + 2), which is not enough for memmap_p. It must be increased to a much higher value.

I think 1024 is good enough for storing all memory ranges for 2nd kernel. So this patch increases CRASH_MAX_MEMMAP_NR to 1024.

---
 kexec/arch/i386/crashdump-x86.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kexec/arch/i386/crashdump-x86.h +1 -1
index b61cf0a..ddee19f 100644
@@ -20,7 +20,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline,
 /* Kernel text size */
 #define X86_64_KERNEL_TEXT_SIZE  (512UL*1024*1024)
 
-#define CRASH_MAX_MEMMAP_NR	(KEXEC_MAX_SEGMENTS + 1)
+#define CRASH_MAX_MEMMAP_NR	1024
 #define CRASH_MAX_MEMORY_RANGES	(MAX_MEMORY_RANGES + 2)
 
 /* Backup Region, First 640K of System RAM. */
Signature · 7 lines
1.9.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
author
#6 lore raw

PATCH v7 6/9 x86, cleanup: Store crash memory ranges kexec_info

In reply to WANG Chao

Add two new members to kexec_info structure:

struct memory_range *crash_range
int nr_crash_ranges;

crash_range contains the memory ranges used to boot 2nd kernel. nr_crash_ranges contains the count of the crash memory ranges.

---
 kexec/arch/i386/crashdump-x86.c | 6 ++++++
 kexec/kexec.h                   | 2 ++
 2 files changed, 8 insertions(+)
kexec/arch/i386/crashdump-x86.c +6 -0
index 39c35ea..7b618a6 100644
@@ -997,6 +997,12 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
 		add_memmap(memmap_p, &nr_memmap, start, size, type);
 		cmdline_add_memmap_acpi(mod_cmdline, start, end);
 	}
+
+	/* Store 2nd kernel boot memory ranges for later reference in
+	 * x86-setup-linux.c: setup_linux_system_parameters() */
+	info->crash_range = memmap_p;
+	info->nr_crash_ranges = nr_memmap;
+
 	return 0;
 }
 
kexec/kexec.h +2 -0
index d69bba2..22d4a42 100644
@@ -148,6 +148,8 @@ struct kexec_info {
 	int nr_segments;
 	struct memory_range *memory_range;
 	int memory_ranges;
+	struct memory_range *crash_range;
+	int nr_crash_ranges;
 	void *entry;
 	struct mem_ehdr rhdr;
 	unsigned long backup_start;
Signature · 7 lines
1.9.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
author
#7 lore raw

PATCH v7 7/9 x86, cleanup: kexec memory range .end to be inclusive

In reply to WANG Chao

Later kexec and kdump memory range will be mapped to E820entry. But currently kexec memory range .end field is exclusive while crash memory range is inclusive.

Given the fact that the exported proc iomem and sysfs memmap are both inclusive, change kexec memory range .end to be inclusive. Later the unified memory range of both kexec and kdump can use the same E820 filling code.

---
 kexec/arch/i386/kexec-x86-common.c | 3 +--
 kexec/arch/i386/x86-linux-setup.c  | 2 +-
 kexec/firmware_memmap.c            | 1 -
 3 files changed, 2 insertions(+), 4 deletions(-)
kexec/arch/i386/kexec-x86-common.c +1 -2
index e416177..bc622e9 100644
@@ -79,7 +79,6 @@ static int get_memory_ranges_proc_iomem(struct memory_range **range, int *ranges
 		if (count != 2)
 			continue;
 		str = line + consumed;
-		end = end + 1;
 
 		dbgprintf("%016Lx-%016Lx : %s", start, end, str);
 
@@ -188,7 +187,7 @@ static int get_memory_ranges_xen(struct memory_range **range, int *ranges)
 
 	for (i = 0; i < rc; ++i) {
 		memory_range[i].start = e820entries[i].addr;
-		memory_range[i].end = e820entries[i].addr + e820entries[i].size;
+		memory_range[i].end = e820entries[i].addr + e820entries[i].size - 1;
 		memory_range[i].type = xen_e820_to_kexec_type(e820entries[i].type);
 	}
 
kexec/arch/i386/x86-linux-setup.c +1 -1
index 8ed36cc..9f8355f 100644
@@ -784,7 +784,7 @@ void setup_linux_system_parameters(struct kexec_info *info,
 	real_mode->e820_map_nr = ranges;
 	for(i = 0; i < ranges; i++) {
 		real_mode->e820_map[i].addr = range[i].start;
-		real_mode->e820_map[i].size = range[i].end - range[i].start;
+		real_mode->e820_map[i].size = range[i].end - range[i].start + 1;
 		switch (range[i].type) {
 		case RANGE_RAM:
 			real_mode->e820_map[i].type = E820_RAM; 
kexec/firmware_memmap.c +0 -1
index 9598933..6be3c7c 100644
@@ -145,7 +145,6 @@ static int parse_memmap_entry(const char *entry, struct memory_range *range)
 	range->end = parse_numeric_sysfs(filename);
 	if (range->end == ULLONG_MAX)
 		return -1;
-	range->end++; /* inclusive vs. exclusive ranges */
 
 	/*
 	 * entry/type
Signature · 7 lines
1.9.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
author
#8 lore raw

PATCH v7 8/9 x86: add --pass-memmap-cmdline option

In reply to WANG Chao

--pass-memmap-cmdline is used for pass memmap=exactmap cmdline for 2nd kernel. Later we will use this option to disable passing E820 memmap method but use the old exactmap method.

---
 kexec/arch/i386/include/arch/options.h | 2 ++
 kexec/arch/i386/kexec-x86.c            | 4 ++++
 kexec/arch/i386/kexec-x86.h            | 1 +
 kexec/arch/x86_64/kexec-x86_64.c       | 5 +++++
 4 files changed, 12 insertions(+)
kexec/arch/i386/include/arch/options.h +2 -0
index aaac731..e5300b5 100644
@@ -30,6 +30,7 @@
 #define OPT_VGA 		(OPT_ARCH_MAX+8)
 #define OPT_REAL_MODE		(OPT_ARCH_MAX+9)
 #define OPT_ENTRY_32BIT		(OPT_ARCH_MAX+10)
+#define OPT_PASS_MEMMAP_CMDLINE	(OPT_ARCH_MAX+11)
 
 /* Options relevant to the architecture (excluding loader-specific ones): */
 #define KEXEC_ARCH_OPTIONS \
@@ -41,6 +42,7 @@
 	{ "console-serial", 0, 0, OPT_CONSOLE_SERIAL }, \
 	{ "elf32-core-headers", 0, 0, OPT_ELF32_CORE }, \
 	{ "elf64-core-headers", 0, 0, OPT_ELF64_CORE }, \
+	{ "pass-memmap-cmdline", 0, 0, OPT_PASS_MEMMAP_CMDLINE }, \
 
 #define KEXEC_ARCH_OPT_STR KEXEC_OPT_STR ""
 
kexec/arch/i386/kexec-x86.c +4 -0
index 014ecd5..0b58dff 100644
@@ -54,6 +54,7 @@ void arch_usage(void)
 		"     --console-serial          Enable the serial console\n"
 		"     --elf32-core-headers      Prepare core headers in ELF32 format\n"
 		"     --elf64-core-headers      Prepare core headers in ELF64 format\n"
+		"     --pass--memmap-cmdline    Pass memory map via command line in kexec on panic case\n"
 		);
 }
 
@@ -64,6 +65,7 @@ struct arch_options_t arch_options = {
 	.console_vga = 0,
 	.console_serial = 0,
 	.core_header_type = CORE_TYPE_UNDEF,
+	.pass_memmap_cmdline = 0,
 };
 
 int arch_process_options(int argc, char **argv)
@@ -133,6 +135,8 @@ int arch_process_options(int argc, char **argv)
 		case OPT_ELF64_CORE:
 			arch_options.core_header_type = CORE_TYPE_ELF64;
 			break;
+		case OPT_PASS_MEMMAP_CMDLINE:
+			arch_options.pass_memmap_cmdline = 1;
 		}
 	}
 	/* Reset getopt for the next pass; called in other source modules */
kexec/arch/i386/kexec-x86.h +1 -0
index 5aa2a46..e8c9188 100644
@@ -50,6 +50,7 @@ struct arch_options_t {
 	uint8_t  	console_vga;
 	uint8_t  	console_serial;
 	enum coretype	core_header_type;
+	uint8_t  	pass_memmap_cmdline;
 };
 
 int multiboot_x86_probe(const char *buf, off_t len);
kexec/arch/x86_64/kexec-x86_64.c +5 -0
index 5c23e01..f70851d 100644
@@ -53,6 +53,7 @@ void arch_usage(void)
 		"     --serial-baud=<baud_rate> Specify the serial port baud rate\n"
 		"     --console-vga             Enable the vga console\n"
 		"     --console-serial          Enable the serial console\n"
+		"     --pass-memmap-cmdline     Pass memory map via command line in kexec on panic case\n"
 		);
 }
 
@@ -63,6 +64,7 @@ struct arch_options_t arch_options = {
 	.console_vga = 0,
 	.console_serial = 0,
 	.core_header_type = CORE_TYPE_ELF64,
+	.pass_memmap_cmdline = 0,
 };
 
 int arch_process_options(int argc, char **argv)
@@ -126,6 +128,9 @@ int arch_process_options(int argc, char **argv)
 			}
 			arch_options.serial_baud = value;
 			break;
+		case OPT_PASS_MEMMAP_CMDLINE:
+			arch_options.pass_memmap_cmdline = 1;
+			break;
 		}
 	}
 	/* Reset getopt for the next pass; called in other source modules */
Signature · 7 lines
1.9.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
author
#9 lore raw

PATCH v7 9/9 x86: Pass memory range via E820 for kdump

In reply to WANG Chao

command line size is restricted by kernel, sometimes memmap=exactmap has too many memory ranges to pass to cmdline. And also memmap=exactmap and kASLR doesn't work together.

A better approach, to pass the memory ranges for crash kernel to boot into, is filling the memory ranges into E820.

boot_params only got 128 slots for E820 map to fit in, when the number of memory map exceeds 128, use setup_data to pass the rest as extended E820 memory map.

kexec boot could also benefit from setup_data in case E820 memory map exceeds 128.

Now this new approach becomes default instead of memmap=exactmap. saved_max_pfn users can specify --pass-memmap-cmdline to use the exactmap approach.

---
 kexec/arch/i386/crashdump-x86.c   |   6 +-
 kexec/arch/i386/x86-linux-setup.c | 149 +++++++++++++++++++++++++-------------
 kexec/arch/i386/x86-linux-setup.h |   1 +
 3 files changed, 103 insertions(+), 53 deletions(-)
kexec/arch/i386/crashdump-x86.c +4 -2
index 7b618a6..4a1491b 100644
@@ -979,7 +979,8 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
 	dbgprintf("Created elf header segment at 0x%lx\n", elfcorehdr);
 	if (delete_memmap(memmap_p, &nr_memmap, elfcorehdr, memsz) < 0)
 		return -1;
-	cmdline_add_memmap(mod_cmdline, memmap_p);
+	if (arch_options.pass_memmap_cmdline)
+		cmdline_add_memmap(mod_cmdline, memmap_p);
 	if (!bzImage_support_efi_boot)
 		cmdline_add_efi(mod_cmdline);
 	cmdline_add_elfcorehdr(mod_cmdline, elfcorehdr);
@@ -995,7 +996,8 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
 		type = mem_range[i].type;
 		size = end - start + 1;
 		add_memmap(memmap_p, &nr_memmap, start, size, type);
-		cmdline_add_memmap_acpi(mod_cmdline, start, end);
+		if (arch_options.pass_memmap_cmdline)
+			cmdline_add_memmap_acpi(mod_cmdline, start, end);
 	}
 
 	/* Store 2nd kernel boot memory ranges for later reference in
kexec/arch/i386/x86-linux-setup.c +98 -51

179 lines not on this page · raw message

kexec/arch/i386/x86-linux-setup.h +1 -0
index 6fb84b4..f5d23d3 100644
@@ -30,5 +30,6 @@ void setup_linux_system_parameters(struct kexec_info *info,
 /* command line parameter may be appended by purgatory */
 #define PURGATORY_CMDLINE_SIZE 64
 extern int bzImage_support_efi_boot;
+extern struct arch_options_t arch_options;
 
 #endif /* X86_LINUX_SETUP_H */
Signature · 7 lines
1.9.0


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
author
#10 lore raw
In reply to WANG Chao
Quoted 20 lines · WANG Chao

Hi, All

This patchset enables passing memory map via E820 map on x86 platform instead of memmap=exactmap. It's a better design and will solve the following problem so far:

- kernel cmdline is limited resource and large machines tend to have many memory ranges that may excceed kernel cmdline limit size.
- kASLR doesn't work with memmap=exactmap, because kASLR happens early than user defined memmap=exactmap takes effect.

Unfortunately, saved_max_pfn still got its user out there (calgry pci, it looks like the only one). So for backward compatibility, I'm introducing a new option --pass-memmap-cmdline to force kexec-tools to pass memmap=exactmap, the old way.

This patchset contains massive updates from the previous one. I take some suggestions from reviewers. I try to split the changes into smaller pieces and keep the whole change as minimal as I can so it wouldn't be too harsh to review the patch.

Quoted 5 lines

Any comment is appreciate!

v7->v6:
dyoung/Simon:
- more description for CRASH_MAX_MEMMAP_NR to be 1024

Hi, Simon

I've changed 5/9 regarding Dave's comment and yours. Could you please pick up this patchset if there's no more problem?

Thanks
WANG Chao

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#11 lore raw
Quoted 23 lines · WANG Chao
Quoted 22 lines · WANG Chao

Hi, All

This patchset enables passing memory map via E820 map on x86 platform instead of memmap=exactmap. It's a better design and will solve the following problem so far:

- kernel cmdline is limited resource and large machines tend to have many memory ranges that may excceed kernel cmdline limit size.
- kASLR doesn't work with memmap=exactmap, because kASLR happens early than user defined memmap=exactmap takes effect.

Unfortunately, saved_max_pfn still got its user out there (calgry pci, it looks like the only one). So for backward compatibility, I'm introducing a new option --pass-memmap-cmdline to force kexec-tools to pass memmap=exactmap, the old way.

This patchset contains massive updates from the previous one. I take some suggestions from reviewers. I try to split the changes into smaller pieces and keep the whole change as minimal as I can so it wouldn't be too harsh to review the patch.

Any comment is appreciate!

Quoted 8 lines
Quoted 3 lines

v7->v6:
dyoung/Simon:
- more description for CRASH_MAX_MEMMAP_NR to be 1024

Hi, Simon

I've changed 5/9 regarding Dave's comment and yours. Could you please pick up this patchset if there's no more problem?

Thanks for all the hard work. I have applied the entire series.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

author
#12 lore raw
Quoted 28 lines · Simon Horman
Quoted 27 lines · WANG Chao
Quoted 25 lines · WANG Chao

Hi, All

This patchset enables passing memory map via E820 map on x86 platform instead of memmap=exactmap. It's a better design and will solve the following problem so far:

- kernel cmdline is limited resource and large machines tend to have many memory ranges that may excceed kernel cmdline limit size.
- kASLR doesn't work with memmap=exactmap, because kASLR happens early than user defined memmap=exactmap takes effect.

Unfortunately, saved_max_pfn still got its user out there (calgry pci, it looks like the only one). So for backward compatibility, I'm introducing a new option --pass-memmap-cmdline to force kexec-tools to pass memmap=exactmap, the old way.

This patchset contains massive updates from the previous one. I take some suggestions from reviewers. I try to split the changes into smaller pieces and keep the whole change as minimal as I can so it wouldn't be too harsh to review the patch.

Any comment is appreciate!

v7->v6:
dyoung/Simon:
- more description for CRASH_MAX_MEMMAP_NR to be 1024

Quoted 6 lines
Quoted 4 lines

Hi, Simon

I've changed 5/9 regarding Dave's comment and yours. Could you please pick up this patchset if there's no more problem?

Thanks for all the hard work. I have applied the entire series.

Thanks!

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#13 lore raw
In reply to WANG Chao

Hi Chao,

I was testing latest kexec-tools and noticed that I still see some memmap entries on command line. I think they are ACPI memory and data areas.

memmap=32K#8192K memmap=960K#8256K memmap=96K#2062752K memmap=16K#2062948K memmap=32K#2096108K memmap=16K#2096140K

Is there a reason why ACPI related entries should be passed through command line and not through bootparams memory map.

Thanks
Vivek

Quoted 70 lines · WANG Chao

Hi, All

This patchset enables passing memory map via E820 map on x86 platform instead of memmap=exactmap. It's a better design and will solve the following problem so far:

- kernel cmdline is limited resource and large machines tend to have many memory ranges that may excceed kernel cmdline limit size.
- kASLR doesn't work with memmap=exactmap, because kASLR happens early than user defined memmap=exactmap takes effect.

Unfortunately, saved_max_pfn still got its user out there (calgry pci, it looks like the only one). So for backward compatibility, I'm introducing a new option --pass-memmap-cmdline to force kexec-tools to pass memmap=exactmap, the old way.

This patchset contains massive updates from the previous one. I take some suggestions from reviewers. I try to split the changes into smaller pieces and keep the whole change as minimal as I can so it wouldn't be too harsh to review the patch.

Any comment is appreciate!

v7->v6:
dyoung/Simon:
- more description for CRASH_MAX_MEMMAP_NR to be 1024

v6->v5:
dyoung:
- use nr_memmap instead of nr_memmap_p
- .end inclusive
Simon:
- more description on some patches

v5->v4:
Dave:
- separate add_setup_data() to another patch.
Vivek:
- adding comments for setup_data.
- store crash memory range info golobally in kexec_info.
me:
-remove dbgprint_mem_range defination, Simon has merged the patch.

v3->v4:
Linn: check return value of malloc (use xmalloc).
me: fix dbgprintf_mem_range.

v2->v3:
Linn:
- do not free sd (setup_data) buffer.
- reuse code in setup_e820 and setup_e820_ext.

v1->v2:
Vivek:
- Use function instead of macro for dbgprint_mem_range
- Do not pass reserved memory range for kdump. It could addressed later separately.

WANG Chao (9):
x86, cleanup: add extra arguments to add_memmap() and delete_memmap() x86, cleanup: add_memmap() only do alignment check on RANGE_RAM x86, cleanup: add other types of memory range for 2nd kernel boot to
memmap_p
x86, cleanup: use dbgprint_mem_range for memory range debugging x86, cleanup: increase CRASH_MAX_MEMMAP_NR up to 1024
x86, cleanup: Store crash memory ranges kexec_info
x86, cleanup: kexec memory range .end to be inclusive
x86: add --pass-memmap-cmdline option
x86: Pass memory range via E820 for kdump

Quoted 15 lines
 kexec/arch/i386/crashdump-x86.c        |  69 +++++++--------
 kexec/arch/i386/crashdump-x86.h        |   2 +-
 kexec/arch/i386/include/arch/options.h |   2 +
 kexec/arch/i386/kexec-x86-common.c     |   3 +-
 kexec/arch/i386/kexec-x86.c            |   4 +
 kexec/arch/i386/kexec-x86.h            |   1 +
 kexec/arch/i386/x86-linux-setup.c      | 149 ++++++++++++++++++++++-----------
 kexec/arch/i386/x86-linux-setup.h      |   1 +
 kexec/arch/x86_64/kexec-x86_64.c       |   5 ++
 kexec/firmware_memmap.c                |   1 -
 kexec/kexec.h                          |   2 +
 11 files changed, 147 insertions(+), 92 deletions(-)
Signature · 1 line
1.9.0

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

author
#14 lore raw
Quoted 11 lines · Vivek Goyal

Hi Chao,

I was testing latest kexec-tools and noticed that I still see some memmap entries on command line. I think they are ACPI memory and data areas.

memmap=32K#8192K memmap=960K#8256K memmap=96K#2062752K memmap=16K#2062948K memmap=32K#2096108K memmap=16K#2096140K

Is there a reason why ACPI related entries should be passed through command line and not through bootparams memory map.

Good catch!

Sorry, I made a mistake in commit 91f5b9c ("kdump: pass e820 reserved region to 2nd kernel via e820 table or setup data").

I've sent a fix:
http://lists.infradead.org/pipermail/kexec/2014-May/011768.html

Please give it try. Thanks in advance.

WANG Chao

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec