cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-dump-eliminate-DumpState.page_shift-guest-s-page-shi.patch

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