aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/xen/grant-table.c2
-rw-r--r--include/asm-x86/xen/interface.h24
-rw-r--r--include/xen/interface/grant_table.h11
3 files changed, 33 insertions, 4 deletions
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index d85dc6d41c2a..d4a89b3d694f 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -470,7 +470,7 @@ static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
470 470
471 setup.dom = DOMID_SELF; 471 setup.dom = DOMID_SELF;
472 setup.nr_frames = nr_gframes; 472 setup.nr_frames = nr_gframes;
473 setup.frame_list = frames; 473 set_xen_guest_handle(setup.frame_list, frames);
474 474
475 rc = HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1); 475 rc = HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
476 if (rc == -ENOSYS) { 476 if (rc == -ENOSYS) {
diff --git a/include/asm-x86/xen/interface.h b/include/asm-x86/xen/interface.h
index 588a0716cd78..6227000a1e84 100644
--- a/include/asm-x86/xen/interface.h
+++ b/include/asm-x86/xen/interface.h
@@ -22,6 +22,30 @@
22#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name) 22#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
23#define GUEST_HANDLE(name) __guest_handle_ ## name 23#define GUEST_HANDLE(name) __guest_handle_ ## name
24 24
25#ifdef __XEN__
26#if defined(__i386__)
27#define set_xen_guest_handle(hnd, val) \
28 do { \
29 if (sizeof(hnd) == 8) \
30 *(uint64_t *)&(hnd) = 0; \
31 (hnd).p = val; \
32 } while (0)
33#elif defined(__x86_64__)
34#define set_xen_guest_handle(hnd, val) do { (hnd).p = val; } while (0)
35#endif
36#else
37#if defined(__i386__)
38#define set_xen_guest_handle(hnd, val) \
39 do { \
40 if (sizeof(hnd) == 8) \
41 *(uint64_t *)&(hnd) = 0; \
42 (hnd) = val; \
43 } while (0)
44#elif defined(__x86_64__)
45#define set_xen_guest_handle(hnd, val) do { (hnd) = val; } while (0)
46#endif
47#endif
48
25#ifndef __ASSEMBLY__ 49#ifndef __ASSEMBLY__
26/* Guest handles for primitive C types. */ 50/* Guest handles for primitive C types. */
27__DEFINE_GUEST_HANDLE(uchar, unsigned char); 51__DEFINE_GUEST_HANDLE(uchar, unsigned char);
diff --git a/include/xen/interface/grant_table.h b/include/xen/interface/grant_table.h
index 219049802cf2..39da93c21de0 100644
--- a/include/xen/interface/grant_table.h
+++ b/include/xen/interface/grant_table.h
@@ -185,6 +185,7 @@ struct gnttab_map_grant_ref {
185 grant_handle_t handle; 185 grant_handle_t handle;
186 uint64_t dev_bus_addr; 186 uint64_t dev_bus_addr;
187}; 187};
188DEFINE_GUEST_HANDLE_STRUCT(gnttab_map_grant_ref);
188 189
189/* 190/*
190 * GNTTABOP_unmap_grant_ref: Destroy one or more grant-reference mappings 191 * GNTTABOP_unmap_grant_ref: Destroy one or more grant-reference mappings
@@ -206,6 +207,7 @@ struct gnttab_unmap_grant_ref {
206 /* OUT parameters. */ 207 /* OUT parameters. */
207 int16_t status; /* GNTST_* */ 208 int16_t status; /* GNTST_* */
208}; 209};
210DEFINE_GUEST_HANDLE_STRUCT(gnttab_unmap_grant_ref);
209 211
210/* 212/*
211 * GNTTABOP_setup_table: Set up a grant table for <dom> comprising at least 213 * GNTTABOP_setup_table: Set up a grant table for <dom> comprising at least
@@ -223,8 +225,9 @@ struct gnttab_setup_table {
223 uint32_t nr_frames; 225 uint32_t nr_frames;
224 /* OUT parameters. */ 226 /* OUT parameters. */
225 int16_t status; /* GNTST_* */ 227 int16_t status; /* GNTST_* */
226 ulong *frame_list; 228 GUEST_HANDLE(ulong) frame_list;
227}; 229};
230DEFINE_GUEST_HANDLE_STRUCT(gnttab_setup_table);
228 231
229/* 232/*
230 * GNTTABOP_dump_table: Dump the contents of the grant table to the 233 * GNTTABOP_dump_table: Dump the contents of the grant table to the
@@ -237,6 +240,7 @@ struct gnttab_dump_table {
237 /* OUT parameters. */ 240 /* OUT parameters. */
238 int16_t status; /* GNTST_* */ 241 int16_t status; /* GNTST_* */
239}; 242};
243DEFINE_GUEST_HANDLE_STRUCT(gnttab_dump_table);
240 244
241/* 245/*
242 * GNTTABOP_transfer_grant_ref: Transfer <frame> to a foreign domain. The 246 * GNTTABOP_transfer_grant_ref: Transfer <frame> to a foreign domain. The
@@ -255,7 +259,7 @@ struct gnttab_transfer {
255 /* OUT parameters. */ 259 /* OUT parameters. */
256 int16_t status; 260 int16_t status;
257}; 261};
258 262DEFINE_GUEST_HANDLE_STRUCT(gnttab_transfer);
259 263
260/* 264/*
261 * GNTTABOP_copy: Hypervisor based copy 265 * GNTTABOP_copy: Hypervisor based copy
@@ -296,6 +300,7 @@ struct gnttab_copy {
296 /* OUT parameters. */ 300 /* OUT parameters. */
297 int16_t status; 301 int16_t status;
298}; 302};
303DEFINE_GUEST_HANDLE_STRUCT(gnttab_copy);
299 304
300/* 305/*
301 * GNTTABOP_query_size: Query the current and maximum sizes of the shared 306 * GNTTABOP_query_size: Query the current and maximum sizes of the shared
@@ -313,7 +318,7 @@ struct gnttab_query_size {
313 uint32_t max_nr_frames; 318 uint32_t max_nr_frames;
314 int16_t status; /* GNTST_* */ 319 int16_t status; /* GNTST_* */
315}; 320};
316 321DEFINE_GUEST_HANDLE_STRUCT(gnttab_query_size);
317 322
318/* 323/*
319 * Bitfield values for update_pin_status.flags. 324 * Bitfield values for update_pin_status.flags.