Blame SOURCES/kexec-tools-2.0.7-makedumpfile-sadump-Support-more-than-16TB-physical-memory.patch

b6bfec
From 37afcd52ac5dd276a51af51cbee9531b91911bfa Mon Sep 17 00:00:00 2001
b6bfec
From: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
b6bfec
Date: Fri, 20 Feb 2015 10:18:41 +0900
b6bfec
Subject: [PATCH] [PATCH] sadump: Support more than 16TB physical memory space.
b6bfec
b6bfec
This patch makes sadump format support more than 16TB physical memory
b6bfec
space.
b6bfec
b6bfec
The limitation is caused by several members of dump_header structure:
b6bfec
max_mapnr and the others. They have 4 byte length only. In particular,
b6bfec
max_mapnr member gets overflow if more than 16TB physical memory space
b6bfec
is given.
b6bfec
b6bfec
To support more than 16TB physical memory space, this patch adds new 4
b6bfec
64-bit length members in dump_header structure:
b6bfec
b6bfec
- max_mapnr_64
b6bfec
- total_ram_blocks_64
b6bfec
- device_blocks_64
b6bfec
- written_blocks_64
b6bfec
b6bfec
Next table shows correspondence between the 32-bit version and the
b6bfec
64-bit version members:
b6bfec
b6bfec
    | 32-bit version         | 64-bit version            |
b6bfec
    |------------------------+---------------------------|
b6bfec
    | max_mapnr              | max_mapnr_64              |
b6bfec
    | total_ram_blocks       | total_ram_blocks_64       |
b6bfec
    | device_blocks          | device_blocks_64          |
b6bfec
    | written_blocks         | written_blocks_64         |
b6bfec
b6bfec
In addition, header_version member of dump_header structure is
b6bfec
increased to 1 in this extended new format.
b6bfec
b6bfec
Old makedumpfile can access the new sadump format under 16TB
b6bfec
correctly.
b6bfec
b6bfec
Current implementation treats vmcore with kernel version 2 or later as
b6bfec
kernel version 1, assuming backward compatibility.
b6bfec
b6bfec
Signed-off-by: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
b6bfec
---
b6bfec
 sadump_info.c | 20 +++++++++++++++++---
b6bfec
 sadump_mod.h  |  8 ++++++++
b6bfec
 2 files changed, 25 insertions(+), 3 deletions(-)
b6bfec
b6bfec
diff --git a/makedumpfile-1.5.7/sadump_info.c b/makedumpfile-1.5.7/sadump_info.c
b6bfec
index 9434ff7..e2c4f03 100644
b6bfec
--- a/makedumpfile-1.5.7/sadump_info.c
b6bfec
+++ b/makedumpfile-1.5.7/sadump_info.c
b6bfec
@@ -84,6 +84,7 @@ struct sadump_info {
b6bfec
 	unsigned long backup_src_size;
b6bfec
 	unsigned long long backup_offset;
b6bfec
 	int kdump_backed_up;
b6bfec
+	mdf_pfn_t max_mapnr;
b6bfec
 };
b6bfec
 
b6bfec
 static char *guid_to_str(efi_guid_t *guid, char *buf, size_t buflen);
b6bfec
@@ -625,6 +626,19 @@ restart:
b6bfec
 		offset += sh->sub_hdr_size * block_size;
b6bfec
 	}
b6bfec
 
b6bfec
+	switch (sh->header_version) {
b6bfec
+	case 0:
b6bfec
+		si->max_mapnr = (mdf_pfn_t)(uint64_t)sh->max_mapnr;
b6bfec
+		break;
b6bfec
+	default:
b6bfec
+		ERRMSG("sadump: unsupported header version: %u\n"
b6bfec
+		       "sadump: assuming header version: 1\n",
b6bfec
+		       sh->header_version);
b6bfec
+	case 1:
b6bfec
+		si->max_mapnr = (mdf_pfn_t)sh->max_mapnr_64;
b6bfec
+		break;
b6bfec
+	}
b6bfec
+
b6bfec
 	if (!sh->bitmap_blocks) {
b6bfec
 		DEBUG_MSG("sadump: bitmap_blocks is zero\n");
b6bfec
 		return FALSE;
b6bfec
@@ -775,7 +789,7 @@ sadump_initialize_bitmap_memory(void)
b6bfec
 	memset(bmp->buf, 0, BUFSIZE_BITMAP);
b6bfec
 	bmp->offset = dumpable_bitmap_offset;
b6bfec
 
b6bfec
-	max_section = divideup(sh->max_mapnr, SADUMP_PF_SECTION_NUM);
b6bfec
+	max_section = divideup(si->max_mapnr, SADUMP_PF_SECTION_NUM);
b6bfec
 
b6bfec
 	block_table = calloc(sizeof(unsigned long long), max_section);
b6bfec
 	if (block_table == NULL) {
b6bfec
@@ -906,7 +920,7 @@ sadump_set_timestamp(struct timeval *ts)
b6bfec
 mdf_pfn_t
b6bfec
 sadump_get_max_mapnr(void)
b6bfec
 {
b6bfec
-	return si->sh_memory->max_mapnr;
b6bfec
+	return si->max_mapnr;
b6bfec
 }
b6bfec
 
b6bfec
 #ifdef __x86_64__
b6bfec
@@ -964,7 +978,7 @@ readpage_sadump(unsigned long long paddr, void *bufptr)
b6bfec
 
b6bfec
 	pfn = paddr_to_pfn(paddr);
b6bfec
 
b6bfec
-	if (pfn >= si->sh_memory->max_mapnr)
b6bfec
+	if (pfn >= si->max_mapnr)
b6bfec
 		return FALSE;
b6bfec
 
b6bfec
 	if (!is_dumpable(info->bitmap_memory, pfn)) {
b6bfec
diff --git a/makedumpfile-1.5.7/sadump_mod.h b/makedumpfile-1.5.7/sadump_mod.h
b6bfec
index afeead8..0dd5bb5 100644
b6bfec
--- a/makedumpfile-1.5.7/sadump_mod.h
b6bfec
+++ b/makedumpfile-1.5.7/sadump_mod.h
b6bfec
@@ -106,6 +106,14 @@ struct sadump_header {
b6bfec
 	uint32_t written_blocks;	/* Number of written blocks */
b6bfec
 	uint32_t current_cpu;	/* CPU# which handles dump */
b6bfec
 	uint32_t nr_cpus;	/* Number of CPUs */
b6bfec
+	/*
b6bfec
+	 * The members from below are supported in header version 1
b6bfec
+	 * and later.
b6bfec
+	 */
b6bfec
+	uint64_t max_mapnr_64;
b6bfec
+	uint64_t total_ram_blocks_64;
b6bfec
+	uint64_t device_blocks_64;
b6bfec
+	uint64_t written_blocks_64;
b6bfec
 };
b6bfec
 
b6bfec
 struct sadump_apic_state {
b6bfec
-- 
b6bfec
1.8.5.3
b6bfec