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