Blame SOURCES/sadump_16TB.patch

d39c82
    Add support for more than 16TB of physical memory space in the SADUMP
d39c82
    dumpfile format.  Without the patch, there is a limitation caused
d39c82
    by several 32-bit members of dump_header structure, in particular
d39c82
    the max_mapnr member, which overflows if the dumpfile contains more
d39c82
    than 16TB of physical memory space.  The header_version member of
d39c82
    the dump_header structure has been increased from 0 to 1 in this
d39c82
    extended new format, and the new 64-bit members will be used.
d39c82
    (d.hatayama@jp.fujitsu.com)
d39c82
d39c82
diff --git a/sadump.c b/sadump.c
d39c82
index d7c6701..bc67354 100644
d39c82
--- a/sadump.c
d39c82
+++ b/sadump.c
d39c82
@@ -20,6 +20,7 @@
d39c82
 #include "sadump.h"
d39c82
 #include <arpa/inet.h> /* htonl, htons */
d39c82
 #include <elf.h>
d39c82
+#include <inttypes.h>
d39c82
 
d39c82
 enum {
d39c82
 	failed = -1
d39c82
@@ -325,6 +326,20 @@ restart:
d39c82
 
d39c82
 	flags |= SADUMP_LOCAL;
d39c82
 
d39c82
+	switch (sh->header_version) {
d39c82
+	case 0:
d39c82
+		sd->max_mapnr = (uint64_t)sh->max_mapnr;
d39c82
+		break;
d39c82
+	default:
d39c82
+		error(WARNING,
d39c82
+		      "sadump: unsupported header version: %u\n"
d39c82
+		      "sadump: assuming header version: 1\n",
d39c82
+		      sh->header_version);
d39c82
+	case 1:
d39c82
+		sd->max_mapnr = sh->max_mapnr_64;
d39c82
+		break;
d39c82
+	}
d39c82
+
d39c82
 	if (sh->sub_hdr_size > 0) {
d39c82
 		if (!read_device(&smram_cpu_state_size, sizeof(uint32_t),
d39c82
 				 &offset)) {
d39c82
@@ -772,7 +787,7 @@ int read_sadump(int fd, void *bufptr, int cnt, ulong addr, physaddr_t paddr)
d39c82
 	curpaddr = paddr & ~((physaddr_t)(sd->block_size-1));
d39c82
 	page_offset = paddr & ((physaddr_t)(sd->block_size-1));
d39c82
 
d39c82
-	if ((pfn >= sd->dump_header->max_mapnr) || !page_is_ram(pfn))
d39c82
+	if ((pfn >= sd->max_mapnr) || !page_is_ram(pfn))
d39c82
 		return SEEK_ERROR;
d39c82
 	if (!page_is_dumpable(pfn)) {
d39c82
 		if (sd->flags & SADUMP_ZERO_EXCLUDED)
d39c82
@@ -979,6 +994,17 @@ int sadump_memory_dump(FILE *fp)
d39c82
 	fprintf(fp, "      written_blocks: %u\n", sh->written_blocks);
d39c82
 	fprintf(fp, "         current_cpu: %u\n", sh->current_cpu);
d39c82
 	fprintf(fp, "             nr_cpus: %u\n", sh->nr_cpus);
d39c82
+	if (sh->header_version >= 1) {
d39c82
+		fprintf(fp,
d39c82
+			"        max_mapnr_64: %" PRIu64 "\n"
d39c82
+			" total_ram_blocks_64: %" PRIu64 "\n"
d39c82
+			"    device_blocks_64: %" PRIu64 "\n"
d39c82
+			"   written_blocks_64: %" PRIu64 "\n",
d39c82
+			sh->max_mapnr_64,
d39c82
+			sh->total_ram_blocks_64,
d39c82
+			sh->device_blocks_64,
d39c82
+			sh->written_blocks_64);
d39c82
+	}
d39c82
 
d39c82
 	fprintf(fp, "\n    dump sub heaer: ");
d39c82
 	if (sh->sub_hdr_size > 0) {
d39c82
@@ -1556,7 +1582,7 @@ static int block_table_init(void)
d39c82
 {
d39c82
 	uint64_t pfn, section, max_section, *block_table;
d39c82
 
d39c82
-	max_section = divideup(sd->dump_header->max_mapnr, SADUMP_PF_SECTION_NUM);
d39c82
+	max_section = divideup(sd->max_mapnr, SADUMP_PF_SECTION_NUM);
d39c82
 
d39c82
 	block_table = calloc(sizeof(uint64_t), max_section);
d39c82
 	if (!block_table) {
d39c82
diff --git a/sadump.h b/sadump.h
d39c82
index 09e313e..7f8e384 100644
d39c82
--- a/sadump.h
d39c82
+++ b/sadump.h
d39c82
@@ -103,6 +103,14 @@ struct sadump_header {
d39c82
 	uint32_t written_blocks;	/* Number of written blocks */
d39c82
 	uint32_t current_cpu;	/* CPU# which handles dump */
d39c82
 	uint32_t nr_cpus;	/* Number of CPUs */
d39c82
+	/*
d39c82
+	 * The members from below are supported in header version 1
d39c82
+	 * and later.
d39c82
+	 */
d39c82
+	uint64_t max_mapnr_64;
d39c82
+	uint64_t total_ram_blocks_64;
d39c82
+	uint64_t device_blocks_64;
d39c82
+	uint64_t written_blocks_64;
d39c82
 };
d39c82
 
d39c82
 struct sadump_apic_state {
d39c82
@@ -209,6 +217,8 @@ struct sadump_data {
d39c82
 	ulonglong backup_src_start;
d39c82
 	ulong backup_src_size;
d39c82
 	ulonglong backup_offset;
d39c82
+
d39c82
+	uint64_t max_mapnr;
d39c82
 };
d39c82
 
d39c82
 struct sadump_data *sadump_get_sadump_data(void);
d39c82
d39c82