This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


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

To: Daniel Castro <evil.dani@xxxxxxxxx>
Subject: Re: [Xen-devel] Question on struct grant table hypercall
From: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Date: Tue, 28 Jun 2011 09:51:52 +0100
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Tue, 28 Jun 2011 01:52:58 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <BANLkTik_qeE8h-LE=kgcBnS9BYF-QDOvwA@xxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Citrix Systems, Inc.
References: <BANLkTik_qeE8h-LE=kgcBnS9BYF-QDOvwA@xxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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.


> 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

<Prev in Thread] Current Thread [Next in Thread>