* Grant tables
@ 2008-04-04 15:26 Carlo Bertoldi
2008-04-04 15:31 ` Samuel Thibault
0 siblings, 1 reply; 10+ messages in thread
From: Carlo Bertoldi @ 2008-04-04 15:26 UTC (permalink / raw)
To: xen-devel
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Grant tables
2008-04-04 15:26 Grant tables Carlo Bertoldi
@ 2008-04-04 15:31 ` Samuel Thibault
2008-04-04 16:56 ` Carlo Bertoldi
0 siblings, 1 reply; 10+ messages in thread
From: Samuel Thibault @ 2008-04-04 15:31 UTC (permalink / raw)
To: Carlo Bertoldi; +Cc: xen-devel
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Grant tables
2008-04-04 15:31 ` Samuel Thibault
@ 2008-04-04 16:56 ` Carlo Bertoldi
2008-04-04 21:42 ` Samuel Thibault
0 siblings, 1 reply; 10+ messages in thread
From: Carlo Bertoldi @ 2008-04-04 16:56 UTC (permalink / raw)
To: xen-devel
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
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: Grant tables
2008-04-04 16:56 ` Carlo Bertoldi
@ 2008-04-04 21:42 ` Samuel Thibault
2008-04-05 8:10 ` Carlo Bertoldi
[not found] ` <47F7339B.90207@tiscali.it>
0 siblings, 2 replies; 10+ messages in thread
From: Samuel Thibault @ 2008-04-04 21:42 UTC (permalink / raw)
To: Carlo Bertoldi; +Cc: xen-devel
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
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: Grant tables
2008-04-04 21:42 ` Samuel Thibault
@ 2008-04-05 8:10 ` Carlo Bertoldi
2008-04-05 21:14 ` Mark Williamson
[not found] ` <47F7339B.90207@tiscali.it>
1 sibling, 1 reply; 10+ messages in thread
From: Carlo Bertoldi @ 2008-04-05 8:10 UTC (permalink / raw)
To: xen-devel
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
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: Grant tables
2008-04-05 8:10 ` Carlo Bertoldi
@ 2008-04-05 21:14 ` Mark Williamson
2008-04-07 16:07 ` Carlo Bertoldi
0 siblings, 1 reply; 10+ messages in thread
From: Mark Williamson @ 2008-04-05 21:14 UTC (permalink / raw)
To: xen-devel; +Cc: Carlo Bertoldi
> >> 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/)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Grant tables
2008-04-05 21:14 ` Mark Williamson
@ 2008-04-07 16:07 ` Carlo Bertoldi
2008-04-07 16:18 ` Daniel Stodden
0 siblings, 1 reply; 10+ messages in thread
From: Carlo Bertoldi @ 2008-04-07 16:07 UTC (permalink / raw)
To: xen-devel
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
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: Grant tables
2008-04-07 16:07 ` Carlo Bertoldi
@ 2008-04-07 16:18 ` Daniel Stodden
0 siblings, 0 replies; 10+ messages in thread
From: Daniel Stodden @ 2008-04-07 16:18 UTC (permalink / raw)
To: Carlo Bertoldi; +Cc: xen-devel
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@cs.tum.edu
PGP Fingerprint: F5A4 1575 4C56 E26A 0B33 3D80 457E 82AE B0D8 735B
^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <47F7339B.90207@tiscali.it>]
* Re: Grant tables
[not found] ` <47F7339B.90207@tiscali.it>
@ 2008-04-05 8:55 ` Samuel Thibault
0 siblings, 0 replies; 10+ messages in thread
From: Samuel Thibault @ 2008-04-05 8:55 UTC (permalink / raw)
To: Carlo Bertoldi; +Cc: xen-devel
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Grant Tables
@ 2007-06-26 11:29 Koripella Srinivas
0 siblings, 0 replies; 10+ messages in thread
From: Koripella Srinivas @ 2007-06-26 11:29 UTC (permalink / raw)
To: xen-devel
[-- Attachment #1.1: Type: text/plain, Size: 903 bytes --]
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
[-- Attachment #1.2: Type: text/html, Size: 1977 bytes --]
[-- Attachment #2: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2008-04-07 16:18 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-04 15:26 Grant tables Carlo Bertoldi
2008-04-04 15:31 ` Samuel Thibault
2008-04-04 16:56 ` Carlo Bertoldi
2008-04-04 21:42 ` Samuel Thibault
2008-04-05 8:10 ` Carlo Bertoldi
2008-04-05 21:14 ` Mark Williamson
2008-04-07 16:07 ` Carlo Bertoldi
2008-04-07 16:18 ` Daniel Stodden
[not found] ` <47F7339B.90207@tiscali.it>
2008-04-05 8:55 ` Samuel Thibault
-- strict thread matches above, loose matches on Subject: below --
2007-06-26 11:29 Grant Tables Koripella Srinivas
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.