<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<tt>Magnus Damm wrote:</tt>
<blockquote TYPE=CITE><tt>Hi Dave,</tt><tt></tt>
<p><tt>Thanks for your comments!</tt><tt></tt>
<p><tt>On Wed, 2006-10-18 at 10:49 -0400, Dave Anderson wrote:</tt>
<br><tt>> Kazuo Moriwaka wrote:</tt>
<br><tt>></tt>
<br><tt>> > Hello,</tt>
<br><tt>> ></tt>
<br><tt>> > From: Dave Anderson <anderson@redhat.com></tt>
<br><tt>> > Subject: Re: [Crash-utility] kdump format may be updated</tt>
<br><tt>> > Date: Tue, 17 Oct 2006 09:01:32 -0400</tt>
<br><tt>> ></tt>
<br><tt>> > > As we discussed before, it would have been preferable in
my</tt>
<br><tt>> > > opinion to have the starting-point mfn value for all the
domains,</tt>
<br><tt>> > > thereby making the dumpfile usable for all domains instead
of</tt>
<br><tt>> > > just dom0.  But I will be happy with at least getting
this change</tt>
<br><tt>> > > in place so that crash can be used directly on the xen dumpfile</tt>
<br><tt>> > > for dom0 analysis without having to run it through some other</tt>
<br><tt>> > > utility.</tt>
<br><tt>> ></tt>
<br><tt>> > Yes, I remember the discussion and I think it is possible to
make headers.</tt>
<br><tt>> > Now, Magnus is cleaning the patch.  He and I discussed,
but I'm not</tt>
<br><tt>> > enough to convince him that dom0 information is need for crash.</tt>
<br><tt>></tt>
<br><tt>> Just to clarify this discussion.  Magnus's patch *does*
include the</tt>
<br><tt>> dom0 cr3 information for x86, and I am quite happy with that. 
With that</tt>
<br><tt>> single, simple, dom0 cr3 value, the crash utility can use the
common</tt>
<br><tt>> xen/dom0 vmcore file unmodified.</tt><tt></tt>
<p><tt>Yes, the patch includes that information today. But say that this
value</tt>
<br><tt>wouldn't be provided as a crash note - isn't it possible for software
to</tt>
<br><tt>locate the value anyhow?</tt>
<br><tt></tt> </blockquote>
<tt>Believe me -- if you could tell me how, I would do it, and</tt>
<br><tt>we could avoid this discussion...</tt>
<blockquote TYPE=CITE><tt></tt> 
<br><tt>Or maybe the CR3 value isn't saved at all? Shouldn't it be saved
instead</tt>
<br><tt>when all the other registers are saved?</tt><tt></tt>
<p><tt>And why do we chose to save CR3 and not CR4? I know what CR3 is
used</tt>
<br><tt>for, but I kind of dislike the ad-hoc approach of how these things
are</tt>
<br><tt>added. Also, maybe more registers are needed under Xen compared
to the</tt>
<br><tt>Linux kernel.</tt><tt></tt>
<p><tt>I'm especially thinking about segment registers and descriptor tables.</tt></blockquote>
<tt>A bit of history -- and I don't mean to "dumb-down" the discussion...</tt><tt></tt>
<p><tt>If you just give me a dump of memory, I can make the crash utility
work</tt>
<br><tt>with it, as long as I can take a physical address and turn it into
a</tt>
<br><tt>file offset into the dumpfile.</tt><tt></tt>
<p><tt>The first set of physical memory reads that crash does take the</tt>
<br><tt>unity-mapped virtual addresses of key kernel data, strip off the</tt>
<br><tt>identifier and pass the physical address to the read function of
the</tt>
<br><tt>particular memory device, i.e., be it the live memory, netdumps,</tt>
<br><tt>diskdumps, LKCD dumps, mcore dumps, kdumps, xen dumps, and xen</tt>
<br><tt>"xm save" files.</tt><tt></tt>
<p><tt>The issue at hand with the xen kdump vmcore is that its ELF header</tt>
<br><tt>describes physical memory in machine memory terms.  To use
that</tt>
<br><tt>vmcore with respect to dom0 instead of the xen binary, for each</tt>
<br><tt>required physical address derived from a dom0 kernel virtual address,</tt>
<br><tt>the physical address is a pseudo-physical address with no correlation</tt>
<br><tt>with the physical (machine) memory descriptors in the ELF header.</tt><tt></tt>
<p><tt>So, given that the dom0 pseudo-physical address needs to be</tt>
<br><tt>translated into a machine address, I need to be able to find
my way</tt>
<br><tt>to the phys_to_machine_mapping array.  From that point on,
it's</tt>
<br><tt>becomes a matter of searching the array for the desired pseudo-physical</tt>
<br><tt>address, getting the associated machine address, and then using</tt>
<br><tt>the PT_LOAD segments of the ELF header to find the memory.</tt><tt></tt>
<p><tt>To find the phys_to_machine_mapping array, there are two keys</tt>
<br><tt>to Pandora's box:</tt><tt></tt>
<p><tt>(1) the dom0 cr3 value -- which in a writable page table kernel,</tt>
<br><tt>    will contain an mfn value.  With that starting
point, a page</tt>
<br><tt>    table walk can be initiated for the "phys_to_machine_mapping"</tt>
<br><tt>    virtual address.</tt><tt></tt>
<p><tt>(2) alternatively, given the dom0 pfn_to_mfn_frame_list_list mfn,</tt>
<br><tt>    I also have a starting point in order to reconstruct
the</tt>
<br><tt>    phys_to_machine_mapping array.</tt><tt></tt>
<p><tt>Either one works.  I preferred #2 because it would presumably
work</tt>
<br><tt>for both writable and shadow page table kernels.  But, I've
never</tt>
<br><tt>done any work with shadow page table kernels (Red Hat is going
with</tt>
<br><tt>writable...), so I don't know what the ramifications are for those</tt>
<br><tt>kernels.</tt><tt></tt>
<p><tt>In fact, my original suggestion was for an ELF note with an array</tt>
<br><tt>of cr3's or pfn_to_mfn_frame_list_list mfn's, i.e., for dom0 and</tt>
<br><tt>all the other domUs running on the system.  That would be
an awesome</tt>
<br><tt>capability -- a single vmcore that could be used against the xen</tt>
<br><tt>binary using gdb, or with the crash utility for analyszing dom0</tt>
<br><tt>or any of the other domU sessions.</tt><tt></tt>
<p><tt>But, there apparently was an issue with the idea of having</tt>
<br><tt>an ELF note with an undetermined size.</tt><tt></tt>
<p><tt>Anyway, like I mentioned to Kazuo, I'd be happy with just the</tt>
<br><tt>dom0 "key"...</tt><tt></tt>
<p><tt>Also, in the ELF NT_PRSTATUS note, the cr3 value is not stored</tt>
<br><tt>since it consists of a processor-specific user_regs_struct.</tt>
<br><tt>So if you were to append it there, I could use that instead.</tt>
<br><tt>Your initial patch seems to have put it both there and</tt>
<br><tt>in the new NT_XEN_DOM0_CR3 note:</tt><tt></tt>
<p><tt>+/* The cr3 for dom0 on each of its vcpus</tt>
<br><tt>+ * It is added as ELF_Prstatus prstatus.pr_reg[ELF_NGREG-1)],
where</tt>
<br><tt>+ * prstatus is the data of the elf note, and ELF_NGREG was extended</tt>
<br><tt>+ * by one to allow extra space.</tt>
<br><tt>+ * This code runs after all cpus except the crashing one have</tt>
<br><tt>+ * been shutdown so as to avoid having to hold domlist_lock,</tt>
<br><tt>+ * as locking after a crash is playing with fire */</tt>
<br><tt></tt> <tt></tt>
<p><tt>+              
buf = append_elf_note(buf, "Xen Domanin-0 CR3",</tt>
<br><tt>+                      
NT_XEN_DOM0_CR3, &cr3, 4);</tt><tt></tt>
<p><tt>But, again, only for x86.</tt>
<br><tt></tt> 
<blockquote TYPE=CITE><tt></tt> <tt></tt>
<p><tt>> What I don't understand is whether the same thing is going to
be done</tt>
<br><tt>> for x86_64?</tt>
<br><tt>></tt>
<br><tt>> NT_XEN_DOM0_CR3 is #define'd in xen/include/xen/elfcore.h in</tt>
<br><tt>> this patch:</tt>
<br><tt>></tt>
<br><tt>>   [Xen-devel] [PATCH 02/04] Kexec / Kdump: Code shared
between x86_32 and x86_64</tt>
<br><tt>></tt>
<br><tt>> NT_XEN_DOM0_CR3 is used by the find_dom0_cr3() function in</tt>
<br><tt>> xen/arch/x86/crash.c, in this patch:</tt>
<br><tt>></tt>
<br><tt>>   [Xen-devel] [PATCH 03/04] Kexec / Kdump: x86_32 specific
code</tt>
<br><tt>></tt>
<br><tt>> But there is no analogous x86_64 usage in this patch:</tt>
<br><tt>></tt>
<br><tt>>   [Xen-devel] [PATCH 04/04] Kexec / Kdump: x86_64 specific
code</tt>
<br><tt>></tt>
<br><tt>> Is NT_XEN_DOM0_CR3 not being used by x86_64 by mistake,</tt>
<br><tt>> or on purpose?  Or perhaps you're saying that it's going
to be</tt>
<br><tt>> pulled out completely?</tt><tt></tt>
<p><tt>Yes and maybe. It was a mistake to put it into that patch, but I
think</tt>
<br><tt>the patch ends up in the common code anyway. Next version will
be</tt>
<br><tt>improved.</tt><tt></tt>
<p><tt>Ripping it out? Well, I'm tempted. But nothing is decided. Feel
free to</tt>
<br><tt>argue. =)</tt><tt></tt>
<p><tt>The main reason behind it is that we need to make kexec-tools xen-aware.</tt>
<br><tt>And this awareness may lead to that we don't need any crash notes
at all</tt>
<br><tt>in the Xen case. Mostly because kexec-tools only knows about dom0,
but</tt>
<br><tt>the crash dump is about the entire system.</tt><tt></tt>
<p><tt>Today we have some code that stores the elf notes in the hypervisor
in</tt>
<br><tt>the same format as the kernel, and to pass these notes we need
to hook</tt>
<br><tt>in hypercalls in the kernel so that the user-space tool can find
the</tt>
<br><tt>address of the crash notes.</tt><tt></tt>
<p><tt>I think it would make sense to let dom0 save it's registers within
dom0</tt>
<br><tt>using the good old crash note format, but to use a simpler format
for</tt>
<br><tt>registers for the hypervisor. And the let the tools locate the
registers</tt>
<br><tt>by looking up global symbols.</tt><tt></tt>
<p><tt>> > I know you don't want to treat xen binary file with crash, but
I'm</tt>
<br><tt>> > not clear why.  Please discuss with him directly to make
up xen kdump</tt>
<br><tt>> > file formats.  The patch will be merged into xen-3.0.4.</tt>
<br><tt>> > I hope we can find solution before merge.</tt>
<br><tt>> ></tt>
<br><tt>></tt>
<br><tt>> The crash utility is wholly based upon the internal structure</tt>
<br><tt>> of the Linux kernel.</tt><tt></tt>
<p><tt>So why can't you just require that Xen dumps needs to be cut out
with</tt>
<br><tt>dom0 cut?</tt>
<br><tt></tt> </blockquote>
<tt>Well, to answer your question with a question:</tt><tt></tt>
<p><tt> Why should it be required if it could be so easily avoided?</tt><tt></tt>
<p><tt>As Henry David Thoreau said, "Simplicity, simplicity, simplicity..."</tt><tt></tt>
<p><tt>My two cents,</tt>
<br><tt>  Dave</tt>
<br><tt></tt> 
<br><tt></tt> </html>