|
|
9ae3a8 |
From 8bc06ed35e121131f16d08b9c2ecaa0b122d7ad3 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Date: Fri, 7 Nov 2014 17:18:09 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 22/41] dump: eliminate DumpState.page_shift ("guest's page
|
|
|
9ae3a8 |
shift")
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Message-id: <1415380693-16593-23-git-send-email-lersek@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 62210
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.1 qemu-kvm PATCH 22/26] dump: eliminate DumpState.page_shift ("guest's page shift")
|
|
|
9ae3a8 |
Bugzilla: 1157798
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: dgibson <dgibson@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Just use TARGET_PAGE_BITS.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
"DumpState.page_shift" used to have type "uint32_t", while the replacement
|
|
|
9ae3a8 |
TARGET_PAGE_BITS has type "int". Since "DumpState.page_shift" was only
|
|
|
9ae3a8 |
used as bit shift counts in the paddr_to_pfn() and pfn_to_paddr() macros,
|
|
|
9ae3a8 |
this is safe.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 22227f121bddb038a0335cf83a3c24f451e2e836)
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
dump.c | 10 ++++------
|
|
|
9ae3a8 |
include/sysemu/dump.h | 8 ++++----
|
|
|
9ae3a8 |
2 files changed, 8 insertions(+), 10 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/dump.c b/dump.c
|
|
|
9ae3a8 |
index ee28777..bc82b55 100644
|
|
|
9ae3a8 |
--- a/dump.c
|
|
|
9ae3a8 |
+++ b/dump.c
|
|
|
9ae3a8 |
@@ -91,7 +91,6 @@ typedef struct DumpState {
|
|
|
9ae3a8 |
size_t note_buf_offset; /* the writing place in note_buf */
|
|
|
9ae3a8 |
uint32_t nr_cpus; /* number of guest's cpu */
|
|
|
9ae3a8 |
size_t page_size; /* guest's page size */
|
|
|
9ae3a8 |
- uint32_t page_shift; /* guest's page shift */
|
|
|
9ae3a8 |
uint64_t max_mapnr; /* the biggest guest's phys-mem's number */
|
|
|
9ae3a8 |
size_t len_dump_bitmap; /* the size of the place used to store
|
|
|
9ae3a8 |
dump_bitmap in vmcore */
|
|
|
9ae3a8 |
@@ -1092,7 +1091,7 @@ static bool get_next_page(GuestPhysBlock **blockptr, uint64_t *pfnptr,
|
|
|
9ae3a8 |
*blockptr = block;
|
|
|
9ae3a8 |
assert(block->target_start % s->page_size == 0);
|
|
|
9ae3a8 |
assert(block->target_end % s->page_size == 0);
|
|
|
9ae3a8 |
- *pfnptr = paddr_to_pfn(block->target_start, s->page_shift);
|
|
|
9ae3a8 |
+ *pfnptr = paddr_to_pfn(block->target_start);
|
|
|
9ae3a8 |
if (bufptr) {
|
|
|
9ae3a8 |
*bufptr = block->host_addr;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
@@ -1100,7 +1099,7 @@ static bool get_next_page(GuestPhysBlock **blockptr, uint64_t *pfnptr,
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
*pfnptr = *pfnptr + 1;
|
|
|
9ae3a8 |
- addr = pfn_to_paddr(*pfnptr, s->page_shift);
|
|
|
9ae3a8 |
+ addr = pfn_to_paddr(*pfnptr);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if ((addr >= block->target_start) &&
|
|
|
9ae3a8 |
(addr + s->page_size <= block->target_end)) {
|
|
|
9ae3a8 |
@@ -1114,7 +1113,7 @@ static bool get_next_page(GuestPhysBlock **blockptr, uint64_t *pfnptr,
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
assert(block->target_start % s->page_size == 0);
|
|
|
9ae3a8 |
assert(block->target_end % s->page_size == 0);
|
|
|
9ae3a8 |
- *pfnptr = paddr_to_pfn(block->target_start, s->page_shift);
|
|
|
9ae3a8 |
+ *pfnptr = paddr_to_pfn(block->target_start);
|
|
|
9ae3a8 |
buf = block->host_addr;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -1540,7 +1539,7 @@ static void get_max_mapnr(DumpState *s)
|
|
|
9ae3a8 |
GuestPhysBlock *last_block;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
last_block = QTAILQ_LAST(&s->guest_phys_blocks.head, GuestPhysBlockHead);
|
|
|
9ae3a8 |
- s->max_mapnr = paddr_to_pfn(last_block->target_end, s->page_shift);
|
|
|
9ae3a8 |
+ s->max_mapnr = paddr_to_pfn(last_block->target_end);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static int dump_init(DumpState *s, int fd, bool has_format,
|
|
|
9ae3a8 |
@@ -1618,7 +1617,6 @@ static int dump_init(DumpState *s, int fd, bool has_format,
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
s->nr_cpus = nr_cpus;
|
|
|
9ae3a8 |
s->page_size = TARGET_PAGE_SIZE;
|
|
|
9ae3a8 |
- s->page_shift = ffs(s->page_size) - 1;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
get_max_mapnr(s);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h
|
|
|
9ae3a8 |
index efab7a3..12af557 100644
|
|
|
9ae3a8 |
--- a/include/sysemu/dump.h
|
|
|
9ae3a8 |
+++ b/include/sysemu/dump.h
|
|
|
9ae3a8 |
@@ -22,10 +22,10 @@
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
#define ARCH_PFN_OFFSET (0)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-#define paddr_to_pfn(X, page_shift) \
|
|
|
9ae3a8 |
- (((unsigned long long)(X) >> (page_shift)) - ARCH_PFN_OFFSET)
|
|
|
9ae3a8 |
-#define pfn_to_paddr(X, page_shift) \
|
|
|
9ae3a8 |
- (((unsigned long long)(X) + ARCH_PFN_OFFSET) << (page_shift))
|
|
|
9ae3a8 |
+#define paddr_to_pfn(X) \
|
|
|
9ae3a8 |
+ (((unsigned long long)(X) >> TARGET_PAGE_BITS) - ARCH_PFN_OFFSET)
|
|
|
9ae3a8 |
+#define pfn_to_paddr(X) \
|
|
|
9ae3a8 |
+ (((unsigned long long)(X) + ARCH_PFN_OFFSET) << TARGET_PAGE_BITS)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/*
|
|
|
9ae3a8 |
* flag for compressed format
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|