[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] Grant tables
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 > 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: 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 -- Daniel Stodden LRR - Lehrstuhl fÃr Rechnertechnik und Rechnerorganisation Institut fÃr Informatik der TU MÃnchen D-85748 Garching http://www.lrr.in.tum.de/~stodden mailto:stodden@xxxxxxxxxx PGP Fingerprint: F5A4 1575 4C56 E26A 0B33 3D80 457E 82AE B0D8 735B _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |