Skip to contentSkip to conversation

kexec-tools, x86: E820 memmap pass for kdump

PATCH Superseded WANG Chao 5 participants 19 messages Feb 20, 2014 – Feb 28, 2014

Subsystems (4)

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

WANG Chao

author
#0 lore raw

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

Hi, All

When kaslr comes in and kdump is broken, it seems about the right time to use E820 instead of memmap=exactmap to pass memmap for kdump for the default memmap passing mechanism:
http://lists.infradead.org/pipermail/kexec/2014-February/011048.html

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.

Any comment is appreciate!

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 (4):
cleanup: add dbgprint_mem_range function
x86: Store memory ranges globally used for crash kernel to boot into
x86: add --pass-memmap-cmdline option
x86: Pass memory range via E820 for kdump

 kexec/arch/i386/crashdump-x86.c        | 157 ++++++++++++++------------
 kexec/arch/i386/crashdump-x86.h        |   6 +-
 kexec/arch/i386/include/arch/options.h |   2 +
 kexec/arch/i386/kexec-x86-common.c     |   6 +-
 kexec/arch/i386/kexec-x86.c            |   4 +
 kexec/arch/i386/kexec-x86.h            |   1 +
 kexec/arch/i386/x86-linux-setup.c      | 195 ++++++++++++++++++++++++---------
 kexec/arch/i386/x86-linux-setup.h      |   1 +
 kexec/arch/x86_64/kexec-x86_64.c       |   5 +
 kexec/kexec.c                          |  10 ++
 kexec/kexec.h                          |   1 +
 11 files changed, 259 insertions(+), 129 deletions(-)
Signature · 7 lines
1.8.5.3


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

PATCH v2 1/4 cleanup: add dbgprint_mem_range function

dbgprint_mem_range is used for printing the given memory range under debugging mode.

---
 kexec/arch/i386/kexec-x86-common.c |  6 +-----
 kexec/kexec.c                      | 10 ++++++++++
 kexec/kexec.h                      |  1 +
 3 files changed, 12 insertions(+), 5 deletions(-)
kexec/arch/i386/kexec-x86-common.c +1 -5
index f55e2c2..e416177 100644
@@ -374,11 +374,7 @@ int get_memory_ranges(struct memory_range **range, int *ranges,
 			mem_max = end;
 	}
 
-	dbgprintf("MEMORY RANGES\n");
-	for (i = 0; i < *ranges; i++) {
-		dbgprintf("%016Lx-%016Lx (%d)\n", (*range)[i].start,
-			  (*range)[i].end, (*range)[i].type);
-	}
+	dbgprint_mem_range("MEMORY RANGES", *range, *ranges);
 
 	return ret;
 }
kexec/kexec.c +10 -0
index 703d524..2d5a2e1 100644
@@ -53,6 +53,16 @@ unsigned long long mem_max = ULONG_MAX;
 static unsigned long kexec_flags = 0;
 int kexec_debug = 0;
 
+void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr)
+{
+	int i;
+	dbgprintf(prefix, "\n");
+	for (i = 0; i < nr_mr; i++) {
+		dbgprintf("%016llx-%016llx (%d)\n", mr[i].start,
+			  mr[i].end, mr[i].type);
+	}
+}
+
 void die(const char *fmt, ...)
 {
 	va_list args;
kexec/kexec.h +1 -0
index 2bd6e96..d69bba2 100644
@@ -232,6 +232,7 @@ extern int file_types;
 
 #define KEXEC_OPT_STR "h?vdfxluet:p"
 
+extern void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr);
 extern void die(const char *fmt, ...)
 	__attribute__ ((format (printf, 1, 2)));
 extern void *xmalloc(size_t size);
Signature · 7 lines
1.8.5.3


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

PATCH v2 2/4 x86: Store memory ranges globally used for crash kernel to boot into

In reply to WANG Chao

Use these two variables to store the memory ranges and the number of memory ranges for crash kernel to boot into:

struct memory_range crash_memory_range;
int crash_memory_range;

These two variables are not static now, so can be used in other file later.

---
 kexec/arch/i386/crashdump-x86.c | 134 ++++++++++++++++++++++------------------
 kexec/arch/i386/crashdump-x86.h |   5 +-
 2 files changed, 77 insertions(+), 62 deletions(-)
kexec/arch/i386/crashdump-x86.c +73 -61
index 979c2bd..c55a6b1 100644
@@ -179,7 +179,8 @@ static int exclude_region(int *nr_ranges, uint64_t start, uint64_t end);
 
 /* Stores a sorted list of RAM memory ranges for which to create elf headers.
  * A separate program header is created for backup region */
-static struct memory_range crash_memory_range[CRASH_MAX_MEMORY_RANGES];
+struct memory_range crash_memory_range[CRASH_MAX_MEMORY_RANGES];
+int crash_memory_ranges;
 
 /* Memory region reserved for storing panic kernel and other data. */
 #define CRASH_RESERVED_MEM_NR	8
@@ -201,7 +202,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,
 				   int kexec_flags, unsigned long lowmem_limit)
 {
 	const char *iomem = proc_iomem();
-	int memory_ranges = 0, gart = 0, i;
+	int gart = 0, i;
 	char line[MAX_LINE];
 	FILE *fp;
 	unsigned long long start, end;
@@ -218,7 +219,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,
 		char *str;
 		int type, consumed, count;
 
-		if (memory_ranges >= CRASH_MAX_MEMORY_RANGES)
+		if (crash_memory_ranges >= CRASH_MAX_MEMORY_RANGES)
 			break;
 		count = sscanf(line, "%Lx-%Lx : %n",
 			&start, &end, &consumed);
@@ -250,17 +251,17 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,
 			continue;
 		}
 
-		crash_memory_range[memory_ranges].start = start;
-		crash_memory_range[memory_ranges].end = end;
-		crash_memory_range[memory_ranges].type = type;
+		crash_memory_range[crash_memory_ranges].start = start;
+		crash_memory_range[crash_memory_ranges].end = end;
+		crash_memory_range[crash_memory_ranges].type = type;
 
-		segregate_lowmem_region(&memory_ranges, lowmem_limit);
+		segregate_lowmem_region(&crash_memory_ranges, lowmem_limit);
 
-		memory_ranges++;
+		crash_memory_ranges++;
 	}
 	fclose(fp);
 	if (kexec_flags & KEXEC_PRESERVE_CONTEXT) {
-		for (i = 0; i < memory_ranges; i++) {
+		for (i = 0; i < crash_memory_ranges; i++) {
 			if (crash_memory_range[i].end > 0x0009ffff) {
 				crash_reserved_mem[0].start = \
 					crash_memory_range[i].start;
@@ -278,17 +279,17 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,
 	}
 
 	for (i = 0; i < crash_reserved_mem_nr; i++)
-		if (exclude_region(&memory_ranges, crash_reserved_mem[i].start,
+		if (exclude_region(&crash_memory_ranges, crash_reserved_mem[i].start,
 				crash_reserved_mem[i].end) < 0)
 			return -1;
 
 	if (gart) {
 		/* exclude GART region if the system has one */
-		if (exclude_region(&memory_ranges, gart_start, gart_end) < 0)
+		if (exclude_region(&crash_memory_ranges, gart_start, gart_end) < 0)
 			return -1;
 	}
 	*range = crash_memory_range;
-	*ranges = memory_ranges;
+	*ranges = crash_memory_ranges;
 
 	return 0;
 }
@@ -324,7 +325,7 @@ static int get_crash_memory_ranges_xen(struct memory_range **range,
 	}
 
 	*range = crash_memory_range;
-	*ranges = j;
+	*ranges = crash_memory_ranges = j;
 
 	qsort(*range, *ranges, sizeof(struct memory_range), compare_ranges);
 
@@ -417,8 +418,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_range,
+					unsigned long long addr, size_t size)
 {
 	int i, j, nr_entries = 0, tidx = 0, align = 1024;
 	unsigned long long mstart, mend;
@@ -450,29 +451,23 @@ static int add_memmap(struct memory_range *memmap_p, unsigned long long addr,
 		else if (addr > mend)
 			tidx = i+1;
 	}
-		/* Insert the memory region. */
-		for (j = nr_entries-1; j >= tidx; j--)
-			memmap_p[j+1] = memmap_p[j];
-		memmap_p[tidx].start = addr;
-		memmap_p[tidx].end = addr + size - 1;
+	/* Insert the memory region. */
+	for (j = nr_entries-1; j >= tidx; j--)
+		memmap_p[j+1] = memmap_p[j];
+	memmap_p[tidx].start = addr;
+	memmap_p[tidx].end = addr + size - 1;
+	memmap_p[tidx].type = RANGE_RAM;
+	*nr_range = 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_range);
 
 	return 0;
 }
 
 /* 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_range,
+					unsigned long long addr, size_t size)
 {
 	int i, j, nr_entries = 0, tidx = -1, operation = 0, align = 1024;
 	unsigned long long mstart, mend;
@@ -534,24 +529,17 @@ 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_range = 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_range = 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_range);
 
 	return 0;
 }
@@ -626,6 +614,9 @@ static int cmdline_add_memmap(char *cmdline, struct memory_range *memmap_p)
 			/* All regions traversed. */
 			break;
 
+		if (memmap_p[i].type != RANGE_RAM)
+			continue;
+
 		/* A region is not worth adding if region size < 100K. It eats
 		 * up precious command line length. */
 		if ((endk - startk) < min_sizek)
@@ -797,6 +788,25 @@ static void get_backup_area(struct kexec_info *info,
 	info->backup_src_size = BACKUP_SRC_END - BACKUP_SRC_START + 1;
 }
 
+static void exclude_ram(struct memory_range *mr, int *nr_mr)
+{
+	int ranges, i, j, m;
+
+	ranges = *nr_mr;
+	for (i = 0, j = 0; i < ranges; i++) {
+		if (mr[j].type == RANGE_RAM) {
+			dbgprintf("Remove RAM %016llx-%016llxx: (%d)\n", mr[j].start, mr[j].end, mr[j].type);
+			for (m = j; m < *nr_mr; m++)
+				mr[m] = mr[m+1];
+			(*nr_mr)--;
+		} else {
+			j++;
+		}
+	}
+
+	dbgprint_mem_range("After remove RAM", mr, *nr_mr);
+}
+
 /* Loads additional segments in case of a panic kernel is being loaded.
  * One segment for backup region, another segment for storing elf headers
  * for crash memory image.
@@ -807,7 +817,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;
-	struct memory_range *mem_range, *memmap_p;
+	struct memory_range *mem_range;
 	struct crash_elf_info elf_info;
 	unsigned kexec_arch;
 
@@ -850,10 +860,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
@@ -878,17 +885,6 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
 	if (get_kernel_vaddr_and_size(info, &elf_info))
 		return -1;
 
-	/* Memory regions which panic kernel can safely use to boot into */
-	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);
-	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)
-			return ENOCRASHKERNEL;
-	}
-
 	/* Create a backup region segment to store backup data*/
 	if (!(info->kexec_flags & KEXEC_PRESERVE_CONTEXT)) {
 		sz = _ALIGN(info->backup_src_size, align);
@@ -898,8 +894,6 @@ 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)
-			return EFAILED;
 	}
 
 	/* Create elf header segment and store crash image data. */
@@ -915,6 +909,23 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
 						ELF_CORE_HEADER_ALIGN) < 0)
 			return EFAILED;
 	}
+
+	/* Memory regions which panic kernel can safely use to boot into */
+	exclude_ram(crash_memory_range, &crash_memory_ranges);
+
+	add_memmap(crash_memory_range, &crash_memory_ranges, info->backup_src_start, info->backup_src_size);
+	for (i = 0; i < crash_reserved_mem_nr; i++) {
+		sz = crash_reserved_mem[i].end - crash_reserved_mem[i].start +1;
+		if (add_memmap(crash_memory_range, &crash_memory_ranges, crash_reserved_mem[i].start, sz) < 0)
+			return ENOCRASHKERNEL;
+	}
+
+	/* exclude backup region from crash dump memory range */
+	sz = _ALIGN(info->backup_src_size, align);
+	if (delete_memmap(crash_memory_range, &crash_memory_ranges, info->backup_start, sz) < 0) {
+		return EFAILED;
+	}
+
 	/* the size of the elf headers allocated is returned in 'bufsz' */
 
 	/* Hack: With some ld versions (GNU ld version 2.14.90.0.4 20030523),
@@ -934,9 +945,9 @@ 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(crash_memory_range, &crash_memory_ranges, elfcorehdr, memsz) < 0)
 		return -1;
-	cmdline_add_memmap(mod_cmdline, memmap_p);
+	cmdline_add_memmap(mod_cmdline, crash_memory_range);
 	if (!bzImage_support_efi_boot)
 		cmdline_add_efi(mod_cmdline);
 	cmdline_add_elfcorehdr(mod_cmdline, elfcorehdr);
@@ -951,6 +962,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
 		end = mem_range[i].end;
 		cmdline_add_memmap_acpi(mod_cmdline, start, end);
 	}
+
 	return 0;
 }
 
kexec/arch/i386/crashdump-x86.h +4 -1
index b61cf0a..633ee0e 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	CRASH_MAX_MEMORY_RANGES
 #define CRASH_MAX_MEMORY_RANGES	(MAX_MEMORY_RANGES + 2)
 
 /* Backup Region, First 640K of System RAM. */
@@ -28,4 +28,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline,
 #define BACKUP_SRC_END		0x0009ffff
 #define BACKUP_SRC_SIZE	(BACKUP_SRC_END - BACKUP_SRC_START + 1)
 
+extern struct memory_range crash_memory_range[CRASH_MAX_MEMORY_RANGES];
+extern int crash_memory_ranges;
+
 #endif /* CRASHDUMP_X86_H */
Signature · 7 lines
1.8.5.3


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

PATCH v2 3/4 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/i386/x86-linux-setup.h      | 1 +
 kexec/arch/x86_64/kexec-x86_64.c       | 5 +++++
 5 files changed, 13 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/i386/x86-linux-setup.h +1 -0
index 6fb84b4..b0ccd26 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 int pass_memmap_cmdline;
 
 #endif /* X86_LINUX_SETUP_H */
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.8.5.3


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

PATCH v2 4/4 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. 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   |  25 +++--
 kexec/arch/i386/crashdump-x86.h   |   1 +
 kexec/arch/i386/x86-linux-setup.c | 195 +++++++++++++++++++++++++++-----------
 3 files changed, 158 insertions(+), 63 deletions(-)
kexec/arch/i386/crashdump-x86.c +15 -10
index c55a6b1..cb19e7d 100644
@@ -182,6 +182,8 @@ static int exclude_region(int *nr_ranges, uint64_t start, uint64_t end);
 struct memory_range crash_memory_range[CRASH_MAX_MEMORY_RANGES];
 int crash_memory_ranges;
 
+int pass_memmap_cmdline;
+
 /* Memory region reserved for storing panic kernel and other data. */
 #define CRASH_RESERVED_MEM_NR	8
 static struct memory_range crash_reserved_mem[CRASH_RESERVED_MEM_NR];
@@ -947,20 +949,23 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
 	dbgprintf("Created elf header segment at 0x%lx\n", elfcorehdr);
 	if (delete_memmap(crash_memory_range, &crash_memory_ranges, elfcorehdr, memsz) < 0)
 		return -1;
-	cmdline_add_memmap(mod_cmdline, crash_memory_range);
 	if (!bzImage_support_efi_boot)
 		cmdline_add_efi(mod_cmdline);
 	cmdline_add_elfcorehdr(mod_cmdline, elfcorehdr);
 
-	/* Inform second kernel about the presence of ACPI tables. */
-	for (i = 0; i < CRASH_MAX_MEMORY_RANGES; i++) {
-		unsigned long start, end;
-		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;
-		cmdline_add_memmap_acpi(mod_cmdline, start, end);
+	pass_memmap_cmdline = arch_options.pass_memmap_cmdline;
+	if (pass_memmap_cmdline) {
+		cmdline_add_memmap(mod_cmdline, crash_memory_range);
+		/* Inform second kernel about the presence of ACPI tables. */
+		for (i = 0; i < CRASH_MAX_MEMORY_RANGES; i++) {
+			unsigned long start, end;
+			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;
+			cmdline_add_memmap_acpi(mod_cmdline, start, end);
+		}
 	}
 
 	return 0;
kexec/arch/i386/crashdump-x86.h +1 -0
index 633ee0e..e68b626 100644
@@ -30,5 +30,6 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline,
 
 extern struct memory_range crash_memory_range[CRASH_MAX_MEMORY_RANGES];
 extern int crash_memory_ranges;
+extern int pass_memmap_cmdline;
 
 #endif /* CRASHDUMP_X86_H */
kexec/arch/i386/x86-linux-setup.c +142 -53

247 lines not on this page · raw message

Signature · 7 lines
1.8.5.3


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

Re: [PATCH v2 4/4] x86: Pass memory range via E820 for kdump

Hi Chao,

On Thu, Feb 20, 2014 at 02:28:32AM -0700, WANG Chao wrote:

[..]

Quoted 44 lines
kexec/arch/i386/x86-linux-setup.c +44 -0
+static void setup_e820_ext(struct kexec_info *info, struct x86_linux_param_header *real_mode,
+                          struct memory_range *range, int nr_range)
+{
+       struct setup_data *sd;
+       struct e820entry *e820;
+       int i, j, nr_range_ext;
+
+       nr_range_ext = nr_range - E820MAX;
+       sd = malloc(sizeof(struct setup_data) + nr_range_ext * sizeof(struct e820entry));
+       sd->next = 0;
+       sd->len = nr_range_ext * sizeof(struct e820entry);
+       sd->type = SETUP_E820_EXT;
+
+       e820 = (struct e820entry *) sd->data;
+       dbgprintf("Extended E820 via setup_data:\n");
+       for(i = 0, j = E820MAX; i < nr_range_ext; i++, j++) {
+               e820[i].addr = range[j].start;
+               e820[i].size = range[j].end - range[j].start;
+               switch (range[j].type) {
+               case RANGE_RAM:
+                       e820[i].type = E820_RAM;
+                       break;
+               case RANGE_ACPI:
+                       e820[i].type = E820_ACPI;
+                       break;
+               case RANGE_ACPI_NVS:
+                       e820[i].type = E820_NVS;
+                       break;
+               default:
+               case RANGE_RESERVED:
+                       e820[i].type = E820_RESERVED;
+                       break;
+               }
+               dbgprintf("%016lx-%016lx (%d)\n",
+                               e820[i].addr,
+                               e820[i].addr + e820[i].size - 1,
+                               e820[i].type);
+
+               if (range[j].type != RANGE_RAM)
+                       continue;
+               if ((range[j].start <= 0x100000) && range[j].end > 0x100000) {
+                       unsigned long long mem_k = (range[j].end >> 10) - (0x100000 >> 10);
+                       real_mode->ext_mem_k = mem_k;
+                       real_mode->alt_mem_k = mem_k;

kexec/arch/i386/x86-linux-setup.c out: · line 738

Quoted 10 lines
kexec/arch/i386/x86-linux-setup.c +10 -0
+                       if (mem_k > 0xfc00) {
+                               real_mode->ext_mem_k = 0xfc00; /* 64M */
+                       }
+                       if (mem_k > 0xffffffff) {
+                               real_mode->alt_mem_k = 0xffffffff;
+                       }
+               }
+       }
+       add_setup_data(info, real_mode, sd);
+       free(sd);

Remove this call to free(sd) or the kernel will not boot if there are more than E820MAX entries.

Quoted 49 lines
kexec/arch/i386/x86-linux-setup.c +49 -0
+}
+
+static void setup_e820(struct kexec_info *info, struct x86_linux_param_header *real_mode,
+                      struct memory_range *range, int nr_range)
+{
+
+       int nr_range_saved = nr_range;
+       int i;
+
+       if (nr_range > E820MAX) {
+               nr_range = E820MAX;
+       }
+
+       real_mode->e820_map_nr = nr_range;
+       dbgprintf("E820 memmap:\n");
+       for(i = 0; i < nr_range; i++) {
+               real_mode->e820_map[i].addr = range[i].start;
+               real_mode->e820_map[i].size = range[i].end - range[i].start;
+               switch (range[i].type) {
+                       case RANGE_RAM:
+                               real_mode->e820_map[i].type = E820_RAM;
+                               break;
+                       case RANGE_ACPI:
+                               real_mode->e820_map[i].type = E820_ACPI;
+                               break;
+                       case RANGE_ACPI_NVS:
+                               real_mode->e820_map[i].type = E820_NVS;
+                               break;
+                       default:
+                       case RANGE_RESERVED:
+                               real_mode->e820_map[i].type = E820_RESERVED;
+                               break;
+               }
+               dbgprintf("%016lx-%016lx (%d)\n",
+                               real_mode->e820_map[i].addr,
+                               real_mode->e820_map[i].addr + real_mode->e820_map[i].size - 1,
+                               real_mode->e820_map[i].type);
+
+               if (range[i].type != RANGE_RAM)
+                       continue;
+               if ((range[i].start <= 0x100000) && range[i].end > 0x100000) {
+                       unsigned long long mem_k = (range[i].end >> 10) - (0x100000 >> 10);
+                       real_mode->ext_mem_k = mem_k;
+                       real_mode->alt_mem_k = mem_k;
+                       if (mem_k > 0xfc00) {
+                               real_mode->ext_mem_k = 0xfc00; /* 64M */
+                       }
+                       if (mem_k > 0xffffffff) {
+                               real_mode->alt_mem_k = 0xffffffff;

kexec/arch/i386/x86-linux-setup.c out: · line 797

Quoted 10 lines
kexec/arch/i386/x86-linux-setup.c +10 -0
+                       }
+               }
+       }
+
+       if (nr_range_saved > E820MAX) {
+               dbgprintf("extra E820 memmap are passed via setup_data\n");
+               setup_e820_ext(info, real_mode, range, nr_range_saved);
+       }
+}
+

setup_e820() and setup_e820_ext() contain a lot of duplication. You could combine them into a single function, similar to the implementation of setup_e820() in the kernel.

Quoted 4 lines

static int
get_efi_mem_desc_version(struct x86_linux_param_header *real_mode) {

(quoted diff) +0 -0
@@ -704,7 +830,7 @@ void setup_linux_system_parameters(struct kexec_info *info,

[..]

kexec/arch/i386/x86-linux-setup.c void setup_linux_system_parameters(struct kexec_info *info, · line 881

Quoted 7 lines
kexec/arch/i386/x86-linux-setup.c +6 -0
+       if (info->kexec_flags & KEXEC_ON_CRASH && !pass_memmap_cmdline) {
+               range = crash_memory_range;
+               ranges = crash_memory_ranges;
+       } else {
+               range = info->memory_range;
+               ranges = info->memory_ranges;
        }

You can move this code into setup_e820(), since range and ranges are not used elsewhere in setup_linux_system_parameters().

Quoted 6 lines

+ setup_e820(info, real_mode, range, ranges);

        /* fill the EDD information */
        setup_edd_info(real_mode);

--
1.8.5.3

I tested boot (with the above fix) on a system with a large memory map, and can easily test changes, if needed.

Thanks,
Linn

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

author
#6 lore raw

Re: [PATCH v2 4/4] x86: Pass memory range via E820 for kdump

Quoted 55 lines · Linn Crosetto

Hi Chao,

On Thu, Feb 20, 2014 at 02:28:32AM -0700, WANG Chao wrote:

[..]

Quoted 49 lines
kexec/arch/i386/x86-linux-setup.c +49 -0
+static void setup_e820_ext(struct kexec_info *info, struct x86_linux_param_header *real_mode,
+                          struct memory_range *range, int nr_range)
+{
+       struct setup_data *sd;
+       struct e820entry *e820;
+       int i, j, nr_range_ext;
+
+       nr_range_ext = nr_range - E820MAX;
+       sd = malloc(sizeof(struct setup_data) + nr_range_ext * sizeof(struct e820entry));
+       sd->next = 0;
+       sd->len = nr_range_ext * sizeof(struct e820entry);
+       sd->type = SETUP_E820_EXT;
+
+       e820 = (struct e820entry *) sd->data;
+       dbgprintf("Extended E820 via setup_data:\n");
+       for(i = 0, j = E820MAX; i < nr_range_ext; i++, j++) {
+               e820[i].addr = range[j].start;
+               e820[i].size = range[j].end - range[j].start;
+               switch (range[j].type) {
+               case RANGE_RAM:
+                       e820[i].type = E820_RAM;
+                       break;
+               case RANGE_ACPI:
+                       e820[i].type = E820_ACPI;
+                       break;
+               case RANGE_ACPI_NVS:
+                       e820[i].type = E820_NVS;
+                       break;
+               default:
+               case RANGE_RESERVED:
+                       e820[i].type = E820_RESERVED;
+                       break;
+               }
+               dbgprintf("%016lx-%016lx (%d)\n",
+                               e820[i].addr,
+                               e820[i].addr + e820[i].size - 1,
+                               e820[i].type);
+
+               if (range[j].type != RANGE_RAM)
+                       continue;
+               if ((range[j].start <= 0x100000) && range[j].end > 0x100000) {
+                       unsigned long long mem_k = (range[j].end >> 10) - (0x100000 >> 10);
+                       real_mode->ext_mem_k = mem_k;
+                       real_mode->alt_mem_k = mem_k;
+                       if (mem_k > 0xfc00) {
+                               real_mode->ext_mem_k = 0xfc00; /* 64M */
+                       }
+                       if (mem_k > 0xffffffff) {
+                               real_mode->alt_mem_k = 0xffffffff;
Quoted 8 lines

kexec/arch/i386/x86-linux-setup.c out: · line 738

Quoted 5 lines
kexec/arch/i386/x86-linux-setup.c +5 -0
+                       }
+               }
+       }
+       add_setup_data(info, real_mode, sd);
+       free(sd);

Remove this call to free(sd) or the kernel will not boot if there are more than E820MAX entries.

You're right.

Quoted 56 lines
Quoted 56 lines
kexec/arch/i386/x86-linux-setup.c +55 -0
+}
+
+static void setup_e820(struct kexec_info *info, struct x86_linux_param_header *real_mode,
+                      struct memory_range *range, int nr_range)
+{
+
+       int nr_range_saved = nr_range;
+       int i;
+
+       if (nr_range > E820MAX) {
+               nr_range = E820MAX;
+       }
+
+       real_mode->e820_map_nr = nr_range;
+       dbgprintf("E820 memmap:\n");
+       for(i = 0; i < nr_range; i++) {
+               real_mode->e820_map[i].addr = range[i].start;
+               real_mode->e820_map[i].size = range[i].end - range[i].start;
+               switch (range[i].type) {
+                       case RANGE_RAM:
+                               real_mode->e820_map[i].type = E820_RAM;
+                               break;
+                       case RANGE_ACPI:
+                               real_mode->e820_map[i].type = E820_ACPI;
+                               break;
+                       case RANGE_ACPI_NVS:
+                               real_mode->e820_map[i].type = E820_NVS;
+                               break;
+                       default:
+                       case RANGE_RESERVED:
+                               real_mode->e820_map[i].type = E820_RESERVED;
+                               break;
+               }
+               dbgprintf("%016lx-%016lx (%d)\n",
+                               real_mode->e820_map[i].addr,
+                               real_mode->e820_map[i].addr + real_mode->e820_map[i].size - 1,
+                               real_mode->e820_map[i].type);
+
+               if (range[i].type != RANGE_RAM)
+                       continue;
+               if ((range[i].start <= 0x100000) && range[i].end > 0x100000) {
+                       unsigned long long mem_k = (range[i].end >> 10) - (0x100000 >> 10);
+                       real_mode->ext_mem_k = mem_k;
+                       real_mode->alt_mem_k = mem_k;
+                       if (mem_k > 0xfc00) {
+                               real_mode->ext_mem_k = 0xfc00; /* 64M */
+                       }
+                       if (mem_k > 0xffffffff) {
+                               real_mode->alt_mem_k = 0xffffffff;
+                       }
+               }
+       }
+
+       if (nr_range_saved > E820MAX) {
+               dbgprintf("extra E820 memmap are passed via setup_data\n");
Quoted 8 lines

kexec/arch/i386/x86-linux-setup.c out: · line 797

Quoted 4 lines
kexec/arch/i386/x86-linux-setup.c +4 -0
+               setup_e820_ext(info, real_mode, range, nr_range_saved);
+       }
+}
+

setup_e820() and setup_e820_ext() contain a lot of duplication. You could combine them into a single function, similar to the implementation of setup_e820() in the kernel.

OK. That makes sense to me.

Quoted 16 lines
Quoted 5 lines

static int
get_efi_mem_desc_version(struct x86_linux_param_header *real_mode) {

(quoted diff) +0 -0
@@ -704,7 +830,7 @@ void setup_linux_system_parameters(struct kexec_info *info,

[..]

kexec/arch/i386/x86-linux-setup.c void setup_linux_system_parameters(struct kexec_info *info, · line 881

Quoted 7 lines
kexec/arch/i386/x86-linux-setup.c +6 -0
+       if (info->kexec_flags & KEXEC_ON_CRASH && !pass_memmap_cmdline) {
+               range = crash_memory_range;
+               ranges = crash_memory_ranges;
+       } else {
+               range = info->memory_range;
+               ranges = info->memory_ranges;
        }
Quoted 2 lines

You can move this code into setup_e820(), since range and ranges are not used elsewhere in setup_linux_system_parameters().

Will do.

Quoted 10 lines
Quoted 7 lines

+ setup_e820(info, real_mode, range, ranges);

        /* fill the EDD information */
        setup_edd_info(real_mode);

--
1.8.5.3

I tested boot (with the above fix) on a system with a large memory map, and can easily test changes, if needed.

Thanks for testing. The result on that real system is helpful and convincing.

I'm holding off v3 for serveral days in case someone would have a comment.

Thanks
WANG Chao

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

#7 lore raw
In reply to WANG Chao
Quoted 11 lines · WANG Chao

Hi, All

When kaslr comes in and kdump is broken, it seems about the right time to use E820 instead of memmap=exactmap to pass memmap for kdump for the default memmap passing mechanism:
http://lists.infradead.org/pipermail/kexec/2014-February/011048.html

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.

The saved_max_pfn usage is calgary pci looks bad/wrong and I wonder:
- whether this is still worth touching, so that the old mechanism:
--pass-memmap-cmdline could vanish in the one or other year and need not to be carried forever
I tried to find such a machine, but couldn't find anything mentioning calgary in quite some machines' dmesg.

Approaches to avoid saved_max_pfn in calgary case:
1) If done correctly from the beginning, the TCE table size would have been exposed via /sys and kexec-tools could simply add:
calgary="128k|512K...|8M" which is already caught by pci-calgary and saved_max_pfn is not needed/touched anymore.
-> Disadvantage: needs a new sysfs entry
2) When finding max_pfn for calgary table size usage, we could try in kdump case to use the highest memory (RAM or RESERVED) showing up in e820 map.

Please find below a patch which would eleminate the last saved_max_pfn user. Unfortunately I could not find a calgary system to test this on.

Be aware: I could not test this.
If someone tells me for what kind of machine (and BIOS stuff enabled?) I should look for, I can try to search for such a platform.

Something else: There is quite some duplicate code in kexec-tools when it is about retrieving the e820 table info (normal kexec vs kdump). Did you see my cleanups I posted long ago? Do you plan to still clean up a bit after this series?

Thomas

X86: Eliminate saved_max_pfn user in pci-calgary and remove the unused variable

Searching for the highest value of RAM and RESERVED memory in kdump case should be the same as max_pfn of the original kernel.
At least this is always the case as long as type usable RAM is the highest entry in original e820 map.

arch/x86/include/asm/e820.h +1 -0
index 779c2ef..712173e 100644
@@ -49,6 +49,7 @@ static inline void early_memtest(unsigned long start, unsigned long end)
 #endif
 
 extern unsigned long e820_end_of_ram_pfn(void);
+extern unsigned long e820_end_of_e820_pfn(void);
 extern unsigned long e820_end_of_low_ram_pfn(void);
 extern u64 early_reserve_e820(u64 sizet, u64 align);
 
arch/x86/kernel/e820.c +7 -9
index 988c00a..699e8fe 100644
@@ -757,7 +757,7 @@ u64 __init early_reserve_e820(u64 size, u64 align)
 /*
  * Find the highest page frame number we have available
  */
-static unsigned long __init e820_end_pfn(unsigned long limit_pfn, unsigned type)
+unsigned long __init e820_end_pfn(unsigned long limit_pfn, unsigned type)
 {
 	int i;
 	unsigned long last_pfn = 0;
@@ -796,6 +796,12 @@ unsigned long __init e820_end_of_ram_pfn(void)
 	return e820_end_pfn(MAX_ARCH_PFN, E820_RAM);
 }
 
+unsigned long __init e820_end_of_e820_pfn(void)
+{
+	return max(e820_end_pfn(MAX_ARCH_PFN, E820_RAM),
+		   e820_end_pfn(MAX_ARCH_PFN, E820_RESERVED);
+}
+
 unsigned long __init e820_end_of_low_ram_pfn(void)
 {
 	return e820_end_pfn(1UL<<(32 - PAGE_SHIFT), E820_RAM);
@@ -847,14 +853,6 @@ static int __init parse_memmap_one(char *p)
 		return -EINVAL;
 
 	if (!strncmp(p, "exactmap", 8)) {
-#ifdef CONFIG_CRASH_DUMP
-		/*
-		 * If we are doing a crash dump, we still need to know
-		 * the real mem size before original memory map is
-		 * reset.
-		 */
-		saved_max_pfn = e820_end_of_ram_pfn();
-#endif
 		e820.nr_map = 0;
 		userdef = 1;
 		return 0;
arch/x86/kernel/pci-calgary_64.c +5 -2
index 299d493..89ae766 100644
@@ -1371,6 +1371,7 @@ int __init detect_calgary(void)
 	unsigned long ptr;
 	unsigned int offset, prev_offset;
 	int ret;
+	unsigned long orig_max_pfn = max_pfn;
 
 	/*
 	 * if the user specified iommu=off or iommu=soft or we found
@@ -1418,8 +1419,10 @@ int __init detect_calgary(void)
 		return -ENOMEM;
 	}
 
-	specified_table_size = determine_tce_table_size((is_kdump_kernel() ?
-					saved_max_pfn : max_pfn) * PAGE_SIZE);
+	if (is_kdump_kernel())
+		orig_max_pfn = e820_end_of_e820_pfn();
+	specified_table_size = determine_tce_table_size(orig_max_pfn
+							* PAGE_SIZE);
 
 	for (bus = 0; bus < MAX_PHB_BUS_NUM; bus++) {
 		struct calgary_bus_info *info = &bus_info[bus];
include/linux/crash_dump.h +0 -1
index 7032518..bce4d97 100644
@@ -87,5 +87,4 @@ extern void unregister_oldmem_pfn_is_ram(void);
 static inline int is_kdump_kernel(void) { return 0; }
 #endif /* CONFIG_CRASH_DUMP */
 
-extern unsigned long saved_max_pfn;
 #endif /* LINUX_CRASHDUMP_H */
kernel/crash_dump.c +0 -6
index c766ee5..9d50486 100644
@@ -5,12 +5,6 @@
 #include <linux/export.h>
 
 /*
- * If we have booted due to a crash, max_pfn will be a very low value. We need
- * to know the amount of memory that the previous kernel used.
- */
-unsigned long saved_max_pfn;
-
-/*
  * stores the physical address of elf header of crash image
  *
  * Note: elfcorehdr_addr is not just limited to vmcore. It is also used by

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

author
#8 lore raw
Quoted 19 lines · Thomas Renninger
Quoted 11 lines · WANG Chao

Hi, All

When kaslr comes in and kdump is broken, it seems about the right time to use E820 instead of memmap=exactmap to pass memmap for kdump for the default memmap passing mechanism:
http://lists.infradead.org/pipermail/kexec/2014-February/011048.html

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.

The saved_max_pfn usage is calgary pci looks bad/wrong and I wonder:
- whether this is still worth touching, so that the old mechanism:
--pass-memmap-cmdline could vanish in the one or other year and need not to be carried forever
I tried to find such a machine, but couldn't find anything mentioning calgary in quite some machines' dmesg.

Quoted 9 lines

Approaches to avoid saved_max_pfn in calgary case:
1) If done correctly from the beginning, the TCE table size would have been exposed via /sys and kexec-tools could simply add:
calgary="128k|512K...|8M" which is already caught by pci-calgary and saved_max_pfn is not needed/touched anymore.
-> Disadvantage: needs a new sysfs entry
2) When finding max_pfn for calgary table size usage, we could try in kdump case to use the highest memory (RAM or RESERVED) showing up in e820 map.

How could this replace saved_max_pfn? The highest memory in kdump can't necessarily be the real ram size. In kdump, RAM range is just part of the real ram, not mentioning we don't pass RESERVED range to kdump E820.

Thanks
WANG Chao

Quoted 4 lines

Please find below a patch which would eleminate the last saved_max_pfn user. Unfortunately I could not find a calgary system to test this on.

Quoted 8 lines

Be aware: I could not test this.
If someone tells me for what kind of machine (and BIOS stuff enabled?) I should look for, I can try to search for such a platform.

Something else: There is quite some duplicate code in kexec-tools when it is about retrieving the e820 table info (normal kexec vs kdump). Did you see my cleanups I posted long ago? Do you plan to still clean up a bit after this series?

Yes, I saw them and find some of them are pretty useful for this patchset. I suppose some cleanups can be done later. Feel free to clean up after this patchset is settled.

Quoted 110 lines

Thomas

X86: Eliminate saved_max_pfn user in pci-calgary and remove the unused variable

Searching for the highest value of RAM and RESERVED memory in kdump case should be the same as max_pfn of the original kernel.
At least this is always the case as long as type usable RAM is the highest entry in original e820 map.

arch/x86/include/asm/e820.h +1 -0
index 779c2ef..712173e 100644
@@ -49,6 +49,7 @@ static inline void early_memtest(unsigned long start, unsigned long end)
 #endif
 
 extern unsigned long e820_end_of_ram_pfn(void);
+extern unsigned long e820_end_of_e820_pfn(void);
 extern unsigned long e820_end_of_low_ram_pfn(void);
 extern u64 early_reserve_e820(u64 sizet, u64 align);
 
arch/x86/kernel/e820.c +7 -9
index 988c00a..699e8fe 100644
@@ -757,7 +757,7 @@ u64 __init early_reserve_e820(u64 size, u64 align)
 /*
  * Find the highest page frame number we have available
  */
-static unsigned long __init e820_end_pfn(unsigned long limit_pfn, unsigned type)
+unsigned long __init e820_end_pfn(unsigned long limit_pfn, unsigned type)
 {
 	int i;
 	unsigned long last_pfn = 0;
@@ -796,6 +796,12 @@ unsigned long __init e820_end_of_ram_pfn(void)
 	return e820_end_pfn(MAX_ARCH_PFN, E820_RAM);
 }
 
+unsigned long __init e820_end_of_e820_pfn(void)
+{
+	return max(e820_end_pfn(MAX_ARCH_PFN, E820_RAM),
+		   e820_end_pfn(MAX_ARCH_PFN, E820_RESERVED);
+}
+
 unsigned long __init e820_end_of_low_ram_pfn(void)
 {
 	return e820_end_pfn(1UL<<(32 - PAGE_SHIFT), E820_RAM);
@@ -847,14 +853,6 @@ static int __init parse_memmap_one(char *p)
 		return -EINVAL;
 
 	if (!strncmp(p, "exactmap", 8)) {
-#ifdef CONFIG_CRASH_DUMP
-		/*
-		 * If we are doing a crash dump, we still need to know
-		 * the real mem size before original memory map is
-		 * reset.
-		 */
-		saved_max_pfn = e820_end_of_ram_pfn();
-#endif
 		e820.nr_map = 0;
 		userdef = 1;
 		return 0;
arch/x86/kernel/pci-calgary_64.c +5 -2
index 299d493..89ae766 100644
@@ -1371,6 +1371,7 @@ int __init detect_calgary(void)
 	unsigned long ptr;
 	unsigned int offset, prev_offset;
 	int ret;
+	unsigned long orig_max_pfn = max_pfn;
 
 	/*
 	 * if the user specified iommu=off or iommu=soft or we found
@@ -1418,8 +1419,10 @@ int __init detect_calgary(void)
 		return -ENOMEM;
 	}
 
-	specified_table_size = determine_tce_table_size((is_kdump_kernel() ?
-					saved_max_pfn : max_pfn) * PAGE_SIZE);
+	if (is_kdump_kernel())
+		orig_max_pfn = e820_end_of_e820_pfn();
+	specified_table_size = determine_tce_table_size(orig_max_pfn
+							* PAGE_SIZE);
 
 	for (bus = 0; bus < MAX_PHB_BUS_NUM; bus++) {
 		struct calgary_bus_info *info = &bus_info[bus];
include/linux/crash_dump.h +0 -1
index 7032518..bce4d97 100644
@@ -87,5 +87,4 @@ extern void unregister_oldmem_pfn_is_ram(void);
 static inline int is_kdump_kernel(void) { return 0; }
 #endif /* CONFIG_CRASH_DUMP */
 
-extern unsigned long saved_max_pfn;
 #endif /* LINUX_CRASHDUMP_H */
kernel/crash_dump.c +0 -0
index c766ee5..9d50486 100644
@@ -5,12 +5,6 @@
 #include <linux/export.h>
 

kernel/crash_dump.c line 10

Quoted 10 lines
kernel/crash_dump.c +0 -6
 /*
- * If we have booted due to a crash, max_pfn will be a very low value. We need
- * to know the amount of memory that the previous kernel used.
- */
-unsigned long saved_max_pfn;
-
-/*
  * stores the physical address of elf header of crash image
  *
  * Note: elfcorehdr_addr is not just limited to vmcore. It is also used by

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

#9 lore raw

First question is if Calgary even exists anymore and if so if someone actually cares about it enough to maintain it.

Quoted 203 lines · WANG Chao
Quoted 4 lines · Thomas Renninger
Quoted 3 lines · WANG Chao

Hi, All

When kaslr comes in and kdump is broken, it seems about the right

time to

Quoted 1 line
Quoted 1 line

use E820 instead of memmap=exactmap to pass memmap for kdump for

the

Quoted 2 lines
Quoted 2 lines

default memmap passing mechanism:

http://lists.infradead.org/pipermail/kexec/2014-February/011048.html

Quoted 2 lines
Quoted 2 lines

Unfortunately, saved_max_pfn still got its user out there (calgry

pci, it

Quoted 1 line
Quoted 1 line

looks like the only one). So for backward compatibility, I'm

introducing a

Quoted 5 lines
Quoted 2 lines

new option --pass-memmap-cmdline to force kexec-tools to pass memmap=exactmap, the old way.

The saved_max_pfn usage is calgary pci looks bad/wrong and I wonder:
- whether this is still worth touching, so that the old mechanism:
--pass-memmap-cmdline could vanish in the one or other year and

need

Quoted 2 lines

not to be carried forever
I tried to find such a machine, but couldn't find anything mentioning

calgary

Quoted 4 lines

in quite some machines' dmesg.

Approaches to avoid saved_max_pfn in calgary case:
1) If done correctly from the beginning, the TCE table size would

have

Quoted 2 lines

been exposed via /sys and kexec-tools could simply add:
calgary="128k|512K...|8M" which is already caught by pci-calgary

and

Quoted 3 lines

saved_max_pfn is not needed/touched anymore.
-> Disadvantage: needs a new sysfs entry
2) When finding max_pfn for calgary table size usage, we could try

in

Quoted 1 line

kdump case to use the highest memory (RAM or RESERVED) showing

up

Quoted 1 line
     in e820 map.

How could this replace saved_max_pfn? The highest memory in kdump can't necessarily be the real ram size. In kdump, RAM range is just part of the real
ram, not mentioning we don't pass RESERVED range to kdump E820.

Thanks
WANG Chao

Quoted 2 lines

Please find below a patch which would eleminate the last

saved_max_pfn

Quoted 1 line

user. Unfortunately I could not find a calgary system to test this

on.

Quoted 3 lines

Be aware: I could not test this.
If someone tells me for what kind of machine (and BIOS stuff

enabled?)

Quoted 3 lines

I should look for, I can try to search for such a platform.

Something else: There is quite some duplicate code in kexec-tools

when it

Quoted 2 lines

is about retrieving the e820 table info (normal kexec vs kdump). Did you see my cleanups I posted long ago? Do you plan to still clean

up

Quoted 1 line

a bit after this series?

Yes, I saw them and find some of them are pretty useful for this patchset. I suppose some cleanups can be done later. Feel free to clean up after this patchset is settled.

Quoted 6 lines

Thomas

X86: Eliminate saved_max_pfn user in pci-calgary and remove the

unused variable

Quoted 2 lines

Searching for the highest value of RAM and RESERVED memory in kdump

case

Quoted 2 lines

should be the same as max_pfn of the original kernel. At least this is always the case as long as type usable RAM is the

highest

Review

Quoted 5 lines

entry in original e820 map.

(quoted diff) +0 -0

b/arch/x86/include/asm/e820.h

arch/x86/include/asm/e820.h static inline void early_memtest(unsigned long

Quoted 4 lines

index 779c2ef..712173e 100644

arch/x86/include/asm/e820.h +0 -0
@@ -49,6 +49,7 @@ static inline void early_memtest(unsigned long

start, unsigned long end)

arch/x86/kernel/e820.c u64 __init early_reserve_e820(u64 size, u64

Quoted 12 lines
arch/x86/include/asm/e820.h +1 -0
 #endif
 
 extern unsigned long e820_end_of_ram_pfn(void);
+extern unsigned long e820_end_of_e820_pfn(void);
 extern unsigned long e820_end_of_low_ram_pfn(void);
 extern u64 early_reserve_e820(u64 sizet, u64 align);
 
arch/x86/kernel/e820.c +0 -0
index 988c00a..699e8fe 100644
@@ -757,7 +757,7 @@ u64 __init early_reserve_e820(u64 size, u64

align)

arch/x86/kernel/e820.c u64 __init early_reserve_e820(u64 size, u64 align)

Quoted 4 lines
arch/x86/kernel/e820.c +0 -1
 /*
  * Find the highest page frame number we have available
  */
-static unsigned long __init e820_end_pfn(unsigned long limit_pfn,

unsigned type)

arch/x86/kernel/e820.c u64 __init early_reserve_e820(u64 size, u64 · line 760

Quoted 1 line
arch/x86/kernel/e820.c +1 -0
+unsigned long __init e820_end_pfn(unsigned long limit_pfn, unsigned

type)

Review

Quoted 32 lines
arch/x86/kernel/e820.c +6 -8
 {
 	int i;
 	unsigned long last_pfn = 0;
@@ -796,6 +796,12 @@ unsigned long __init e820_end_of_ram_pfn(void)
 	return e820_end_pfn(MAX_ARCH_PFN, E820_RAM);
 }
 
+unsigned long __init e820_end_of_e820_pfn(void)
+{
+	return max(e820_end_pfn(MAX_ARCH_PFN, E820_RAM),
+		   e820_end_pfn(MAX_ARCH_PFN, E820_RESERVED);
+}
+
 unsigned long __init e820_end_of_low_ram_pfn(void)
 {
 	return e820_end_pfn(1UL<<(32 - PAGE_SHIFT), E820_RAM);
@@ -847,14 +853,6 @@ static int __init parse_memmap_one(char *p)
 		return -EINVAL;
 
 	if (!strncmp(p, "exactmap", 8)) {
-#ifdef CONFIG_CRASH_DUMP
-		/*
-		 * If we are doing a crash dump, we still need to know
-		 * the real mem size before original memory map is
-		 * reset.
-		 */
-		saved_max_pfn = e820_end_of_ram_pfn();
-#endif
 		e820.nr_map = 0;
 		userdef = 1;
 		return 0;
(quoted diff) +0 -0

b/arch/x86/kernel/pci-calgary_64.c

Quoted 12 lines

index 299d493..89ae766 100644

arch/x86/kernel/pci-calgary_64.c +1 -0
@@ -1371,6 +1371,7 @@ int __init detect_calgary(void)
 	unsigned long ptr;
 	unsigned int offset, prev_offset;
 	int ret;
+	unsigned long orig_max_pfn = max_pfn;
 
 	/*
 	 * if the user specified iommu=off or iommu=soft or we found

arch/x86/kernel/pci-calgary_64.c int __init detect_calgary(void) · line 1421

Quoted 4 lines
arch/x86/kernel/pci-calgary_64.c +0 -1
@@ -1418,8 +1419,10 @@ int __init detect_calgary(void)
 		return -ENOMEM;
 	}
 
-	specified_table_size = determine_tce_table_size((is_kdump_kernel()

?

Quoted 23 lines
arch/x86/kernel/pci-calgary_64.c +4 -1
-					saved_max_pfn : max_pfn) * PAGE_SIZE);
+	if (is_kdump_kernel())
+		orig_max_pfn = e820_end_of_e820_pfn();
+	specified_table_size = determine_tce_table_size(orig_max_pfn
+							* PAGE_SIZE);
 
 	for (bus = 0; bus < MAX_PHB_BUS_NUM; bus++) {
 		struct calgary_bus_info *info = &bus_info[bus];
include/linux/crash_dump.h +0 -1
index 7032518..bce4d97 100644
@@ -87,5 +87,4 @@ extern void unregister_oldmem_pfn_is_ram(void);
 static inline int is_kdump_kernel(void) { return 0; }
 #endif /* CONFIG_CRASH_DUMP */
 
-extern unsigned long saved_max_pfn;
 #endif /* LINUX_CRASHDUMP_H */
kernel/crash_dump.c +0 -0
index c766ee5..9d50486 100644

kernel/crash_dump.c line 8

Quoted 4 lines
kernel/crash_dump.c +0 -1
@@ -5,12 +5,6 @@
 #include <linux/export.h>
 
 /*
- * If we have booted due to a crash, max_pfn will be a very low

value. We need

kernel/crash_dump.c

Quoted 8 lines
kernel/crash_dump.c +0 -5
- * to know the amount of memory that the previous kernel used.
- */
-unsigned long saved_max_pfn;
-
-/*
  * stores the physical address of elf header of crash image
  *
  * Note: elfcorehdr_addr is not just limited to vmcore. It is also

used by

Quoted 1 line
Signature · 6 lines
Sent from my mobile phone.  Please pardon brevity and lack of formatting.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#10 lore raw
Quoted 1 line · H. Peter Anvin

First question is if Calgary even exists anymore and if so if someone actually cares about it enough to maintain it.

Atleast MAINTAINERS file says it is maintained.

CALGARY x86-64 IOMMU

M:      Muli Ben-Yehuda <[email protected]>
M:      "Jon D. Mason" <[email protected]>
L:      [email protected]
S:      Maintained
F:      arch/x86/kernel/pci-calgary_64.c
F:      arch/x86/kernel/tce_64.c
F:      arch/x86/include/asm/calgary.h
F:      arch/x86/include/asm/tce.h

I am add maintainers to CC list and they can shed more light on if calgary still exists and if somebody actually cares about it.

Thanks
Vivek

Quoted 195 lines · WANG Chao
Quoted 193 lines · Thomas Renninger
Quoted 4 lines · WANG Chao
Quoted 3 lines

Hi, All

When kaslr comes in and kdump is broken, it seems about the right

time to

Quoted 1 line
Quoted 1 line

use E820 instead of memmap=exactmap to pass memmap for kdump for

the

Quoted 2 lines
Quoted 2 lines

default memmap passing mechanism:

http://lists.infradead.org/pipermail/kexec/2014-February/011048.html

Quoted 2 lines
Quoted 2 lines

Unfortunately, saved_max_pfn still got its user out there (calgry

pci, it

Quoted 1 line
Quoted 1 line

looks like the only one). So for backward compatibility, I'm

introducing a

Quoted 5 lines
Quoted 2 lines

new option --pass-memmap-cmdline to force kexec-tools to pass memmap=exactmap, the old way.

The saved_max_pfn usage is calgary pci looks bad/wrong and I wonder:
- whether this is still worth touching, so that the old mechanism:
--pass-memmap-cmdline could vanish in the one or other year and

need

Quoted 2 lines

not to be carried forever
I tried to find such a machine, but couldn't find anything mentioning

calgary

Quoted 4 lines

in quite some machines' dmesg.

Approaches to avoid saved_max_pfn in calgary case:
1) If done correctly from the beginning, the TCE table size would

have

Quoted 2 lines

been exposed via /sys and kexec-tools could simply add:
calgary="128k|512K...|8M" which is already caught by pci-calgary

and

Quoted 3 lines

saved_max_pfn is not needed/touched anymore.
-> Disadvantage: needs a new sysfs entry
2) When finding max_pfn for calgary table size usage, we could try

in

Quoted 1 line

kdump case to use the highest memory (RAM or RESERVED) showing

up

Quoted 1 line
     in e820 map.

How could this replace saved_max_pfn? The highest memory in kdump can't necessarily be the real ram size. In kdump, RAM range is just part of the real
ram, not mentioning we don't pass RESERVED range to kdump E820.

Thanks
WANG Chao

Quoted 2 lines

Please find below a patch which would eleminate the last

saved_max_pfn

Quoted 1 line

user. Unfortunately I could not find a calgary system to test this

on.

Quoted 3 lines

Be aware: I could not test this.
If someone tells me for what kind of machine (and BIOS stuff

enabled?)

Quoted 3 lines

I should look for, I can try to search for such a platform.

Something else: There is quite some duplicate code in kexec-tools

when it

Quoted 2 lines

is about retrieving the e820 table info (normal kexec vs kdump). Did you see my cleanups I posted long ago? Do you plan to still clean

up

Quoted 1 line

a bit after this series?

Yes, I saw them and find some of them are pretty useful for this patchset. I suppose some cleanups can be done later. Feel free to clean up after this patchset is settled.

Quoted 6 lines

Thomas

X86: Eliminate saved_max_pfn user in pci-calgary and remove the

unused variable

Quoted 2 lines

Searching for the highest value of RAM and RESERVED memory in kdump

case

Quoted 2 lines

should be the same as max_pfn of the original kernel. At least this is always the case as long as type usable RAM is the

highest

Review

Quoted 5 lines

entry in original e820 map.

(quoted diff) +0 -0

b/arch/x86/include/asm/e820.h

arch/x86/include/asm/e820.h static inline void early_memtest(unsigned long

Quoted 4 lines

index 779c2ef..712173e 100644

arch/x86/include/asm/e820.h +0 -0
@@ -49,6 +49,7 @@ static inline void early_memtest(unsigned long

start, unsigned long end)

arch/x86/kernel/e820.c u64 __init early_reserve_e820(u64 size, u64

Quoted 12 lines
arch/x86/include/asm/e820.h +1 -0
 #endif
 
 extern unsigned long e820_end_of_ram_pfn(void);
+extern unsigned long e820_end_of_e820_pfn(void);
 extern unsigned long e820_end_of_low_ram_pfn(void);
 extern u64 early_reserve_e820(u64 sizet, u64 align);
 
arch/x86/kernel/e820.c +0 -0
index 988c00a..699e8fe 100644
@@ -757,7 +757,7 @@ u64 __init early_reserve_e820(u64 size, u64

align)

arch/x86/kernel/e820.c u64 __init early_reserve_e820(u64 size, u64 align)

Quoted 4 lines
arch/x86/kernel/e820.c +0 -1
 /*
  * Find the highest page frame number we have available
  */
-static unsigned long __init e820_end_pfn(unsigned long limit_pfn,

unsigned type)

arch/x86/kernel/e820.c u64 __init early_reserve_e820(u64 size, u64 · line 760

Quoted 1 line
arch/x86/kernel/e820.c +1 -0
+unsigned long __init e820_end_pfn(unsigned long limit_pfn, unsigned

type)

Review

Quoted 32 lines
arch/x86/kernel/e820.c +6 -8
 {
 	int i;
 	unsigned long last_pfn = 0;
@@ -796,6 +796,12 @@ unsigned long __init e820_end_of_ram_pfn(void)
 	return e820_end_pfn(MAX_ARCH_PFN, E820_RAM);
 }
 
+unsigned long __init e820_end_of_e820_pfn(void)
+{
+	return max(e820_end_pfn(MAX_ARCH_PFN, E820_RAM),
+		   e820_end_pfn(MAX_ARCH_PFN, E820_RESERVED);
+}
+
 unsigned long __init e820_end_of_low_ram_pfn(void)
 {
 	return e820_end_pfn(1UL<<(32 - PAGE_SHIFT), E820_RAM);
@@ -847,14 +853,6 @@ static int __init parse_memmap_one(char *p)
 		return -EINVAL;
 
 	if (!strncmp(p, "exactmap", 8)) {
-#ifdef CONFIG_CRASH_DUMP
-		/*
-		 * If we are doing a crash dump, we still need to know
-		 * the real mem size before original memory map is
-		 * reset.
-		 */
-		saved_max_pfn = e820_end_of_ram_pfn();
-#endif
 		e820.nr_map = 0;
 		userdef = 1;
 		return 0;
(quoted diff) +0 -0

b/arch/x86/kernel/pci-calgary_64.c

Quoted 12 lines

index 299d493..89ae766 100644

arch/x86/kernel/pci-calgary_64.c +1 -0
@@ -1371,6 +1371,7 @@ int __init detect_calgary(void)
 	unsigned long ptr;
 	unsigned int offset, prev_offset;
 	int ret;
+	unsigned long orig_max_pfn = max_pfn;
 
 	/*
 	 * if the user specified iommu=off or iommu=soft or we found

arch/x86/kernel/pci-calgary_64.c int __init detect_calgary(void) · line 1421

Quoted 4 lines
arch/x86/kernel/pci-calgary_64.c +0 -1
@@ -1418,8 +1419,10 @@ int __init detect_calgary(void)
 		return -ENOMEM;
 	}
 
-	specified_table_size = determine_tce_table_size((is_kdump_kernel()

?

Quoted 23 lines
arch/x86/kernel/pci-calgary_64.c +4 -1
-					saved_max_pfn : max_pfn) * PAGE_SIZE);
+	if (is_kdump_kernel())
+		orig_max_pfn = e820_end_of_e820_pfn();
+	specified_table_size = determine_tce_table_size(orig_max_pfn
+							* PAGE_SIZE);
 
 	for (bus = 0; bus < MAX_PHB_BUS_NUM; bus++) {
 		struct calgary_bus_info *info = &bus_info[bus];
include/linux/crash_dump.h +0 -1
index 7032518..bce4d97 100644
@@ -87,5 +87,4 @@ extern void unregister_oldmem_pfn_is_ram(void);
 static inline int is_kdump_kernel(void) { return 0; }
 #endif /* CONFIG_CRASH_DUMP */
 
-extern unsigned long saved_max_pfn;
 #endif /* LINUX_CRASHDUMP_H */
kernel/crash_dump.c +0 -0
index c766ee5..9d50486 100644

kernel/crash_dump.c line 8

Quoted 4 lines
kernel/crash_dump.c +0 -1
@@ -5,12 +5,6 @@
 #include <linux/export.h>
 
 /*
- * If we have booted due to a crash, max_pfn will be a very low

value. We need

Quoted 13 lines
Quoted 10 lines

kernel/crash_dump.c

Quoted 8 lines
kernel/crash_dump.c +0 -5
- * to know the amount of memory that the previous kernel used.
- */
-unsigned long saved_max_pfn;
-
-/*
  * stores the physical address of elf header of crash image
  *
  * Note: elfcorehdr_addr is not just limited to vmcore. It is also

used by

Quoted 1 line
Signature · 1 line
Sent from my mobile phone.  Please pardon brevity and lack of formatting.

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

#11 lore raw
Quoted 16 lines · Vivek Goyal
Quoted 1 line · H. Peter Anvin

First question is if Calgary even exists anymore and if so if someone actually cares about it enough to maintain it.

Atleast MAINTAINERS file says it is maintained.

CALGARY x86-64 IOMMU

M:      Muli Ben-Yehuda <[email protected]>
M:      "Jon D. Mason" <[email protected]>
L:      [email protected]
S:      Maintained
F:      arch/x86/kernel/pci-calgary_64.c
F:      arch/x86/kernel/tce_64.c
F:      arch/x86/include/asm/calgary.h
F:      arch/x86/include/asm/tce.h
Quoted 2 lines

I am add maintainers to CC list and they can shed more light on if calgary still exists and if somebody actually cares about it.

Jon,

Muli's mail is bouncing. Is he still maintaining calgary and is his mail id still valid as mentioned in MAINTAINERS entry above.

Thanks
Vivek

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

#12 lore raw

I think Muli had moved on a while ago.

Quoted 28 lines · Vivek Goyal
Quoted 2 lines · Vivek Goyal
Quoted 1 line · H. Peter Anvin

First question is if Calgary even exists anymore and if so if

someone actually cares about it enough to maintain it.

Quoted 14 lines

Atleast MAINTAINERS file says it is maintained.

CALGARY x86-64 IOMMU

M:      Muli Ben-Yehuda <[email protected]>
M:      "Jon D. Mason" <[email protected]>
L:      [email protected]
S:      Maintained
F:      arch/x86/kernel/pci-calgary_64.c
F:      arch/x86/kernel/tce_64.c
F:      arch/x86/include/asm/calgary.h
F:      arch/x86/include/asm/tce.h
Quoted 2 lines

I am add maintainers to CC list and they can shed more light on if calgary still exists and if somebody actually cares about it.

Jon,

Muli's mail is bouncing. Is he still maintaining calgary and is his mail id still valid as mentioned in MAINTAINERS entry above.

Thanks
Vivek

Signature · 6 lines
Sent from my mobile phone.  Please pardon brevity and lack of formatting.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#13 lore raw
In reply to WANG Chao

On Mon, Feb 24, 2014 at 10:58:41PM +0800, WANG Chao wrote:
[..]

Quoted 10 lines
Quoted 9 lines

Approaches to avoid saved_max_pfn in calgary case:
1) If done correctly from the beginning, the TCE table size would have been exposed via /sys and kexec-tools could simply add:
calgary="128k|512K...|8M" which is already caught by pci-calgary and saved_max_pfn is not needed/touched anymore.
-> Disadvantage: needs a new sysfs entry
2) When finding max_pfn for calgary table size usage, we could try in kdump case to use the highest memory (RAM or RESERVED) showing up in e820 map.

Quoted 3 lines

How could this replace saved_max_pfn? The highest memory in kdump can't necessarily be the real ram size. In kdump, RAM range is just part of the real ram, not mentioning we don't pass RESERVED range to kdump E820.

I vaguely remember there was some discussion about passing first kerne's RAM as special reserved ranges. Say E820_RESERVED_KDUMP. And use that to figure out saved_max_pfn.

I personally feel that just create a new command line parameter "saved_max_pfn" and pass it to second kernel and be done with it. Modify calgary code to first look for saved_max_pfn and if not present, calculate saved_max_pfn from e820.

saved_max_pfn command line option is pretty ugly, not sure what are the better options here.

Thanks
Vivek

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

#14 lore raw

I would like to see if there is any actual use for it before doing anything else. The Calgary code may just be off.

Quoted 39 lines · Vivek Goyal

On Mon, Feb 24, 2014 at 10:58:41PM +0800, WANG Chao wrote:
[..]

Quoted 2 lines
Quoted 2 lines

Approaches to avoid saved_max_pfn in calgary case:
1) If done correctly from the beginning, the TCE table size would

have

Quoted 2 lines
Quoted 2 lines

been exposed via /sys and kexec-tools could simply add:
calgary="128k|512K...|8M" which is already caught by

pci-calgary and

Quoted 3 lines
Quoted 3 lines

saved_max_pfn is not needed/touched anymore.
-> Disadvantage: needs a new sysfs entry
2) When finding max_pfn for calgary table size usage, we could

try in

Quoted 1 line
Quoted 1 line

kdump case to use the highest memory (RAM or RESERVED) showing

up

Quoted 3 lines
Quoted 1 line
     in e820 map.

How could this replace saved_max_pfn? The highest memory in kdump

can't

Quoted 1 line

necessarily be the real ram size. In kdump, RAM range is just part of

the real

Quoted 1 line

ram, not mentioning we don't pass RESERVED range to kdump E820.

I vaguely remember there was some discussion about passing first kerne's
RAM as special reserved ranges. Say E820_RESERVED_KDUMP. And use that to figure out saved_max_pfn.

I personally feel that just create a new command line parameter "saved_max_pfn" and pass it to second kernel and be done with it. Modify
calgary code to first look for saved_max_pfn and if not present, calculate
saved_max_pfn from e820.

saved_max_pfn command line option is pretty ugly, not sure what are the better options here.

Thanks
Vivek

Signature · 6 lines
Sent from my mobile phone.  Please pardon brevity and lack of formatting.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#15 lore raw
In reply to Vivek Goyal
Quoted 20 lines · Vivek Goyal

On Mon, Feb 24, 2014 at 10:58:41PM +0800, WANG Chao wrote:
[..]

Quoted 17 lines
Quoted 9 lines

Approaches to avoid saved_max_pfn in calgary case:
1) If done correctly from the beginning, the TCE table size would have

been exposed via /sys and kexec-tools could simply add:
calgary="128k|512K...|8M" which is already caught by pci-calgary and
saved_max_pfn is not needed/touched anymore.
-> Disadvantage: needs a new sysfs entry

Quoted 4 lines

2) When finding max_pfn for calgary table size usage, we could try in

kdump case to use the highest memory (RAM or RESERVED) showing up in e820 map.

How could this replace saved_max_pfn? The highest memory in kdump can't necessarily be the real ram size. In kdump, RAM range is just part of the real ram, not mentioning we don't pass RESERVED range to kdump E820.

I expected you pass RAM that must not be used as RESERVED. Then, still depending on which mem type is the last one, it might have worked.

Quoted 11 lines

I vaguely remember there was some discussion about passing first kerne's RAM as special reserved ranges. Say E820_RESERVED_KDUMP. And use that to figure out saved_max_pfn.

I personally feel that just create a new command line parameter "saved_max_pfn" and pass it to second kernel and be done with it. Modify calgary code to first look for saved_max_pfn and if not present, calculate saved_max_pfn from e820.

saved_max_pfn command line option is pretty ugly, not sure what are the better options here.

It should be done like that:

The specified_table_size variable must be exported via sysfs. If kexec-tools finds it existing it can pass in the table size via boot param:
calgary=
(compare with calgary_parse_options() in arch/x86/kernel/pci-calgary_64.c).

Then the table size detection (for which saved_max_pfn is needed) would fall off in kdump case.

If this really is supported/relevant, I can send something, but it would need kexec-tools code as well.

Thomas

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

#16 lore raw

On Mon, Feb 24, 2014 at 04:34:26PM +0100, Thomas Renninger wrote:

[..]

Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

How could this replace saved_max_pfn? The highest memory in kdump can't necessarily be the real ram size. In kdump, RAM range is just part of the real ram, not mentioning we don't pass RESERVED range to kdump E820.

I expected you pass RAM that must not be used as RESERVED. Then, still depending on which mem type is the last one, it might have worked.

No we don't. There is a proposal though to pass first kernel's reserved ranges to second kernel as SGI folks need that somehow.

Thanks
Vivek

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

#17 lore raw

Not just SGI, I don't think. You definitely need to do this.

Quoted 18 lines · Vivek Goyal

On Mon, Feb 24, 2014 at 04:34:26PM +0100, Thomas Renninger wrote:

[..]

Quoted 1 line
Quoted 1 line
Quoted 1 line

How could this replace saved_max_pfn? The highest memory in kdump

can't

Quoted 1 line
Quoted 1 line
Quoted 1 line

necessarily be the real ram size. In kdump, RAM range is just

part of the

Quoted 1 line
Quoted 1 line
Quoted 1 line

real ram, not mentioning we don't pass RESERVED range to kdump

E820.

Quoted 1 line

I expected you pass RAM that must not be used as RESERVED. Then,

still

Quoted 1 line

depending on which mem type is the last one, it might have worked.

No we don't. There is a proposal though to pass first kernel's reserved ranges to second kernel as SGI folks need that somehow.

Thanks
Vivek

Signature · 6 lines
Sent from my mobile phone.  Please pardon brevity and lack of formatting.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#18 lore raw
Quoted 1 line · H. Peter Anvin

Not just SGI, I don't think. You definitely need to do this.

Ok. Once we have resolved the calgary issue and merged the patches where kdump memory ranges are passed in bootparams, we can take care of passing reserved ranges too. One thing at a time.

Solving calgary issue is important though as this has been blocking new patches for quite some time now.

Thanks
Vivek

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