[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] Question on struct grant table hypercall



On Tue, 2011-06-28 at 01:38 +0100, Daniel Castro wrote:
> Hello All,
> 
> 
> I am calling the hypercall to map the grant table on a HVM domain, on
> the code I have the cmd and struct gnttab_setup_table required to call
> the hypercall, yet on the struct you have XEN_GUEST_HANDLE as a type
> to a list of frames, my environment does not include the whole of xen,
> I have to include manually all the necessary structs and global
> variables needed. But the XEN_GUEST_HANDLE gives me an error, can I
> substitute the type with a simple array?

XEN_GUEST_HANDLE is a wrapper for a pointer rather than an array. IIRC
it was originally introduced to encapsulate some oddities of the
guest-pointer on the PPC architecture. These days I think the hypervisor
only uses to enforce alignment constraints on pointers. The tools also
use it to try and enforce type-safety for these pointers when hypercalls
are made from userspace (since the pointers need to be to memory which
is safe to use as a hypercall argument).

Although in principal you could replace the guest handle with a suitably
aligned pointer definition I think it would be wise to pull in the
necessary macros. They are defined in xen/include/public/arch-x86/xen.h.

You want the version corresponding to "__XEN_INTERFACE_VERSION__ >=
0x00030201". think you can also ignore the bits related to
XEN_GUEST_HANDLE_64 since they are for control domain use only. (IOW you
can ignore the override in xen/include/public/arch-x86/xen-x86_32.h).

You will also want some of the (__)DEFINE_XEN_GUEST_HANDLE calls from
xen/include/public/xen.h to define the baseline types you need. e.g.
your gnttab example below will require the
"__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);" so that
XEN_GUEST_HANDLE(ulong) means something.

Ian.

> 
> This is the code I am referring:
> 
> //This code is slightly modified.
> /*
>  * GNTTABOP_setup_table: Set up a grant table for <dom> comprising at least
>  * <nr_frames> pages. The frame addresses are written to the <frame_list>.
>  * Only <nr_frames> addresses are written, even if the table is larger.
>  * NOTES:
>  *  1. <dom> may be specified as DOMID_SELF.
>  *  2. Only a sufficiently-privileged domain may specify <dom> != DOMID_SELF.
>  *  3. Xen may not support more than a single grant-table page per domain.
>  */
> #define GNTTABOP_setup_table          2
> struct gnttab_setup_table {
>     /* IN parameters. */
>     u32  dom;
>     u32 nr_frames;
>     /* OUT parameters. */
>     u16  status;              /* GNTST_* */
>     //??????????????XEN_GUEST_HANDLE(ulong) frame_list;
> };
> typedef struct gnttab_setup_table gnttab_setup_table_t;
> 
> 
> 
> Thanks for the help,
> 
> Daniel
> 



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.