|
|
5d360b |
From 4e6b46284cde10374bd0660e89958fe9c2477887 Mon Sep 17 00:00:00 2001
|
|
|
5d360b |
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
|
|
|
5d360b |
Date: Wed, 13 Dec 2017 13:38:52 +0100
|
|
|
5d360b |
Subject: [PATCH 21/41] dump: allow target to set the page size
|
|
|
5d360b |
MIME-Version: 1.0
|
|
|
5d360b |
Content-Type: text/plain; charset=UTF-8
|
|
|
5d360b |
Content-Transfer-Encoding: 8bit
|
|
|
5d360b |
|
|
|
5d360b |
RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
5d360b |
Message-id: <20171213133912.26176-22-marcandre.lureau@redhat.com>
|
|
|
5d360b |
Patchwork-id: 78370
|
|
|
5d360b |
O-Subject: [RHEL-7.5 qemu-kvm PATCH v3 21/41] dump: allow target to set the page size
|
|
|
5d360b |
Bugzilla: 1411490
|
|
|
5d360b |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
5d360b |
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
5d360b |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
5d360b |
|
|
|
5d360b |
From: Andrew Jones <drjones@redhat.com>
|
|
|
5d360b |
|
|
|
5d360b |
This is necessary for targets that don't have TARGET_PAGE_SIZE ==
|
|
|
5d360b |
real-target-page-size. The target should set the page size to the
|
|
|
5d360b |
correct one, if known, or, if not known, to the maximum page size
|
|
|
5d360b |
it supports.
|
|
|
5d360b |
|
|
|
5d360b |
(No functional change.)
|
|
|
5d360b |
|
|
|
5d360b |
Signed-off-by: Andrew Jones <drjones@redhat.com>
|
|
|
5d360b |
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
|
|
5d360b |
Message-id: 1452542185-10914-4-git-send-email-drjones@redhat.com
|
|
|
5d360b |
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
|
|
5d360b |
|
|
|
5d360b |
(cherry picked from commit 8161befdd15ddc5a8bb9e807ff1ac5907c594688)
|
|
|
5d360b |
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
5d360b |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
5d360b |
|
|
|
5d360b |
dump.c | 127 ++++++++++++++++++++++++++++
|
|
|
5d360b |
include/sysemu/dump-arch.h | 8 +
|
|
|
5d360b |
include/sysemu/dump.h | 10 +
|
|
|
5d360b |
3 files changed, 85 insertions(+), 60 deletions(-)
|
|
|
5d360b |
|
|
|
5d360b |
diff
|
|
|
5d360b |
index 83b6d20..b5d6608 100644
|
|
|
5d360b |
|
|
|
5d360b |
+++ b/dump.c
|
|
|
5d360b |
@@ -352,18 +352,18 @@ static void write_memory(DumpState *s, GuestPhysBlock *block, ram_addr_t start,
|
|
|
5d360b |
int64_t i;
|
|
|
5d360b |
Error *local_err = NULL;
|
|
|
5d360b |
|
|
|
5d360b |
- for (i = 0; i < size / TARGET_PAGE_SIZE; i++) {
|
|
|
5d360b |
- write_data(s, block->host_addr + start + i * TARGET_PAGE_SIZE,
|
|
|
5d360b |
- TARGET_PAGE_SIZE, &local_err);
|
|
|
5d360b |
+ for (i = 0; i < size / s->dump_info.page_size; i++) {
|
|
|
5d360b |
+ write_data(s, block->host_addr + start + i * s->dump_info.page_size,
|
|
|
5d360b |
+ s->dump_info.page_size, &local_err);
|
|
|
5d360b |
if (local_err) {
|
|
|
5d360b |
error_propagate(errp, local_err);
|
|
|
5d360b |
return;
|
|
|
5d360b |
}
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
- if ((size % TARGET_PAGE_SIZE) != 0) {
|
|
|
5d360b |
- write_data(s, block->host_addr + start + i * TARGET_PAGE_SIZE,
|
|
|
5d360b |
- size % TARGET_PAGE_SIZE, &local_err);
|
|
|
5d360b |
+ if ((size % s->dump_info.page_size) != 0) {
|
|
|
5d360b |
+ write_data(s, block->host_addr + start + i * s->dump_info.page_size,
|
|
|
5d360b |
+ size % s->dump_info.page_size, &local_err);
|
|
|
5d360b |
if (local_err) {
|
|
|
5d360b |
error_propagate(errp, local_err);
|
|
|
5d360b |
return;
|
|
|
5d360b |
@@ -742,7 +742,7 @@ static void create_header32(DumpState *s, Error **errp)
|
|
|
5d360b |
|
|
|
5d360b |
strncpy(dh->signature, KDUMP_SIGNATURE, strlen(KDUMP_SIGNATURE));
|
|
|
5d360b |
dh->header_version = cpu_to_dump32(s, 6);
|
|
|
5d360b |
- block_size = TARGET_PAGE_SIZE;
|
|
|
5d360b |
+ block_size = s->dump_info.page_size;
|
|
|
5d360b |
dh->block_size = cpu_to_dump32(s, block_size);
|
|
|
5d360b |
sub_hdr_size = sizeof(struct KdumpSubHeader32) + s->note_size;
|
|
|
5d360b |
sub_hdr_size = DIV_ROUND_UP(sub_hdr_size, block_size);
|
|
|
5d360b |
@@ -842,7 +842,7 @@ static void create_header64(DumpState *s, Error **errp)
|
|
|
5d360b |
|
|
|
5d360b |
strncpy(dh->signature, KDUMP_SIGNATURE, strlen(KDUMP_SIGNATURE));
|
|
|
5d360b |
dh->header_version = cpu_to_dump32(s, 6);
|
|
|
5d360b |
- block_size = TARGET_PAGE_SIZE;
|
|
|
5d360b |
+ block_size = s->dump_info.page_size;
|
|
|
5d360b |
dh->block_size = cpu_to_dump32(s, block_size);
|
|
|
5d360b |
sub_hdr_size = sizeof(struct KdumpSubHeader64) + s->note_size;
|
|
|
5d360b |
sub_hdr_size = DIV_ROUND_UP(sub_hdr_size, block_size);
|
|
|
5d360b |
@@ -938,6 +938,11 @@ static void write_dump_header(DumpState *s, Error **errp)
|
|
|
5d360b |
}
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
+static size_t dump_bitmap_get_bufsize(DumpState *s)
|
|
|
5d360b |
+{
|
|
|
5d360b |
+ return s->dump_info.page_size;
|
|
|
5d360b |
+}
|
|
|
5d360b |
+
|
|
|
5d360b |
/*
|
|
|
5d360b |
* set dump_bitmap sequencely. the bit before last_pfn is not allowed to be
|
|
|
5d360b |
* rewritten, so if need to set the first bit, set last_pfn and pfn to 0.
|
|
|
5d360b |
@@ -951,6 +956,8 @@ static int set_dump_bitmap(uint64_t last_pfn, uint64_t pfn, bool value,
|
|
|
5d360b |
off_t old_offset, new_offset;
|
|
|
5d360b |
off_t offset_bitmap1, offset_bitmap2;
|
|
|
5d360b |
uint32_t byte, bit;
|
|
|
5d360b |
+ size_t bitmap_bufsize = dump_bitmap_get_bufsize(s);
|
|
|
5d360b |
+ size_t bits_per_buf = bitmap_bufsize * CHAR_BIT;
|
|
|
5d360b |
|
|
|
5d360b |
|
|
|
5d360b |
assert(last_pfn <= pfn);
|
|
|
5d360b |
@@ -961,14 +968,14 @@ static int set_dump_bitmap(uint64_t last_pfn, uint64_t pfn, bool value,
|
|
|
5d360b |
* making new_offset be bigger than old_offset can also sync remained data
|
|
|
5d360b |
* into vmcore.
|
|
|
5d360b |
*/
|
|
|
5d360b |
- old_offset = BUFSIZE_BITMAP * (last_pfn / PFN_BUFBITMAP);
|
|
|
5d360b |
- new_offset = BUFSIZE_BITMAP * (pfn / PFN_BUFBITMAP);
|
|
|
5d360b |
+ old_offset = bitmap_bufsize * (last_pfn / bits_per_buf);
|
|
|
5d360b |
+ new_offset = bitmap_bufsize * (pfn / bits_per_buf);
|
|
|
5d360b |
|
|
|
5d360b |
while (old_offset < new_offset) {
|
|
|
5d360b |
|
|
|
5d360b |
offset_bitmap1 = s->offset_dump_bitmap + old_offset;
|
|
|
5d360b |
if (write_buffer(s->fd, offset_bitmap1, buf,
|
|
|
5d360b |
- BUFSIZE_BITMAP) < 0) {
|
|
|
5d360b |
+ bitmap_bufsize) < 0) {
|
|
|
5d360b |
return -1;
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
@@ -976,17 +983,17 @@ static int set_dump_bitmap(uint64_t last_pfn, uint64_t pfn, bool value,
|
|
|
5d360b |
offset_bitmap2 = s->offset_dump_bitmap + s->len_dump_bitmap +
|
|
|
5d360b |
old_offset;
|
|
|
5d360b |
if (write_buffer(s->fd, offset_bitmap2, buf,
|
|
|
5d360b |
- BUFSIZE_BITMAP) < 0) {
|
|
|
5d360b |
+ bitmap_bufsize) < 0) {
|
|
|
5d360b |
return -1;
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
- memset(buf, 0, BUFSIZE_BITMAP);
|
|
|
5d360b |
- old_offset += BUFSIZE_BITMAP;
|
|
|
5d360b |
+ memset(buf, 0, bitmap_bufsize);
|
|
|
5d360b |
+ old_offset += bitmap_bufsize;
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
|
|
|
5d360b |
- byte = (pfn % PFN_BUFBITMAP) / CHAR_BIT;
|
|
|
5d360b |
- bit = (pfn % PFN_BUFBITMAP) % CHAR_BIT;
|
|
|
5d360b |
+ byte = (pfn % bits_per_buf) / CHAR_BIT;
|
|
|
5d360b |
+ bit = (pfn % bits_per_buf) % CHAR_BIT;
|
|
|
5d360b |
if (value) {
|
|
|
5d360b |
buf[byte] |= 1u << bit;
|
|
|
5d360b |
} else {
|
|
|
5d360b |
@@ -996,6 +1003,20 @@ static int set_dump_bitmap(uint64_t last_pfn, uint64_t pfn, bool value,
|
|
|
5d360b |
return 0;
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
+static uint64_t dump_paddr_to_pfn(DumpState *s, uint64_t addr)
|
|
|
5d360b |
+{
|
|
|
5d360b |
+ int target_page_shift = ctz32(s->dump_info.page_size);
|
|
|
5d360b |
+
|
|
|
5d360b |
+ return (addr >> target_page_shift) - ARCH_PFN_OFFSET;
|
|
|
5d360b |
+}
|
|
|
5d360b |
+
|
|
|
5d360b |
+static uint64_t dump_pfn_to_paddr(DumpState *s, uint64_t pfn)
|
|
|
5d360b |
+{
|
|
|
5d360b |
+ int target_page_shift = ctz32(s->dump_info.page_size);
|
|
|
5d360b |
+
|
|
|
5d360b |
+ return (pfn + ARCH_PFN_OFFSET) << target_page_shift;
|
|
|
5d360b |
+}
|
|
|
5d360b |
+
|
|
|
5d360b |
/*
|
|
|
5d360b |
* exam every page and return the page frame number and the address of the page.
|
|
|
5d360b |
* bufptr can be NULL. note: the blocks here is supposed to reflect guest-phys
|
|
|
5d360b |
@@ -1006,16 +1027,16 @@ static bool get_next_page(GuestPhysBlock **blockptr, uint64_t *pfnptr,
|
|
|
5d360b |
uint8_t **bufptr, DumpState *s)
|
|
|
5d360b |
{
|
|
|
5d360b |
GuestPhysBlock *block = *blockptr;
|
|
|
5d360b |
- hwaddr addr;
|
|
|
5d360b |
+ hwaddr addr, target_page_mask = ~((hwaddr)s->dump_info.page_size - 1);
|
|
|
5d360b |
uint8_t *buf;
|
|
|
5d360b |
|
|
|
5d360b |
|
|
|
5d360b |
if (!block) {
|
|
|
5d360b |
block = QTAILQ_FIRST(&s->guest_phys_blocks.head);
|
|
|
5d360b |
*blockptr = block;
|
|
|
5d360b |
- assert((block->target_start & ~TARGET_PAGE_MASK) == 0);
|
|
|
5d360b |
- assert((block->target_end & ~TARGET_PAGE_MASK) == 0);
|
|
|
5d360b |
- *pfnptr = paddr_to_pfn(block->target_start);
|
|
|
5d360b |
+ assert((block->target_start & ~target_page_mask) == 0);
|
|
|
5d360b |
+ assert((block->target_end & ~target_page_mask) == 0);
|
|
|
5d360b |
+ *pfnptr = dump_paddr_to_pfn(s, block->target_start);
|
|
|
5d360b |
if (bufptr) {
|
|
|
5d360b |
*bufptr = block->host_addr;
|
|
|
5d360b |
}
|
|
|
5d360b |
@@ -1023,10 +1044,10 @@ static bool get_next_page(GuestPhysBlock **blockptr, uint64_t *pfnptr,
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
*pfnptr = *pfnptr + 1;
|
|
|
5d360b |
- addr = pfn_to_paddr(*pfnptr);
|
|
|
5d360b |
+ addr = dump_pfn_to_paddr(s, *pfnptr);
|
|
|
5d360b |
|
|
|
5d360b |
if ((addr >= block->target_start) &&
|
|
|
5d360b |
- (addr + TARGET_PAGE_SIZE <= block->target_end)) {
|
|
|
5d360b |
+ (addr + s->dump_info.page_size <= block->target_end)) {
|
|
|
5d360b |
buf = block->host_addr + (addr - block->target_start);
|
|
|
5d360b |
} else {
|
|
|
5d360b |
|
|
|
5d360b |
@@ -1035,9 +1056,9 @@ static bool get_next_page(GuestPhysBlock **blockptr, uint64_t *pfnptr,
|
|
|
5d360b |
if (!block) {
|
|
|
5d360b |
return false;
|
|
|
5d360b |
}
|
|
|
5d360b |
- assert((block->target_start & ~TARGET_PAGE_MASK) == 0);
|
|
|
5d360b |
- assert((block->target_end & ~TARGET_PAGE_MASK) == 0);
|
|
|
5d360b |
- *pfnptr = paddr_to_pfn(block->target_start);
|
|
|
5d360b |
+ assert((block->target_start & ~target_page_mask) == 0);
|
|
|
5d360b |
+ assert((block->target_end & ~target_page_mask) == 0);
|
|
|
5d360b |
+ *pfnptr = dump_paddr_to_pfn(s, block->target_start);
|
|
|
5d360b |
buf = block->host_addr;
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
@@ -1055,9 +1076,11 @@ static void write_dump_bitmap(DumpState *s, Error **errp)
|
|
|
5d360b |
void *dump_bitmap_buf;
|
|
|
5d360b |
size_t num_dumpable;
|
|
|
5d360b |
GuestPhysBlock *block_iter = NULL;
|
|
|
5d360b |
+ size_t bitmap_bufsize = dump_bitmap_get_bufsize(s);
|
|
|
5d360b |
+ size_t bits_per_buf = bitmap_bufsize * CHAR_BIT;
|
|
|
5d360b |
|
|
|
5d360b |
|
|
|
5d360b |
- dump_bitmap_buf = g_malloc0(BUFSIZE_BITMAP);
|
|
|
5d360b |
+ dump_bitmap_buf = g_malloc0(bitmap_bufsize);
|
|
|
5d360b |
|
|
|
5d360b |
num_dumpable = 0;
|
|
|
5d360b |
last_pfn = 0;
|
|
|
5d360b |
@@ -1079,11 +1102,11 @@ static void write_dump_bitmap(DumpState *s, Error **errp)
|
|
|
5d360b |
|
|
|
5d360b |
/*
|
|
|
5d360b |
* set_dump_bitmap will always leave the recently set bit un-sync. Here we
|
|
|
5d360b |
- * set last_pfn + PFN_BUFBITMAP to 0 and those set but un-sync bit will be
|
|
|
5d360b |
- * synchronized into vmcore.
|
|
|
5d360b |
+ * set the remaining bits from last_pfn to the end of the bitmap buffer to
|
|
|
5d360b |
+ * 0. With those set, the un-sync bit will be synchronized into the vmcore.
|
|
|
5d360b |
*/
|
|
|
5d360b |
if (num_dumpable > 0) {
|
|
|
5d360b |
- ret = set_dump_bitmap(last_pfn, last_pfn + PFN_BUFBITMAP, false,
|
|
|
5d360b |
+ ret = set_dump_bitmap(last_pfn, last_pfn + bits_per_buf, false,
|
|
|
5d360b |
dump_bitmap_buf, s);
|
|
|
5d360b |
if (ret < 0) {
|
|
|
5d360b |
dump_error(s, "dump: failed to sync dump_bitmap", errp);
|
|
|
5d360b |
@@ -1103,8 +1126,8 @@ static void prepare_data_cache(DataCache *data_cache, DumpState *s,
|
|
|
5d360b |
{
|
|
|
5d360b |
data_cache->fd = s->fd;
|
|
|
5d360b |
data_cache->data_size = 0;
|
|
|
5d360b |
- data_cache->buf_size = BUFSIZE_DATA_CACHE;
|
|
|
5d360b |
- data_cache->buf = g_malloc0(BUFSIZE_DATA_CACHE);
|
|
|
5d360b |
+ data_cache->buf_size = 4 * dump_bitmap_get_bufsize(s);
|
|
|
5d360b |
+ data_cache->buf = g_malloc0(data_cache->buf_size);
|
|
|
5d360b |
data_cache->offset = offset;
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
@@ -1198,7 +1221,7 @@ static void write_dump_pages(DumpState *s, Error **errp)
|
|
|
5d360b |
prepare_data_cache(&page_data, s, offset_data);
|
|
|
5d360b |
|
|
|
5d360b |
|
|
|
5d360b |
- len_buf_out = get_len_buf_out(TARGET_PAGE_SIZE, s->flag_compress);
|
|
|
5d360b |
+ len_buf_out = get_len_buf_out(s->dump_info.page_size, s->flag_compress);
|
|
|
5d360b |
assert(len_buf_out != 0);
|
|
|
5d360b |
|
|
|
5d360b |
#ifdef CONFIG_LZO
|
|
|
5d360b |
@@ -1211,19 +1234,19 @@ static void write_dump_pages(DumpState *s, Error **errp)
|
|
|
5d360b |
* init zero page's page_desc and page_data, because every zero page
|
|
|
5d360b |
* uses the same page_data
|
|
|
5d360b |
*/
|
|
|
5d360b |
- pd_zero.size = cpu_to_dump32(s, TARGET_PAGE_SIZE);
|
|
|
5d360b |
+ pd_zero.size = cpu_to_dump32(s, s->dump_info.page_size);
|
|
|
5d360b |
pd_zero.flags = cpu_to_dump32(s, 0);
|
|
|
5d360b |
pd_zero.offset = cpu_to_dump64(s, offset_data);
|
|
|
5d360b |
pd_zero.page_flags = cpu_to_dump64(s, 0);
|
|
|
5d360b |
- buf = g_malloc0(TARGET_PAGE_SIZE);
|
|
|
5d360b |
- ret = write_cache(&page_data, buf, TARGET_PAGE_SIZE, false);
|
|
|
5d360b |
+ buf = g_malloc0(s->dump_info.page_size);
|
|
|
5d360b |
+ ret = write_cache(&page_data, buf, s->dump_info.page_size, false);
|
|
|
5d360b |
g_free(buf);
|
|
|
5d360b |
if (ret < 0) {
|
|
|
5d360b |
dump_error(s, "dump: failed to write page data (zero page)", errp);
|
|
|
5d360b |
goto out;
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
- offset_data += TARGET_PAGE_SIZE;
|
|
|
5d360b |
+ offset_data += s->dump_info.page_size;
|
|
|
5d360b |
|
|
|
5d360b |
/*
|
|
|
5d360b |
* dump memory to vmcore page by page. zero page will all be resided in the
|
|
|
5d360b |
@@ -1231,7 +1254,7 @@ static void write_dump_pages(DumpState *s, Error **errp)
|
|
|
5d360b |
*/
|
|
|
5d360b |
while (get_next_page(&block_iter, &pfn_iter, &buf, s)) {
|
|
|
5d360b |
|
|
|
5d360b |
- if (is_zero_page(buf, TARGET_PAGE_SIZE)) {
|
|
|
5d360b |
+ if (is_zero_page(buf, s->dump_info.page_size)) {
|
|
|
5d360b |
ret = write_cache(&page_desc, &pd_zero, sizeof(PageDescriptor),
|
|
|
5d360b |
false);
|
|
|
5d360b |
if (ret < 0) {
|
|
|
5d360b |
@@ -1253,8 +1276,8 @@ static void write_dump_pages(DumpState *s, Error **errp)
|
|
|
5d360b |
size_out = len_buf_out;
|
|
|
5d360b |
if ((s->flag_compress & DUMP_DH_COMPRESSED_ZLIB) &&
|
|
|
5d360b |
(compress2(buf_out, (uLongf *)&size_out, buf,
|
|
|
5d360b |
- TARGET_PAGE_SIZE, Z_BEST_SPEED) == Z_OK) &&
|
|
|
5d360b |
- (size_out < TARGET_PAGE_SIZE)) {
|
|
|
5d360b |
+ s->dump_info.page_size, Z_BEST_SPEED) == Z_OK) &&
|
|
|
5d360b |
+ (size_out < s->dump_info.page_size)) {
|
|
|
5d360b |
pd.flags = cpu_to_dump32(s, DUMP_DH_COMPRESSED_ZLIB);
|
|
|
5d360b |
pd.size = cpu_to_dump32(s, size_out);
|
|
|
5d360b |
|
|
|
5d360b |
@@ -1265,9 +1288,9 @@ static void write_dump_pages(DumpState *s, Error **errp)
|
|
|
5d360b |
}
|
|
|
5d360b |
#ifdef CONFIG_LZO
|
|
|
5d360b |
} else if ((s->flag_compress & DUMP_DH_COMPRESSED_LZO) &&
|
|
|
5d360b |
- (lzo1x_1_compress(buf, TARGET_PAGE_SIZE, buf_out,
|
|
|
5d360b |
+ (lzo1x_1_compress(buf, s->dump_info.page_size, buf_out,
|
|
|
5d360b |
(lzo_uint *)&size_out, wrkmem) == LZO_E_OK) &&
|
|
|
5d360b |
- (size_out < TARGET_PAGE_SIZE)) {
|
|
|
5d360b |
+ (size_out < s->dump_info.page_size)) {
|
|
|
5d360b |
pd.flags = cpu_to_dump32(s, DUMP_DH_COMPRESSED_LZO);
|
|
|
5d360b |
pd.size = cpu_to_dump32(s, size_out);
|
|
|
5d360b |
|
|
|
5d360b |
@@ -1279,9 +1302,9 @@ static void write_dump_pages(DumpState *s, Error **errp)
|
|
|
5d360b |
#endif
|
|
|
5d360b |
#ifdef CONFIG_SNAPPY
|
|
|
5d360b |
} else if ((s->flag_compress & DUMP_DH_COMPRESSED_SNAPPY) &&
|
|
|
5d360b |
- (snappy_compress((char *)buf, TARGET_PAGE_SIZE,
|
|
|
5d360b |
+ (snappy_compress((char *)buf, s->dump_info.page_size,
|
|
|
5d360b |
(char *)buf_out, &size_out) == SNAPPY_OK) &&
|
|
|
5d360b |
- (size_out < TARGET_PAGE_SIZE)) {
|
|
|
5d360b |
+ (size_out < s->dump_info.page_size)) {
|
|
|
5d360b |
pd.flags = cpu_to_dump32(s, DUMP_DH_COMPRESSED_SNAPPY);
|
|
|
5d360b |
pd.size = cpu_to_dump32(s, size_out);
|
|
|
5d360b |
|
|
|
5d360b |
@@ -1294,13 +1317,14 @@ static void write_dump_pages(DumpState *s, Error **errp)
|
|
|
5d360b |
} else {
|
|
|
5d360b |
/*
|
|
|
5d360b |
* fall back to save in plaintext, size_out should be
|
|
|
5d360b |
- * assigned TARGET_PAGE_SIZE
|
|
|
5d360b |
+ * assigned the target's page size
|
|
|
5d360b |
*/
|
|
|
5d360b |
pd.flags = cpu_to_dump32(s, 0);
|
|
|
5d360b |
- size_out = TARGET_PAGE_SIZE;
|
|
|
5d360b |
+ size_out = s->dump_info.page_size;
|
|
|
5d360b |
pd.size = cpu_to_dump32(s, size_out);
|
|
|
5d360b |
|
|
|
5d360b |
- ret = write_cache(&page_data, buf, TARGET_PAGE_SIZE, false);
|
|
|
5d360b |
+ ret = write_cache(&page_data, buf,
|
|
|
5d360b |
+ s->dump_info.page_size, false);
|
|
|
5d360b |
if (ret < 0) {
|
|
|
5d360b |
dump_error(s, "dump: failed to write page data", errp);
|
|
|
5d360b |
goto out;
|
|
|
5d360b |
@@ -1435,7 +1459,7 @@ static void get_max_mapnr(DumpState *s)
|
|
|
5d360b |
GuestPhysBlock *last_block;
|
|
|
5d360b |
|
|
|
5d360b |
last_block = QTAILQ_LAST(&s->guest_phys_blocks.head, GuestPhysBlockHead);
|
|
|
5d360b |
- s->max_mapnr = paddr_to_pfn(last_block->target_end);
|
|
|
5d360b |
+ s->max_mapnr = dump_paddr_to_pfn(s, last_block->target_end);
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
static void dump_init(DumpState *s, int fd, bool has_format,
|
|
|
5d360b |
@@ -1494,6 +1518,10 @@ static void dump_init(DumpState *s, int fd, bool has_format,
|
|
|
5d360b |
goto cleanup;
|
|
|
5d360b |
}
|
|
|
5d360b |
|
|
|
5d360b |
+ if (!s->dump_info.page_size) {
|
|
|
5d360b |
+ s->dump_info.page_size = TARGET_PAGE_SIZE;
|
|
|
5d360b |
+ }
|
|
|
5d360b |
+
|
|
|
5d360b |
s->note_size = cpu_get_note_size(s->dump_info.d_class,
|
|
|
5d360b |
s->dump_info.d_machine, nr_cpus);
|
|
|
5d360b |
if (s->note_size < 0) {
|
|
|
5d360b |
@@ -1517,8 +1545,9 @@ static void dump_init(DumpState *s, int fd, bool has_format,
|
|
|
5d360b |
get_max_mapnr(s);
|
|
|
5d360b |
|
|
|
5d360b |
uint64_t tmp;
|
|
|
5d360b |
- tmp = DIV_ROUND_UP(DIV_ROUND_UP(s->max_mapnr, CHAR_BIT), TARGET_PAGE_SIZE);
|
|
|
5d360b |
- s->len_dump_bitmap = tmp * TARGET_PAGE_SIZE;
|
|
|
5d360b |
+ tmp = DIV_ROUND_UP(DIV_ROUND_UP(s->max_mapnr, CHAR_BIT),
|
|
|
5d360b |
+ s->dump_info.page_size);
|
|
|
5d360b |
+ s->len_dump_bitmap = tmp * s->dump_info.page_size;
|
|
|
5d360b |
|
|
|
5d360b |
/* init for kdump-compressed format */
|
|
|
5d360b |
if (has_format && format != DUMP_GUEST_MEMORY_FORMAT_ELF) {
|
|
|
5d360b |
diff
|
|
|
5d360b |
index 9c95ced..4335839 100644
|
|
|
5d360b |
|
|
|
5d360b |
+++ b/include/sysemu/dump-arch.h
|
|
|
5d360b |
@@ -15,9 +15,11 @@
|
|
|
5d360b |
#define DUMP_ARCH_H
|
|
|
5d360b |
|
|
|
5d360b |
typedef struct ArchDumpInfo {
|
|
|
5d360b |
- int d_machine;
|
|
|
5d360b |
- int d_endian;
|
|
|
5d360b |
- int d_class;
|
|
|
5d360b |
+ int d_machine;
|
|
|
5d360b |
+ int d_endian;
|
|
|
5d360b |
+ int d_class;
|
|
|
5d360b |
+ uint32_t page_size; /* The target's page size. If it's variable and
|
|
|
5d360b |
+ * unknown, then this should be the maximum. */
|
|
|
5d360b |
} ArchDumpInfo;
|
|
|
5d360b |
|
|
|
5d360b |
struct GuestPhysBlockList;
|
|
|
5d360b |
diff
|
|
|
5d360b |
index 7e4ec5c..16cbd8d 100644
|
|
|
5d360b |
|
|
|
5d360b |
+++ b/include/sysemu/dump.h
|
|
|
5d360b |
@@ -20,12 +20,9 @@
|
|
|
5d360b |
#define VERSION_FLAT_HEADER (1)
|
|
|
5d360b |
#define END_FLAG_FLAT_HEADER (-1)
|
|
|
5d360b |
|
|
|
5d360b |
+#ifndef ARCH_PFN_OFFSET
|
|
|
5d360b |
#define ARCH_PFN_OFFSET (0)
|
|
|
5d360b |
-
|
|
|
5d360b |
-#define paddr_to_pfn(X) \
|
|
|
5d360b |
- (((unsigned long long)(X) >> TARGET_PAGE_BITS) - ARCH_PFN_OFFSET)
|
|
|
5d360b |
-#define pfn_to_paddr(X) \
|
|
|
5d360b |
- (((unsigned long long)(X) + ARCH_PFN_OFFSET) << TARGET_PAGE_BITS)
|
|
|
5d360b |
+#endif
|
|
|
5d360b |
|
|
|
5d360b |
/*
|
|
|
5d360b |
* flag for compressed format
|
|
|
5d360b |
@@ -39,9 +36,6 @@
|
|
|
5d360b |
#define PHYS_BASE (0)
|
|
|
5d360b |
#define DUMP_LEVEL (1)
|
|
|
5d360b |
#define DISKDUMP_HEADER_BLOCKS (1)
|
|
|
5d360b |
-#define BUFSIZE_BITMAP (TARGET_PAGE_SIZE)
|
|
|
5d360b |
-#define PFN_BUFBITMAP (CHAR_BIT * BUFSIZE_BITMAP)
|
|
|
5d360b |
-#define BUFSIZE_DATA_CACHE (TARGET_PAGE_SIZE * 4)
|
|
|
5d360b |
|
|
|
5d360b |
#include "sysemu/dump-arch.h"
|
|
|
5d360b |
#include "sysemu/memory_mapping.h"
|
|
|
5d360b |
--
|
|
|
5d360b |
1.8.3.1
|
|
|
5d360b |
|