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] xc_map_foreign_range usage

To: "Alex V" <allex.vong@xxxxxxxxx>
Subject: Re: [Xen-devel] xc_map_foreign_range usage
From: "Derek Murray" <Derek.Murray@xxxxxxxxxxxx>
Date: Sun, 24 Feb 2008 11:11:00 +0000
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Sun, 24 Feb 2008 03:11:25 -0800
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:reply-to:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=ekxNU58N64hVSEvovXTbYsi98Z8+s4+r6ndYVchyLi4=; b=f6Ls0askDBK/KuZpB5pvbDx+/N4NI7mH0LxR2VsPpeSBFQy2oLVftq0M6FGeuONe9mKLJXvCB9wrJVOGveohODw5+rXi1Frb7lp/XxT1NTZ5akYI/Xb3sXpbthjB0VW1Z2ZO6PH0YXyLW9QMjnUrd+2S+JFe8BqVtPIPKDsfHbU=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=C3ZnFGd1stEG0zzWVBYwisVVj2Ar2k8dn9GMkMAyofhAhiShHVMHNqgfWfTtzVNdoc4/+PWvU9IW5DKziI+MGb2pcAC5y39uX4oyZThup/h1i3lWPiRVI9ePwY9SBge1uamK+rIc/DRNpfF+xpTzzQ9oOYPUArRjr24ZL+jfXfo=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <a12af4bd0802240222s47095620o132e02c46e200131@xxxxxxxxxxxxxx>
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>
References: <a12af4bd0802240222s47095620o132e02c46e200131@xxxxxxxxxxxxxx>
Reply-to: Derek.Murray@xxxxxxxxxxxx
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Hi Alex,

On Sun, Feb 24, 2008 at 10:22 AM, Alex V <allex.vong@xxxxxxxxx> wrote:
>  It seemed pretty straightforward but in xenctrl.h it's stated that:
>  --------------------------------------------
>  In Linux, the ring queue for the control channel is accessible by
>  mapping the shared_info_frame (from xc_domain_getinfo()) + 2048.  The
>  structure stored there is of type control_if_t.
>  ---------------------------------------------
>
>  which confuses me since I could not find info about this structure and
>  therefore cast ret value to it.

I think this might be a spurious comment, as I cannot see anything
about this structure in the source of either Xen or PV Linux.

>  All I need is basically just to have an access from dom0 to the buffer
>  I allocated at domU. Could you tell me where I am able to see simple
>  example which deals with that?
>
>  Assume I already malloc'ed some buffer at domU and granted access to
>  it (have a reference number - ref)
>
>  Then in dom0 I map it using all info
>
>  void* my_addr = xc_map_foreign_range(handle, dom_id, rw, ref);
>
>  How can I change/read the buffer I granted access to dom0 previously?
>  I casted it to unsigned long and got an address (I suppose) but
>  casting it to (char*) and trying to print it out caused an segfault.

First of all some questions. Did you allocate the buffer in user-space
or kernel-space? Which guest operating system are you using? Did you
grant access to it using the Xen grant table mechanism?

xc_map_foreign_range() allows you to map the machine frame number
(essentially the real physical address) of a page of memory from
another domain into Dom0. Therefore, the last parameter in your call
should be a machine frame number, and not a grant reference.

However, a better way to do this would be to use the xc_gnttab_*
functions to map the page. These assume that you have created a grant
reference for your buffer in the guest domain. Then you can use the
code like this:

uint32_t domid = ...;
uint32_t ref = ...;
int xcg = xc_gnttab_open();
void *my_addr = xc_gnttab_map_grant_ref(xcg, dom_id, ref, PROT_READ |
PROT_WRITE);

Let me know if you have any further questions.

Regards,

Derek Murray.

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

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