浏览代码

xen: add missing definitions for xen grant table which ia64/xen needs

Add xen handles realted definitions for grant table which ia64/xen
needs.
Pointer argumsnts for ia64/xen hypercall are passed in pseudo physical
address (guest physical address) so that it is required to convert
guest kernel virtual address into pseudo physical address right before
issuing hypercall.
The xen guest handle represents such arguments.
Define necessary handles and helper functions.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Isaku Yamahata 17 年之前
父节点
当前提交
87e27cf628
共有 3 个文件被更改,包括 33 次插入4 次删除
  1. 1 1
      drivers/xen/grant-table.c
  2. 24 0
      include/asm-x86/xen/interface.h
  3. 8 3
      include/xen/interface/grant_table.h

+ 1 - 1
drivers/xen/grant-table.c

@@ -470,7 +470,7 @@ static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
 
 
 	setup.dom        = DOMID_SELF;
 	setup.dom        = DOMID_SELF;
 	setup.nr_frames  = nr_gframes;
 	setup.nr_frames  = nr_gframes;
-	setup.frame_list = frames;
+	set_xen_guest_handle(setup.frame_list, frames);
 
 
 	rc = HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
 	rc = HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
 	if (rc == -ENOSYS) {
 	if (rc == -ENOSYS) {

+ 24 - 0
include/asm-x86/xen/interface.h

@@ -22,6 +22,30 @@
 #define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
 #define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
 #define GUEST_HANDLE(name)        __guest_handle_ ## name
 #define GUEST_HANDLE(name)        __guest_handle_ ## name
 
 
+#ifdef __XEN__
+#if defined(__i386__)
+#define set_xen_guest_handle(hnd, val)			\
+	do {						\
+		if (sizeof(hnd) == 8)			\
+			*(uint64_t *)&(hnd) = 0;	\
+		(hnd).p = val;				\
+	} while (0)
+#elif defined(__x86_64__)
+#define set_xen_guest_handle(hnd, val)	do { (hnd).p = val; } while (0)
+#endif
+#else
+#if defined(__i386__)
+#define set_xen_guest_handle(hnd, val)			\
+	do {						\
+		if (sizeof(hnd) == 8)			\
+			*(uint64_t *)&(hnd) = 0;	\
+		(hnd) = val;				\
+	} while (0)
+#elif defined(__x86_64__)
+#define set_xen_guest_handle(hnd, val)	do { (hnd) = val; } while (0)
+#endif
+#endif
+
 #ifndef __ASSEMBLY__
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
 /* Guest handles for primitive C types. */
 __DEFINE_GUEST_HANDLE(uchar, unsigned char);
 __DEFINE_GUEST_HANDLE(uchar, unsigned char);

+ 8 - 3
include/xen/interface/grant_table.h

@@ -185,6 +185,7 @@ struct gnttab_map_grant_ref {
     grant_handle_t handle;
     grant_handle_t handle;
     uint64_t dev_bus_addr;
     uint64_t dev_bus_addr;
 };
 };
+DEFINE_GUEST_HANDLE_STRUCT(gnttab_map_grant_ref);
 
 
 /*
 /*
  * GNTTABOP_unmap_grant_ref: Destroy one or more grant-reference mappings
  * GNTTABOP_unmap_grant_ref: Destroy one or more grant-reference mappings
@@ -206,6 +207,7 @@ struct gnttab_unmap_grant_ref {
     /* OUT parameters. */
     /* OUT parameters. */
     int16_t  status;              /* GNTST_* */
     int16_t  status;              /* GNTST_* */
 };
 };
+DEFINE_GUEST_HANDLE_STRUCT(gnttab_unmap_grant_ref);
 
 
 /*
 /*
  * GNTTABOP_setup_table: Set up a grant table for <dom> comprising at least
  * GNTTABOP_setup_table: Set up a grant table for <dom> comprising at least
@@ -223,8 +225,9 @@ struct gnttab_setup_table {
     uint32_t nr_frames;
     uint32_t nr_frames;
     /* OUT parameters. */
     /* OUT parameters. */
     int16_t  status;              /* GNTST_* */
     int16_t  status;              /* GNTST_* */
-    ulong *frame_list;
+    GUEST_HANDLE(ulong) frame_list;
 };
 };
+DEFINE_GUEST_HANDLE_STRUCT(gnttab_setup_table);
 
 
 /*
 /*
  * GNTTABOP_dump_table: Dump the contents of the grant table to the
  * GNTTABOP_dump_table: Dump the contents of the grant table to the
@@ -237,6 +240,7 @@ struct gnttab_dump_table {
     /* OUT parameters. */
     /* OUT parameters. */
     int16_t status;               /* GNTST_* */
     int16_t status;               /* GNTST_* */
 };
 };
+DEFINE_GUEST_HANDLE_STRUCT(gnttab_dump_table);
 
 
 /*
 /*
  * GNTTABOP_transfer_grant_ref: Transfer <frame> to a foreign domain. The
  * GNTTABOP_transfer_grant_ref: Transfer <frame> to a foreign domain. The
@@ -255,7 +259,7 @@ struct gnttab_transfer {
     /* OUT parameters. */
     /* OUT parameters. */
     int16_t       status;
     int16_t       status;
 };
 };
-
+DEFINE_GUEST_HANDLE_STRUCT(gnttab_transfer);
 
 
 /*
 /*
  * GNTTABOP_copy: Hypervisor based copy
  * GNTTABOP_copy: Hypervisor based copy
@@ -296,6 +300,7 @@ struct gnttab_copy {
 	/* OUT parameters. */
 	/* OUT parameters. */
 	int16_t       status;
 	int16_t       status;
 };
 };
+DEFINE_GUEST_HANDLE_STRUCT(gnttab_copy);
 
 
 /*
 /*
  * GNTTABOP_query_size: Query the current and maximum sizes of the shared
  * GNTTABOP_query_size: Query the current and maximum sizes of the shared
@@ -313,7 +318,7 @@ struct gnttab_query_size {
     uint32_t max_nr_frames;
     uint32_t max_nr_frames;
     int16_t  status;              /* GNTST_* */
     int16_t  status;              /* GNTST_* */
 };
 };
-
+DEFINE_GUEST_HANDLE_STRUCT(gnttab_query_size);
 
 
 /*
 /*
  * Bitfield values for update_pin_status.flags.
  * Bitfield values for update_pin_status.flags.