The intention is to switch off physical-to-machine address translation
temporarily. Overriding readmem works, but only for a single file
format. Using the flag is a better solution, because it does not
add a dependency on a single file format.

Unsetting the flag (rather than restoring it) is safe, because these
functions are not called if XEN_MACHINE_ADDR is set in pc->curcmd_flags.

Signed-off-by: Petr Tesarik <[email protected]>
---
 ia64.c     | 22 ++++++++++------------
 x86.c      | 15 +++++++--------
 x86_64.c   | 15 +++++++--------
 xen_dom0.c | 12 ++++++++++--
 4 files changed, 34 insertions(+), 30 deletions(-)

diff --git a/ia64.c b/ia64.c
index 60fcf20..2e1d15f 100644
--- a/ia64.c
+++ b/ia64.c
@@ -3983,13 +3983,12 @@ static int
 ia64_xen_kdump_p2m_create(struct xen_kdump_data *xkd)
 {
        /*
-        *  Temporarily read physical (machine) addresses from vmcore by
-        *  going directly to read_netdump() instead of via read_kdump().
+        *  Temporarily read physical (machine) addresses from vmcore.
         */
-       pc->readmem = read_netdump;
+       pc->curcmd_flags |= XEN_MACHINE_ADDR;
 
        if (CRASHDEBUG(1)) {
-               fprintf(fp, "readmem (temporary): read_netdump()\n");
+               fprintf(fp, "readmem (temporary): force XEN_MACHINE_ADDR\n");
                fprintf(fp, "ia64_xen_kdump_p2m_create: p2m_mfn: %lx\n", 
xkd->p2m_mfn);
        }
 
@@ -4002,9 +4001,9 @@ ia64_xen_kdump_p2m_create(struct xen_kdump_data *xkd)
 
        xkd->p2m_frames = PAGESIZE()/sizeof(ulong);
 
-       pc->readmem = read_kdump;
+       pc->curcmd_flags &= ~XEN_MACHINE_ADDR;
        if (CRASHDEBUG(1))
-               fprintf(fp, "readmem (restore): read_kdump()\n");
+               fprintf(fp, "readmem (restore): p2m translation\n");
 
        return TRUE;
 }
@@ -4017,12 +4016,11 @@ ia64_xen_kdump_p2m(struct xen_kdump_data *xkd, 
physaddr_t pseudo)
        physaddr_t paddr;
 
        /*
-        *  Temporarily read physical (machine) addresses from vmcore by
-        *  going directly to read_netdump() instead of via read_kdump().
+        *  Temporarily read physical (machine) addresses from vmcore.
         */
-       pc->readmem = read_netdump;
+       pc->curcmd_flags |= XEN_MACHINE_ADDR;
        if (CRASHDEBUG(1))
-               fprintf(fp, "readmem (temporary): read_netdump()\n");
+               fprintf(fp, "readmem (temporary): force XEN_MACHINE_ADDR\n");
 
        xkd->accesses += 2;
 
@@ -4074,9 +4072,9 @@ ia64_xen_kdump_p2m(struct xen_kdump_data *xkd, physaddr_t 
pseudo)
        paddr = (paddr & _PFN_MASK) | PAGEOFFSET(pseudo);
 
 out:
-       pc->readmem = read_kdump;
+       pc->curcmd_flags &= ~XEN_MACHINE_ADDR;
        if (CRASHDEBUG(1))
-               fprintf(fp, "readmem (restore): read_kdump()\n");
+               fprintf(fp, "readmem (restore): p2m translation\n");
 
        return paddr;
 }
diff --git a/x86.c b/x86.c
index f5a0275..54ce7a5 100644
--- a/x86.c
+++ b/x86.c
@@ -4541,12 +4541,11 @@ x86_xen_kdump_p2m_create(struct xen_kdump_data *xkd)
        int mfns[MAX_X86_FRAMES] = { 0 };
 
        /*
-        *  Temporarily read physical (machine) addresses from vmcore by
-        *  going directly to read_netdump() instead of via read_kdump().
+        *  Temporarily read physical (machine) addresses from vmcore.
         */ 
-       pc->readmem = read_netdump;
+       pc->curcmd_flags |= XEN_MACHINE_ADDR;
        if (CRASHDEBUG(1)) 
-               fprintf(fp, "readmem (temporary): read_netdump()\n");
+               fprintf(fp, "readmem (temporary): force XEN_MACHINE_ADDR\n");
 
        if (xkd->flags & KDUMP_CR3)
                goto use_cr3;
@@ -4623,9 +4622,9 @@ x86_xen_kdump_p2m_create(struct xen_kdump_data *xkd)
                 fprintf(fp, "\n");
         }
 
-       pc->readmem = read_kdump;
+       pc->curcmd_flags &= ~XEN_MACHINE_ADDR;
        if (CRASHDEBUG(1)) 
-               fprintf(fp, "readmem (restore): read_kdump()\n");
+               fprintf(fp, "readmem (restore): p2m translation\n");
 
        return TRUE;
 
@@ -4714,9 +4713,9 @@ use_cr3:
         machdep->last_ptbl_read = 0;
         machdep->last_pmd_read = 0;
         machdep->last_pgd_read = 0;
-       pc->readmem = read_kdump;
+       pc->curcmd_flags &= ~XEN_MACHINE_ADDR;
        if (CRASHDEBUG(1)) 
-               fprintf(fp, "readmem (restore): read_kdump()\n");
+               fprintf(fp, "readmem (restore): p2m translation\n");
 
        return TRUE;
 }
diff --git a/x86_64.c b/x86_64.c
index 975354d..ff6fdd5 100644
--- a/x86_64.c
+++ b/x86_64.c
@@ -5748,12 +5748,11 @@ x86_64_xen_kdump_p2m_create(struct xen_kdump_data *xkd)
        struct syment *sp;
 
         /*
-         *  Temporarily read physical (machine) addresses from vmcore by
-         *  going directly to read_netdump() instead of via read_kdump().
+         *  Temporarily read physical (machine) addresses from vmcore.
          */
-        pc->readmem = read_netdump;
+       pc->curcmd_flags |= XEN_MACHINE_ADDR;
        if (CRASHDEBUG(1))
-               fprintf(fp, "readmem (temporary): read_netdump()\n");
+               fprintf(fp, "readmem (temporary): force XEN_MACHINE_ADDR\n");
 
         if (xkd->flags & KDUMP_CR3)
                 goto use_cr3;
@@ -5813,9 +5812,9 @@ x86_64_xen_kdump_p2m_create(struct xen_kdump_data *xkd)
                fprintf(fp, "\n");
        }
 
-        pc->readmem = read_kdump;
+       pc->curcmd_flags &= ~XEN_MACHINE_ADDR;
        if (CRASHDEBUG(1))
-               fprintf(fp, "readmem (restore): read_kdump()\n");
+               fprintf(fp, "readmem (restore): p2m translation\n");
 
        return TRUE;
 
@@ -5882,9 +5881,9 @@ use_cr3:
        machdep->last_pgd_read = 0;
         machdep->last_ptbl_read = 0;
         machdep->last_pmd_read = 0;
-        pc->readmem = read_kdump;
+       pc->curcmd_flags &= ~XEN_MACHINE_ADDR;
        if (CRASHDEBUG(1))
-               fprintf(fp, "readmem (restore): read_kdump()\n");
+               fprintf(fp, "readmem (restore): p2m translation\n");
 
         return TRUE;
 }
diff --git a/xen_dom0.c b/xen_dom0.c
index 826a90b..7c9c76e 100644
--- a/xen_dom0.c
+++ b/xen_dom0.c
@@ -206,12 +206,20 @@ xen_kdump_p2m(physaddr_t pseudo)
        if (mfn_frame == xkd->last_mfn_read)
                xkd->cache_hits++;
        else {
+               int res;
+
                if (CRASHDEBUG(8))
                        fprintf(fp, "xen_kdump_p2m: paddr/pfn: %llx/%lx: "
                            "read mfn_frame: %llx\n",
                                (ulonglong)pseudo, pfn, PTOB(mfn_frame));
-               if (read_netdump(0, xkd->page, PAGESIZE(), 0,
-                   (physaddr_t)PTOB(mfn_frame)) != PAGESIZE())
+
+               pc->curcmd_flags |= XEN_MACHINE_ADDR;
+               res = readmem((physaddr_t)PTOB(mfn_frame), PHYSADDR,
+                             xkd->page, PAGESIZE(),
+                             "xen_kdump_p2m mfn frame", RETURN_ON_ERROR);
+               pc->curcmd_flags &= ~XEN_MACHINE_ADDR;
+
+               if (!res)
                        return P2M_FAILURE;
        }
 
-- 
2.1.4

--
Crash-utility mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/crash-utility

Reply via email to