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