All of lore.kernel.org
 help / color / mirror / Atom feed
* xc_get_pfn_list() creates broken core files
@ 2006-11-23  2:45 John Levon
  2006-11-23  8:52 ` Keir Fraser
  0 siblings, 1 reply; 21+ messages in thread
From: John Levon @ 2006-11-23  2:45 UTC (permalink / raw)
  To: xen-devel


I noticed that the p2m list in domain core files was incorrect. The problem lies
in XEN_DOMCTL_getmemlist, here:

227             list_ent = d->page_list.next;
228             for ( i = 0; (i < max_pfns) && (list_ent != &d->page_list); i++ )
229             {
230                 mfn = page_to_mfn(list_entry(
231                     list_ent, struct page_info, list));
...
238                 list_ent = mfn_to_page(mfn)->list.next;
239             }

This does not account correctly for 'holes' where the pfn no longer maps an
mfn, and thus doesn't appear on page_list. As a result the whole array gets out
of sync. What's the right fix here? Below is what I threw together to verify
the problem.

thanks,
john

diff --git a/tools/libxc/xc_core.c b/tools/libxc/xc_core.c
--- a/tools/libxc/xc_core.c
+++ b/tools/libxc/xc_core.c
@@ -103,7 +103,12 @@ xc_domain_dumpcore_via_callback(int xc_h
 
     for ( dump_mem = dump_mem_start, i = 0; i < nr_pages; i++ )
     {
-        copy_from_domain_page(xc_handle, domid, page_array[i], dump_mem);
+	fprintf(stderr, "page_array %d is %lx\n", i, page_array[i]);
+	if (page_array[i] == -1) {
+		memset(dump_mem, 0, PAGE_SIZE);
+	} else {
+        	copy_from_domain_page(xc_handle, domid, page_array[i], dump_mem);
+	}
         dump_mem += PAGE_SIZE;
         if ( ((i + 1) % DUMP_INCREMENT == 0) || ((i + 1) == nr_pages) )
         {
diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -215,6 +215,7 @@ long arch_do_domctl(
         struct domain *d = find_domain_by_id(domctl->domain);
         unsigned long max_pfns = domctl->u.getmemlist.max_pfns;
         unsigned long mfn, gmfn;
+	unsigned long gpfn;
         struct list_head *list_ent;
 
         ret = -EINVAL;
@@ -255,6 +256,26 @@ long arch_do_domctl(
                 {
                     mfn = page_to_mfn(list_entry(
                         list_ent, struct page_info, list));
+                    gpfn = get_gpfn_from_mfn(mfn);
+#ifdef __x86_64__
+                    if (gpfn != 0x5555555555555555L)
+#else
+                    if (gpfn != 0x55555555L)
+#endif
+                    {
+                        /* Account for unmapped gpfn's. */
+                        while (i < gpfn)
+                        {
+                            unsigned long tmp = -1;
+                            if ( copy_to_guest_offset(domctl->u.getmemlist.buffer,
+                                                      i, &tmp, 1) )
+                            {
+                                 ret = -EFAULT;
+                                 break;
+                            }
+                            i++;
+                        }
+                    }
                     if ( copy_to_guest_offset(domctl->u.getmemlist.buffer,
                                               i, &mfn, 1) )
                     {

^ permalink raw reply	[flat|nested] 21+ messages in thread
* RE: xc_get_pfn_list() creates broken core files
@ 2006-11-23 18:53 Ian Pratt
  2006-11-23 19:05 ` Keir Fraser
  0 siblings, 1 reply; 21+ messages in thread
From: Ian Pratt @ 2006-11-23 18:53 UTC (permalink / raw)
  To: Keir Fraser, John Levon; +Cc: xen-devel

> Pagetables etc. are all in 'p' address space, so there should 
> be no need for p2m or m2p in that case I think
> 
> In fact pagetables could be canonicalised into 'p' space for 
> PV guests too (xc_linux_save has the code for this) then 
> there'd be no need to dump the p2m table in the core dump at 
> all. Save format and core dump format should probably be one 
> and the same!

Trouble is, the PV guest hasn't done an orderly suspend, and may be
holding machine address references in registers/memory and in pagetables
that haven't been pinned yet.

The guest's core dump will already contain the p2m table, and its root
location has been registered with xen during boot, so this just needs to
be saved too.

Ian

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2007-01-18 12:42 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-23  2:45 xc_get_pfn_list() creates broken core files John Levon
2006-11-23  8:52 ` Keir Fraser
2006-11-23 18:16   ` John Levon
2006-11-23 18:39     ` Keir Fraser
2006-11-23 19:17       ` John Levon
2006-11-23 19:20         ` Keir Fraser
2006-11-23 20:52           ` John Levon
2006-11-23 22:05             ` John Levon
2006-11-25 16:03               ` Jimi Xenidis
2006-11-23 23:33             ` Keir Fraser
2006-11-23 23:48               ` John Levon
2007-01-15  9:16                 ` [PATCH][RFC] dump-core: PFN-GMFN table and ELF formatify (was Re: [Xen-devel] xc_get_pfn_list() creates broken core files) Isaku Yamahata
2007-01-15 10:13                   ` Keir Fraser
2007-01-15 12:38                     ` John Levon
2007-01-17  3:59                   ` [PATCH][RFC] dump-core: PFN-GMFN table and ELF formatify (was " John Levon
2007-01-17  5:54                     ` [PATCH][RFC] dump-core: PFN-GMFN table and ELF formatify (was Re: [Xen-devel] " Isaku Yamahata
2007-01-17 13:06                       ` [PATCH][RFC] dump-core: PFN-GMFN table and ELF formatify (was " John Levon
2007-01-18  1:41                         ` [PATCH][RFC] dump-core: PFN-GMFN table and ELF formatify (was Re: [Xen-devel] " Isaku Yamahata
2007-01-18 12:42                           ` [PATCH][RFC] dump-core: PFN-GMFN table and ELF formatify (was " John Levon
  -- strict thread matches above, loose matches on Subject: below --
2006-11-23 18:53 xc_get_pfn_list() creates broken core files Ian Pratt
2006-11-23 19:05 ` Keir Fraser

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.