thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
97168e
From bb55fde4d8ca587e2ef52ce58a0c22e4d66a08dc Mon Sep 17 00:00:00 2001
97168e
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
97168e
Date: Thu, 25 Aug 2022 12:40:12 +0400
97168e
Subject: [PATCH 30/42] dump: simplify a bit kdump get_next_page()
97168e
MIME-Version: 1.0
97168e
Content-Type: text/plain; charset=UTF-8
97168e
Content-Transfer-Encoding: 8bit
97168e
97168e
RH-Author: Cédric Le Goater <clg@redhat.com>
97168e
RH-MergeRequest: 226: s390: Enhanced Interpretation for PCI Functions and Secure Execution guest dump
97168e
RH-Bugzilla: 1664378 2043909
97168e
RH-Acked-by: Thomas Huth <thuth@redhat.com>
97168e
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
97168e
RH-Acked-by: Jon Maloy <jmaloy@redhat.com>
97168e
RH-Commit: [30/41] 417ac19fa96036e0242f40121ac6e87a9f3f70ba
97168e
97168e
This should be functionally equivalent, but slightly easier to read,
97168e
with simplified paths and checks at the end of the function.
97168e
97168e
The following patch is a major rewrite to get rid of the assert().
97168e
97168e
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
97168e
Reviewed-by: David Hildenbrand <david@redhat.com>
97168e
(cherry picked from commit 08df343874fcddd260021a04ce3c5a34f2c48164)
97168e
Signed-off-by: Cédric Le Goater <clg@redhat.com>
97168e
---
97168e
 dump/dump.c | 21 ++++++++-------------
97168e
 1 file changed, 8 insertions(+), 13 deletions(-)
97168e
97168e
diff --git a/dump/dump.c b/dump/dump.c
97168e
index c2c1341ad7..1c49232390 100644
97168e
--- a/dump/dump.c
97168e
+++ b/dump/dump.c
97168e
@@ -1133,17 +1133,11 @@ static bool get_next_page(GuestPhysBlock **blockptr, uint64_t *pfnptr,
97168e
     if (!block) {
97168e
         block = QTAILQ_FIRST(&s->guest_phys_blocks.head);
97168e
         *blockptr = block;
97168e
-        assert((block->target_start & ~target_page_mask) == 0);
97168e
-        assert((block->target_end & ~target_page_mask) == 0);
97168e
-        *pfnptr = dump_paddr_to_pfn(s, block->target_start);
97168e
-        if (bufptr) {
97168e
-            *bufptr = block->host_addr;
97168e
-        }
97168e
-        return true;
97168e
+        addr = block->target_start;
97168e
+    } else {
97168e
+        addr = dump_pfn_to_paddr(s, *pfnptr + 1);
97168e
     }
97168e
-
97168e
-    *pfnptr = *pfnptr + 1;
97168e
-    addr = dump_pfn_to_paddr(s, *pfnptr);
97168e
+    assert(block != NULL);
97168e
 
97168e
     if ((addr >= block->target_start) &&
97168e
         (addr + s->dump_info.page_size <= block->target_end)) {
97168e
@@ -1155,12 +1149,13 @@ static bool get_next_page(GuestPhysBlock **blockptr, uint64_t *pfnptr,
97168e
         if (!block) {
97168e
             return false;
97168e
         }
97168e
-        assert((block->target_start & ~target_page_mask) == 0);
97168e
-        assert((block->target_end & ~target_page_mask) == 0);
97168e
-        *pfnptr = dump_paddr_to_pfn(s, block->target_start);
97168e
+        addr = block->target_start;
97168e
         buf = block->host_addr;
97168e
     }
97168e
 
97168e
+    assert((block->target_start & ~target_page_mask) == 0);
97168e
+    assert((block->target_end & ~target_page_mask) == 0);
97168e
+    *pfnptr = dump_paddr_to_pfn(s, addr);
97168e
     if (bufptr) {
97168e
         *bufptr = buf;
97168e
     }
97168e
-- 
97168e
2.37.3
97168e