Re: [Crash-utility] Kernel Crash Analysis on Android
by Shankar, AmarX
Hi Dave,
Thanks for your info regarding kexec tool.
I am unable to download kexec from below link.
http://www.kernel.org/pub/linux/kernel/people/horms/kexec-tools/kexec-too...
It says HTTP 404 Page Not Found.
Could you please guide me on this?
Thanks & Regards,
Amar Shankar
> On Wed, Mar 21, 2012 at 06:00:00PM +0000, Shankar, AmarX wrote:
>
> > I want to do kernel crash Analysis on Android Merrifield Target.
> >
> > Could someone please help me how to do it?
>
> Merrifield is pretty much similar than Medfield, e.g it has x86 core. So I
> guess you can follow the instructions how to setup kdump on x86 (see
> Documentation/kdump/kdump.txt) unless you already have that configured.
>
> crash should support this directly presuming you have vmlinux/vmcore files to
> feed it. You can configure crash to support x86 on x86_64 host by running:
>
> % make target=X86
> & make
>
> (or something along those lines).
Right -- just the first make command will suffice, i.e., when running
on an x86_64 host:
$ wget http://people.redhat.com/anderson/crash-6.0.4.tar.gz
$ tar xzf crash-6.0.4.tar.gz
...
$ cd crash-6.0.4
$ make target=X86
...
$ ./crash <path-to>/vmlinux <path-to>/vmcore
Dave
From: Shankar, AmarX
Sent: Wednesday, March 21, 2012 11:30 PM
To: 'crash-utility(a)redhat.com'
Subject: Kernel Crash Analysis on Android
Hi,
I want to do kernel crash Analysis on Android Merrifield Target.
Could someone please help me how to do it?
Thanks & Regards,
Amar Shankar
1 year
[PATCH] kmem, snap: iomem/ioport display and vmcore snapshot support
by HATAYAMA Daisuke
Some days ago I was in a situation that I had to convert vmcore in
kvmdump format into ELF since some extension module we have locally
can be used only on relatively old crash utility, around version 4,
but such old crash utility cannot handle kvmdump format.
To do the conversion in handy, I used snap command with some modifications
so that it tries to use iomem information in vmcore instead of host's
/proc/iomem. This patch is its cleaned-up version.
In this development, I naturally got down to also making an interface
for an access to resource objects, and so together with the snap
command's patch, I also extended kmem command for iomem/ioport
support. Actually:
kmem -r displays /proc/iomem
crash> kmem -r
00000000-0000ffff : reserved
00010000-0009dbff : System RAM
0009dc00-0009ffff : reserved
000c0000-000c7fff : Video ROM
...
and kmem -R displays /proc/ioport
crash> kmem -R
0000-001f : dma1
0020-0021 : pic1
0040-0043 : timer0
0050-0053 : timer1
...
Looking into old version of kernel source code back, resource structure
has been unchanged since linux-2.4.0. I borrowed the way of walking on
resouce tree in this patch from the lastest v3.3-rc series, but I
guess the logic is also applicable to old kernels. I expect Dave's
regression testsuite.
Also, there would be another command more sutable for iomem/ioport.
If necessay, I'll repost the patch.
---
HATAYAMA Daisuke (4):
Add vmcore snapshot support
Add kmem -r and -R options
Add dump iomem/ioport functions; a helper for resource objects
Add a helper function for iterating resource objects
defs.h | 9 ++++
extensions/snap.c | 54 ++++++++++++++++++++++-
help.c | 2 +
memory.c | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++--
4 files changed, 180 insertions(+), 7 deletions(-)
--
Thanks.
HATAYAMA Daisuke
1 year
Re: [Crash-utility] question about phys_base
by Dave Anderson
----- Original Message -----
> >
> > OK, so then I don't understand what you mean by "may be the same"?
> >
> > You didn't answer my original question, but if I understand you correctly,
> > it would be impossible for the qemu host to create a PT_LOAD segment that
> > describes an x86_64 guest's __START_KERNEL_map region, because the host
> > doesn't know that what kind of kernel the guest is running.
>
> Yes. Even if the guest is linux, it is still impossible to do it. Because
> the guest maybe in the second kernel.
>
> qemu-dump walks all guest's page table and collect virtual address and
> physical address mapping. If the page is not used by guest, the virtual is set
> to 0. I create PT_LOAD according to such mapping. So if the guest is linux,
> there may be a PT_LOAD segment that describes __START_KERNEL_map region.
> But the information stored in PT_LOAD maybe for the second kernel. If crash
> uses it, crash will see the second kernel, not the first kernel.
Just to be clear -- what do you mean by the "second" kernel? Do you
mean that a guest kernel crashed guest, and did a kdump operation,
and that second kdump kernel failed somehow, and now you're trying
to do a "virsh dump" on the kdump kernel?
Dave
1 year
question about phys_base
by Wen Congyang
Hi, Dave
I am implementing a new dump command in the qemu. The vmcore's
format is elf(like kdump). And I try to provide phys_base in
the PT_LOAD. But if the os uses the first vcpu do kdump, the
value of phys_base is wrong.
I find a function x86_64_virt_phys_base() in crash's code.
Is it OK to call this function first? If the function
successes, we do not calculate phys_base according to PT_LOAD.
Thanks
Wen Congyang
1 year
[PATCH] runq: search current task's runqueue explicitly
by HATAYAMA Daisuke
Currently, runq sub-command doesn't consider CFS runqueue's current
task removed from CFS runqueue. Due to this, the remaining CFS
runqueus that follow the current task's is not displayed. This patch
fixes this by making runq sub-command search current task's runqueue
explicitly.
Note that CFS runqueue exists for each task group, and so does CFS
runqueue's current task, and the above search needs to be done
recursively.
Test
====
On vmcore I made 7 task groups:
root group --- A --- AA --- AAA
+ +- AAB
|
+- AB --- ABA
+- ABB
and then I ran three CPU bound tasks, which is exactly the same as
int main(void) { for (;;) continue; return 0; }
for each task group, including root group; so total 24 tasks. For
readability, I annotated each task name with its belonging group name.
For example, loop.ABA belongs to task group ABA.
Look at CPU0 collumn below. [before] lacks 8 tasks and [after]
successfully shows all tasks on the runqueue, which is identical to
the result of [sched debug] that is expected to ouput correct result.
I'll send this vmcore later.
[before]
crash> runq | cat
CPU 0 RUNQUEUE: ffff88000a215f80
CURRENT: PID: 28263 TASK: ffff880037aaa040 COMMAND: "loop.ABA"
RT PRIO_ARRAY: ffff88000a216098
[no tasks queued]
CFS RB_ROOT: ffff88000a216010
[120] PID: 28262 TASK: ffff880037cc40c0 COMMAND: "loop.ABA"
<cut>
[after]
crash_fix> runq
CPU 0 RUNQUEUE: ffff88000a215f80
CURRENT: PID: 28263 TASK: ffff880037aaa040 COMMAND: "loop.ABA"
RT PRIO_ARRAY: ffff88000a216098
[no tasks queued]
CFS RB_ROOT: ffff88000a216010
[120] PID: 28262 TASK: ffff880037cc40c0 COMMAND: "loop.ABA"
[120] PID: 28271 TASK: ffff8800787a8b40 COMMAND: "loop.ABB"
[120] PID: 28272 TASK: ffff880037afd580 COMMAND: "loop.ABB"
[120] PID: 28245 TASK: ffff8800785e8b00 COMMAND: "loop.AB"
[120] PID: 28246 TASK: ffff880078628ac0 COMMAND: "loop.AB"
[120] PID: 28241 TASK: ffff880078616b40 COMMAND: "loop.AA"
[120] PID: 28239 TASK: ffff8800785774c0 COMMAND: "loop.AA"
[120] PID: 28240 TASK: ffff880078617580 COMMAND: "loop.AA"
[120] PID: 28232 TASK: ffff880079b5d4c0 COMMAND: "loop.A"
<cut>
[sched debug]
crash> runq -d
CPU 0
[120] PID: 28232 TASK: ffff880079b5d4c0 COMMAND: "loop.A"
[120] PID: 28239 TASK: ffff8800785774c0 COMMAND: "loop.AA"
[120] PID: 28240 TASK: ffff880078617580 COMMAND: "loop.AA"
[120] PID: 28241 TASK: ffff880078616b40 COMMAND: "loop.AA"
[120] PID: 28245 TASK: ffff8800785e8b00 COMMAND: "loop.AB"
[120] PID: 28246 TASK: ffff880078628ac0 COMMAND: "loop.AB"
[120] PID: 28262 TASK: ffff880037cc40c0 COMMAND: "loop.ABA"
[120] PID: 28263 TASK: ffff880037aaa040 COMMAND: "loop.ABA"
[120] PID: 28271 TASK: ffff8800787a8b40 COMMAND: "loop.ABB"
[120] PID: 28272 TASK: ffff880037afd580 COMMAND: "loop.ABB"
<cut>
Diff stat
=========
defs.h | 1 +
task.c | 37 +++++++++++++++++--------------------
2 files changed, 18 insertions(+), 20 deletions(-)
Thanks.
HATAYAMA, Daisuke
1 year
[RFC] makedumpfile, crash: LZO compression support
by HATAYAMA Daisuke
Hello,
This is a RFC patch set that adds LZO compression support to
makedumpfile and crash utility. LZO is as good as in size but by far
better in speed than ZLIB, leading to reducing down time during
generation of crash dump and refiltering.
How to build:
1. Get LZO library, which is provided as lzo-devel package on recent
linux distributions, and is also available on author's website:
http://www.oberhumer.com/opensource/lzo/.
2. Apply the patch set to makedumpfile v1.4.0 and crash v6.0.0.
3. Build both using make. But for crash, do the following now:
$ make CFLAGS="-llzo2"
How to use:
I've newly used -l option for lzo compression in this patch. So for
example, do as follows:
$ makedumpfile -l vmcore dumpfile
$ crash vmlinux dumpfile
Request of configure-like feature for crash utility:
I would like configure-like feature on crash utility for users to
select wheather to add LZO feature actually or not in build-time,
that is: ./configure --enable-lzo or ./configure --disable-lzo.
The reason is that support staff often downloads and installs the
latest version of crash utility on machines where lzo library is not
provided.
Looking at the source code, it looks to me that crash does some kind
of configuration processing in a local manner, around configure.c,
and I guess it's difficult to use autoconf tools directly.
Or is there another better way?
Performance Comparison:
Sample Data
Ideally, I must have measured the performance for many enough
vmcores generated from machines that was actually running, but now
I don't have enough sample vmcores, I couldn't do so. So this
comparison doesn't answer question on I/O time improvement. This
is TODO for now.
Instead, I choosed worst and best cases regarding compression
ratio and speed only. Specifically, the former is /dev/urandom and
the latter is /dev/zero.
I get the sample data of 10MB, 100MB and 1GB by doing like this:
$ dd bs=4096 count=$((1024*1024*1024/4096)) if=/dev/urandom of=urandom.1GB
How to measure
Then I performed compression for each block, 4096 bytes, and
measured total compression time and output size. See attached
mycompress.c.
Result
See attached file result.txt.
Discussion
For both kinds of data, lzo's compression was considerably quicker
than zlib's. Compression ratio is about 37% for urandom data, and
about 8.5% for zero data. Actual situation of physical memory
would be in between the two cases, and so I guess average
compression time ratio is between 37% and 8.5%.
Although beyond the topic of this patch set, we can estimate worst
compression time on more data size since compression is performed
block size wise and the compression time increases
linearly. Estimated worst time on 2TB memory is about 15 hours for
lzo and about 40 hours for zlib. In this case, compressed data
size is larger than the original, so they are really not used,
compression time is fully meaningless. I think compression must be
done in parallel, and I'll post such patch later.
Diffstat
* makedumpfile
diskdump_mod.h | 3 +-
makedumpfile.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++------
makedumpfile.h | 12 +++++++
3 files changed, 101 insertions(+), 12 deletions(-)
* crash
defs.h | 1 +
diskdump.c | 20 +++++++++++++++++++-
diskdump.h | 3 ++-
3 files changed, 22 insertions(+), 2 deletions(-)
TODO
* evaluation including I/O time using actual vmcores
Thanks.
HATAYAMA, Daisuke
1 year
Re: [Crash-utility] [RFI] Support Fujitsu's sadump dump format
by tachibana@mxm.nes.nec.co.jp
Hi Hatayama-san,
On 2011/06/29 12:12:18 +0900, HATAYAMA Daisuke <d.hatayama(a)jp.fujitsu.com> wrote:
> From: Dave Anderson <anderson(a)redhat.com>
> Subject: Re: [Crash-utility] [RFI] Support Fujitsu's sadump dump format
> Date: Tue, 28 Jun 2011 08:57:42 -0400 (EDT)
>
> >
> >
> > ----- Original Message -----
> >> Fujitsu has stand-alone dump mechanism based on firmware level
> >> functionality, which we call SADUMP, in short.
> >>
> >> We've maintained utility tools internally but now we're thinking that
> >> the best is crash utility and makedumpfile supports the sadump format
> >> for the viewpoint of both portability and maintainability.
> >>
> >> We'll be of course responsible for its maintainance in a continuous
> >> manner. The sadump dump format is very similar to diskdump format and
> >> so kdump (compressed) format, so we estimate patch set would be a
> >> relatively small size.
> >>
> >> Could you tell me whether crash utility and makedumpfile can support
> >> the sadump format? If OK, we'll start to make patchset.
I think it's not bad to support sadump by makedumpfile. However I have
several questions.
- Do you want to use makedumpfile to make an existing file that sadump has
dumped small?
- It isn't possible to support the same form as kdump-compressed format
now, is it?
- When the information that makedumpfile reads from a note of /proc/vmcore
(or a header of kdump-compressed format) is added by an extension of
makedumpfile, do you need to modify sadump?
Thanks
tachibana
> >
> > Sure, yes, the crash utility can always support another dumpfile format.
> >
>
> Thanks. It helps a lot.
>
> > It's unclear to me how similar SADUMP is to diskdump/compressed-kdump.
> > Does your internal version patch diskdump.c, or do you maintain your
> > own "sadump.c"? I ask because if your patchset is at all intrusive,
> > I'd prefer it be kept in its own file, primarily for maintainability,
> > but also because SADUMP is essentially a black-box to anybody outside
> > Fujitsu.
>
> What I meant when I used ``similar'' is both literally and
> logically. The format consists of diskdump header-like header, two
> kinds of bitmaps used for the same purpose as those in diskump format,
> and memory data. They can be handled in common with the existing data
> structure, diskdump_data, non-intrusively, so I hope they are placed
> in diskdump.c.
>
> On the other hand, there's a code to be placed at such specific
> area. sadump is triggered depending on kdump's progress and so
> register values to be contained in vmcore varies according to the
> progress: If crash_notes has been initialized when sadump is
> triggered, sadump packs the register values in crash_notes; if not
> yet, packs registers gathered by firmware. This is sadump specific
> processing, so I think putting it in specific sadump.c file is a
> natural and reasonable choise.
>
> Anyway, I have not made any patch set for this. I'll post a patch set
> when I complete.
>
> Again, thanks a lot for the positive answer.
>
> Thanks.
> HATAYAMA, Daisuke
>
>
> _______________________________________________
> kexec mailing list
> kexec(a)lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec
1 year
[PATCH] xen: Add support for domU with Linux kernel 3.19 and newer
by Honglei Wang
crash patch c3413456599161cabc4e910a0ae91dfe5eec3c21 (xen: Add support for
dom0 with Linux kernel 3.19 and newer) from Daniel made crash utility
support xen dom0 vmcores after linux kernel commit
054954eb051f35e74b75a566a96fe756015352c8 (xen: switch to linear virtual
mapped sparse p2m list).
This patch can be deemed as a subsequent and make this utility support Xen
PV domU dumpfiles again.
Basically speaking, readmem() can't be used to read xen_p2m_addr associate
memory directly during m2p translation. It introduces infinite recursion.
Following call sequence shows the scenario, it comes from a section of
backtrace with only kvaddr, machine addr and mfn left as parameter:
module_init()
/* The first readmem() from module_init(). */
readmem(addr=0xffffffffa02fe4a0)
/* readmem() needs physical address, so calls kvtop(). */
kvtop(kvaddr=0xffffffffa02fe4a0)
x86_64_kvtop(kvaddr=ffffffffa02fe4a0)
/* Calculate physical address by traversing page tables. */
x86_64_kvtop_xen_wpt(kvaddr=0xffffffffa02fe4a0)
/*
* x86_64_kvtop_xen_wpt() is going to traverse the page table to
* get the physical address for 0xffffffffa02fe4a0. So, at first it
* is needed to translate the pgd from machine address to physical
* address. So invoke xen_m2p() here to do the translation. 0x58687f000
* is the pgd machine address in x86_64_kvtop_xen_wpt() and is needed
* to be translated to its physical address.
*/
xen_m2p(machine=0x58687f000)
__xen_m2p(machine=0x58687f000, mfn=0x58687f)
/*
* __xen_m2p() is going to search mfn 0x58687f in p2m VMA which starts
* at VMA 0xffffc900001cf000. It compares every mfn stored in it with
* 0x58687f. Once it's proved 0x58687f is one mfn in the p2m, its offset
* will be used to calculate the pfn.
*
* readmem() is invoked by __xen_m2p() to read the page from VMA
* 0xffffc900001cf000 here.
*/
readmem(addr=0xffffc900001cf000)
/*
* readmem() needs physical address of 0xffffc900001cf000 to make the
* reading done. So it invokes kvtop() to get the physical address.
*/
kvtop(kvaddr=0xffffc900001cf000)
x86_64_kvtop(kvaddr=0xffffc900001cf000)
/* It needs to calculate physical address by traversing page tables. */
x86_64_kvtop_xen_wpt(kvaddr=0xffffc900001cf000)
/*
* 0x581b7e000 is the machine address of pgd need to be translated here.
* The mfn is calculated in this way at x86_64_kvtop_xen_wpt():
*
* pml4 = ((ulong *)machdep->machspec->pml4) + pml4_index(kvaddr);
* pgd_paddr = (*pml4) & PHYSICAL_PAGE_MASK;
*
* The kvaddr 0xffffc900001cf000 here is quite different from the one
* above, so the machine address of pgd is not the same one. And this
* pgd is the one we use to access the VMA of p2m table.
*/
xen_m2p(machine=0x581b7e000)
__xen_m2p(machine=0x581b7e000, mfn=0x581b7e)
/*
* Looking for mfn 0x581b7e in the range of p2m page which starts at
* VMA 0xffffc900001f5000.
*/
readmem(addr=0xffffc900001f5000)
/* Need physical address of VMA 0xffffc900001f5000 as same reason above. */
kvtop(kvaddr=0xffffc900001f5000)
x86_64_kvtop(kvaddr=0xffffc900001f5000)
/* Need to traverse page tables to calculate physical address for it. */
x86_64_kvtop_xen_wpt(kvaddr=0xffffc900001f5000)
/*
* Unfortunately, machine address 0x581b7e000 have to be translated again.
* Endless loop starts from here.
*/
xen_m2p(machine=0x581b7e000)
__xen_m2p(machine=0x581b7e000, mfn=0x581b7e)
readmem(addr=0xffffc900001f5000)
Fortunately, PV domU p2m mapping is also stored at xd->xfd + xch_index_offset
and organized as struct xen_dumpcore_p2m. We have a chance to read the p2m
stuff directly from there, and then we avoid the loop above.
So, this patch implements a special reading function read_xc_p2m() to extract
the mfns from xd->xfd + xch_index_offset. This function does not need to read
mfns from p2m VMA like readmem() does, so, we avoid the endless loop introduced
by the address translation.
Signed-off-by: Honglei Wang <honglei.wang(a)oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper(a)oracle.com>
---
kernel.c | 151 +++++++++++++++++++++++++++++++++++++++++++++++++++++++------
xendump.c | 2 +-
xendump.h | 2 +
3 files changed, 140 insertions(+), 15 deletions(-)
diff --git a/kernel.c b/kernel.c
index 395736c..7a5ce64 100644
--- a/kernel.c
+++ b/kernel.c
@@ -22,6 +22,7 @@
#include <libgen.h>
#include <ctype.h>
#include <stdbool.h>
+#include "xendump.h"
static void do_module_cmd(ulong, char *, ulong, char *, char *);
static void show_module_taint(void);
@@ -67,6 +68,9 @@ static ulong __xen_m2p(ulonglong, ulong);
static ulong __xen_pvops_m2p_l2(ulonglong, ulong);
static ulong __xen_pvops_m2p_l3(ulonglong, ulong);
static ulong __xen_pvops_m2p_hyper(ulonglong, ulong);
+static ulong __xen_pvops_m2p_domU(ulonglong, ulong);
+static int read_xc_p2m(ulonglong addr, void *buffer, long size);
+static void read_p2m(ulong cache_index, int memtype, void *buffer);
static int search_mapping_page(ulong, ulong *, ulong *, ulong *);
static void read_in_kernel_config_err(int, char *);
static void BUG_bytes_init(void);
@@ -181,10 +185,7 @@ kernel_init()
&kt->pvops_xen.p2m_mid_missing);
get_symbol_data("p2m_missing", sizeof(ulong),
&kt->pvops_xen.p2m_missing);
- } else if (symbol_exists("xen_p2m_addr")) {
- if (!XEN_CORE_DUMPFILE())
- error(FATAL, "p2m array in new format is unreadable.");
- } else {
+ } else if (!symbol_exists("xen_p2m_addr")) {
kt->pvops_xen.p2m_top_entries = get_array_length("p2m_top", NULL, 0);
kt->pvops_xen.p2m_top = symbol_value("p2m_top");
kt->pvops_xen.p2m_missing = symbol_value("p2m_missing");
@@ -9305,13 +9306,7 @@ __xen_m2p(ulonglong machine, ulong mfn)
if (memtype == PHYSADDR)
pc->curcmd_flags |= XEN_MACHINE_ADDR;
- if (!readmem(kt->p2m_mapping_cache[c].mapping, memtype,
- mp, PAGESIZE(), "phys_to_machine_mapping page (cached)",
- RETURN_ON_ERROR))
- error(FATAL, "cannot access "
- "phys_to_machine_mapping page\n");
- else
- kt->last_mapping_read = kt->p2m_mapping_cache[c].mapping;
+ read_p2m(c, memtype, mp);
if (memtype == PHYSADDR)
pc->curcmd_flags &= ~XEN_MACHINE_ADDR;
@@ -9349,9 +9344,12 @@ __xen_m2p(ulonglong machine, ulong mfn)
*/
if (symbol_exists("p2m_mid_missing"))
pfn = __xen_pvops_m2p_l3(machine, mfn);
- else if (symbol_exists("xen_p2m_addr"))
- pfn = __xen_pvops_m2p_hyper(machine, mfn);
- else
+ else if (symbol_exists("xen_p2m_addr")) {
+ if (XEN_CORE_DUMPFILE())
+ pfn = __xen_pvops_m2p_hyper(machine, mfn);
+ else
+ pfn = __xen_pvops_m2p_domU(machine, mfn);
+ } else
pfn = __xen_pvops_m2p_l2(machine, mfn);
if (pfn != XEN_MFN_NOT_FOUND)
@@ -9559,6 +9557,131 @@ __xen_pvops_m2p_hyper(ulonglong machine, ulong mfn)
return XEN_MFN_NOT_FOUND;
}
+static void read_p2m(ulong cache_index, int memtype, void *buffer)
+{
+ /*
+ * Use special read function for PV domain p2m reading.
+ * See the comments of read_xc_p2m().
+ */
+ if (symbol_exists("xen_p2m_addr") && !XEN_CORE_DUMPFILE()) {
+ if (!read_xc_p2m(kt->p2m_mapping_cache[cache_index].mapping,
+ buffer, PAGESIZE()))
+ error(FATAL, "cannot access phys_to_machine_mapping page\n");
+ } else if (!readmem(kt->p2m_mapping_cache[cache_index].mapping, memtype,
+ buffer, PAGESIZE(), "phys_to_machine_mapping page (cached)",
+ RETURN_ON_ERROR))
+ error(FATAL, "cannot access phys_to_machine_mapping page\n");
+
+ kt->last_mapping_read = kt->p2m_mapping_cache[cache_index].mapping;
+}
+
+/*
+ * PV domain p2m mapping info is stored in xd->xfd at xch_index_offset. It
+ * is organized as struct xen_dumpcore_p2m and the pfns are progressively
+ * increased by 1 from 0.
+ *
+ * This is a special p2m reading function for xen PV domain vmcores after
+ * kernel commit 054954eb051f35e74b75a566a96fe756015352c8 (xen: switch
+ * to linear virtual mapped sparse p2m list). It is invoked for reading
+ * p2m associate stuff by read_p2m().
+ */
+static int read_xc_p2m(ulonglong addr, void *buffer, long size)
+{
+ ulong i, new_p2m_buf_size;
+ off_t offset;
+ struct xen_dumpcore_p2m *new_p2m_buf;
+ static struct xen_dumpcore_p2m *p2m_buf;
+ static ulong p2m_buf_size = 0;
+
+ if (size <= 0) {
+ if ((CRASHDEBUG(1) && !STREQ(pc->curcmd, "search")) ||
+ CRASHDEBUG(2))
+ error(INFO, "invalid size request: %ld\n", size);
+ return FALSE;
+ }
+
+ /*
+ * We extract xen_dumpcore_p2m.gmfn and copy them into the
+ * buffer. So, we need temporary p2m_buf whose size is
+ * (size * (sizeof(struct xen_dumpcore_p2m) / sizeof(ulong)))
+ * to put xen_dumpcore_p2m structures read from xd->xfd.
+ */
+ new_p2m_buf_size = size * (sizeof(struct xen_dumpcore_p2m) / sizeof(ulong));
+
+ if (p2m_buf_size != new_p2m_buf_size) {
+ p2m_buf_size = new_p2m_buf_size;
+
+ new_p2m_buf = realloc(p2m_buf, p2m_buf_size);
+ if (new_p2m_buf == NULL) {
+ free(p2m_buf);
+ error(FATAL, "cannot realloc p2m buffer\n");
+ }
+ p2m_buf = new_p2m_buf;
+ }
+
+ offset = addr * (sizeof(struct xen_dumpcore_p2m) / sizeof(ulong));
+ offset += xd->xc_core.header.xch_index_offset;
+
+ if (lseek(xd->xfd, offset, SEEK_SET) == -1)
+ error(FATAL,
+ "cannot lseek to xch_index_offset offset 0x%lx\n", offset);
+ if (read(xd->xfd, (void*)p2m_buf, p2m_buf_size) != p2m_buf_size)
+ error(FATAL,
+ "cannot read from xch_index_offset offset 0x%lx\n", offset);
+
+ for (i = 0; i < size / sizeof(ulong); i++)
+ *((ulong *)buffer + i) = p2m_buf[i].gmfn;
+
+ return TRUE;
+}
+
+static ulong
+__xen_pvops_m2p_domU(ulonglong machine, ulong mfn)
+{
+ ulong c, end, i, mapping, p, pfn, start;
+
+ /*
+ * xch_nr_pages is the number of pages of p2m mapping. It is composed
+ * of struct xen_dumpcore_p2m. The stuff we want to copy into the mapping
+ * page is mfn whose type is unsigned long.
+ * So actual number of p2m pages should be:
+ *
+ * xch_nr_pages / (sizeof(struct xen_dumpcore_p2m) / sizeof(ulong))
+ */
+ for (p = 0;
+ p < xd->xc_core.header.xch_nr_pages /
+ (sizeof(struct xen_dumpcore_p2m) / sizeof(ulong));
+ ++p) {
+
+ mapping = p * PAGESIZE();
+
+ if (mapping != kt->last_mapping_read) {
+ if (!read_xc_p2m(mapping, (void *)kt->m2p_page, PAGESIZE()))
+ error(FATAL, "cannot read the last mapping page\n");
+ kt->last_mapping_read = mapping;
+ }
+ kt->p2m_pages_searched++;
+
+ if (search_mapping_page(mfn, &i, &start, &end)) {
+ pfn = p * XEN_PFNS_PER_PAGE + i;
+ c = kt->p2m_cache_index;
+ if (CRASHDEBUG (1))
+ console("mfn: %lx (%llx) i: %ld pfn: %lx (%llx)\n",
+ mfn, machine, i, pfn, XEN_PFN_TO_PSEUDO(pfn));
+
+ kt->p2m_mapping_cache[c].start = start;
+ kt->p2m_mapping_cache[c].end = end;
+ kt->p2m_mapping_cache[c].mapping = mapping;
+ kt->p2m_mapping_cache[c].pfn = p * XEN_PFNS_PER_PAGE;
+ kt->p2m_cache_index = (c+1) % P2M_MAPPING_CACHE;
+
+ return pfn;
+ }
+ }
+
+ return XEN_MFN_NOT_FOUND;
+}
+
/*
* Search for an mfn in the current mapping page, and if found,
* determine the range of contiguous mfns that it's contained
diff --git a/xendump.c b/xendump.c
index 8170b22..4bd59b5 100644
--- a/xendump.c
+++ b/xendump.c
@@ -19,7 +19,7 @@
#include "xendump.h"
static struct xendump_data xendump_data = { 0 };
-static struct xendump_data *xd = &xendump_data;
+struct xendump_data *xd = &xendump_data;
static int xc_save_verify(char *);
static int xc_core_verify(char *, char *);
diff --git a/xendump.h b/xendump.h
index 08d41b4..b7bae65 100644
--- a/xendump.h
+++ b/xendump.h
@@ -192,3 +192,5 @@ struct xen_dumpcore_p2m {
uint64_t pfn;
uint64_t gmfn;
};
+
+extern struct xendump_data *xd;
--
1.7.1
7 years, 6 months
Fwd: [PATCH] s390x: Fix virtual address check for 5 level page tables
by Zaslonko Mikhail
Hello Dave,
We have recently found that Crash is not capable of processing 5 level
page tables virtual addresses (higher than 8 Petabytes). Please find the
enclosed patch below.
Thanks,
Mikhail Zaslonko
[PATCH] s390x: Fix virtual address check for 5 level page tables
The current validity check for virtual addresses fails for
five level page tables because in that case it uses a 64 bit
left-shift operation which is undefined in the C standard.
Quote from C99 standard:
If the value of the right operand is negative or is
greater than or equal to the width of the promoted left operand,
the behavior is undefined.
To fix this, we just skip the validity check in case of highest
page-level (level = 3) due to redundancy
Signed-off-by: Mikhail Zaslonko <zaslonko(a)linux.vnet.ibm.com>
---
s390x.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/s390x.c b/s390x.c
index e13bd59..96ce3dc 100644
--- a/s390x.c
+++ b/s390x.c
@@ -688,7 +688,7 @@ int s390x_vtop(ulong table, ulong vaddr, physaddr_t *phys_addr, int verbose)
/* Read the first entry to find the number of page table levels. */
readmem(table, KVADDR, &entry, sizeof(entry), "entry", FAULT_ON_ERROR);
level = (entry & 0xcULL) >> 2;
- if ((vaddr >> (31 + 11*level)) != 0ULL) {
+ if ((level < 3) && (vaddr >> (31 + 11*level)) != 0ULL) {
/* Address too big for the number of page table levels. */
return FALSE;
}
--
2.10.2
7 years, 6 months