From mboxrd@z Thu Jan 1 00:00:00 1970 From: Koripella Srinivas Subject: Grant Tables Date: Tue, 26 Jun 2007 16:59:12 +0530 (IST) Message-ID: <205229.67298.qm@web94101.mail.in2.yahoo.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1088941461==" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Mime-version: 1.0 Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --===============1088941461== Content-Type: multipart/alternative; boundary="0-1526507678-1182857352=:67298" --0-1526507678-1182857352=:67298 Content-Type: text/plain; charset=ascii Hello, I am setting up shared memory using grant tables between two hvm guests. In the process of doing so, the function create_grant_host_mapping( uint64_t addr, unsigned long frame, unsigned int flags) in mm.c is getting called to create a mapping at the specified virtual addr (as specified by parameter addr in the call) for the specified machine frame address (specified by parameter frame). But when the function returns the guest physical address gets changed to point to the parameter value frame and the machine address of the virtual address points to 0xffffffff. Is it because this function-create_grant_host_mapping does not work for hvm guests and i have to rewrite this function to use shadow page tables or is there some other error?? What could be the problem?? Thanks Bollywood, fun, friendship, sports and more... you name it, we have it at http://in.groups.yahoo.com --0-1526507678-1182857352=:67298 Content-Type: text/html; charset=ascii
Hello,

I am setting up shared memory using grant tables between two hvm guests.
In the process of doing so, the function create_grant_host_mapping( uint64_t addr, unsigned long frame, unsigned int flags) in mm.c is getting called to create a mapping at the specified virtual addr (as specified by parameter addr in the call) for the specified machine frame address (specified by parameter frame).

But when the function returns the guest physical address gets changed to point to the parameter value frame  and the machine address of the virtual address points to 0xffffffff.
Is it because this function-create_grant_host_mapping  does not work for hvm guests and i have to rewrite this function to use shadow page tables or is there some other error??

What could be the problem??


Thanks



Once upon a time there was 1 GB storage on Yahoo! Mail. Click here for happy ending! --0-1526507678-1182857352=:67298-- --===============1088941461== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --===============1088941461==-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carlo Bertoldi Subject: Grant tables Date: Fri, 04 Apr 2008 17:26:30 +0200 Message-ID: <47F648A6.3000104@tiscali.it> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Hi, I need to use the grant table mechanism, but I can't find any example regarding how to do it. Could you please provide some examples? Thanks Carlo -- È molto più bello sapere qualcosa di tutto, che sapere tutto di una cosa. Blaise Pascal From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samuel Thibault Subject: Re: Grant tables Date: Fri, 4 Apr 2008 17:31:06 +0200 Message-ID: <20080404153106.GK4075@implementation> References: <47F648A6.3000104@tiscali.it> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Return-path: Content-Disposition: inline In-Reply-To: <47F648A6.3000104@tiscali.it> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Carlo Bertoldi Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Carlo Bertoldi, le Fri 04 Apr 2008 17:26:30 +0200, a écrit : > I need to use the grant table mechanism, but I can't find any example > regarding how to do it. Could you please provide some examples? See tools/fs-back/fs-ops.c for instance (xc_gnttab* functions). Samuel From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carlo Bertoldi Subject: Re: Grant tables Date: Fri, 04 Apr 2008 18:56:06 +0200 Message-ID: <47F65DA6.3000007@tiscali.it> References: <47F648A6.3000104@tiscali.it> <20080404153106.GK4075@implementation> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Return-path: In-Reply-To: <20080404153106.GK4075@implementation> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Samuel Thibault wrote, on the 04/04/2008 17.31: Thanks, for the prompt answer. > See tools/fs-back/fs-ops.c for instance (xc_gnttab* functions). > Ok, so I found this: buf = xc_gnttab_map_grant_ref(mount->gnth, mount->dom_id, req->u.fwrite.gref, PROT_READ); it's fine, except that I don't understand how to obtain the gref. IOW how can I build a grant reference from a domain? Carlo -- È molto più bello sapere qualcosa di tutto, che sapere tutto di una cosa. Blaise Pascal From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samuel Thibault Subject: Re: Grant tables Date: Fri, 4 Apr 2008 23:42:40 +0200 Message-ID: <20080404214240.GE4014@implementation> References: <47F648A6.3000104@tiscali.it> <20080404153106.GK4075@implementation> <47F65DA6.3000007@tiscali.it> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Return-path: Content-Disposition: inline In-Reply-To: <47F65DA6.3000007@tiscali.it> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Carlo Bertoldi Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Carlo Bertoldi, le Fri 04 Apr 2008 18:56:06 +0200, a écrit : > Samuel Thibault wrote, on the 04/04/2008 17.31: > > Thanks, for the prompt answer. > > See tools/fs-back/fs-ops.c for instance (xc_gnttab* functions). > > > Ok, so I found this: > > buf = xc_gnttab_map_grant_ref(mount->gnth, > mount->dom_id, > req->u.fwrite.gref, > PROT_READ); > > it's fine, except that I don't understand how to obtain the gref. IOW > how can I build a grant reference from a domain? To my knowledge, there is no user interface for that yet, you need to do it from the Linux kernel. Samuel From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carlo Bertoldi Subject: Re: Grant tables Date: Sat, 05 Apr 2008 10:10:57 +0200 Message-ID: <47F73411.6010705@tiscali.it> References: <47F648A6.3000104@tiscali.it> <20080404153106.GK4075@implementation> <47F65DA6.3000007@tiscali.it> <20080404214240.GE4014@implementation> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Return-path: In-Reply-To: <20080404214240.GE4014@implementation> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Samuel Thibault wrote, on the 04/04/2008 23.42: >> >> it's fine, except that I don't understand how to obtain the gref. IOW how can I build a grant reference from a domain? > > To my knowledge, there is no user interface for that yet, you need to do > it from the Linux kernel. > I agree, can you provide some examples about that? > Samuel Thanks, Carlo -- È molto più bello sapere qualcosa di tutto, che sapere tutto di una cosa. Blaise Pascal From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samuel Thibault Subject: Re: Grant tables Date: Sat, 5 Apr 2008 10:55:30 +0200 Message-ID: <20080405085530.GA3858@implementation> References: <47F648A6.3000104@tiscali.it> <20080404153106.GK4075@implementation> <47F65DA6.3000007@tiscali.it> <20080404214240.GE4014@implementation> <47F7339B.90207@tiscali.it> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Return-path: Content-Disposition: inline In-Reply-To: <47F7339B.90207@tiscali.it> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Carlo Bertoldi Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Carlo Bertoldi, le Sat 05 Apr 2008 10:08:59 +0200, a écrit : > Samuel Thibault wrote, on the 04/04/2008 23.42: > >> > >>it's fine, except that I don't understand how to obtain the gref. IOW > >>how can I build a grant reference from a domain? > > > >To my knowledge, there is no user interface for that yet, you need to do > >it from the Linux kernel. > > > I agree, can you provide some examples about that? Look for gnttab_grant_foreign_access in linux/drivers/xen Samuel From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark Williamson Subject: Re: Grant tables Date: Sat, 5 Apr 2008 22:14:01 +0100 Message-ID: <200804052214.02300.mark.williamson@cl.cam.ac.uk> References: <47F648A6.3000104@tiscali.it> <20080404214240.GE4014@implementation> <47F73411.6010705@tiscali.it> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <47F73411.6010705@tiscali.it> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: Carlo Bertoldi List-Id: xen-devel@lists.xenproject.org > >> it's fine, except that I don't understand how to obtain the gref. > > IOW how can I build a grant reference from a domain? The idea is that the domain you're mapping memory from will create a grant reference, then (somehow) tell your mapping code what that reference is. For the split front/back drivers, the frontend picks a page to be used for the communications ring, grants it to the backend domain, and puts the grant reference into XenStore so the backend can map that page. During IO, grant references can then be passed through the shared memory ring already established, which is more efficient. This is how most of the driver code does things under Xen. > > To my knowledge, there is no user interface for that yet, you need to do > > it from the Linux kernel. > > I agree, can you provide some examples about that? Take a look in the Xen Linux tree at the drivers/xen/blkfront/ for some creation of grant references. As Samuel says, searching for grant table functions under drivers/xen/ is going to find you some interesting examples in various places. hope that helps, Cheers, Mark -- Push Me Pull You - Distributed SCM tool (http://www.cl.cam.ac.uk/~maw48/pmpu/) From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carlo Bertoldi Subject: Re: Grant tables Date: Mon, 07 Apr 2008 18:07:20 +0200 Message-ID: <47FA46B8.8050206@tiscali.it> References: <47F648A6.3000104@tiscali.it> <20080404214240.GE4014@implementation> <47F73411.6010705@tiscali.it> <200804052214.02300.mark.williamson@cl.cam.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Return-path: In-Reply-To: <200804052214.02300.mark.williamson@cl.cam.ac.uk> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Mark Williamson wrote, on the 05/04/2008 23.14: > Take a look in the Xen Linux tree at the drivers/xen/blkfront/ for some creation of grant references. As Samuel says, searching for grant table functions under drivers/xen/ is going to find you some interesting examples in various places. > I studied the suggested code and I wrote something to test my understanding. It compiles and run fine, but I've got a problem: when I read the value of the shared structure it's not right. This is the function, contained in a module, that creates the grant: static void offer_page() { int code; struct foo foo_struct; foo_struct.numero = 5; if ( ( code = gnttab_grant_foreign_access(0, virt_to_mfn(&foo_struct), 0)) == -1) { printk(KERN_INFO "grant error\n"); } } In userspace I use the following code to read the granted page: void grant(int xcg_handle, int domid) { struct foo *foo_struct; void *buf; int i; buf = xc_gnttab_map_grant_ref(xcg_handle, domid, 851, PROT_READ); // yes, ugly hardcoded value if (buf != NULL) { foo_struct = (struct foo *) buf; printf("numero = %d\n", foo_struct->numero); } } I'd expect it to print five, but it always write zero. What am I doing wrong here? > hope that helps, > Cheers, > Mark Thanks, Carlo -- È molto più bello sapere qualcosa di tutto, che sapere tutto di una cosa. Blaise Pascal From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Stodden Subject: Re: Grant tables Date: Mon, 07 Apr 2008 18:18:23 +0200 Message-ID: <1207585103.13737.8.camel@thinkpad.localdomain> References: <47F648A6.3000104@tiscali.it> <20080404214240.GE4014@implementation> <47F73411.6010705@tiscali.it> <200804052214.02300.mark.williamson@cl.cam.ac.uk> <47FA46B8.8050206@tiscali.it> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <47FA46B8.8050206@tiscali.it> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Carlo Bertoldi Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org On Mon, 2008-04-07 at 18:07 +0200, Carlo Bertoldi wrote: > Mark Williamson wrote, on the 05/04/2008 23.14: > > Take a look in the Xen Linux tree at the drivers/xen/blkfront/ for=20 > some creation of grant references. As Samuel says, searching for grant= =20 > table functions under drivers/xen/ is going to find you some interestin= g=20 > examples in various places. > > > I studied the suggested code and I wrote something to test my=20 > understanding. It compiles and run fine, but I've got a problem: when I= =20 > read the value of the shared structure it's not right. >=20 > This is the function, contained in a module, that creates the grant: >=20 > static void offer_page() > { > int code; > struct foo foo_struct; >=20 > foo_struct.numero =3D 5; >=20 > if ( ( code =3D gnttab_grant_foreign_access(0,=20 > virt_to_mfn(&foo_struct), 0)) =3D=3D -1) { > printk(KERN_INFO "grant error\n"); > } > } >=20 > In userspace I use the following code to read the granted page: you're granting a part of the kernel stack. the allocation of the memory block you're using won't survive subsequent return from the function. the granttab_-functions probably let you get away with it, but numero is likely to be overwritten shortly after executing the code above. allocate a whole frame (e.g. via get_free_page[s]()) and use that. remember to release it upon module unload. regards, daniel --=20 Daniel Stodden LRR - Lehrstuhl f=C3=BCr Rechnertechnik und Rechnerorganisation Institut f=C3=BCr Informatik der TU M=C3=BCnchen D-85748 Garc= hing http://www.lrr.in.tum.de/~stodden mailto:stodden@cs.tum.edu PGP Fingerprint: F5A4 1575 4C56 E26A 0B33 3D80 457E 82AE B0D8 735B