summaryrefslogtreecommitdiff
path: root/dump.c
diff options
context:
space:
mode:
Diffstat (limited to 'dump.c')
-rw-r--r--dump.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/dump.c b/dump.c
index cde14d9d75..e0a606fbbc 100644
--- a/dump.c
+++ b/dump.c
@@ -90,7 +90,6 @@ typedef struct DumpState {
uint8_t *note_buf; /* buffer for notes */
size_t note_buf_offset; /* the writing place in note_buf */
uint32_t nr_cpus; /* number of guest's cpu */
- size_t page_size; /* guest's page size */
uint64_t max_mapnr; /* the biggest guest's phys-mem's number */
size_t len_dump_bitmap; /* the size of the place used to store
dump_bitmap in vmcore */
@@ -805,7 +804,7 @@ static int create_header32(DumpState *s)
strncpy(dh->signature, KDUMP_SIGNATURE, strlen(KDUMP_SIGNATURE));
dh->header_version = cpu_convert_to_target32(6, endian);
- block_size = s->page_size;
+ block_size = TARGET_PAGE_SIZE;
dh->block_size = cpu_convert_to_target32(block_size, endian);
sub_hdr_size = sizeof(struct KdumpSubHeader32) + s->note_size;
sub_hdr_size = DIV_ROUND_UP(sub_hdr_size, block_size);
@@ -912,7 +911,7 @@ static int create_header64(DumpState *s)
strncpy(dh->signature, KDUMP_SIGNATURE, strlen(KDUMP_SIGNATURE));
dh->header_version = cpu_convert_to_target32(6, endian);
- block_size = s->page_size;
+ block_size = TARGET_PAGE_SIZE;
dh->block_size = cpu_convert_to_target32(block_size, endian);
sub_hdr_size = sizeof(struct KdumpSubHeader64) + s->note_size;
sub_hdr_size = DIV_ROUND_UP(sub_hdr_size, block_size);
@@ -1083,8 +1082,8 @@ static bool get_next_page(GuestPhysBlock **blockptr, uint64_t *pfnptr,
if (!block) {
block = QTAILQ_FIRST(&s->guest_phys_blocks.head);
*blockptr = block;
- assert(block->target_start % s->page_size == 0);
- assert(block->target_end % s->page_size == 0);
+ assert((block->target_start & ~TARGET_PAGE_MASK) == 0);
+ assert((block->target_end & ~TARGET_PAGE_MASK) == 0);
*pfnptr = paddr_to_pfn(block->target_start);
if (bufptr) {
*bufptr = block->host_addr;
@@ -1096,7 +1095,7 @@ static bool get_next_page(GuestPhysBlock **blockptr, uint64_t *pfnptr,
addr = pfn_to_paddr(*pfnptr);
if ((addr >= block->target_start) &&
- (addr + s->page_size <= block->target_end)) {
+ (addr + TARGET_PAGE_SIZE <= block->target_end)) {
buf = block->host_addr + (addr - block->target_start);
} else {
/* the next page is in the next block */
@@ -1105,8 +1104,8 @@ static bool get_next_page(GuestPhysBlock **blockptr, uint64_t *pfnptr,
if (!block) {
return false;
}
- assert(block->target_start % s->page_size == 0);
- assert(block->target_end % s->page_size == 0);
+ assert((block->target_start & ~TARGET_PAGE_MASK) == 0);
+ assert((block->target_end & ~TARGET_PAGE_MASK) == 0);
*pfnptr = paddr_to_pfn(block->target_start);
buf = block->host_addr;
}
@@ -1291,7 +1290,7 @@ static int write_dump_pages(DumpState *s)
prepare_data_cache(&page_data, s, offset_data);
/* prepare buffer to store compressed data */
- len_buf_out = get_len_buf_out(s->page_size, s->flag_compress);
+ len_buf_out = get_len_buf_out(TARGET_PAGE_SIZE, s->flag_compress);
if (len_buf_out == 0) {
dump_error(s, "dump: failed to get length of output buffer.\n");
goto out;
@@ -1307,19 +1306,19 @@ static int write_dump_pages(DumpState *s)
* init zero page's page_desc and page_data, because every zero page
* uses the same page_data
*/
- pd_zero.size = cpu_convert_to_target32(s->page_size, endian);
+ pd_zero.size = cpu_convert_to_target32(TARGET_PAGE_SIZE, endian);
pd_zero.flags = cpu_convert_to_target32(0, endian);
pd_zero.offset = cpu_convert_to_target64(offset_data, endian);
pd_zero.page_flags = cpu_convert_to_target64(0, endian);
- buf = g_malloc0(s->page_size);
- ret = write_cache(&page_data, buf, s->page_size, false);
+ buf = g_malloc0(TARGET_PAGE_SIZE);
+ ret = write_cache(&page_data, buf, TARGET_PAGE_SIZE, false);
g_free(buf);
if (ret < 0) {
dump_error(s, "dump: failed to write page data(zero page).\n");
goto out;
}
- offset_data += s->page_size;
+ offset_data += TARGET_PAGE_SIZE;
/*
* dump memory to vmcore page by page. zero page will all be resided in the
@@ -1327,7 +1326,7 @@ static int write_dump_pages(DumpState *s)
*/
while (get_next_page(&block_iter, &pfn_iter, &buf, s)) {
/* check zero page */
- if (is_zero_page(buf, s->page_size)) {
+ if (is_zero_page(buf, TARGET_PAGE_SIZE)) {
ret = write_cache(&page_desc, &pd_zero, sizeof(PageDescriptor),
false);
if (ret < 0) {
@@ -1348,8 +1347,9 @@ static int write_dump_pages(DumpState *s)
*/
size_out = len_buf_out;
if ((s->flag_compress & DUMP_DH_COMPRESSED_ZLIB) &&
- (compress2(buf_out, (uLongf *)&size_out, buf, s->page_size,
- Z_BEST_SPEED) == Z_OK) && (size_out < s->page_size)) {
+ (compress2(buf_out, (uLongf *)&size_out, buf,
+ TARGET_PAGE_SIZE, Z_BEST_SPEED) == Z_OK) &&
+ (size_out < TARGET_PAGE_SIZE)) {
pd.flags = cpu_convert_to_target32(DUMP_DH_COMPRESSED_ZLIB,
endian);
pd.size = cpu_convert_to_target32(size_out, endian);
@@ -1361,9 +1361,9 @@ static int write_dump_pages(DumpState *s)
}
#ifdef CONFIG_LZO
} else if ((s->flag_compress & DUMP_DH_COMPRESSED_LZO) &&
- (lzo1x_1_compress(buf, s->page_size, buf_out,
+ (lzo1x_1_compress(buf, TARGET_PAGE_SIZE, buf_out,
(lzo_uint *)&size_out, wrkmem) == LZO_E_OK) &&
- (size_out < s->page_size)) {
+ (size_out < TARGET_PAGE_SIZE)) {
pd.flags = cpu_convert_to_target32(DUMP_DH_COMPRESSED_LZO,
endian);
pd.size = cpu_convert_to_target32(size_out, endian);
@@ -1376,9 +1376,9 @@ static int write_dump_pages(DumpState *s)
#endif
#ifdef CONFIG_SNAPPY
} else if ((s->flag_compress & DUMP_DH_COMPRESSED_SNAPPY) &&
- (snappy_compress((char *)buf, s->page_size,
+ (snappy_compress((char *)buf, TARGET_PAGE_SIZE,
(char *)buf_out, &size_out) == SNAPPY_OK) &&
- (size_out < s->page_size)) {
+ (size_out < TARGET_PAGE_SIZE)) {
pd.flags = cpu_convert_to_target32(
DUMP_DH_COMPRESSED_SNAPPY, endian);
pd.size = cpu_convert_to_target32(size_out, endian);
@@ -1392,13 +1392,13 @@ static int write_dump_pages(DumpState *s)
} else {
/*
* fall back to save in plaintext, size_out should be
- * assigned to s->page_size
+ * assigned TARGET_PAGE_SIZE
*/
pd.flags = cpu_convert_to_target32(0, endian);
- size_out = s->page_size;
+ size_out = TARGET_PAGE_SIZE;
pd.size = cpu_convert_to_target32(size_out, endian);
- ret = write_cache(&page_data, buf, s->page_size, false);
+ ret = write_cache(&page_data, buf, TARGET_PAGE_SIZE, false);
if (ret < 0) {
dump_error(s, "dump: failed to write page data.\n");
goto out;
@@ -1610,13 +1610,12 @@ static int dump_init(DumpState *s, int fd, bool has_format,
}
s->nr_cpus = nr_cpus;
- s->page_size = TARGET_PAGE_SIZE;
get_max_mapnr(s);
uint64_t tmp;
- tmp = DIV_ROUND_UP(DIV_ROUND_UP(s->max_mapnr, CHAR_BIT), s->page_size);
- s->len_dump_bitmap = tmp * s->page_size;
+ tmp = DIV_ROUND_UP(DIV_ROUND_UP(s->max_mapnr, CHAR_BIT), TARGET_PAGE_SIZE);
+ s->len_dump_bitmap = tmp * TARGET_PAGE_SIZE;
/* init for kdump-compressed format */
if (has_format && format != DUMP_GUEST_MEMORY_FORMAT_ELF) {