From: Carlo Bertoldi <mcbain@tiscali.it>
To: xen-devel@lists.xensource.com
Subject: Re: Grant tables
Date: Mon, 07 Apr 2008 18:07:20 +0200 [thread overview]
Message-ID: <47FA46B8.8050206@tiscali.it> (raw)
In-Reply-To: <200804052214.02300.mark.williamson@cl.cam.ac.uk>
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
next prev parent reply other threads:[~2008-04-07 16:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47FA46B8.8050206@tiscali.it \
--to=mcbain@tiscali.it \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.