WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] Question about xc_ptrace and PV domU process memory map.

To: Necrosoft <necrosoft82@xxxxxxxx>
Subject: Re: [Xen-devel] Question about xc_ptrace and PV domU process memory map.
From: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Date: Mon, 12 Nov 2007 15:59:36 +0000
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Mon, 12 Nov 2007 08:00:42 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <4734E8C6.2050703@xxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Newsgroups: chiark.mail.xen.devel
References: <4734E8C6.2050703@xxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Necrosoft writes ("[Xen-devel] Question about xc_ptrace and PV domU process 
memory map."):
> If I simply call xp_ptrace(xc_handle, PTRACE_PEEKTEXT, 0, virt_address, 
> 0) (where xc_handle is obtained by xc_handle = xc_interface_open() and 
> first 0 is vcpu used) I receive this message:

You mean xc_ptrace ?  I think these functions are designed only to be
used following PTRACE_ATTACH.  PTRACE_ATTACH will pause the target
domain, which may not be what you want.

http://xenaccess.sourceforge.net/ may be more what you want.  (I have
no knowledge of whether XenAccess is any good - I just saw the link
from wiki.xensource.com.)

If you want to use libxc you will have to put up with pausing the
domain, or do some work on the races which result from allowing it to
run: by my reading of the code it's not correct to arrange to skip the
pause, or unpause the domain after PTRACE_ATTACH, because
xc_ptrace.c:map_domain_va assumes that the domain does not allocate
additional pages between its calls to xc_get_tot_pages and
xc_get_pfn_list.

Arguably it would be better if xc_ptrace.c asserted that
current_domid was valid.  (The purpose of the test
`current_domid > 0 ?' in the call to xc_domain_unpause PTRACE_DETACH
seems to be to work around some bug in a caller but it seems unlikely
to DTRT except under very specific circumstances.)

> long npgs = xc_get_tot_pages(xc_handle, current_domid);
...
> I think that the error reported above is caused by a wrong value 
> returned by xc_get_tot_pages function. In particular I think it is 
> current_domid set incorrectly.

You don't say whether you used a debugger to check the value of
current_domid.  I guess from your message that you didn't, and
evidently you didn't spot that current_domid is assigned in
PTRACE_ATTACH.  That's where it is supposed to be initialised.  I
guess that you probably aren't calling _ATTACH.

As a result current_domid will be -1 (probably) and this will cause
domctl getdomaininfo to fail.  map_domain_va fails to check for this
error case and carries blithely on, passing (-1 * sizeof(...)) to
malloc.

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>