Skip to contentSkip to conversation

32/64-bit hypercall interface revisited

RFC PATCH In review Hollis Blanchard 3 participants 9 messages Apr 14, 2006 – Apr 26, 2006 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 32/64-bit hypercall interface revisited

Last year we had a discussion[1] about how the hypercall ABI unfortunately contains fields that change width between 32- and 64-bit builds. This is a huge problem as we come up on the python management stack for ppc64, since the distributions ship 32-bit python. A 32-bit python/libxc cannot currently manage a 64-bit hypervisor.

I had a patch but was unable to test it, and some other things were more important at the time so I dropped the issue. Ultimately, there were three main issues:

First, "unsigned longs" in the dom0 interface (but not the guest interface) should be converted[2] to a new type[3]:

	typedef unsigned long long __attribute__((aligned(8))) foo_t;

Second, hypercalls that deal with frame numbers, e.g. DOM0_GETMEMLIST, also use "unsigned long". I've sent a separate mail about this, but I think it makes sense to define a DOM0_GETMEMLIST2 hypercall for this issue. I haven't investigated this fully.

Third, the tools need to treat GUEST_HANDLEs specially.[4] The attached patch does this; I have a ppc32 app successfully making DOM0_GETVCPUCONTEXT hcalls to a ppc64 Xen. The patch has only been compile-tested on x86-32, so I would appreciate it if people could try it out on x86.

For reference, the PPC changes look something like this:
- typedef struct { type *p; } __guest_handle_ ## name
+ typedef union { uint64_t u; type *p; } __guest_handle_ ## name

+#define SET_HANDLE(hnd, val) do { \
+ (void)((hnd).p == (val)); \
+ (hnd).u = (uint64_t)(unsigned long)(void *)(val); \
+ } while (0)
+
+#define GET_HANDLE(val, hnd) do { \
+ (val) = (hnd).p; \
+ } while (0)

This patch could be applied in advance of solving problems #1 and #2 above. However, it will likely require hand-merging with the libxc whitespace patch I sent recently.

[1] In the archive, the thread spilled from Sep to Oct:
http://lists.xensource.com/archives/html/xen-devel/2005-09/threads.html#01106
http://lists.xensource.com/archives/html/xen-devel/2005-10/threads.html#00205

[2]
http://lists.xensource.com/archives/html/xen-devel/2005-10/msg00078.html

[3] the alignment of long long on 32-bit x86 is 4 bytes, not 8
http://lists.xensource.com/archives/html/xen-devel/2005-10/msg00117.html

[4] the original incarnation of GUEST_HANDLE
http://lists.xensource.com/archives/html/xen-devel/2005-10/msg00205.html

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
#1 lore raw
Quoted 6 lines · Hollis Blanchard

Third, the tools need to treat GUEST_HANDLEs specially.[4] The attached patch does this; I have a ppc32 app successfully making DOM0_GETVCPUCONTEXT hcalls to a ppc64 Xen. The patch has only been compile-tested on x86-32, so I would appreciate it if people could try it out on x86.

Looks like I forgot to attach the patch. I guess that shows me how many people read the mail. ;)

I've attached it below.

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
tools/libxc/xc_domain.c +9 -9
diff -r 56e1802303e5 tools/libxc/xc_domain.c
@@ -171,7 +171,7 @@ int xc_domain_getinfolist(int xc_handle,
     op.cmd = DOM0_GETDOMAININFOLIST;
     op.u.getdomaininfolist.first_domain = first_domain;
     op.u.getdomaininfolist.max_domains  = max_domains;
-    op.u.getdomaininfolist.buffer       = info;
+    SET_HANDLE(op.u.getdomaininfolist.buffer, info);
 
     if ( xc_dom0_op(xc_handle, &op) < 0 )
         ret = -1;
@@ -195,7 +195,7 @@ int xc_vcpu_getcontext(int xc_handle,
     op.cmd = DOM0_GETVCPUCONTEXT;
     op.u.getvcpucontext.domain = (domid_t)domid;
     op.u.getvcpucontext.vcpu   = (uint16_t)vcpu;
-    op.u.getvcpucontext.ctxt   = ctxt;
+    SET_HANDLE(op.u.getvcpucontext.ctxt, ctxt);
 
     if ( (rc = mlock(ctxt, sizeof(*ctxt))) != 0 )
         return rc;
@@ -220,7 +220,7 @@ int xc_shadow_control(int xc_handle,
     op.cmd = DOM0_SHADOW_CONTROL;
     op.u.shadow_control.domain = (domid_t)domid;
     op.u.shadow_control.op     = sop;
-    op.u.shadow_control.dirty_bitmap = dirty_bitmap;
+    SET_HANDLE(op.u.shadow_control.dirty_bitmap, dirty_bitmap);
     op.u.shadow_control.pages  = pages;
 
     rc = do_dom0_op(xc_handle, &op);
@@ -295,12 +295,12 @@ int xc_domain_memory_increase_reservatio
 {
     int err;
     struct xen_memory_reservation reservation = {
-        .extent_start = extent_start, /* may be NULL */
         .nr_extents   = nr_extents,
         .extent_order = extent_order,  
         .address_bits = address_bits,
         .domid        = domid
     };
+    SET_HANDLE(reservation.extent_start, extent_start); /* may be NULL */
 
     err = xc_memory_op(xc_handle, XENMEM_increase_reservation, &reservation);
     if ( err == nr_extents )
@@ -326,12 +326,12 @@ int xc_domain_memory_decrease_reservatio
 {
     int err;
     struct xen_memory_reservation reservation = {
-        .extent_start = extent_start, 
         .nr_extents   = nr_extents,
         .extent_order = extent_order,  
         .address_bits = 0,
         .domid        = domid
     };
+    SET_HANDLE(reservation.extent_start, extent_start); /* may be NULL */
 
     if ( extent_start == NULL )
     {
@@ -364,12 +364,12 @@ int xc_domain_memory_populate_physmap(in
 {
     int err;
     struct xen_memory_reservation reservation = {
-        .extent_start = extent_start,
         .nr_extents   = nr_extents,
         .extent_order = extent_order,
         .address_bits = address_bits,
         .domid        = domid
     };
+    SET_HANDLE(reservation.extent_start, extent_start); /* may be NULL */
 
     err = xc_memory_op(xc_handle, XENMEM_populate_physmap, &reservation);
     if ( err == nr_extents )
@@ -395,9 +395,9 @@ int xc_domain_translate_gpfn_list(int xc
     struct xen_translate_gpfn_list op = {
         .domid        = domid,
         .nr_gpfns     = nr_gpfns,
-        .gpfn_list    = gpfn_list,
-        .mfn_list     = mfn_list
     };
+    SET_HANDLE(op.gpfn_list, gpfn_list);
+    SET_HANDLE(op.mfn_list, mfn_list);
 
     return xc_memory_op(xc_handle, XENMEM_translate_gpfn_list, &op);
 }
@@ -467,7 +467,7 @@ int xc_vcpu_setcontext(int xc_handle,
     op.cmd = DOM0_SETVCPUCONTEXT;
     op.u.setvcpucontext.domain = domid;
     op.u.setvcpucontext.vcpu = vcpu;
-    op.u.setvcpucontext.ctxt = ctxt;
+    SET_HANDLE(op.u.setvcpucontext.ctxt, ctxt);
 
     if ( (rc = mlock(ctxt, sizeof(*ctxt))) != 0 )
         return rc;
tools/libxc/xc_hvm_build.c +1 -1
diff -r 56e1802303e5 tools/libxc/xc_hvm_build.c
@@ -440,7 +440,7 @@ static int xc_hvm_build_internal(int xc_
 
     launch_op.u.setvcpucontext.domain = (domid_t)domid;
     launch_op.u.setvcpucontext.vcpu   = 0;
-    launch_op.u.setvcpucontext.ctxt   = ctxt;
+    SET_HANDLE(launch_op.u.setvcpucontext.ctxt, ctxt);
 
     launch_op.cmd = DOM0_SETVCPUCONTEXT;
     rc = xc_dom0_op(xc_handle, &launch_op);
tools/libxc/xc_linux_restore.c +2 -2
diff -r 56e1802303e5 tools/libxc/xc_linux_restore.c
@@ -583,11 +583,11 @@ int xc_linux_restore(int xc_handle, int 
         if (count > 0) {
 
             struct xen_memory_reservation reservation = {
-                .extent_start = pfntab,
                 .nr_extents   = count,
                 .extent_order = 0,
                 .domid        = dom
             };
+            SET_HANDLE(reservation.extent_start, pfntab);
 
             if ((rc = xc_memory_op(xc_handle, XENMEM_decrease_reservation,
                                    &reservation)) != count) { 
@@ -727,7 +727,7 @@ int xc_linux_restore(int xc_handle, int 
     op.cmd = DOM0_SETVCPUCONTEXT;
     op.u.setvcpucontext.domain = (domid_t)dom;
     op.u.setvcpucontext.vcpu   = 0;
-    op.u.setvcpucontext.ctxt   = &ctxt;
+    SET_HANDLE(op.u.setvcpucontext.ctxt, &ctxt);
     rc = xc_dom0_op(xc_handle, &op);
 
     if (rc != 0) {
tools/libxc/xc_linux_save.c +5 -3
diff -r 56e1802303e5 tools/libxc/xc_linux_save.c
@@ -509,16 +509,18 @@ static unsigned long *xc_map_m2p(int xc_
     privcmd_mmap_entry_t *entries; 
     unsigned long m2p_chunks, m2p_size; 
     unsigned long *m2p; 
+    unsigned long *extent_start; 
     int i, rc; 
 
     m2p_size   = M2P_SIZE(max_mfn); 
     m2p_chunks = M2P_CHUNKS(max_mfn); 
 
     xmml.max_extents = m2p_chunks;
-    if (!(xmml.extent_start = malloc(m2p_chunks * sizeof(unsigned long)))) { 
+    if (!(extent_start = malloc(m2p_chunks * sizeof(unsigned long)))) { 
         ERR("failed to allocate space for m2p mfns"); 
         return NULL; 
     } 
+    SET_HANDLE(xmml.extent_start, extent_start);
 
     if (xc_memory_op(xc_handle, XENMEM_machphys_mfn_list, &xmml) ||
         (xmml.nr_extents != m2p_chunks)) {
@@ -543,7 +545,7 @@ static unsigned long *xc_map_m2p(int xc_
     
     for (i=0; i < m2p_chunks; i++) { 
         entries[i].va = (unsigned long)(((void *)m2p) + (i * M2P_CHUNK_SIZE)); 
-        entries[i].mfn = xmml.extent_start[i];
+        entries[i].mfn = extent_start[i];
         entries[i].npages = M2P_CHUNK_SIZE >> PAGE_SHIFT;
     }
 
@@ -552,7 +554,7 @@ static unsigned long *xc_map_m2p(int xc_
         return NULL; 
     }
 
-    free(xmml.extent_start);
+    free(extent_start);
     free(entries); 
 
     return m2p; 
tools/libxc/xc_misc.c +3 -3
diff -r 56e1802303e5 tools/libxc/xc_misc.c
@@ -30,7 +30,7 @@ int xc_readconsolering(int xc_handle,
     unsigned int nr_chars = *pnr_chars;
 
     op.cmd = DOM0_READCONSOLE;
-    op.u.readconsole.buffer = buffer;
+    SET_HANDLE(op.u.readconsole.buffer, buffer);
     op.u.readconsole.count  = nr_chars;
     op.u.readconsole.clear  = clear;
 
@@ -39,7 +39,7 @@ int xc_readconsolering(int xc_handle,
 
     if ( (ret = do_dom0_op(xc_handle, &op)) == 0 )
     {
-        *pbuffer   = op.u.readconsole.buffer;
+        GET_HANDLE(*pbuffer, op.u.readconsole.buffer);
         *pnr_chars = op.u.readconsole.count;
     }
 
@@ -91,7 +91,7 @@ int xc_perfc_control(int xc_handle,
 
     op.cmd = DOM0_PERFCCONTROL;
     op.u.perfccontrol.op   = opcode;
-    op.u.perfccontrol.desc = desc;
+    SET_HANDLE(op.u.perfccontrol.desc, desc);
 
     rc = do_dom0_op(xc_handle, &op);
 
tools/libxc/xc_private.c +26 -15

98 lines not on this page · raw message

xen/include/public/arch-x86_32.h +2 -5
diff -r 56e1802303e5 xen/include/public/arch-x86_32.h
@@ -9,16 +9,13 @@
 #ifndef __XEN_PUBLIC_ARCH_X86_32_H__
 #define __XEN_PUBLIC_ARCH_X86_32_H__
 
-#ifdef __XEN__
 #define __DEFINE_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
 
 #define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
 #define GUEST_HANDLE(name)        __guest_handle_ ## name
+#define SET_HANDLE(hnd, val)      do { (hnd).p = val; } while (0)
+#define GET_HANDLE(val, hnd)      do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw
In reply to Hollis Blanchard
Quoted 6 lines · Hollis Blanchard

Third, the tools need to treat GUEST_HANDLEs specially.[4] The attached patch does this; I have a ppc32 app successfully making DOM0_GETVCPUCONTEXT hcalls to a ppc64 Xen. The patch has only been compile-tested on x86-32, so I would appreciate it if people could try it out on x86.

I noticed that I'd forgotten the corresponding ia64 and x86_64 changes, so this is the updated patch. Note that this overlaps with the frameno_t patch I just sent out; if both are acceptable, I would prefer that one goes in first and I can update and resend this one.

Signature · 382 lines
Hollis Blanchard
IBM Linux Technology Center

Introduce wrappers to access GUEST_HANDLES in libxc.

Signed-off-by: Hollis Blanchard <[email protected]>

diff -r 56e1802303e5 tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c	Wed Apr 12 15:41:55 2006 -0500
+++ b/tools/libxc/xc_domain.c	Wed Apr 19 12:53:37 2006 -0500
@@ -171,7 +171,7 @@ int xc_domain_getinfolist(int xc_handle,
     op.cmd = DOM0_GETDOMAININFOLIST;
     op.u.getdomaininfolist.first_domain = first_domain;
     op.u.getdomaininfolist.max_domains  = max_domains;
-    op.u.getdomaininfolist.buffer       = info;
+    SET_HANDLE(op.u.getdomaininfolist.buffer, info);
 
     if ( xc_dom0_op(xc_handle, &op) < 0 )
         ret = -1;
@@ -195,7 +195,7 @@ int xc_vcpu_getcontext(int xc_handle,
     op.cmd = DOM0_GETVCPUCONTEXT;
     op.u.getvcpucontext.domain = (domid_t)domid;
     op.u.getvcpucontext.vcpu   = (uint16_t)vcpu;
-    op.u.getvcpucontext.ctxt   = ctxt;
+    SET_HANDLE(op.u.getvcpucontext.ctxt, ctxt);
 
     if ( (rc = mlock(ctxt, sizeof(*ctxt))) != 0 )
         return rc;
@@ -220,7 +220,7 @@ int xc_shadow_control(int xc_handle,
     op.cmd = DOM0_SHADOW_CONTROL;
     op.u.shadow_control.domain = (domid_t)domid;
     op.u.shadow_control.op     = sop;
-    op.u.shadow_control.dirty_bitmap = dirty_bitmap;
+    SET_HANDLE(op.u.shadow_control.dirty_bitmap, dirty_bitmap);
     op.u.shadow_control.pages  = pages;
 
     rc = do_dom0_op(xc_handle, &op);
@@ -295,12 +295,12 @@ int xc_domain_memory_increase_reservatio
 {
     int err;
     struct xen_memory_reservation reservation = {
-        .extent_start = extent_start, /* may be NULL */
         .nr_extents   = nr_extents,
         .extent_order = extent_order,  
         .address_bits = address_bits,
         .domid        = domid
     };
+    SET_HANDLE(reservation.extent_start, extent_start); /* may be NULL */
 
     err = xc_memory_op(xc_handle, XENMEM_increase_reservation, &reservation);
     if ( err == nr_extents )
@@ -326,12 +326,12 @@ int xc_domain_memory_decrease_reservatio
 {
     int err;
     struct xen_memory_reservation reservation = {
-        .extent_start = extent_start, 
         .nr_extents   = nr_extents,
         .extent_order = extent_order,  
         .address_bits = 0,
         .domid        = domid
     };
+    SET_HANDLE(reservation.extent_start, extent_start); /* may be NULL */
 
     if ( extent_start == NULL )
     {
@@ -364,12 +364,12 @@ int xc_domain_memory_populate_physmap(in
 {
     int err;
     struct xen_memory_reservation reservation = {
-        .extent_start = extent_start,
         .nr_extents   = nr_extents,
         .extent_order = extent_order,
         .address_bits = address_bits,
         .domid        = domid
     };
+    SET_HANDLE(reservation.extent_start, extent_start); /* may be NULL */
 
     err = xc_memory_op(xc_handle, XENMEM_populate_physmap, &reservation);
     if ( err == nr_extents )
@@ -395,9 +395,9 @@ int xc_domain_translate_gpfn_list(int xc
     struct xen_translate_gpfn_list op = {
         .domid        = domid,
         .nr_gpfns     = nr_gpfns,
-        .gpfn_list    = gpfn_list,
-        .mfn_list     = mfn_list
     };
+    SET_HANDLE(op.gpfn_list, gpfn_list);
+    SET_HANDLE(op.mfn_list, mfn_list);
 
     return xc_memory_op(xc_handle, XENMEM_translate_gpfn_list, &op);
 }
@@ -467,7 +467,7 @@ int xc_vcpu_setcontext(int xc_handle,
     op.cmd = DOM0_SETVCPUCONTEXT;
     op.u.setvcpucontext.domain = domid;
     op.u.setvcpucontext.vcpu = vcpu;
-    op.u.setvcpucontext.ctxt = ctxt;
+    SET_HANDLE(op.u.setvcpucontext.ctxt, ctxt);
 
     if ( (rc = mlock(ctxt, sizeof(*ctxt))) != 0 )
         return rc;
diff -r 56e1802303e5 tools/libxc/xc_hvm_build.c
--- a/tools/libxc/xc_hvm_build.c	Wed Apr 12 15:41:55 2006 -0500
+++ b/tools/libxc/xc_hvm_build.c	Wed Apr 19 12:53:37 2006 -0500
@@ -440,7 +440,7 @@ static int xc_hvm_build_internal(int xc_
 
     launch_op.u.setvcpucontext.domain = (domid_t)domid;
     launch_op.u.setvcpucontext.vcpu   = 0;
-    launch_op.u.setvcpucontext.ctxt   = ctxt;
+    SET_HANDLE(launch_op.u.setvcpucontext.ctxt, ctxt);
 
     launch_op.cmd = DOM0_SETVCPUCONTEXT;
     rc = xc_dom0_op(xc_handle, &launch_op);
diff -r 56e1802303e5 tools/libxc/xc_linux_restore.c
--- a/tools/libxc/xc_linux_restore.c	Wed Apr 12 15:41:55 2006 -0500
+++ b/tools/libxc/xc_linux_restore.c	Wed Apr 19 12:53:37 2006 -0500
@@ -583,11 +583,11 @@ int xc_linux_restore(int xc_handle, int 
         if (count > 0) {
 
             struct xen_memory_reservation reservation = {
-                .extent_start = pfntab,
                 .nr_extents   = count,
                 .extent_order = 0,
                 .domid        = dom
             };
+            SET_HANDLE(reservation.extent_start, pfntab);
 
             if ((rc = xc_memory_op(xc_handle, XENMEM_decrease_reservation,
                                    &reservation)) != count) { 
@@ -727,7 +727,7 @@ int xc_linux_restore(int xc_handle, int 
     op.cmd = DOM0_SETVCPUCONTEXT;
     op.u.setvcpucontext.domain = (domid_t)dom;
     op.u.setvcpucontext.vcpu   = 0;
-    op.u.setvcpucontext.ctxt   = &ctxt;
+    SET_HANDLE(op.u.setvcpucontext.ctxt, &ctxt);
     rc = xc_dom0_op(xc_handle, &op);
 
     if (rc != 0) {
diff -r 56e1802303e5 tools/libxc/xc_linux_save.c
--- a/tools/libxc/xc_linux_save.c	Wed Apr 12 15:41:55 2006 -0500
+++ b/tools/libxc/xc_linux_save.c	Wed Apr 19 12:53:37 2006 -0500
@@ -509,16 +509,18 @@ static unsigned long *xc_map_m2p(int xc_
     privcmd_mmap_entry_t *entries; 
     unsigned long m2p_chunks, m2p_size; 
     unsigned long *m2p; 
+    unsigned long *extent_start; 
     int i, rc; 
 
     m2p_size   = M2P_SIZE(max_mfn); 
     m2p_chunks = M2P_CHUNKS(max_mfn); 
 
     xmml.max_extents = m2p_chunks;
-    if (!(xmml.extent_start = malloc(m2p_chunks * sizeof(unsigned long)))) { 
+    if (!(extent_start = malloc(m2p_chunks * sizeof(unsigned long)))) { 
         ERR("failed to allocate space for m2p mfns"); 
         return NULL; 
     } 
+    SET_HANDLE(xmml.extent_start, extent_start);
 
     if (xc_memory_op(xc_handle, XENMEM_machphys_mfn_list, &xmml) ||
         (xmml.nr_extents != m2p_chunks)) {
@@ -543,7 +545,7 @@ static unsigned long *xc_map_m2p(int xc_
     
     for (i=0; i < m2p_chunks; i++) { 
         entries[i].va = (unsigned long)(((void *)m2p) + (i * M2P_CHUNK_SIZE)); 
-        entries[i].mfn = xmml.extent_start[i];
+        entries[i].mfn = extent_start[i];
         entries[i].npages = M2P_CHUNK_SIZE >> PAGE_SHIFT;
     }
 
@@ -552,7 +554,7 @@ static unsigned long *xc_map_m2p(int xc_
         return NULL; 
     }
 
-    free(xmml.extent_start);
+    free(extent_start);
     free(entries); 
 
     return m2p; 
diff -r 56e1802303e5 tools/libxc/xc_misc.c
--- a/tools/libxc/xc_misc.c	Wed Apr 12 15:41:55 2006 -0500
+++ b/tools/libxc/xc_misc.c	Wed Apr 19 12:53:37 2006 -0500
@@ -30,7 +30,7 @@ int xc_readconsolering(int xc_handle,
     unsigned int nr_chars = *pnr_chars;
 
     op.cmd = DOM0_READCONSOLE;
-    op.u.readconsole.buffer = buffer;
+    SET_HANDLE(op.u.readconsole.buffer, buffer);
     op.u.readconsole.count  = nr_chars;
     op.u.readconsole.clear  = clear;
 
@@ -39,7 +39,7 @@ int xc_readconsolering(int xc_handle,
 
     if ( (ret = do_dom0_op(xc_handle, &op)) == 0 )
     {
-        *pbuffer   = op.u.readconsole.buffer;
+        GET_HANDLE(*pbuffer, op.u.readconsole.buffer);
         *pnr_chars = op.u.readconsole.count;
     }
 
@@ -91,7 +91,7 @@ int xc_perfc_control(int xc_handle,
 
     op.cmd = DOM0_PERFCCONTROL;
     op.u.perfccontrol.op   = opcode;
-    op.u.perfccontrol.desc = desc;
+    SET_HANDLE(op.u.perfccontrol.desc, desc);
 
     rc = do_dom0_op(xc_handle, &op);
 
diff -r 56e1802303e5 tools/libxc/xc_private.c
--- a/tools/libxc/xc_private.c	Wed Apr 12 15:41:55 2006 -0500
+++ b/tools/libxc/xc_private.c	Wed Apr 19 12:53:37 2006 -0500
@@ -71,7 +71,7 @@ int xc_get_pfn_type_batch(int xc_handle,
     op.cmd = DOM0_GETPAGEFRAMEINFO2;
     op.u.getpageframeinfo2.domain = (domid_t)dom;
     op.u.getpageframeinfo2.num    = num;
-    op.u.getpageframeinfo2.array  = arr;
+    SET_HANDLE(op.u.getpageframeinfo2.array, arr);
     return do_dom0_op(xc_handle, &op);
 }
 
@@ -191,6 +191,9 @@ int xc_memory_op(int xc_handle,
     struct xen_memory_reservation *reservation = arg;
     struct xen_machphys_mfn_list *xmml = arg;
     struct xen_translate_gpfn_list *trans = arg;
+    unsigned long *extent_start;
+    unsigned long *gpfn_list;
+    unsigned long *mfn_list;
     long ret = -EINVAL;
 
     hypercall.op     = __HYPERVISOR_memory_op;
@@ -207,8 +210,9 @@ int xc_memory_op(int xc_handle,
             PERROR("Could not mlock");
             goto out1;
         }
-        if ( (reservation->extent_start != NULL) &&
-             (mlock(reservation->extent_start,
+        GET_HANDLE(extent_start, reservation->extent_start);
+        if ( (extent_start != NULL) &&
+             (mlock(extent_start,
                     reservation->nr_extents * sizeof(unsigned long)) != 0) )
         {
             PERROR("Could not mlock");
@@ -222,7 +226,8 @@ int xc_memory_op(int xc_handle,
             PERROR("Could not mlock");
             goto out1;
         }
-        if ( mlock(xmml->extent_start,
+        GET_HANDLE(extent_start, reservation->extent_start);
+        if ( mlock(extent_start,
                    xmml->max_extents * sizeof(unsigned long)) != 0 )
         {
             PERROR("Could not mlock");
@@ -243,16 +248,18 @@ int xc_memory_op(int xc_handle,
             PERROR("Could not mlock");
             goto out1;
         }
-        if ( mlock(trans->gpfn_list, trans->nr_gpfns * sizeof(long)) != 0 )
+        GET_HANDLE(gpfn_list, trans->gpfn_list);
+        if ( mlock(gpfn_list, trans->nr_gpfns * sizeof(long)) != 0 )
         {
             PERROR("Could not mlock");
             safe_munlock(trans, sizeof(*trans));
             goto out1;
         }
-        if ( mlock(trans->mfn_list, trans->nr_gpfns * sizeof(long)) != 0 )
-        {
-            PERROR("Could not mlock");
-            safe_munlock(trans->gpfn_list, trans->nr_gpfns * sizeof(long));
+        GET_HANDLE(mfn_list, trans->mfn_list);
+        if ( mlock(mfn_list, trans->nr_gpfns * sizeof(long)) != 0 )
+        {
+            PERROR("Could not mlock");
+            safe_munlock(gpfn_list, trans->nr_gpfns * sizeof(long));
             safe_munlock(trans, sizeof(*trans));
             goto out1;
         }
@@ -267,21 +274,25 @@ int xc_memory_op(int xc_handle,
     case XENMEM_decrease_reservation:
     case XENMEM_populate_physmap:
         safe_munlock(reservation, sizeof(*reservation));
-        if ( reservation->extent_start != NULL )
-            safe_munlock(reservation->extent_start,
+        GET_HANDLE(extent_start, reservation->extent_start);
+        if ( extent_start != NULL )
+            safe_munlock(extent_start,
                          reservation->nr_extents * sizeof(unsigned long));
         break;
     case XENMEM_machphys_mfn_list:
         safe_munlock(xmml, sizeof(*xmml));
-        safe_munlock(xmml->extent_start,
+        GET_HANDLE(extent_start, reservation->extent_start);
+        safe_munlock(extent_start,
                      xmml->max_extents * sizeof(unsigned long));
         break;
     case XENMEM_add_to_physmap:
         safe_munlock(arg, sizeof(struct xen_add_to_physmap));
         break;
     case XENMEM_translate_gpfn_list:
-            safe_munlock(trans->mfn_list, trans->nr_gpfns * sizeof(long));
-            safe_munlock(trans->gpfn_list, trans->nr_gpfns * sizeof(long));
+            GET_HANDLE(mfn_list, trans->mfn_list);
+            safe_munlock(mfn_list, trans->nr_gpfns * sizeof(long));
+            GET_HANDLE(gpfn_list, trans->gpfn_list);
+            safe_munlock(gpfn_list, trans->nr_gpfns * sizeof(long));
             safe_munlock(trans, sizeof(*trans));
         break;
     }
@@ -317,7 +328,7 @@ int xc_get_pfn_list(int xc_handle,
     op.cmd = DOM0_GETMEMLIST;
     op.u.getmemlist.domain   = (domid_t)domid;
     op.u.getmemlist.max_pfns = max_pfns;
-    op.u.getmemlist.buffer   = pfn_buf;
+    SET_HANDLE(op.u.getmemlist.buffer, pfn_buf);
 
 #ifdef VALGRIND
     memset(pfn_buf, 0, max_pfns * sizeof(unsigned long));
diff -r 56e1802303e5 xen/include/public/arch-ia64.h
--- a/xen/include/public/arch-ia64.h	Wed Apr 12 15:41:55 2006 -0500
+++ b/xen/include/public/arch-ia64.h	Wed Apr 19 12:53:37 2006 -0500
@@ -7,16 +7,13 @@
 #ifndef __HYPERVISOR_IF_IA64_H__
 #define __HYPERVISOR_IF_IA64_H__
 
-#ifdef __XEN__
 #define __DEFINE_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
 
 #define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
 #define GUEST_HANDLE(name)        __guest_handle_ ## name
+#define SET_HANDLE(hnd, val)      do { (hnd).p = val; } while (0)
+#define GET_HANDLE(val, hnd)      do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
diff -r 56e1802303e5 xen/include/public/arch-x86_32.h
--- a/xen/include/public/arch-x86_32.h	Wed Apr 12 15:41:55 2006 -0500
+++ b/xen/include/public/arch-x86_32.h	Wed Apr 19 12:53:37 2006 -0500
@@ -9,16 +9,13 @@
 #ifndef __XEN_PUBLIC_ARCH_X86_32_H__
 #define __XEN_PUBLIC_ARCH_X86_32_H__
 
-#ifdef __XEN__
 #define __DEFINE_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
 
 #define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
 #define GUEST_HANDLE(name)        __guest_handle_ ## name
+#define SET_HANDLE(hnd, val)      do { (hnd).p = val; } while (0)
+#define GET_HANDLE(val, hnd)      do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
diff -r 56e1802303e5 xen/include/public/arch-x86_64.h
--- a/xen/include/public/arch-x86_64.h	Wed Apr 12 15:41:55 2006 -0500
+++ b/xen/include/public/arch-x86_64.h	Wed Apr 19 12:53:37 2006 -0500
@@ -9,16 +9,13 @@
 #ifndef __XEN_PUBLIC_ARCH_X86_64_H__
 #define __XEN_PUBLIC_ARCH_X86_64_H__
 
-#ifdef __XEN__
 #define __DEFINE_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
 
 #define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
 #define GUEST_HANDLE(name)        __guest_handle_ ## name
+#define SET_HANDLE(hnd, val)      do { (hnd).p = val; } while (0)
+#define GET_HANDLE(val, hnd)      do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
#3 lore raw
Quoted 8 lines · Hollis Blanchard
Quoted 6 lines · Hollis Blanchard

Third, the tools need to treat GUEST_HANDLEs specially.[4] The attached patch does this; I have a ppc32 app successfully making DOM0_GETVCPUCONTEXT hcalls to a ppc64 Xen. The patch has only been compile-tested on x86-32, so I would appreciate it if people could try it out on x86.

Quoted 4 lines

I noticed that I'd forgotten the corresponding ia64 and x86_64 changes, so this is the updated patch. Note that this overlaps with the frameno_t patch I just sent out; if both are acceptable, I would prefer that one goes in first and I can update and resend this one.

Since the other patch is still undergoing discussion, please commit this one. As suggested, I've changed the macro names to GET/SET_GUEST_HANDLE().

Signature · 402 lines
Hollis Blanchard
IBM Linux Technology Center

Introduce wrappers to access GUEST_HANDLES in libxc.

Signed-off-by: Hollis Blanchard <[email protected]>

diff -r ea6c5cf58588 tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c	Mon Apr 24 11:21:16 2006 +0100
+++ b/tools/libxc/xc_domain.c	Mon Apr 24 14:20:07 2006 -0500
@@ -171,7 +171,7 @@ int xc_domain_getinfolist(int xc_handle,
     op.cmd = DOM0_GETDOMAININFOLIST;
     op.u.getdomaininfolist.first_domain = first_domain;
     op.u.getdomaininfolist.max_domains  = max_domains;
-    op.u.getdomaininfolist.buffer       = info;
+    SET_GUEST_HANDLE(op.u.getdomaininfolist.buffer, info);
 
     if ( xc_dom0_op(xc_handle, &op) < 0 )
         ret = -1;
@@ -195,7 +195,7 @@ int xc_vcpu_getcontext(int xc_handle,
     op.cmd = DOM0_GETVCPUCONTEXT;
     op.u.getvcpucontext.domain = (domid_t)domid;
     op.u.getvcpucontext.vcpu   = (uint16_t)vcpu;
-    op.u.getvcpucontext.ctxt   = ctxt;
+    SET_GUEST_HANDLE(op.u.getvcpucontext.ctxt, ctxt);
 
     if ( (rc = mlock(ctxt, sizeof(*ctxt))) != 0 )
         return rc;
@@ -220,7 +220,7 @@ int xc_shadow_control(int xc_handle,
     op.cmd = DOM0_SHADOW_CONTROL;
     op.u.shadow_control.domain = (domid_t)domid;
     op.u.shadow_control.op     = sop;
-    op.u.shadow_control.dirty_bitmap = dirty_bitmap;
+    SET_GUEST_HANDLE(op.u.shadow_control.dirty_bitmap, dirty_bitmap);
     op.u.shadow_control.pages  = pages;
 
     rc = do_dom0_op(xc_handle, &op);
@@ -295,12 +295,12 @@ int xc_domain_memory_increase_reservatio
 {
     int err;
     struct xen_memory_reservation reservation = {
-        .extent_start = extent_start, /* may be NULL */
         .nr_extents   = nr_extents,
         .extent_order = extent_order,
         .address_bits = address_bits,
         .domid        = domid
     };
+    SET_GUEST_HANDLE(reservation.extent_start, extent_start); /* may be NULL */
 
     err = xc_memory_op(xc_handle, XENMEM_increase_reservation, &reservation);
     if ( err == nr_extents )
@@ -326,12 +326,12 @@ int xc_domain_memory_decrease_reservatio
 {
     int err;
     struct xen_memory_reservation reservation = {
-        .extent_start = extent_start,
         .nr_extents   = nr_extents,
         .extent_order = extent_order,
         .address_bits = 0,
         .domid        = domid
     };
+    SET_GUEST_HANDLE(reservation.extent_start, extent_start);
 
     if ( extent_start == NULL )
     {
@@ -364,12 +364,12 @@ int xc_domain_memory_populate_physmap(in
 {
     int err;
     struct xen_memory_reservation reservation = {
-        .extent_start = extent_start,
         .nr_extents   = nr_extents,
         .extent_order = extent_order,
         .address_bits = address_bits,
         .domid        = domid
     };
+    SET_GUEST_HANDLE(reservation.extent_start, extent_start); /* may be NULL */
 
     err = xc_memory_op(xc_handle, XENMEM_populate_physmap, &reservation);
     if ( err == nr_extents )
@@ -395,9 +395,9 @@ int xc_domain_translate_gpfn_list(int xc
     struct xen_translate_gpfn_list op = {
         .domid        = domid,
         .nr_gpfns     = nr_gpfns,
-        .gpfn_list    = gpfn_list,
-        .mfn_list     = mfn_list
     };
+    SET_GUEST_HANDLE(op.gpfn_list, gpfn_list);
+    SET_GUEST_HANDLE(op.mfn_list, mfn_list);
 
     return xc_memory_op(xc_handle, XENMEM_translate_gpfn_list, &op);
 }
@@ -467,7 +467,7 @@ int xc_vcpu_setcontext(int xc_handle,
     op.cmd = DOM0_SETVCPUCONTEXT;
     op.u.setvcpucontext.domain = domid;
     op.u.setvcpucontext.vcpu = vcpu;
-    op.u.setvcpucontext.ctxt = ctxt;
+    SET_GUEST_HANDLE(op.u.setvcpucontext.ctxt, ctxt);
 
     if ( (rc = mlock(ctxt, sizeof(*ctxt))) != 0 )
         return rc;
diff -r ea6c5cf58588 tools/libxc/xc_hvm_build.c
--- a/tools/libxc/xc_hvm_build.c	Mon Apr 24 11:21:16 2006 +0100
+++ b/tools/libxc/xc_hvm_build.c	Mon Apr 24 14:20:07 2006 -0500
@@ -440,7 +440,7 @@ static int xc_hvm_build_internal(int xc_
 
     launch_op.u.setvcpucontext.domain = (domid_t)domid;
     launch_op.u.setvcpucontext.vcpu   = 0;
-    launch_op.u.setvcpucontext.ctxt   = ctxt;
+    SET_GUEST_HANDLE(launch_op.u.setvcpucontext.ctxt, ctxt);
 
     launch_op.cmd = DOM0_SETVCPUCONTEXT;
     rc = xc_dom0_op(xc_handle, &launch_op);
diff -r ea6c5cf58588 tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c	Mon Apr 24 11:21:16 2006 +0100
+++ b/tools/libxc/xc_linux_build.c	Mon Apr 24 14:20:07 2006 -0500
@@ -1180,7 +1180,7 @@ static int xc_linux_build_internal(int x
 
     launch_op.u.setvcpucontext.domain = (domid_t)domid;
     launch_op.u.setvcpucontext.vcpu   = 0;
-    launch_op.u.setvcpucontext.ctxt   = ctxt;
+    SET_GUEST_HANDLE(launch_op.u.setvcpucontext.ctxt, ctxt);
 
     launch_op.cmd = DOM0_SETVCPUCONTEXT;
     rc = xc_dom0_op(xc_handle, &launch_op);
diff -r ea6c5cf58588 tools/libxc/xc_linux_restore.c
--- a/tools/libxc/xc_linux_restore.c	Mon Apr 24 11:21:16 2006 +0100
+++ b/tools/libxc/xc_linux_restore.c	Mon Apr 24 14:20:07 2006 -0500
@@ -583,11 +583,11 @@ int xc_linux_restore(int xc_handle, int 
         if (count > 0) {
 
             struct xen_memory_reservation reservation = {
-                .extent_start = pfntab,
                 .nr_extents   = count,
                 .extent_order = 0,
                 .domid        = dom
             };
+            SET_GUEST_HANDLE(reservation.extent_start, pfntab);
 
             if ((rc = xc_memory_op(xc_handle, XENMEM_decrease_reservation,
                                    &reservation)) != count) {
@@ -727,7 +727,7 @@ int xc_linux_restore(int xc_handle, int 
     op.cmd = DOM0_SETVCPUCONTEXT;
     op.u.setvcpucontext.domain = (domid_t)dom;
     op.u.setvcpucontext.vcpu   = 0;
-    op.u.setvcpucontext.ctxt   = &ctxt;
+    SET_GUEST_HANDLE(op.u.setvcpucontext.ctxt, &ctxt);
     rc = xc_dom0_op(xc_handle, &op);
 
     if (rc != 0) {
diff -r ea6c5cf58588 tools/libxc/xc_linux_save.c
--- a/tools/libxc/xc_linux_save.c	Mon Apr 24 11:21:16 2006 +0100
+++ b/tools/libxc/xc_linux_save.c	Mon Apr 24 14:20:07 2006 -0500
@@ -509,16 +509,18 @@ static unsigned long *xc_map_m2p(int xc_
     privcmd_mmap_entry_t *entries;
     unsigned long m2p_chunks, m2p_size;
     unsigned long *m2p;
+    unsigned long *extent_start;
     int i, rc;
 
     m2p_size   = M2P_SIZE(max_mfn);
     m2p_chunks = M2P_CHUNKS(max_mfn);
 
     xmml.max_extents = m2p_chunks;
-    if (!(xmml.extent_start = malloc(m2p_chunks * sizeof(unsigned long)))) {
+    if (!(extent_start = malloc(m2p_chunks * sizeof(unsigned long)))) {
         ERR("failed to allocate space for m2p mfns");
         return NULL;
     }
+    SET_GUEST_HANDLE(xmml.extent_start, extent_start);
 
     if (xc_memory_op(xc_handle, XENMEM_machphys_mfn_list, &xmml) ||
         (xmml.nr_extents != m2p_chunks)) {
@@ -543,7 +545,7 @@ static unsigned long *xc_map_m2p(int xc_
 
     for (i=0; i < m2p_chunks; i++) {
         entries[i].va = (unsigned long)(((void *)m2p) + (i * M2P_CHUNK_SIZE));
-        entries[i].mfn = xmml.extent_start[i];
+        entries[i].mfn = extent_start[i];
         entries[i].npages = M2P_CHUNK_SIZE >> PAGE_SHIFT;
     }
 
@@ -552,7 +554,7 @@ static unsigned long *xc_map_m2p(int xc_
         return NULL;
     }
 
-    free(xmml.extent_start);
+    free(extent_start);
     free(entries);
 
     return m2p;
diff -r ea6c5cf58588 tools/libxc/xc_misc.c
--- a/tools/libxc/xc_misc.c	Mon Apr 24 11:21:16 2006 +0100
+++ b/tools/libxc/xc_misc.c	Mon Apr 24 14:20:07 2006 -0500
@@ -30,7 +30,7 @@ int xc_readconsolering(int xc_handle,
     unsigned int nr_chars = *pnr_chars;
 
     op.cmd = DOM0_READCONSOLE;
-    op.u.readconsole.buffer = buffer;
+    SET_GUEST_HANDLE(op.u.readconsole.buffer, buffer);
     op.u.readconsole.count  = nr_chars;
     op.u.readconsole.clear  = clear;
 
@@ -39,7 +39,7 @@ int xc_readconsolering(int xc_handle,
 
     if ( (ret = do_dom0_op(xc_handle, &op)) == 0 )
     {
-        *pbuffer   = op.u.readconsole.buffer;
+        GET_GUEST_HANDLE(*pbuffer, op.u.readconsole.buffer);
         *pnr_chars = op.u.readconsole.count;
     }
 
@@ -91,7 +91,7 @@ int xc_perfc_control(int xc_handle,
 
     op.cmd = DOM0_PERFCCONTROL;
     op.u.perfccontrol.op   = opcode;
-    op.u.perfccontrol.desc = desc;
+    SET_GUEST_HANDLE(op.u.perfccontrol.desc, desc);
 
     rc = do_dom0_op(xc_handle, &op);
 
diff -r ea6c5cf58588 tools/libxc/xc_private.c
--- a/tools/libxc/xc_private.c	Mon Apr 24 11:21:16 2006 +0100
+++ b/tools/libxc/xc_private.c	Mon Apr 24 14:20:07 2006 -0500
@@ -71,7 +71,7 @@ int xc_get_pfn_type_batch(int xc_handle,
     op.cmd = DOM0_GETPAGEFRAMEINFO2;
     op.u.getpageframeinfo2.domain = (domid_t)dom;
     op.u.getpageframeinfo2.num    = num;
-    op.u.getpageframeinfo2.array  = arr;
+    SET_GUEST_HANDLE(op.u.getpageframeinfo2.array, arr);
     return do_dom0_op(xc_handle, &op);
 }
 
@@ -191,6 +191,9 @@ int xc_memory_op(int xc_handle,
     struct xen_memory_reservation *reservation = arg;
     struct xen_machphys_mfn_list *xmml = arg;
     struct xen_translate_gpfn_list *trans = arg;
+    unsigned long *extent_start;
+    unsigned long *gpfn_list;
+    unsigned long *mfn_list;
     long ret = -EINVAL;
 
     hypercall.op     = __HYPERVISOR_memory_op;
@@ -207,8 +210,9 @@ int xc_memory_op(int xc_handle,
             PERROR("Could not mlock");
             goto out1;
         }
-        if ( (reservation->extent_start != NULL) &&
-             (mlock(reservation->extent_start,
+        GET_GUEST_HANDLE(extent_start, reservation->extent_start);
+        if ( (extent_start != NULL) &&
+             (mlock(extent_start,
                     reservation->nr_extents * sizeof(unsigned long)) != 0) )
         {
             PERROR("Could not mlock");
@@ -222,7 +226,8 @@ int xc_memory_op(int xc_handle,
             PERROR("Could not mlock");
             goto out1;
         }
-        if ( mlock(xmml->extent_start,
+        GET_GUEST_HANDLE(extent_start, reservation->extent_start);
+        if ( mlock(extent_start,
                    xmml->max_extents * sizeof(unsigned long)) != 0 )
         {
             PERROR("Could not mlock");
@@ -243,16 +248,18 @@ int xc_memory_op(int xc_handle,
             PERROR("Could not mlock");
             goto out1;
         }
-        if ( mlock(trans->gpfn_list, trans->nr_gpfns * sizeof(long)) != 0 )
+        GET_GUEST_HANDLE(gpfn_list, trans->gpfn_list);
+        if ( mlock(gpfn_list, trans->nr_gpfns * sizeof(long)) != 0 )
         {
             PERROR("Could not mlock");
             safe_munlock(trans, sizeof(*trans));
             goto out1;
         }
-        if ( mlock(trans->mfn_list, trans->nr_gpfns * sizeof(long)) != 0 )
-        {
-            PERROR("Could not mlock");
-            safe_munlock(trans->gpfn_list, trans->nr_gpfns * sizeof(long));
+        GET_GUEST_HANDLE(mfn_list, trans->mfn_list);
+        if ( mlock(mfn_list, trans->nr_gpfns * sizeof(long)) != 0 )
+        {
+            PERROR("Could not mlock");
+            safe_munlock(gpfn_list, trans->nr_gpfns * sizeof(long));
             safe_munlock(trans, sizeof(*trans));
             goto out1;
         }
@@ -267,21 +274,25 @@ int xc_memory_op(int xc_handle,
     case XENMEM_decrease_reservation:
     case XENMEM_populate_physmap:
         safe_munlock(reservation, sizeof(*reservation));
-        if ( reservation->extent_start != NULL )
-            safe_munlock(reservation->extent_start,
+        GET_GUEST_HANDLE(extent_start, reservation->extent_start);
+        if ( extent_start != NULL )
+            safe_munlock(extent_start,
                          reservation->nr_extents * sizeof(unsigned long));
         break;
     case XENMEM_machphys_mfn_list:
         safe_munlock(xmml, sizeof(*xmml));
-        safe_munlock(xmml->extent_start,
+        GET_GUEST_HANDLE(extent_start, reservation->extent_start);
+        safe_munlock(extent_start,
                      xmml->max_extents * sizeof(unsigned long));
         break;
     case XENMEM_add_to_physmap:
         safe_munlock(arg, sizeof(struct xen_add_to_physmap));
         break;
     case XENMEM_translate_gpfn_list:
-            safe_munlock(trans->mfn_list, trans->nr_gpfns * sizeof(long));
-            safe_munlock(trans->gpfn_list, trans->nr_gpfns * sizeof(long));
+            GET_GUEST_HANDLE(mfn_list, trans->mfn_list);
+            safe_munlock(mfn_list, trans->nr_gpfns * sizeof(long));
+            GET_GUEST_HANDLE(gpfn_list, trans->gpfn_list);
+            safe_munlock(gpfn_list, trans->nr_gpfns * sizeof(long));
             safe_munlock(trans, sizeof(*trans));
         break;
     }
@@ -317,7 +328,7 @@ int xc_get_pfn_list(int xc_handle,
     op.cmd = DOM0_GETMEMLIST;
     op.u.getmemlist.domain   = (domid_t)domid;
     op.u.getmemlist.max_pfns = max_pfns;
-    op.u.getmemlist.buffer   = pfn_buf;
+    SET_GUEST_HANDLE(op.u.getmemlist.buffer, pfn_buf);
 
 #ifdef VALGRIND
     memset(pfn_buf, 0, max_pfns * sizeof(unsigned long));
diff -r ea6c5cf58588 xen/include/public/arch-ia64.h
--- a/xen/include/public/arch-ia64.h	Mon Apr 24 11:21:16 2006 +0100
+++ b/xen/include/public/arch-ia64.h	Mon Apr 24 14:20:07 2006 -0500
@@ -7,16 +7,13 @@
 #ifndef __HYPERVISOR_IF_IA64_H__
 #define __HYPERVISOR_IF_IA64_H__
 
-#ifdef __XEN__
 #define __DEFINE_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
-
-#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
-#define GUEST_HANDLE(name)        __guest_handle_ ## name
+
+#define DEFINE_GUEST_HANDLE(name)   __DEFINE_GUEST_HANDLE(name, name)
+#define GUEST_HANDLE(name)          __guest_handle_ ## name
+#define SET_GUEST_HANDLE(hnd, val)  do { (hnd).p = val; } while (0)
+#define GET_GUEST_HANDLE(val, hnd)  do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
diff -r ea6c5cf58588 xen/include/public/arch-x86_32.h
--- a/xen/include/public/arch-x86_32.h	Mon Apr 24 11:21:16 2006 +0100
+++ b/xen/include/public/arch-x86_32.h	Mon Apr 24 14:20:07 2006 -0500
@@ -9,16 +9,13 @@
 #ifndef __XEN_PUBLIC_ARCH_X86_32_H__
 #define __XEN_PUBLIC_ARCH_X86_32_H__
 
-#ifdef __XEN__
 #define __DEFINE_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
 
-#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
-#define GUEST_HANDLE(name)        __guest_handle_ ## name
+#define DEFINE_GUEST_HANDLE(name)   __DEFINE_GUEST_HANDLE(name, name)
+#define GUEST_HANDLE(name)          __guest_handle_ ## name
+#define SET_GUEST_HANDLE(hnd, val)  do { (hnd).p = val; } while (0)
+#define GET_GUEST_HANDLE(val, hnd)  do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
diff -r ea6c5cf58588 xen/include/public/arch-x86_64.h
--- a/xen/include/public/arch-x86_64.h	Mon Apr 24 11:21:16 2006 +0100
+++ b/xen/include/public/arch-x86_64.h	Mon Apr 24 14:20:07 2006 -0500
@@ -9,16 +9,13 @@
 #ifndef __XEN_PUBLIC_ARCH_X86_64_H__
 #define __XEN_PUBLIC_ARCH_X86_64_H__
 
-#ifdef __XEN__
 #define __DEFINE_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
-
-#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
-#define GUEST_HANDLE(name)        __guest_handle_ ## name
+
+#define DEFINE_GUEST_HANDLE(name)   __DEFINE_GUEST_HANDLE(name, name)
+#define GUEST_HANDLE(name)          __guest_handle_ ## name
+#define SET_GUEST_HANDLE(hnd, val)  do { (hnd).p = val; } while (0)
+#define GET_GUEST_HANDLE(val, hnd)  do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
#4 lore raw
Quoted 3 lines · Hollis Blanchard

Since the other patch is still undergoing discussion, please commit this one. As suggested, I've changed the macro names to GET/SET_GUEST_HANDLE().

This patch will unconditionally use the 'structural' definition of guest handles for tools and kernels as well as Xen, right? Can XenLinux for x86/ia64 still build with this patch, without needing a bunch of GET/SET_GUEST_HANDLE changes?

-- Keir

#5 lore raw
Quoted 11 lines · Keir Fraser
Quoted 4 lines · Hollis Blanchard

Since the other patch is still undergoing discussion, please commit this
one. As suggested, I've changed the macro names to GET/SET_GUEST_HANDLE().

This patch will unconditionally use the 'structural' definition of guest handles for tools and kernels as well as Xen, right? Can XenLinux for x86/ia64 still build with this patch, without needing a bunch of GET/SET_GUEST_HANDLE changes?

Sorry, you're right. Attached are three patches: the Xen patch, the linux-2.6-merge patch, and the linux-2.6-sparse patch.

Signature · 7 lines
Hollis Blanchard
IBM Linux Technology Center


Introduce wrappers to access GUEST_HANDLES in libxc and Linux.

Signed-off-by: Hollis Blanchard <[email protected]>
tools/libxc/xc_domain.c +9 -9
diff -r 56e1802303e5 tools/libxc/xc_domain.c
@@ -171,7 +171,7 @@ int xc_domain_getinfolist(int xc_handle,
     op.cmd = DOM0_GETDOMAININFOLIST;
     op.u.getdomaininfolist.first_domain = first_domain;
     op.u.getdomaininfolist.max_domains  = max_domains;
-    op.u.getdomaininfolist.buffer       = info;
+    SET_GUEST_HANDLE(op.u.getdomaininfolist.buffer, info);
 
     if ( xc_dom0_op(xc_handle, &op) < 0 )
         ret = -1;
@@ -195,7 +195,7 @@ int xc_vcpu_getcontext(int xc_handle,
     op.cmd = DOM0_GETVCPUCONTEXT;
     op.u.getvcpucontext.domain = (domid_t)domid;
     op.u.getvcpucontext.vcpu   = (uint16_t)vcpu;
-    op.u.getvcpucontext.ctxt   = ctxt;
+    SET_GUEST_HANDLE(op.u.getvcpucontext.ctxt, ctxt);
 
     if ( (rc = mlock(ctxt, sizeof(*ctxt))) != 0 )
         return rc;
@@ -220,7 +220,7 @@ int xc_shadow_control(int xc_handle,
     op.cmd = DOM0_SHADOW_CONTROL;
     op.u.shadow_control.domain = (domid_t)domid;
     op.u.shadow_control.op     = sop;
-    op.u.shadow_control.dirty_bitmap = dirty_bitmap;
+    SET_GUEST_HANDLE(op.u.shadow_control.dirty_bitmap, dirty_bitmap);
     op.u.shadow_control.pages  = pages;
 
     rc = do_dom0_op(xc_handle, &op);
@@ -295,12 +295,12 @@ int xc_domain_memory_increase_reservatio
 {
     int err;
     struct xen_memory_reservation reservation = {
-        .extent_start = extent_start, /* may be NULL */
         .nr_extents   = nr_extents,
         .extent_order = extent_order,  
         .address_bits = address_bits,
         .domid        = domid
     };
+    SET_GUEST_HANDLE(reservation.extent_start, extent_start); /* may be NULL */
 
     err = xc_memory_op(xc_handle, XENMEM_increase_reservation, &reservation);
     if ( err == nr_extents )
@@ -326,12 +326,12 @@ int xc_domain_memory_decrease_reservatio
 {
     int err;
     struct xen_memory_reservation reservation = {
-        .extent_start = extent_start, 
         .nr_extents   = nr_extents,
         .extent_order = extent_order,  
         .address_bits = 0,
         .domid        = domid
     };
+    SET_GUEST_HANDLE(reservation.extent_start, extent_start);
 
     if ( extent_start == NULL )
     {
@@ -364,12 +364,12 @@ int xc_domain_memory_populate_physmap(in
 {
     int err;
     struct xen_memory_reservation reservation = {
-        .extent_start = extent_start,
         .nr_extents   = nr_extents,
         .extent_order = extent_order,
         .address_bits = address_bits,
         .domid        = domid
     };
+    SET_GUEST_HANDLE(reservation.extent_start, extent_start); /* may be NULL */
 
     err = xc_memory_op(xc_handle, XENMEM_populate_physmap, &reservation);
     if ( err == nr_extents )
@@ -395,9 +395,9 @@ int xc_domain_translate_gpfn_list(int xc
     struct xen_translate_gpfn_list op = {
         .domid        = domid,
         .nr_gpfns     = nr_gpfns,
-        .gpfn_list    = gpfn_list,
-        .mfn_list     = mfn_list
     };
+    SET_GUEST_HANDLE(op.gpfn_list, gpfn_list);
+    SET_GUEST_HANDLE(op.mfn_list, mfn_list);
 
     return xc_memory_op(xc_handle, XENMEM_translate_gpfn_list, &op);
 }
@@ -467,7 +467,7 @@ int xc_vcpu_setcontext(int xc_handle,
     op.cmd = DOM0_SETVCPUCONTEXT;
     op.u.setvcpucontext.domain = domid;
     op.u.setvcpucontext.vcpu = vcpu;
-    op.u.setvcpucontext.ctxt = ctxt;
+    SET_GUEST_HANDLE(op.u.setvcpucontext.ctxt, ctxt);
 
     if ( (rc = mlock(ctxt, sizeof(*ctxt))) != 0 )
         return rc;
tools/libxc/xc_hvm_build.c +1 -1
diff -r 56e1802303e5 tools/libxc/xc_hvm_build.c
@@ -440,7 +440,7 @@ static int xc_hvm_build_internal(int xc_
 
     launch_op.u.setvcpucontext.domain = (domid_t)domid;
     launch_op.u.setvcpucontext.vcpu   = 0;
-    launch_op.u.setvcpucontext.ctxt   = ctxt;
+    SET_GUEST_HANDLE(launch_op.u.setvcpucontext.ctxt, ctxt);
 
     launch_op.cmd = DOM0_SETVCPUCONTEXT;
     rc = xc_dom0_op(xc_handle, &launch_op);
tools/libxc/xc_linux_build.c +1 -1
diff -r 56e1802303e5 tools/libxc/xc_linux_build.c
@@ -1180,7 +1180,7 @@ static int xc_linux_build_internal(int x
 
     launch_op.u.setvcpucontext.domain = (domid_t)domid;
     launch_op.u.setvcpucontext.vcpu   = 0;
-    launch_op.u.setvcpucontext.ctxt   = ctxt;
+    SET_GUEST_HANDLE(launch_op.u.setvcpucontext.ctxt, ctxt);
 
     launch_op.cmd = DOM0_SETVCPUCONTEXT;
     rc = xc_dom0_op(xc_handle, &launch_op);
tools/libxc/xc_linux_restore.c +2 -2
diff -r 56e1802303e5 tools/libxc/xc_linux_restore.c
@@ -583,11 +583,11 @@ int xc_linux_restore(int xc_handle, int 
         if (count > 0) {
 
             struct xen_memory_reservation reservation = {
-                .extent_start = pfntab,
                 .nr_extents   = count,
                 .extent_order = 0,
                 .domid        = dom
             };
+            SET_GUEST_HANDLE(reservation.extent_start, pfntab);
 
             if ((rc = xc_memory_op(xc_handle, XENMEM_decrease_reservation,
                                    &reservation)) != count) { 
@@ -727,7 +727,7 @@ int xc_linux_restore(int xc_handle, int 
     op.cmd = DOM0_SETVCPUCONTEXT;
     op.u.setvcpucontext.domain = (domid_t)dom;
     op.u.setvcpucontext.vcpu   = 0;
-    op.u.setvcpucontext.ctxt   = &ctxt;
+    SET_GUEST_HANDLE(op.u.setvcpucontext.ctxt, &ctxt);
     rc = xc_dom0_op(xc_handle, &op);
 
     if (rc != 0) {
tools/libxc/xc_linux_save.c +5 -3
diff -r 56e1802303e5 tools/libxc/xc_linux_save.c
@@ -509,16 +509,18 @@ static unsigned long *xc_map_m2p(int xc_
     privcmd_mmap_entry_t *entries; 
     unsigned long m2p_chunks, m2p_size; 
     unsigned long *m2p; 
+    unsigned long *extent_start;
     int i, rc; 
 
     m2p_size   = M2P_SIZE(max_mfn); 
     m2p_chunks = M2P_CHUNKS(max_mfn); 
 
     xmml.max_extents = m2p_chunks;
-    if (!(xmml.extent_start = malloc(m2p_chunks * sizeof(unsigned long)))) { 
+    if (!(extent_start = malloc(m2p_chunks * sizeof(unsigned long)))) {
         ERR("failed to allocate space for m2p mfns"); 
         return NULL; 
     } 
+    SET_GUEST_HANDLE(xmml.extent_start, extent_start);
 
     if (xc_memory_op(xc_handle, XENMEM_machphys_mfn_list, &xmml) ||
         (xmml.nr_extents != m2p_chunks)) {
@@ -543,7 +545,7 @@ static unsigned long *xc_map_m2p(int xc_
     
     for (i=0; i < m2p_chunks; i++) { 
         entries[i].va = (unsigned long)(((void *)m2p) + (i * M2P_CHUNK_SIZE)); 
-        entries[i].mfn = xmml.extent_start[i];
+        entries[i].mfn = extent_start[i];
         entries[i].npages = M2P_CHUNK_SIZE >> PAGE_SHIFT;
     }
 
@@ -552,7 +554,7 @@ static unsigned long *xc_map_m2p(int xc_
         return NULL; 
     }
 
-    free(xmml.extent_start);
+    free(extent_start);
     free(entries); 
 
     return m2p; 
tools/libxc/xc_misc.c +3 -3
diff -r 56e1802303e5 tools/libxc/xc_misc.c
@@ -30,7 +30,7 @@ int xc_readconsolering(int xc_handle,
     unsigned int nr_chars = *pnr_chars;
 
     op.cmd = DOM0_READCONSOLE;
-    op.u.readconsole.buffer = buffer;
+    SET_GUEST_HANDLE(op.u.readconsole.buffer, buffer);
     op.u.readconsole.count  = nr_chars;
     op.u.readconsole.clear  = clear;
 
@@ -39,7 +39,7 @@ int xc_readconsolering(int xc_handle,
 
     if ( (ret = do_dom0_op(xc_handle, &op)) == 0 )
     {
-        *pbuffer   = op.u.readconsole.buffer;
+        GET_GUEST_HANDLE(*pbuffer, op.u.readconsole.buffer);
         *pnr_chars = op.u.readconsole.count;
     }
 
@@ -91,7 +91,7 @@ int xc_perfc_control(int xc_handle,
 
     op.cmd = DOM0_PERFCCONTROL;
     op.u.perfccontrol.op   = opcode;
-    op.u.perfccontrol.desc = desc;
+    SET_GUEST_HANDLE(op.u.perfccontrol.desc, desc);
 
     rc = do_dom0_op(xc_handle, &op);
 
tools/libxc/xc_private.c +26 -15

98 lines not on this page · raw message

xen/include/public/arch-ia64.h +5 -8
diff -r 56e1802303e5 xen/include/public/arch-ia64.h
@@ -7,16 +7,13 @@
 #ifndef __HYPERVISOR_IF_IA64_H__
 #define __HYPERVISOR_IF_IA64_H__
 
-#ifdef __XEN__
 #define __DEFINE_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
-
-#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
-#define GUEST_HANDLE(name)        __guest_handle_ ## name
+
+#define DEFINE_GUEST_HANDLE(name)   __DEFINE_GUEST_HANDLE(name, name)
+#define GUEST_HANDLE(name)          __guest_handle_ ## name
+#define SET_GUEST_HANDLE(hnd, val)  do { (hnd).p = val; } while (0)
+#define GET_GUEST_HANDLE(val, hnd)  do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
xen/include/public/arch-x86_32.h +4 -7
diff -r 56e1802303e5 xen/include/public/arch-x86_32.h
@@ -9,16 +9,13 @@
 #ifndef __XEN_PUBLIC_ARCH_X86_32_H__
 #define __XEN_PUBLIC_ARCH_X86_32_H__
 
-#ifdef __XEN__
 #define __DEFINE_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
 
-#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
-#define GUEST_HANDLE(name)        __guest_handle_ ## name
+#define DEFINE_GUEST_HANDLE(name)   __DEFINE_GUEST_HANDLE(name, name)
+#define GUEST_HANDLE(name)          __guest_handle_ ## name
+#define SET_GUEST_HANDLE(hnd, val)  do { (hnd).p = val; } while (0)
+#define GET_GUEST_HANDLE(val, hnd)  do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
xen/include/public/arch-x86_64.h +5 -8
diff -r 56e1802303e5 xen/include/public/arch-x86_64.h
@@ -9,16 +9,13 @@
 #ifndef __XEN_PUBLIC_ARCH_X86_64_H__
 #define __XEN_PUBLIC_ARCH_X86_64_H__
 
-#ifdef __XEN__
 #define __DEFINE_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
-
-#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
-#define GUEST_HANDLE(name)        __guest_handle_ ## name
+
+#define DEFINE_GUEST_HANDLE(name)   __DEFINE_GUEST_HANDLE(name, name)
+#define GUEST_HANDLE(name)          __guest_handle_ ## name
+#define SET_GUEST_HANDLE(hnd, val)  do { (hnd).p = val; } while (0)
+#define GET_GUEST_HANDLE(val, hnd)  do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
arch/i386/kernel/microcode-xen.c +1 -1
diff -r 3c49a47b866f arch/i386/kernel/microcode-xen.c
@@ -70,7 +70,7 @@ static int do_microcode_update (void)
 		return err;
 
 	op.cmd = DOM0_MICROCODE;
-	op.u.microcode.data = user_buffer;
+	SET_GUEST_HANDLE(op.u.microcode.data, user_buffer);
 	op.u.microcode.length = user_buffer_size;
 	err = HYPERVISOR_dom0_op(&op);
 
arch/i386/kernel/setup-xen.c +1 -1
diff -r 3c49a47b866f arch/i386/kernel/setup-xen.c
@@ -1371,7 +1371,7 @@ legacy_init_iomem_resources(struct resou
 #ifdef CONFIG_XEN
 	map = alloc_bootmem_low_pages(PAGE_SIZE);
 	op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
-	op.u.physical_memory_map.memory_map = map;
+	SET_GUEST_HANDLE(op.u.physical_memory_map.memory_map, map);
 	op.u.physical_memory_map.max_map_entries =
 		PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
 	BUG_ON(HYPERVISOR_dom0_op(&op));
arch/i386/mm/hypervisor.c +2 -2
diff -r 3c49a47b866f arch/i386/mm/hypervisor.c
@@ -271,11 +271,11 @@ int xen_create_contiguous_region(
 	pte_t         *pte;
 	unsigned long  frame, i, flags;
 	struct xen_memory_reservation reservation = {
-		.extent_start = &frame,
 		.nr_extents   = 1,
 		.extent_order = 0,
 		.domid        = DOMID_SELF
 	};
+	SET_GUEST_HANDLE(reservation.extent_start, &frame);
 
 	/*
 	 * Currently an auto-translated guest will not perform I/O, nor will
@@ -357,11 +357,11 @@ void xen_destroy_contiguous_region(unsig
 	pte_t         *pte;
 	unsigned long  frame, i, flags;
 	struct xen_memory_reservation reservation = {
-		.extent_start = &frame,
 		.nr_extents   = 1,
 		.extent_order = 0,
 		.domid        = DOMID_SELF
 	};
+	SET_GUEST_HANDLE(reservation.extent_start, &frame);
 
 	if (xen_feature(XENFEAT_auto_translated_physmap))
 		return;
arch/x86_64/kernel/e820-xen.c +1 -1
diff -r 3c49a47b866f arch/x86_64/kernel/e820-xen.c
@@ -600,7 +600,7 @@ void __init e820_reserve_resources(void)
 
 	map = alloc_bootmem_low_pages(PAGE_SIZE);
 	op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
-	op.u.physical_memory_map.memory_map = map;
+	SET_GUEST_HANDLE(op.u.physical_memory_map.memory_map, map);
 	op.u.physical_memory_map.max_map_entries =
 		PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
 	BUG_ON(HYPERVISOR_dom0_op(&op));
drivers/xen/balloon/balloon.c +4 -4
diff -r 3c49a47b866f drivers/xen/balloon/balloon.c
@@ -195,14 +195,14 @@ static int increase_reservation(unsigned
 		page = balloon_next_page(page);
 	}
 
-	reservation.extent_start = frame_list;
+	SET_GUEST_HANDLE(reservation.extent_start, frame_list);
 	reservation.nr_extents   = nr_pages;
 	rc = HYPERVISOR_memory_op(
 		XENMEM_populate_physmap, &reservation);
 	if (rc < nr_pages) {
 		int ret;
 		/* We hit the Xen hard limit: reprobe. */
-		reservation.extent_start = frame_list;
+		SET_GUEST_HANDLE(reservation.extent_start, frame_list);
 		reservation.nr_extents   = rc;
 		ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
 				&reservation);
@@ -308,7 +308,7 @@ static int decrease_reservation(unsigned
 		balloon_append(pfn_to_page(pfn));
 	}
 
-	reservation.extent_start = frame_list;
+	SET_GUEST_HANDLE(reservation.extent_start, frame_list);
 	reservation.nr_extents   = nr_pages;
 	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
 	BUG_ON(ret != nr_pages);
@@ -522,11 +522,11 @@ static int dealloc_pte_fn(
 	unsigned long mfn = pte_mfn(*pte);
 	int ret;
 	struct xen_memory_reservation reservation = {
-		.extent_start = &mfn,
 		.nr_extents   = 1,
 		.extent_order = 0,
 		.domid        = DOMID_SELF
 	};
+	SET_GUEST_HANDLE(reservation.extent_start, &mfn);
 	set_pte_at(&init_mm, addr, pte, __pte_ma(0));
 	set_phys_to_machine(__pa(addr) >> PAGE_SHIFT, INVALID_P2M_ENTRY);
 	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
drivers/xen/core/gnttab.c +1 -1
diff -r 3c49a47b866f drivers/xen/core/gnttab.c
@@ -392,7 +392,7 @@ gnttab_resume(void)
 
 	setup.dom        = DOMID_SELF;
 	setup.nr_frames  = NR_GRANT_FRAMES;
-	setup.frame_list = frames;
+	SET_GUEST_HANDLE(setup.frame_list, frames);
 
 	rc = HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
 	BUG_ON(rc || setup.status);
drivers/xen/netback/netback.c +1 -1
diff -r 3c49a47b866f drivers/xen/netback/netback.c
@@ -105,11 +105,11 @@ static unsigned long alloc_mfn(void)
 {
 	unsigned long mfn = 0, flags;
 	struct xen_memory_reservation reservation = {
-		.extent_start = mfn_list,
 		.nr_extents   = MAX_MFN_ALLOC,
 		.extent_order = 0,
 		.domid        = DOMID_SELF
 	};
+	SET_GUEST_HANDLE(reservation.extent_start, mfn_list);
 	spin_lock_irqsave(&mfn_lock, flags);
 	if ( unlikely(alloc_index == 0) )
 		alloc_index = HYPERVISOR_memory_op(
drivers/xen/netfront/netfront.c +1 -1
diff -r 3c49a47b866f drivers/xen/netfront/netfront.c
@@ -610,7 +610,7 @@ static void network_alloc_rx_buffers(str
 	/* Tell the ballon driver what is going on. */
 	balloon_update_driver_allowance(i);
 
-	reservation.extent_start = np->rx_pfn_array;
+	SET_GUEST_HANDLE(reservation.extent_start, np->rx_pfn_array);
 	reservation.nr_extents   = i;
 	reservation.extent_order = 0;
 	reservation.address_bits = 0;
include/asm-i386/hypercall.h +5 -4
diff -r 3c49a47b866f include/asm-i386/hypercall.h
@@ -189,13 +189,14 @@ HYPERVISOR_poll(
 	evtchn_port_t *ports, unsigned int nr_ports, u64 timeout)
 {
 	struct sched_poll sched_poll = {
-		.ports = ports,
 		.nr_ports = nr_ports,
 		.timeout = jiffies_to_st(timeout)
 	};
-
-	int rc = HYPERVISOR_sched_op_new(SCHEDOP_poll, &sched_poll);
-
+	int rc;
+
+	SET_GUEST_HANDLE(sched_poll.ports, ports);
+
+	rc = HYPERVISOR_sched_op_new(SCHEDOP_poll, &sched_poll);
 	if (rc == -ENOSYS)
 		rc = HYPERVISOR_sched_op(SCHEDOP_yield, 0);
 
include/xen/interface/arch-ia64.h +5 -8
diff -r 3c49a47b866f include/xen/interface/arch-ia64.h
@@ -7,16 +7,13 @@
 #ifndef __HYPERVISOR_IF_IA64_H__
 #define __HYPERVISOR_IF_IA64_H__
 
-#ifdef __XEN__
 #define __DEFINE_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
-
-#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
-#define GUEST_HANDLE(name)        __guest_handle_ ## name
+
+#define DEFINE_GUEST_HANDLE(name)   __DEFINE_GUEST_HANDLE(name, name)
+#define GUEST_HANDLE(name)          __guest_handle_ ## name
+#define SET_GUEST_HANDLE(hnd, val)  do { (hnd).p = val; } while (0)
+#define GET_GUEST_HANDLE(val, hnd)  do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
include/xen/interface/arch-x86_32.h +4 -7
diff -r 3c49a47b866f include/xen/interface/arch-x86_32.h
@@ -9,16 +9,13 @@
 #ifndef __XEN_PUBLIC_ARCH_X86_32_H__
 #define __XEN_PUBLIC_ARCH_X86_32_H__
 
-#ifdef __XEN__
 #define __DEFINE_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
 
-#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
-#define GUEST_HANDLE(name)        __guest_handle_ ## name
+#define DEFINE_GUEST_HANDLE(name)   __DEFINE_GUEST_HANDLE(name, name)
+#define GUEST_HANDLE(name)          __guest_handle_ ## name
+#define SET_GUEST_HANDLE(hnd, val)  do { (hnd).p = val; } while (0)
+#define GET_GUEST_HANDLE(val, hnd)  do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
include/xen/interface/arch-x86_64.h +5 -8
diff -r 3c49a47b866f include/xen/interface/arch-x86_64.h
@@ -9,16 +9,13 @@
 #ifndef __XEN_PUBLIC_ARCH_X86_64_H__
 #define __XEN_PUBLIC_ARCH_X86_64_H__
 
-#ifdef __XEN__
 #define __DEFINE_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
-
-#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
-#define GUEST_HANDLE(name)        __guest_handle_ ## name
+
+#define DEFINE_GUEST_HANDLE(name)   __DEFINE_GUEST_HANDLE(name, name)
+#define GUEST_HANDLE(name)          __guest_handle_ ## name
+#define SET_GUEST_HANDLE(hnd, val)  do { (hnd).p = val; } while (0)
+#define GET_GUEST_HANDLE(val, hnd)  do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c +1 -1
diff -r 61d8ff110da9 linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c
@@ -70,7 +70,7 @@ static int do_microcode_update (void)
 		return err;
 
 	op.cmd = DOM0_MICROCODE;
-	op.u.microcode.data = user_buffer;
+	SET_GUEST_HANDLE(op.u.microcode.data, user_buffer);
 	op.u.microcode.length = user_buffer_size;
 	err = HYPERVISOR_dom0_op(&op);
 
linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c +1 -1
diff -r 61d8ff110da9 linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c
@@ -1368,7 +1368,7 @@ legacy_init_iomem_resources(struct resou
 #ifdef CONFIG_XEN
 	map = alloc_bootmem_low_pages(PAGE_SIZE);
 	op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
-	op.u.physical_memory_map.memory_map = map;
+	SET_GUEST_HANDLE(op.u.physical_memory_map.memory_map, map);
 	op.u.physical_memory_map.max_map_entries =
 		PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
 	BUG_ON(HYPERVISOR_dom0_op(&op));
linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c +2 -2
diff -r 61d8ff110da9 linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c
@@ -271,11 +271,11 @@ int xen_create_contiguous_region(
 	pte_t         *pte;
 	unsigned long  frame, i, flags;
 	struct xen_memory_reservation reservation = {
-		.extent_start = &frame,
 		.nr_extents   = 1,
 		.extent_order = 0,
 		.domid        = DOMID_SELF
 	};
+	SET_GUEST_HANDLE(reservation.extent_start, &frame);
 
 	/*
 	 * Currently an auto-translated guest will not perform I/O, nor will
@@ -357,11 +357,11 @@ void xen_destroy_contiguous_region(unsig
 	pte_t         *pte;
 	unsigned long  frame, i, flags;
 	struct xen_memory_reservation reservation = {
-		.extent_start = &frame,
 		.nr_extents   = 1,
 		.extent_order = 0,
 		.domid        = DOMID_SELF
 	};
+	SET_GUEST_HANDLE(reservation.extent_start, &frame);
 
 	if (xen_feature(XENFEAT_auto_translated_physmap))
 		return;
linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c +1 -1
diff -r 61d8ff110da9 linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c
@@ -600,7 +600,7 @@ void __init e820_reserve_resources(void)
 
 	map = alloc_bootmem_low_pages(PAGE_SIZE);
 	op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
-	op.u.physical_memory_map.memory_map = map;
+	SET_GUEST_HANDLE(op.u.physical_memory_map.memory_map, map);
 	op.u.physical_memory_map.max_map_entries =
 		PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
 	BUG_ON(HYPERVISOR_dom0_op(&op));
linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c +4 -4
diff -r 61d8ff110da9 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
@@ -195,14 +195,14 @@ static int increase_reservation(unsigned
 		page = balloon_next_page(page);
 	}
 
-	reservation.extent_start = frame_list;
+	SET_GUEST_HANDLE(reservation.extent_start, frame_list);
 	reservation.nr_extents   = nr_pages;
 	rc = HYPERVISOR_memory_op(
 		XENMEM_populate_physmap, &reservation);
 	if (rc < nr_pages) {
 		int ret;
 		/* We hit the Xen hard limit: reprobe. */
-		reservation.extent_start = frame_list;
+		SET_GUEST_HANDLE(reservation.extent_start, frame_list);
 		reservation.nr_extents   = rc;
 		ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
 				&reservation);
@@ -308,7 +308,7 @@ static int decrease_reservation(unsigned
 		balloon_append(pfn_to_page(pfn));
 	}
 
-	reservation.extent_start = frame_list;
+	SET_GUEST_HANDLE(reservation.extent_start, frame_list);
 	reservation.nr_extents   = nr_pages;
 	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
 	BUG_ON(ret != nr_pages);
@@ -522,11 +522,11 @@ static int dealloc_pte_fn(
 	unsigned long mfn = pte_mfn(*pte);
 	int ret;
 	struct xen_memory_reservation reservation = {
-		.extent_start = &mfn,
 		.nr_extents   = 1,
 		.extent_order = 0,
 		.domid        = DOMID_SELF
 	};
+	SET_GUEST_HANDLE(reservation.extent_start, &mfn);
 	set_pte_at(&init_mm, addr, pte, __pte_ma(0));
 	set_phys_to_machine(__pa(addr) >> PAGE_SHIFT, INVALID_P2M_ENTRY);
 	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
linux-2.6-xen-sparse/drivers/xen/core/gnttab.c +1 -1
diff -r 61d8ff110da9 linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
@@ -392,7 +392,7 @@ gnttab_resume(void)
 
 	setup.dom        = DOMID_SELF;
 	setup.nr_frames  = NR_GRANT_FRAMES;
-	setup.frame_list = frames;
+	SET_GUEST_HANDLE(setup.frame_list, frames);
 
 	rc = HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
 	if (rc == -ENOSYS)
linux-2.6-xen-sparse/drivers/xen/netback/netback.c +1 -1
diff -r 61d8ff110da9 linux-2.6-xen-sparse/drivers/xen/netback/netback.c
@@ -105,11 +105,11 @@ static unsigned long alloc_mfn(void)
 {
 	unsigned long mfn = 0, flags;
 	struct xen_memory_reservation reservation = {
-		.extent_start = mfn_list,
 		.nr_extents   = MAX_MFN_ALLOC,
 		.extent_order = 0,
 		.domid        = DOMID_SELF
 	};
+	SET_GUEST_HANDLE(reservation.extent_start, mfn_list);
 	spin_lock_irqsave(&mfn_lock, flags);
 	if ( unlikely(alloc_index == 0) )
 		alloc_index = HYPERVISOR_memory_op(
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c +1 -1
diff -r 61d8ff110da9 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
@@ -610,7 +610,7 @@ static void network_alloc_rx_buffers(str
 	/* Tell the ballon driver what is going on. */
 	balloon_update_driver_allowance(i);
 
-	reservation.extent_start = np->rx_pfn_array;
+	SET_GUEST_HANDLE(reservation.extent_start, np->rx_pfn_array);
 	reservation.nr_extents   = i;
 	reservation.extent_order = 0;
 	reservation.address_bits = 0;
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h +5 -4
diff -r 61d8ff110da9 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h
@@ -163,13 +163,14 @@ HYPERVISOR_poll(
 	evtchn_port_t *ports, unsigned int nr_ports, u64 timeout)
 {
 	struct sched_poll sched_poll = {
-		.ports = ports,
 		.nr_ports = nr_ports,
 		.timeout = jiffies_to_st(timeout)
 	};
-
-	int rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll);
-
+    int rc;
+
+	SET_GUEST_HANDLE(sched_poll.ports, ports);
+
+	rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll);
 	if (rc == -ENOSYS)
 		rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#6 lore raw
Quoted 7 lines · Hollis Blanchard
Quoted 4 lines

This patch will unconditionally use the 'structural' definition of guest handles for tools and kernels as well as Xen, right? Can XenLinux for x86/ia64 still build with this patch, without needing a bunch of GET/SET_GUEST_HANDLE changes?

Sorry, you're right. Attached are three patches: the Xen patch, the linux-2.6-merge patch, and the linux-2.6-sparse patch.

This looks basically acceptable except....

Christian suggested providing GET/SET_XEN_GUEST_HANDLE(), for use at least in the Linux patches. These could be defined in xen.h after including arch-foo.h and simply invoke the arch-defined macros.

Alternatively we could simply change the names of all the macros to ...XEN_GUEST_HANDLE, and use the new names everywhere. I think that would be okay as the names aren't that much longer and they aren't used *that* often outside header files anyway. It'll make the patch a lot bigger, but most of it'll be search-replace. And XEN_GUEST is more informative than GUEST.

I don't think there's a need to send a patch for the merge tree -- Christian pulls unstable patches into that in a half-automated way.

Also, no need to use GET_GUEST_HANDLE() in the libxc's read_console function. Xen will never update the buffer pointer these days -- it always fills the buffer from the start. When we eventually kill the mlock() crap and implement it properly, I think GET_GUEST_HANDLE() can be killed off entirely.

-- Keir

#7 lore raw
Quoted 17 lines · Keir Fraser
Quoted 8 lines · Hollis Blanchard
Quoted 5 lines

This patch will unconditionally use the 'structural' definition of guest handles for tools and kernels as well as Xen, right? Can XenLinux
for x86/ia64 still build with this patch, without needing a bunch of GET/SET_GUEST_HANDLE changes?

Sorry, you're right. Attached are three patches: the Xen patch, the linux-2.6-merge patch, and the linux-2.6-sparse patch.

This looks basically acceptable except....

Christian suggested providing GET/SET_XEN_GUEST_HANDLE(), for use at least in the Linux patches. These could be defined in xen.h after including arch-foo.h and simply invoke the arch-defined macros.

Quoted 6 lines

Alternatively we could simply change the names of all the macros to ...XEN_GUEST_HANDLE, and use the new names everywhere. I think that would be okay as the names aren't that much longer and they aren't used *that* often outside header files anyway. It'll make the patch a lot bigger, but most of it'll be search-replace. And XEN_GUEST is more informative than GUEST.

Fine with me. I've split the global rename into a separate patch.

Quoted 2 lines

I don't think there's a need to send a patch for the merge tree -- Christian pulls unstable patches into that in a half-automated way.

Ok.

Quoted 5 lines

Also, no need to use GET_GUEST_HANDLE() in the libxc's read_console function. Xen will never update the buffer pointer these days -- it always fills the buffer from the start. When we eventually kill the mlock() crap and implement it properly, I think GET_GUEST_HANDLE() can be killed off entirely.

That's fine, but I would like to avoid changing any behavior with these patch. If you want to remove that, you're welcome to...

These patches have been compile-tested (Xen, libxc, sparse Linux) on x86(32).

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center

Rename *GUEST_HANDLE to *XEN_GUEST_HANDLE.

xen/arch/ia64/xen/dom0_ops.c +1 -1
diff -r 1d69cff40b8c xen/arch/ia64/xen/dom0_ops.c
@@ -20,7 +20,7 @@
 #include <public/sched_ctl.h>
 #include <asm/vmx.h>
 
-long arch_do_dom0_op(dom0_op_t *op, GUEST_HANDLE(dom0_op_t) u_dom0_op)
+long arch_do_dom0_op(dom0_op_t *op, XEN_GUEST_HANDLE(dom0_op_t) u_dom0_op)
 {
     long ret = 0;
 
xen/arch/x86/dom0_ops.c +1 -1
diff -r 1d69cff40b8c xen/arch/x86/dom0_ops.c
@@ -49,7 +49,7 @@ static void read_msr_for(void *unused)
         (void)rdmsr_safe(msr_addr, msr_lo, msr_hi);
 }
 
-long arch_do_dom0_op(struct dom0_op *op, GUEST_HANDLE(dom0_op_t) u_dom0_op)
+long arch_do_dom0_op(struct dom0_op *op, XEN_GUEST_HANDLE(dom0_op_t) u_dom0_op)
 {
     long ret = 0;
 
xen/arch/x86/domain.c +1 -1
diff -r 1d69cff40b8c xen/arch/x86/domain.c
@@ -364,7 +364,7 @@ int arch_set_info_guest(
 
 long
 arch_do_vcpu_op(
-    int cmd, struct vcpu *v, GUEST_HANDLE(void) arg)
+    int cmd, struct vcpu *v, XEN_GUEST_HANDLE(void) arg)
 {
     long rc = 0;
 
xen/arch/x86/mm.c +6 -6
diff -r 1d69cff40b8c xen/arch/x86/mm.c
@@ -1757,9 +1757,9 @@ static inline cpumask_t vcpumask_to_pcpu
 }
 
 int do_mmuext_op(
-    GUEST_HANDLE(mmuext_op_t) uops,
+    XEN_GUEST_HANDLE(mmuext_op_t) uops,
     unsigned int count,
-    GUEST_HANDLE(uint) pdone,
+    XEN_GUEST_HANDLE(uint) pdone,
     unsigned int foreigndom)
 {
     struct mmuext_op op;
@@ -2007,9 +2007,9 @@ int do_mmuext_op(
 }
 
 int do_mmu_update(
-    GUEST_HANDLE(mmu_update_t) ureqs,
+    XEN_GUEST_HANDLE(mmu_update_t) ureqs,
     unsigned int count,
-    GUEST_HANDLE(uint) pdone,
+    XEN_GUEST_HANDLE(uint) pdone,
     unsigned int foreigndom)
 {
     struct mmu_update req;
@@ -2708,7 +2708,7 @@ long set_gdt(struct vcpu *v,
 }
 
 
-long do_set_gdt(GUEST_HANDLE(ulong) frame_list, unsigned int entries)
+long do_set_gdt(XEN_GUEST_HANDLE(ulong) frame_list, unsigned int entries)
 {
     int nr_pages = (entries + 511) / 512;
     unsigned long frames[16];
@@ -2812,7 +2812,7 @@ long do_update_descriptor(u64 pa, u64 de
 }
 
 
-long arch_memory_op(int op, GUEST_HANDLE(void) arg)
+long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg)
 {
     switch ( op )
     {
xen/arch/x86/oprofile/xenoprof.c +2 -2
diff -r 1d69cff40b8c xen/arch/x86/oprofile/xenoprof.c
@@ -349,7 +349,7 @@ void free_xenoprof_pages(struct domain *
     d->xenoprof = NULL;
 }
 
-int xenoprof_op_init(GUEST_HANDLE(void) arg)
+int xenoprof_op_init(XEN_GUEST_HANDLE(void) arg)
 {
     struct xenoprof_init xenoprof_init;
     int is_primary, num_events;
@@ -410,7 +410,7 @@ int xenoprof_op_init(GUEST_HANDLE(void) 
                    || (op == XENOPROF_release_counters) \
                    || (op == XENOPROF_shutdown))
 
-int do_xenoprof_op(int op, GUEST_HANDLE(void) arg)
+int do_xenoprof_op(int op, XEN_GUEST_HANDLE(void) arg)
 {
     int ret = 0;
 
xen/arch/x86/physdev.c +1 -1
diff -r 1d69cff40b8c xen/arch/x86/physdev.c
@@ -25,7 +25,7 @@ pirq_acktype(
 /*
  * Demuxing hypercall.
  */
-long do_physdev_op(GUEST_HANDLE(physdev_op_t) uop)
+long do_physdev_op(XEN_GUEST_HANDLE(physdev_op_t) uop)
 {
     struct physdev_op op;
     long ret;
xen/arch/x86/traps.c +1 -1
diff -r 1d69cff40b8c xen/arch/x86/traps.c
@@ -1535,7 +1535,7 @@ void __init trap_init(void)
 }
 
 
-long do_set_trap_table(GUEST_HANDLE(trap_info_t) traps)
+long do_set_trap_table(XEN_GUEST_HANDLE(trap_info_t) traps)
 {
     struct trap_info cur;
     struct trap_info *dst = current->arch.guest_context.trap_ctxt;
xen/arch/x86/x86_32/mm.c +1 -1
diff -r 1d69cff40b8c xen/arch/x86/x86_32/mm.c
@@ -189,7 +189,7 @@ void subarch_init_memory(void)
     }
 }
 
-long subarch_memory_op(int op, GUEST_HANDLE(void) arg)
+long subarch_memory_op(int op, XEN_GUEST_HANDLE(void) arg)
 {
     struct xen_machphys_mfn_list xmml;
     unsigned long mfn;
xen/arch/x86/x86_32/traps.c +1 -1
diff -r 1d69cff40b8c xen/arch/x86/x86_32/traps.c
@@ -387,7 +387,7 @@ static long unregister_guest_callback(st
 }
 
 
-long do_callback_op(int cmd, GUEST_HANDLE(void) arg)
+long do_callback_op(int cmd, XEN_GUEST_HANDLE(void) arg)
 {
     long ret;
 
xen/arch/x86/x86_64/mm.c +1 -1
diff -r 1d69cff40b8c xen/arch/x86/x86_64/mm.c
@@ -181,7 +181,7 @@ void subarch_init_memory(void)
     }
 }
 
-long subarch_memory_op(int op, GUEST_HANDLE(void) arg)
+long subarch_memory_op(int op, XEN_GUEST_HANDLE(void) arg)
 {
     struct xen_machphys_mfn_list xmml;
     l3_pgentry_t l3e;
xen/arch/x86/x86_64/traps.c +1 -1
diff -r 1d69cff40b8c xen/arch/x86/x86_64/traps.c
@@ -371,7 +371,7 @@ static long unregister_guest_callback(st
 }
 
 
-long do_callback_op(int cmd, GUEST_HANDLE(void) arg)
+long do_callback_op(int cmd, XEN_GUEST_HANDLE(void) arg)
 {
     long ret;
 
xen/common/acm_ops.c +2 -2
diff -r 1d69cff40b8c xen/common/acm_ops.c
@@ -32,7 +32,7 @@
 
 #ifndef ACM_SECURITY
 
-long do_acm_op(GUEST_HANDLE(acm_op_t) u_acm_op)
+long do_acm_op(XEN_GUEST_HANDLE(acm_op_t) u_acm_op)
 {
     return -ENOSYS;
 }
@@ -57,7 +57,7 @@ int acm_authorize_acm_ops(struct domain 
     return 0;
 }
 
-long do_acm_op(GUEST_HANDLE(acm_op_t) u_acm_op)
+long do_acm_op(XEN_GUEST_HANDLE(acm_op_t) u_acm_op)
 {
     long ret = 0;
     struct acm_op curop, *op = &curop;
xen/common/dom0_ops.c +2 -2
diff -r 1d69cff40b8c xen/common/dom0_ops.c
@@ -24,7 +24,7 @@
 #include <acm/acm_hooks.h>
 
 extern long arch_do_dom0_op(
-    struct dom0_op *op, GUEST_HANDLE(dom0_op_t) u_dom0_op);
+    struct dom0_op *op, XEN_GUEST_HANDLE(dom0_op_t) u_dom0_op);
 extern void arch_getdomaininfo_ctxt(
     struct vcpu *, struct vcpu_guest_context *);
 
@@ -90,7 +90,7 @@ static void getdomaininfo(struct domain 
     memcpy(info->handle, d->handle, sizeof(xen_domain_handle_t));
 }
 
-long do_dom0_op(GUEST_HANDLE(dom0_op_t) u_dom0_op)
+long do_dom0_op(XEN_GUEST_HANDLE(dom0_op_t) u_dom0_op)
 {
     long ret = 0;
     struct dom0_op curop, *op = &curop;
xen/common/domain.c +1 -1
diff -r 1d69cff40b8c xen/common/domain.c
@@ -408,7 +408,7 @@ int boot_vcpu(struct domain *d, int vcpu
     return arch_set_info_guest(v, ctxt);
 }
 
-long do_vcpu_op(int cmd, int vcpuid, GUEST_HANDLE(void) arg)
+long do_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE(void) arg)
 {
     struct domain *d = current->domain;
     struct vcpu *v;
xen/common/event_channel.c +1 -1
diff -r 1d69cff40b8c xen/common/event_channel.c
@@ -683,7 +683,7 @@ static long evtchn_unmask(evtchn_unmask_
 }
 
 
-long do_event_channel_op(GUEST_HANDLE(evtchn_op_t) uop)
+long do_event_channel_op(XEN_GUEST_HANDLE(evtchn_op_t) uop)
 {
     long rc;
     struct evtchn_op op;
xen/common/grant_table.c +8 -8
diff -r 1d69cff40b8c xen/common/grant_table.c
@@ -301,7 +301,7 @@ __gnttab_map_grant_ref(
 
 static long
 gnttab_map_grant_ref(
-    GUEST_HANDLE(gnttab_map_grant_ref_t) uop, unsigned int count)
+    XEN_GUEST_HANDLE(gnttab_map_grant_ref_t) uop, unsigned int count)
 {
     int i;
     struct gnttab_map_grant_ref op;
@@ -438,7 +438,7 @@ __gnttab_unmap_grant_ref(
 
 static long
 gnttab_unmap_grant_ref(
-    GUEST_HANDLE(gnttab_unmap_grant_ref_t) uop, unsigned int count)
+    XEN_GUEST_HANDLE(gnttab_unmap_grant_ref_t) uop, unsigned int count)
 {
     int i;
     struct gnttab_unmap_grant_ref op;
@@ -462,7 +462,7 @@ fault:
 
 static long 
 gnttab_setup_table(
-    GUEST_HANDLE(gnttab_setup_table_t) uop, unsigned int count)
+    XEN_GUEST_HANDLE(gnttab_setup_table_t) uop, unsigned int count)
 {
     struct gnttab_setup_table op;
     struct domain *d;
@@ -598,7 +598,7 @@ gnttab_prepare_for_transfer(
 
 static long
 gnttab_transfer(
-    GUEST_HANDLE(gnttab_transfer_t) uop, unsigned int count)
+    XEN_GUEST_HANDLE(gnttab_transfer_t) uop, unsigned int count)
 {
     struct domain *d = current->domain;
     struct domain *e;
@@ -711,7 +711,7 @@ gnttab_transfer(
 
 long
 do_grant_table_op(
-    unsigned int cmd, GUEST_HANDLE(void) uop, unsigned int count)
+    unsigned int cmd, XEN_GUEST_HANDLE(void) uop, unsigned int count)
 {
     long rc;
     struct domain *d = current->domain;
@@ -728,7 +728,7 @@ do_grant_table_op(
     {
     case GNTTABOP_map_grant_ref:
     {
-        GUEST_HANDLE(gnttab_map_grant_ref_t) map =
+        XEN_GUEST_HANDLE(gnttab_map_grant_ref_t) map =
             guest_handle_cast(uop, gnttab_map_grant_ref_t);
         if ( unlikely(!guest_handle_okay(map, count)) )
             goto out;
@@ -737,7 +737,7 @@ do_grant_table_op(
     }
     case GNTTABOP_unmap_grant_ref:
     {
-        GUEST_HANDLE(gnttab_unmap_grant_ref_t) unmap =
+        XEN_GUEST_HANDLE(gnttab_unmap_grant_ref_t) unmap =
             guest_handle_cast(uop, gnttab_unmap_grant_ref_t);
         if ( unlikely(!guest_handle_okay(unmap, count)) )
             goto out;
@@ -752,7 +752,7 @@ do_grant_table_op(
     }
     case GNTTABOP_transfer:
     {
-        GUEST_HANDLE(gnttab_transfer_t) transfer =
+        XEN_GUEST_HANDLE(gnttab_transfer_t) transfer =
             guest_handle_cast(uop, gnttab_transfer_t);
         if ( unlikely(!guest_handle_okay(transfer, count)) )
             goto out;
xen/common/kernel.c +2 -2
diff -r 1d69cff40b8c xen/common/kernel.c
@@ -118,7 +118,7 @@ void add_taint(unsigned flag)
  * Simple hypercalls.
  */
 
-long do_xen_version(int cmd, GUEST_HANDLE(void) arg)
+long do_xen_version(int cmd, XEN_GUEST_HANDLE(void) arg)
 {
     switch ( cmd )
     {
@@ -244,7 +244,7 @@ long unregister_guest_nmi_callback(void)
     return 0;
 }
 
-long do_nmi_op(unsigned int cmd, GUEST_HANDLE(void) arg)
+long do_nmi_op(unsigned int cmd, XEN_GUEST_HANDLE(void) arg)
 {
     struct xennmi_callback cb;
     long rc = 0;
xen/common/memory.c +5 -5
diff -r 1d69cff40b8c xen/common/memory.c
@@ -31,7 +31,7 @@ static long
 static long
 increase_reservation(
     struct domain *d, 
-    GUEST_HANDLE(ulong) extent_list,
+    XEN_GUEST_HANDLE(ulong) extent_list,
     unsigned int   nr_extents,
     unsigned int   extent_order,
     unsigned int   flags,
@@ -80,7 +80,7 @@ static long
 static long
 populate_physmap(
     struct domain *d, 
-    GUEST_HANDLE(ulong) extent_list,
+    XEN_GUEST_HANDLE(ulong) extent_list,
     unsigned int  nr_extents,
     unsigned int  extent_order,
     unsigned int  flags,
@@ -177,7 +177,7 @@ static long
 static long
 decrease_reservation(
     struct domain *d,
-    GUEST_HANDLE(ulong) extent_list,
+    XEN_GUEST_HANDLE(ulong) extent_list,
     unsigned int   nr_extents,
     unsigned int   extent_order,
     unsigned int   flags,
@@ -211,7 +211,7 @@ decrease_reservation(
 
 static long
 translate_gpfn_list(
-    GUEST_HANDLE(xen_translate_gpfn_list_t) uop, unsigned long *progress)
+    XEN_GUEST_HANDLE(xen_translate_gpfn_list_t) uop, unsigned long *progress)
 {
     struct xen_translate_gpfn_list op;
     unsigned long i, gpfn, mfn;
@@ -270,7 +270,7 @@ translate_gpfn_list(
     return 0;
 }
 
-long do_memory_op(unsigned long cmd, GUEST_HANDLE(void) arg)
+long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE(void) arg)
 {
     struct domain *d;
     int rc, op, flags = 0, preempted = 0;
xen/common/multicall.c +1 -1
diff -r 1d69cff40b8c xen/common/multicall.c
@@ -18,7 +18,7 @@ struct mc_state mc_state[NR_CPUS];
 
 long
 do_multicall(
-    GUEST_HANDLE(multicall_entry_t) call_list, unsigned int nr_calls)
+    XEN_GUEST_HANDLE(multicall_entry_t) call_list, unsigned int nr_calls)
 {
     struct mc_state *mcs = &mc_state[smp_processor_id()];
     unsigned int     i;
xen/common/perfc.c +1 -1
diff -r 1d69cff40b8c xen/common/perfc.c
@@ -131,7 +131,7 @@ void perfc_reset(unsigned char key)
 
 static dom0_perfc_desc_t perfc_d[NR_PERFCTRS];
 static int               perfc_init = 0;
-static int perfc_copy_info(GUEST_HANDLE(dom0_perfc_desc_t) desc)
+static int perfc_copy_info(XEN_GUEST_HANDLE(dom0_perfc_desc_t) desc)
 {
     unsigned int i, j;
     atomic_t *counters = (atomic_t *)&perfcounters;
xen/common/schedule.c +1 -1
diff -r 1d69cff40b8c xen/common/schedule.c
@@ -365,7 +365,7 @@ long do_sched_op_compat(int cmd, unsigne
     return ret;
 }
 
-long do_sched_op(int cmd, GUEST_HANDLE(void) arg)
+long do_sched_op(int cmd, XEN_GUEST_HANDLE(void) arg)
 {
     long ret = 0;
 
xen/drivers/char/console.c +3 -3
diff -r 1d69cff40b8c xen/drivers/char/console.c
@@ -221,7 +221,7 @@ static void putchar_console_ring(int c)
         conringc = conringp - CONRING_SIZE;
 }
 
-long read_console_ring(GUEST_HANDLE(char) str, u32 *pcount, int clear)
+long read_console_ring(XEN_GUEST_HANDLE(char) str, u32 *pcount, int clear)
 {
     unsigned int idx, len, max, sofar, c;
     unsigned long flags;
@@ -319,7 +319,7 @@ static void serial_rx(char c, struct cpu
     __serial_rx(c, regs);
 }
 
-static long guest_console_write(GUEST_HANDLE(char) buffer, int count)
+static long guest_console_write(XEN_GUEST_HANDLE(char) buffer, int count)
 {
     char kbuf[128], *kptr;
     int kcount;
@@ -355,7 +355,7 @@ static long guest_console_write(GUEST_HA
     return 0;
 }
 
-long do_console_io(int cmd, int count, GUEST_HANDLE(char) buffer)
+long do_console_io(int cmd, int count, XEN_GUEST_HANDLE(char) buffer)
 {
     long rc;
     unsigned int idx, len;
xen/include/asm-ia64/guest_access.h +2 -2
diff -r 1d69cff40b8c xen/include/asm-ia64/guest_access.h
@@ -18,10 +18,10 @@
 /* Cast a guest handle to the specified type of handle. */
 #define guest_handle_cast(hnd, type) ({         \
     type *_x = (hnd).p;                         \
-    (GUEST_HANDLE(type)) { _x };                \
+    (XEN_GUEST_HANDLE(type)) { _x };                \
 })
 
-#define guest_handle_from_ptr(ptr, type) ((GUEST_HANDLE(type)) { (type *)ptr })
+#define guest_handle_from_ptr(ptr, type) ((XEN_GUEST_HANDLE(type)) { (type *)ptr })
 
 /*
  * Copy an array of objects to guest context via a guest handle,
xen/include/asm-x86/guest_access.h +1 -1
diff -r 1d69cff40b8c xen/include/asm-x86/guest_access.h
@@ -18,7 +18,7 @@
 /* Cast a guest handle to the specified type of handle. */
 #define guest_handle_cast(hnd, type) ({         \
     type *_x = (hnd).p;                         \
-    (GUEST_HANDLE(type)) { _x };                \
+    (XEN_GUEST_HANDLE(type)) { _x };                \
 })
 
 /*
xen/include/asm-x86/hypercall.h +8 -8
diff -r 1d69cff40b8c xen/include/asm-x86/hypercall.h
@@ -9,18 +9,18 @@
 
 extern long
 do_set_trap_table(
-    GUEST_HANDLE(trap_info_t) traps);
+    XEN_GUEST_HANDLE(trap_info_t) traps);
 
 extern int
 do_mmu_update(
-    GUEST_HANDLE(mmu_update_t) ureqs,
+    XEN_GUEST_HANDLE(mmu_update_t) ureqs,
     unsigned int count,
-    GUEST_HANDLE(uint) pdone,
+    XEN_GUEST_HANDLE(uint) pdone,
     unsigned int foreigndom);
 
 extern long
 do_set_gdt(
-    GUEST_HANDLE(ulong) frame_list,
+    XEN_GUEST_HANDLE(ulong) frame_list,
     unsigned int entries);
 
 extern long
@@ -54,7 +54,7 @@ do_update_va_mapping(
 
 extern long
 do_physdev_op(
-    GUEST_HANDLE(physdev_op_t) uop);
+    XEN_GUEST_HANDLE(physdev_op_t) uop);
 
 extern int
 do_update_va_mapping_otherdomain(
@@ -65,9 +65,9 @@ do_update_va_mapping_otherdomain(
 
 extern int
 do_mmuext_op(
-    GUEST_HANDLE(mmuext_op_t) uops,
+    XEN_GUEST_HANDLE(mmuext_op_t) uops,
     unsigned int count,
-    GUEST_HANDLE(uint) pdone,
+    XEN_GUEST_HANDLE(uint) pdone,
     unsigned int foreigndom);
 
 extern unsigned long
@@ -77,7 +77,7 @@ struct vcpu;
 struct vcpu;
 extern long
 arch_do_vcpu_op(
-    int cmd, struct vcpu *v, GUEST_HANDLE(void) arg);
+    int cmd, struct vcpu *v, XEN_GUEST_HANDLE(void) arg);
 
 #ifdef __x86_64__
 
xen/include/asm-x86/mm.h +2 -2
diff -r 1d69cff40b8c xen/include/asm-x86/mm.h
@@ -382,7 +382,7 @@ int __sync_lazy_execstate(void);
 int __sync_lazy_execstate(void);
 
 /* Arch-specific portion of memory_op hypercall. */
-long arch_memory_op(int op, GUEST_HANDLE(void) arg);
-long subarch_memory_op(int op, GUEST_HANDLE(void) arg);
+long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg);
+long subarch_memory_op(int op, XEN_GUEST_HANDLE(void) arg);
 
 #endif /* __ASM_X86_MM_H__ */
xen/include/public/acm_ops.h +1 -1
diff -r 1d69cff40b8c xen/include/public/acm_ops.h
@@ -83,7 +83,7 @@ typedef struct acm_op {
         struct acm_getdecision getdecision;
     } u;
 } acm_op_t;
-DEFINE_GUEST_HANDLE(acm_op_t);
+DEFINE_XEN_GUEST_HANDLE(acm_op_t);
 
 #endif                          /* __XEN_PUBLIC_ACM_OPS_H__ */
 
xen/include/public/arch-ia64.h +12 -12
diff -r 1d69cff40b8c xen/include/public/arch-ia64.h
@@ -8,25 +8,25 @@
 #define __HYPERVISOR_IF_IA64_H__
 
 #ifdef __XEN__
-#define __DEFINE_GUEST_HANDLE(name, type) \
+#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
 #else
-#define __DEFINE_GUEST_HANDLE(name, type) \
+#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
     typedef type * __guest_handle_ ## name
 #endif
 
-#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
-#define GUEST_HANDLE(name)        __guest_handle_ ## name
+#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
+#define XEN_GUEST_HANDLE(name)        __guest_handle_ ## name
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
-__DEFINE_GUEST_HANDLE(uchar, unsigned char);
-__DEFINE_GUEST_HANDLE(uint,  unsigned int);
-__DEFINE_GUEST_HANDLE(ulong, unsigned long);
-DEFINE_GUEST_HANDLE(char);
-DEFINE_GUEST_HANDLE(int);
-DEFINE_GUEST_HANDLE(long);
-DEFINE_GUEST_HANDLE(void);
+__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
+__DEFINE_XEN_GUEST_HANDLE(uint,  unsigned int);
+__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
+DEFINE_XEN_GUEST_HANDLE(char);
+DEFINE_XEN_GUEST_HANDLE(int);
+DEFINE_XEN_GUEST_HANDLE(long);
+DEFINE_XEN_GUEST_HANDLE(void);
 #endif
 
 /* Maximum number of virtual CPUs in multi-processor guests. */
@@ -320,7 +320,7 @@ typedef struct vcpu_guest_context {
     arch_initrd_info_t initrd;
     char cmdline[IA64_COMMAND_LINE_SIZE];
 } vcpu_guest_context_t;
-DEFINE_GUEST_HANDLE(vcpu_guest_context_t);
+DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
 
 #endif /* !__ASSEMBLY__ */
 
xen/include/public/arch-x86_32.h +14 -14
diff -r 1d69cff40b8c xen/include/public/arch-x86_32.h
@@ -10,25 +10,25 @@
 #define __XEN_PUBLIC_ARCH_X86_32_H__
 
 #ifdef __XEN__
-#define __DEFINE_GUEST_HANDLE(name, type) \
+#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
 #else
-#define __DEFINE_GUEST_HANDLE(name, type) \
+#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
     typedef type * __guest_handle_ ## name
 #endif
 
-#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
-#define GUEST_HANDLE(name)        __guest_handle_ ## name
+#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
+#define XEN_GUEST_HANDLE(name)        __guest_handle_ ## name
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
-__DEFINE_GUEST_HANDLE(uchar, unsigned char);
-__DEFINE_GUEST_HANDLE(uint,  unsigned int);
-__DEFINE_GUEST_HANDLE(ulong, unsigned long);
-DEFINE_GUEST_HANDLE(char);
-DEFINE_GUEST_HANDLE(int);
-DEFINE_GUEST_HANDLE(long);
-DEFINE_GUEST_HANDLE(void);
+__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
+__DEFINE_XEN_GUEST_HANDLE(uint,  unsigned int);
+__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
+DEFINE_XEN_GUEST_HANDLE(char);
+DEFINE_XEN_GUEST_HANDLE(int);
+DEFINE_XEN_GUEST_HANDLE(long);
+DEFINE_XEN_GUEST_HANDLE(void);
 #endif
 
 /*
@@ -102,7 +102,7 @@ typedef struct trap_info {
     uint16_t      cs;      /* code selector                                 */
     unsigned long address; /* code offset                                   */
 } trap_info_t;
-DEFINE_GUEST_HANDLE(trap_info_t);
+DEFINE_XEN_GUEST_HANDLE(trap_info_t);
 
 typedef struct cpu_user_regs {
     uint32_t ebx;
@@ -126,7 +126,7 @@ typedef struct cpu_user_regs {
     uint16_t fs, _pad4;
     uint16_t gs, _pad5;
 } cpu_user_regs_t;
-DEFINE_GUEST_HANDLE(cpu_user_regs_t);
+DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t);
 
 typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */
 
@@ -154,7 +154,7 @@ typedef struct vcpu_guest_context {
     unsigned long failsafe_callback_eip;
     unsigned long vm_assist;                /* VMASST_TYPE_* bitmap */
 } vcpu_guest_context_t;
-DEFINE_GUEST_HANDLE(vcpu_guest_context_t);
+DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
 
 typedef struct arch_shared_info {
     unsigned long max_pfn;                  /* max pfn that appears in table */
xen/include/public/arch-x86_64.h +14 -14
diff -r 1d69cff40b8c xen/include/public/arch-x86_64.h
@@ -10,25 +10,25 @@
 #define __XEN_PUBLIC_ARCH_X86_64_H__
 
 #ifdef __XEN__
-#define __DEFINE_GUEST_HANDLE(name, type) \
+#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
 #else
-#define __DEFINE_GUEST_HANDLE(name, type) \
+#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
     typedef type * __guest_handle_ ## name
 #endif
 
-#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name)
-#define GUEST_HANDLE(name)        __guest_handle_ ## name
+#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
+#define XEN_GUEST_HANDLE(name)        __guest_handle_ ## name
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
-__DEFINE_GUEST_HANDLE(uchar, unsigned char);
-__DEFINE_GUEST_HANDLE(uint,  unsigned int);
-__DEFINE_GUEST_HANDLE(ulong, unsigned long);
-DEFINE_GUEST_HANDLE(char);
-DEFINE_GUEST_HANDLE(int);
-DEFINE_GUEST_HANDLE(long);
-DEFINE_GUEST_HANDLE(void);
+__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char);
+__DEFINE_XEN_GUEST_HANDLE(uint,  unsigned int);
+__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long);
+DEFINE_XEN_GUEST_HANDLE(char);
+DEFINE_XEN_GUEST_HANDLE(int);
+DEFINE_XEN_GUEST_HANDLE(long);
+DEFINE_XEN_GUEST_HANDLE(void);
 #endif
 
 /*
@@ -157,7 +157,7 @@ typedef struct trap_info {
     uint16_t      cs;      /* code selector                                 */
     unsigned long address; /* code offset                                   */
 } trap_info_t;
-DEFINE_GUEST_HANDLE(trap_info_t);
+DEFINE_XEN_GUEST_HANDLE(trap_info_t);
 
 #ifdef __GNUC__
 /* Anonymous union includes both 32- and 64-bit names (e.g., eax/rax). */
@@ -197,7 +197,7 @@ typedef struct cpu_user_regs {
     uint16_t fs, _pad5[3]; /* Non-zero => takes precedence over fs_base.     */
     uint16_t gs, _pad6[3]; /* Non-zero => takes precedence over gs_base_usr. */
 } cpu_user_regs_t;
-DEFINE_GUEST_HANDLE(cpu_user_regs_t);
+DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t);
 
 #undef __DECL_REG
 
@@ -230,7 +230,7 @@ typedef struct vcpu_guest_context {
     uint64_t      gs_base_kernel;
     uint64_t      gs_base_user;
 } vcpu_guest_context_t;
-DEFINE_GUEST_HANDLE(vcpu_guest_context_t);
+DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
 
 typedef struct arch_shared_info {
     unsigned long max_pfn;                  /* max pfn that appears in table */
xen/include/public/callback.h +2 -2
diff -r 1d69cff40b8c xen/include/public/callback.h
@@ -36,7 +36,7 @@ typedef struct callback_register {
      int type;
      xen_callback_t address;
 } callback_register_t;
-DEFINE_GUEST_HANDLE(callback_register_t);
+DEFINE_XEN_GUEST_HANDLE(callback_register_t);
 
 /*
  * Unregister a callback.
@@ -48,7 +48,7 @@ typedef struct callback_unregister {
 typedef struct callback_unregister {
      int type;
 } callback_unregister_t;
-DEFINE_GUEST_HANDLE(callback_unregister_t);
+DEFINE_XEN_GUEST_HANDLE(callback_unregister_t);
 
 #endif /* __XEN_PUBLIC_CALLBACK_H__ */
 
xen/include/public/dom0_ops.h +51 -51

359 lines not on this page · raw message

xen/include/public/event_channel.h +2 -2
diff -r 1d69cff40b8c xen/include/public/event_channel.h
@@ -10,7 +10,7 @@
 #define __XEN_PUBLIC_EVENT_CHANNEL_H__
 
 typedef uint32_t evtchn_port_t;
-DEFINE_GUEST_HANDLE(evtchn_port_t);
+DEFINE_XEN_GUEST_HANDLE(evtchn_port_t);
 
 /*
  * EVTCHNOP_alloc_unbound: Allocate a port in domain <dom> and mark as
@@ -196,7 +196,7 @@ typedef struct evtchn_op {
         evtchn_unmask_t           unmask;
     } u;
 } evtchn_op_t;
-DEFINE_GUEST_HANDLE(evtchn_op_t);
+DEFINE_XEN_GUEST_HANDLE(evtchn_op_t);
 
 #endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */
 
xen/include/public/grant_table.h +6 -6
diff -r 1d69cff40b8c xen/include/public/grant_table.h
@@ -167,7 +167,7 @@ typedef struct gnttab_map_grant_ref {
     grant_handle_t handle;
     uint64_t dev_bus_addr;
 } gnttab_map_grant_ref_t;
-DEFINE_GUEST_HANDLE(gnttab_map_grant_ref_t);
+DEFINE_XEN_GUEST_HANDLE(gnttab_map_grant_ref_t);
 
 /*
  * GNTTABOP_unmap_grant_ref: Destroy one or more grant-reference mappings
@@ -189,7 +189,7 @@ typedef struct gnttab_unmap_grant_ref {
     /* OUT parameters. */
     int16_t  status;              /* GNTST_* */
 } gnttab_unmap_grant_ref_t;
-DEFINE_GUEST_HANDLE(gnttab_unmap_grant_ref_t);
+DEFINE_XEN_GUEST_HANDLE(gnttab_unmap_grant_ref_t);
 
 /*
  * GNTTABOP_setup_table: Set up a grant table for <dom> comprising at least
@@ -207,9 +207,9 @@ typedef struct gnttab_setup_table {
     uint32_t nr_frames;
     /* OUT parameters. */
     int16_t  status;              /* GNTST_* */
-    GUEST_HANDLE(ulong) frame_list;
+    XEN_GUEST_HANDLE(ulong) frame_list;
 } gnttab_setup_table_t;
-DEFINE_GUEST_HANDLE(gnttab_setup_table_t);
+DEFINE_XEN_GUEST_HANDLE(gnttab_setup_table_t);
 
 /*
  * GNTTABOP_dump_table: Dump the contents of the grant table to the
@@ -222,7 +222,7 @@ typedef struct gnttab_dump_table {
     /* OUT parameters. */
     int16_t status;               /* GNTST_* */
 } gnttab_dump_table_t;
-DEFINE_GUEST_HANDLE(gnttab_dump_table_t);
+DEFINE_XEN_GUEST_HANDLE(gnttab_dump_table_t);
 
 /*
  * GNTTABOP_transfer_grant_ref: Transfer <frame> to a foreign domain. The
@@ -241,7 +241,7 @@ typedef struct gnttab_transfer {
     /* OUT parameters. */
     int16_t       status;
 } gnttab_transfer_t;
-DEFINE_GUEST_HANDLE(gnttab_transfer_t);
+DEFINE_XEN_GUEST_HANDLE(gnttab_transfer_t);
 
 /*
  * Bitfield values for update_pin_status.flags.
xen/include/public/memory.h +8 -8
diff -r 1d69cff40b8c xen/include/public/memory.h
@@ -29,7 +29,7 @@ typedef struct xen_memory_reservation {
      *   OUT: GMFN bases of extents that were allocated
      *   (NB. This command also updates the mach_to_phys translation table)
      */
-    GUEST_HANDLE(ulong) extent_start;
+    XEN_GUEST_HANDLE(ulong) extent_start;
 
     /* Number of extents, and size/alignment of each (2^extent_order pages). */
     unsigned long  nr_extents;
@@ -50,7 +50,7 @@ typedef struct xen_memory_reservation {
     domid_t        domid;
 
 } xen_memory_reservation_t;
-DEFINE_GUEST_HANDLE(xen_memory_reservation_t);
+DEFINE_XEN_GUEST_HANDLE(xen_memory_reservation_t);
 
 /*
  * Returns the maximum machine frame number of mapped RAM in this system.
@@ -86,7 +86,7 @@ typedef struct xen_machphys_mfn_list {
      * any large discontiguities in the machine address space, 2MB gaps in
      * the machphys table will be represented by an MFN base of zero.
      */
-    GUEST_HANDLE(ulong) extent_start;
+    XEN_GUEST_HANDLE(ulong) extent_start;
 
     /*
      * Number of extents written to the above array. This will be smaller
@@ -94,7 +94,7 @@ typedef struct xen_machphys_mfn_list {
      */
     unsigned int nr_extents;
 } xen_machphys_mfn_list_t;
-DEFINE_GUEST_HANDLE(xen_machphys_mfn_list_t);
+DEFINE_XEN_GUEST_HANDLE(xen_machphys_mfn_list_t);
 
 /*
  * Sets the GPFN at which a particular page appears in the specified guest's
@@ -117,7 +117,7 @@ typedef struct xen_add_to_physmap {
     /* GPFN where the source mapping page should appear. */
     unsigned long gpfn;
 } xen_add_to_physmap_t;
-DEFINE_GUEST_HANDLE(xen_add_to_physmap_t);
+DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_t);
 
 /*
  * Translates a list of domain-specific GPFNs into MFNs. Returns a -ve error
@@ -132,15 +132,15 @@ typedef struct xen_translate_gpfn_list {
     unsigned long nr_gpfns;
 
     /* List of GPFNs to translate. */
-    GUEST_HANDLE(ulong) gpfn_list;
+    XEN_GUEST_HANDLE(ulong) gpfn_list;
 
     /*
      * Output list to contain MFN translations. May be the same as the input
      * list (in which case each input GPFN is overwritten with the output MFN).
      */
-    GUEST_HANDLE(ulong) mfn_list;
+    XEN_GUEST_HANDLE(ulong) mfn_list;
 } xen_translate_gpfn_list_t;
-DEFINE_GUEST_HANDLE(xen_translate_gpfn_list_t);
+DEFINE_XEN_GUEST_HANDLE(xen_translate_gpfn_list_t);
 
 #endif /* __XEN_PUBLIC_MEMORY_H__ */
 
xen/include/public/nmi.h +1 -1
diff -r 1d69cff40b8c xen/include/public/nmi.h
@@ -38,7 +38,7 @@ typedef struct xennmi_callback {
     unsigned long handler_address;
     unsigned long pad;
 } xennmi_callback_t;
-DEFINE_GUEST_HANDLE(xennmi_callback_t);
+DEFINE_XEN_GUEST_HANDLE(xennmi_callback_t);
 
 /*
  * Deregister NMI callback for this (calling) VCPU.
xen/include/public/physdev.h +1 -1
diff -r 1d69cff40b8c xen/include/public/physdev.h
@@ -56,7 +56,7 @@ typedef struct physdev_op {
         physdevop_irq_t                   irq_op;
     } u;
 } physdev_op_t;
-DEFINE_GUEST_HANDLE(physdev_op_t);
+DEFINE_XEN_GUEST_HANDLE(physdev_op_t);
 
 #endif /* __XEN_PUBLIC_PHYSDEV_H__ */
 
xen/include/public/sched.h +4 -4
diff -r 1d69cff40b8c xen/include/public/sched.h
@@ -49,7 +49,7 @@ typedef struct sched_shutdown {
 typedef struct sched_shutdown {
     unsigned int reason; /* SHUTDOWN_* */
 } sched_shutdown_t;
-DEFINE_GUEST_HANDLE(sched_shutdown_t);
+DEFINE_XEN_GUEST_HANDLE(sched_shutdown_t);
 
 /*
  * Poll a set of event-channel ports. Return when one or more are pending. An
@@ -58,11 +58,11 @@ DEFINE_GUEST_HANDLE(sched_shutdown_t);
  */
 #define SCHEDOP_poll        3
 typedef struct sched_poll {
-    GUEST_HANDLE(evtchn_port_t) ports;
+    XEN_GUEST_HANDLE(evtchn_port_t) ports;
     unsigned int nr_ports;
     uint64_t timeout;
 } sched_poll_t;
-DEFINE_GUEST_HANDLE(sched_poll_t);
+DEFINE_XEN_GUEST_HANDLE(sched_poll_t);
 
 /*
  * Declare a shutdown for another domain. The main use of this function is
@@ -75,7 +75,7 @@ typedef struct sched_remote_shutdown {
     domid_t domain_id;         /* Remote domain ID */
     unsigned int reason;       /* SHUTDOWN_xxx reason */
 } sched_remote_shutdown_t;
-DEFINE_GUEST_HANDLE(sched_remote_shutdown_t);
+DEFINE_XEN_GUEST_HANDLE(sched_remote_shutdown_t);
 
 /*
  * Reason codes for SCHEDOP_shutdown. These may be interpreted by control
xen/include/public/xen.h +3 -3
diff -r 1d69cff40b8c xen/include/public/xen.h
@@ -185,7 +185,7 @@ typedef struct mmuext_op {
         void *vcpumask;
     } arg2;
 } mmuext_op_t;
-DEFINE_GUEST_HANDLE(mmuext_op_t);
+DEFINE_XEN_GUEST_HANDLE(mmuext_op_t);
 #endif
 
 /* These are passed as 'flags' to update_va_mapping. They can be ORed. */
@@ -252,7 +252,7 @@ typedef struct mmu_update {
     uint64_t ptr;       /* Machine address of PTE. */
     uint64_t val;       /* New contents of PTE.    */
 } mmu_update_t;
-DEFINE_GUEST_HANDLE(mmu_update_t);
+DEFINE_XEN_GUEST_HANDLE(mmu_update_t);
 
 /*
  * Send an array of these to HYPERVISOR_multicall().
@@ -262,7 +262,7 @@ typedef struct multicall_entry {
     unsigned long op, result;
     unsigned long args[6];
 } multicall_entry_t;
-DEFINE_GUEST_HANDLE(multicall_entry_t);
+DEFINE_XEN_GUEST_HANDLE(multicall_entry_t);
 
 /*
  * Event channel endpoints per domain:
xen/include/public/xenoprof.h +3 -3
diff -r 1d69cff40b8c xen/include/public/xenoprof.h
@@ -52,7 +52,7 @@ typedef struct xenoprof_buf {
     uint64_t lost_samples;
     struct event_log event_log[1];
 } xenoprof_buf_t;
-DEFINE_GUEST_HANDLE(xenoprof_buf_t);
+DEFINE_XEN_GUEST_HANDLE(xenoprof_buf_t);
 
 typedef struct xenoprof_init {
     int32_t  max_samples;
@@ -63,7 +63,7 @@ typedef struct xenoprof_init {
     uint64_t buf_maddr;
     char cpu_type[XENOPROF_CPU_TYPE_SIZE];
 } xenoprof_init_t;
-DEFINE_GUEST_HANDLE(xenoprof_init_t);
+DEFINE_XEN_GUEST_HANDLE(xenoprof_init_t);
 
 typedef struct xenoprof_counter {
     uint32_t ind;
@@ -75,7 +75,7 @@ typedef struct xenoprof_counter {
     uint32_t user;
     uint64_t unit_mask;
 } xenoprof_counter_t;
-DEFINE_GUEST_HANDLE(xenoprof_counter_t);
+DEFINE_XEN_GUEST_HANDLE(xenoprof_counter_t);
 
 
 #endif /* __XEN_PUBLIC_XENOPROF_H__ */
xen/include/xen/console.h +1 -1
diff -r 1d69cff40b8c xen/include/xen/console.h
@@ -14,7 +14,7 @@ extern spinlock_t console_lock;
 
 void set_printk_prefix(const char *prefix);
 
-long read_console_ring(GUEST_HANDLE(char), u32 *, int);
+long read_console_ring(XEN_GUEST_HANDLE(char), u32 *, int);
 
 void init_console(void);
 void console_endboot(int disable_vga);
xen/include/xen/hypercall.h +11 -11
diff -r 1d69cff40b8c xen/include/xen/hypercall.h
@@ -25,20 +25,20 @@ extern long
 extern long
 do_sched_op(
     int cmd,
-    GUEST_HANDLE(void) arg);
+    XEN_GUEST_HANDLE(void) arg);
 
 extern long
 do_dom0_op(
-    GUEST_HANDLE(dom0_op_t) u_dom0_op);
+    XEN_GUEST_HANDLE(dom0_op_t) u_dom0_op);
 
 extern long
 do_memory_op(
     int cmd,
-    GUEST_HANDLE(void) arg);
+    XEN_GUEST_HANDLE(void) arg);
 
 extern long
 do_multicall(
-    GUEST_HANDLE(multicall_entry_t) call_list,
+    XEN_GUEST_HANDLE(multicall_entry_t) call_list,
     unsigned int nr_calls);
 
 extern long
@@ -47,23 +47,23 @@ do_set_timer_op(
 
 extern long
 do_event_channel_op(
-    GUEST_HANDLE(evtchn_op_t) uop);
+    XEN_GUEST_HANDLE(evtchn_op_t) uop);
 
 extern long
 do_xen_version(
     int cmd,
-    GUEST_HANDLE(void) arg);
+    XEN_GUEST_HANDLE(void) arg);
 
 extern long
 do_console_io(
     int cmd,
     int count,
-    GUEST_HANDLE(char) buffer);
+    XEN_GUEST_HANDLE(char) buffer);
 
 extern long
 do_grant_table_op(
     unsigned int cmd,
-    GUEST_HANDLE(void) uop,
+    XEN_GUEST_HANDLE(void) uop,
     unsigned int count);
 
 extern long
@@ -75,15 +75,15 @@ do_vcpu_op(
 do_vcpu_op(
     int cmd,
     int vcpuid,
-    GUEST_HANDLE(void) arg);
+    XEN_GUEST_HANDLE(void) arg);
 
 extern long
 do_acm_op(
-    GUEST_HANDLE(acm_op_t) u_acm_op);
+    XEN_GUEST_HANDLE(acm_op_t) u_acm_op);
 
 extern long
 do_nmi_op(
     unsigned int cmd,
-    GUEST_HANDLE(void) arg);
+    XEN_GUEST_HANDLE(void) arg);
 
 #endif /* __XEN_HYPERCALL_H__ */
xen/include/xen/sched.h +1 -1
diff -r 1d69cff40b8c xen/include/xen/sched.h
@@ -316,7 +316,7 @@ void startup_cpu_idle_loop(void);
  * It contains one character per argument as follows:
  *  'i' [unsigned] {char, int}
  *  'l' [unsigned] long
- *  'h' guest handle (GUEST_HANDLE(foo))
+ *  'h' guest handle (XEN_GUEST_HANDLE(foo))
  */
 unsigned long hypercall_create_continuation(
     unsigned int op, const char *format, ...);

Wrap all GUEST_HANDLEs in structures, and define SET/GET macros to access them in Linux and libxc.

linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c +1 -1
diff -r 96cc994dee76 linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c
@@ -70,7 +70,7 @@ static int do_microcode_update (void)
 		return err;
 
 	op.cmd = DOM0_MICROCODE;
-	op.u.microcode.data = user_buffer;
+	SET_XEN_GUEST_HANDLE(op.u.microcode.data, user_buffer);
 	op.u.microcode.length = user_buffer_size;
 	err = HYPERVISOR_dom0_op(&op);
 
linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c +1 -1
diff -r 96cc994dee76 linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c
@@ -1368,7 +1368,7 @@ legacy_init_iomem_resources(struct resou
 #ifdef CONFIG_XEN
 	map = alloc_bootmem_low_pages(PAGE_SIZE);
 	op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
-	op.u.physical_memory_map.memory_map = map;
+	SET_XEN_GUEST_HANDLE(op.u.physical_memory_map.memory_map, map);
 	op.u.physical_memory_map.max_map_entries =
 		PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
 	BUG_ON(HYPERVISOR_dom0_op(&op));
linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c +2 -2
diff -r 96cc994dee76 linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c
@@ -271,11 +271,11 @@ int xen_create_contiguous_region(
 	pte_t         *pte;
 	unsigned long  frame, i, flags;
 	struct xen_memory_reservation reservation = {
-		.extent_start = &frame,
 		.nr_extents   = 1,
 		.extent_order = 0,
 		.domid        = DOMID_SELF
 	};
+	SET_XEN_GUEST_HANDLE(reservation.extent_start, &frame);
 
 	/*
 	 * Currently an auto-translated guest will not perform I/O, nor will
@@ -357,11 +357,11 @@ void xen_destroy_contiguous_region(unsig
 	pte_t         *pte;
 	unsigned long  frame, i, flags;
 	struct xen_memory_reservation reservation = {
-		.extent_start = &frame,
 		.nr_extents   = 1,
 		.extent_order = 0,
 		.domid        = DOMID_SELF
 	};
+	SET_XEN_GUEST_HANDLE(reservation.extent_start, &frame);
 
 	if (xen_feature(XENFEAT_auto_translated_physmap))
 		return;
linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c +1 -1
diff -r 96cc994dee76 linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c
@@ -600,7 +600,7 @@ void __init e820_reserve_resources(void)
 
 	map = alloc_bootmem_low_pages(PAGE_SIZE);
 	op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
-	op.u.physical_memory_map.memory_map = map;
+	SET_XEN_GUEST_HANDLE(op.u.physical_memory_map.memory_map, map);
 	op.u.physical_memory_map.max_map_entries =
 		PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
 	BUG_ON(HYPERVISOR_dom0_op(&op));
linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c +4 -4
diff -r 96cc994dee76 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
@@ -195,14 +195,14 @@ static int increase_reservation(unsigned
 		page = balloon_next_page(page);
 	}
 
-	reservation.extent_start = frame_list;
+	SET_XEN_GUEST_HANDLE(reservation.extent_start, frame_list);
 	reservation.nr_extents   = nr_pages;
 	rc = HYPERVISOR_memory_op(
 		XENMEM_populate_physmap, &reservation);
 	if (rc < nr_pages) {
 		int ret;
 		/* We hit the Xen hard limit: reprobe. */
-		reservation.extent_start = frame_list;
+		SET_XEN_GUEST_HANDLE(reservation.extent_start, frame_list);
 		reservation.nr_extents   = rc;
 		ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
 				&reservation);
@@ -308,7 +308,7 @@ static int decrease_reservation(unsigned
 		balloon_append(pfn_to_page(pfn));
 	}
 
-	reservation.extent_start = frame_list;
+	SET_XEN_GUEST_HANDLE(reservation.extent_start, frame_list);
 	reservation.nr_extents   = nr_pages;
 	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
 	BUG_ON(ret != nr_pages);
@@ -522,11 +522,11 @@ static int dealloc_pte_fn(
 	unsigned long mfn = pte_mfn(*pte);
 	int ret;
 	struct xen_memory_reservation reservation = {
-		.extent_start = &mfn,
 		.nr_extents   = 1,
 		.extent_order = 0,
 		.domid        = DOMID_SELF
 	};
+	SET_XEN_GUEST_HANDLE(reservation.extent_start, &mfn);
 	set_pte_at(&init_mm, addr, pte, __pte_ma(0));
 	set_phys_to_machine(__pa(addr) >> PAGE_SHIFT, INVALID_P2M_ENTRY);
 	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
linux-2.6-xen-sparse/drivers/xen/core/gnttab.c +1 -1
diff -r 96cc994dee76 linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
@@ -399,7 +399,7 @@ gnttab_resume(void)
 
 	setup.dom        = DOMID_SELF;
 	setup.nr_frames  = NR_GRANT_FRAMES;
-	setup.frame_list = frames;
+	SET_XEN_GUEST_HANDLE(setup.frame_list, frames);
 
 	rc = HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
 	if (rc == -ENOSYS)
linux-2.6-xen-sparse/drivers/xen/netback/netback.c +1 -1
diff -r 96cc994dee76 linux-2.6-xen-sparse/drivers/xen/netback/netback.c
@@ -105,11 +105,11 @@ static unsigned long alloc_mfn(void)
 {
 	unsigned long mfn = 0, flags;
 	struct xen_memory_reservation reservation = {
-		.extent_start = mfn_list,
 		.nr_extents   = MAX_MFN_ALLOC,
 		.extent_order = 0,
 		.domid        = DOMID_SELF
 	};
+	SET_XEN_GUEST_HANDLE(reservation.extent_start, mfn_list);
 	spin_lock_irqsave(&mfn_lock, flags);
 	if ( unlikely(alloc_index == 0) )
 		alloc_index = HYPERVISOR_memory_op(
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c +1 -1
diff -r 96cc994dee76 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
@@ -607,7 +607,7 @@ static void network_alloc_rx_buffers(str
 	/* Tell the ballon driver what is going on. */
 	balloon_update_driver_allowance(i);
 
-	reservation.extent_start = np->rx_pfn_array;
+	SET_XEN_GUEST_HANDLE(reservation.extent_start, np->rx_pfn_array);
 	reservation.nr_extents   = i;
 	reservation.extent_order = 0;
 	reservation.address_bits = 0;
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h +5 -4
diff -r 96cc994dee76 linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h
@@ -163,13 +163,14 @@ HYPERVISOR_poll(
 	evtchn_port_t *ports, unsigned int nr_ports, u64 timeout)
 {
 	struct sched_poll sched_poll = {
-		.ports = ports,
 		.nr_ports = nr_ports,
 		.timeout = jiffies_to_st(timeout)
 	};
-
-	int rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll);
-
+	int rc;
+
+	SET_XEN_GUEST_HANDLE(sched_poll.ports, ports);
+
+	rc = HYPERVISOR_sched_op(SCHEDOP_poll, &sched_poll);
 	if (rc == -ENOSYS)
 		rc = HYPERVISOR_sched_op_compat(SCHEDOP_yield, 0);
 
tools/libxc/xc_domain.c +12 -9
diff -r 96cc994dee76 tools/libxc/xc_domain.c
@@ -171,7 +171,7 @@ int xc_domain_getinfolist(int xc_handle,
     op.cmd = DOM0_GETDOMAININFOLIST;
     op.u.getdomaininfolist.first_domain = first_domain;
     op.u.getdomaininfolist.max_domains  = max_domains;
-    op.u.getdomaininfolist.buffer       = info;
+    SET_XEN_GUEST_HANDLE(op.u.getdomaininfolist.buffer, info);
 
     if ( xc_dom0_op(xc_handle, &op) < 0 )
         ret = -1;
@@ -195,7 +195,7 @@ int xc_vcpu_getcontext(int xc_handle,
     op.cmd = DOM0_GETVCPUCONTEXT;
     op.u.getvcpucontext.domain = (domid_t)domid;
     op.u.getvcpucontext.vcpu   = (uint16_t)vcpu;
-    op.u.getvcpucontext.ctxt   = ctxt;
+    SET_XEN_GUEST_HANDLE(op.u.getvcpucontext.ctxt, ctxt);
 
     if ( (rc = mlock(ctxt, sizeof(*ctxt))) != 0 )
         return rc;
@@ -220,7 +220,7 @@ int xc_shadow_control(int xc_handle,
     op.cmd = DOM0_SHADOW_CONTROL;
     op.u.shadow_control.domain = (domid_t)domid;
     op.u.shadow_control.op     = sop;
-    op.u.shadow_control.dirty_bitmap = dirty_bitmap;
+    SET_XEN_GUEST_HANDLE(op.u.shadow_control.dirty_bitmap, dirty_bitmap);
     op.u.shadow_control.pages  = pages;
 
     rc = do_dom0_op(xc_handle, &op);
@@ -295,13 +295,15 @@ int xc_domain_memory_increase_reservatio
 {
     int err;
     struct xen_memory_reservation reservation = {
-        .extent_start = extent_start, /* may be NULL */
         .nr_extents   = nr_extents,
         .extent_order = extent_order,
         .address_bits = address_bits,
         .domid        = domid
     };
 
+    /* may be NULL */
+    SET_XEN_GUEST_HANDLE(reservation.extent_start, extent_start);
+
     err = xc_memory_op(xc_handle, XENMEM_increase_reservation, &reservation);
     if ( err == nr_extents )
         return 0;
@@ -326,12 +328,13 @@ int xc_domain_memory_decrease_reservatio
 {
     int err;
     struct xen_memory_reservation reservation = {
-        .extent_start = extent_start,
         .nr_extents   = nr_extents,
         .extent_order = extent_order,
         .address_bits = 0,
         .domid        = domid
     };
+
+    SET_XEN_GUEST_HANDLE(reservation.extent_start, extent_start);
 
     if ( extent_start == NULL )
     {
@@ -364,12 +367,12 @@ int xc_domain_memory_populate_physmap(in
 {
     int err;
     struct xen_memory_reservation reservation = {
-        .extent_start = extent_start,
         .nr_extents   = nr_extents,
         .extent_order = extent_order,
         .address_bits = address_bits,
         .domid        = domid
     };
+    SET_XEN_GUEST_HANDLE(reservation.extent_start, extent_start);
 
     err = xc_memory_op(xc_handle, XENMEM_populate_physmap, &reservation);
     if ( err == nr_extents )
@@ -395,9 +398,9 @@ int xc_domain_translate_gpfn_list(int xc
     struct xen_translate_gpfn_list op = {
         .domid        = domid,
         .nr_gpfns     = nr_gpfns,
-        .gpfn_list    = gpfn_list,
-        .mfn_list     = mfn_list
     };
+    SET_XEN_GUEST_HANDLE(op.gpfn_list, gpfn_list);
+    SET_XEN_GUEST_HANDLE(op.mfn_list, mfn_list);
 
     return xc_memory_op(xc_handle, XENMEM_translate_gpfn_list, &op);
 }
@@ -467,7 +470,7 @@ int xc_vcpu_setcontext(int xc_handle,
     op.cmd = DOM0_SETVCPUCONTEXT;
     op.u.setvcpucontext.domain = domid;
     op.u.setvcpucontext.vcpu = vcpu;
-    op.u.setvcpucontext.ctxt = ctxt;
+    SET_XEN_GUEST_HANDLE(op.u.setvcpucontext.ctxt, ctxt);
 
     if ( (rc = mlock(ctxt, sizeof(*ctxt))) != 0 )
         return rc;
tools/libxc/xc_hvm_build.c +1 -1
diff -r 96cc994dee76 tools/libxc/xc_hvm_build.c
@@ -440,7 +440,7 @@ static int xc_hvm_build_internal(int xc_
 
     launch_op.u.setvcpucontext.domain = (domid_t)domid;
     launch_op.u.setvcpucontext.vcpu   = 0;
-    launch_op.u.setvcpucontext.ctxt   = ctxt;
+    SET_XEN_GUEST_HANDLE(launch_op.u.setvcpucontext.ctxt, ctxt);
 
     launch_op.cmd = DOM0_SETVCPUCONTEXT;
     rc = xc_dom0_op(xc_handle, &launch_op);
tools/libxc/xc_linux_build.c +1 -1
diff -r 96cc994dee76 tools/libxc/xc_linux_build.c
@@ -1180,7 +1180,7 @@ static int xc_linux_build_internal(int x
 
     launch_op.u.setvcpucontext.domain = (domid_t)domid;
     launch_op.u.setvcpucontext.vcpu   = 0;
-    launch_op.u.setvcpucontext.ctxt   = ctxt;
+    SET_XEN_GUEST_HANDLE(launch_op.u.setvcpucontext.ctxt, ctxt);
 
     launch_op.cmd = DOM0_SETVCPUCONTEXT;
     rc = xc_dom0_op(xc_handle, &launch_op);
tools/libxc/xc_linux_restore.c +2 -2
diff -r 96cc994dee76 tools/libxc/xc_linux_restore.c
@@ -583,11 +583,11 @@ int xc_linux_restore(int xc_handle, int 
         if (count > 0) {
 
             struct xen_memory_reservation reservation = {
-                .extent_start = pfntab,
                 .nr_extents   = count,
                 .extent_order = 0,
                 .domid        = dom
             };
+            SET_XEN_GUEST_HANDLE(reservation.extent_start, pfntab);
 
             if ((rc = xc_memory_op(xc_handle, XENMEM_decrease_reservation,
                                    &reservation)) != count) {
@@ -727,7 +727,7 @@ int xc_linux_restore(int xc_handle, int 
     op.cmd = DOM0_SETVCPUCONTEXT;
     op.u.setvcpucontext.domain = (domid_t)dom;
     op.u.setvcpucontext.vcpu   = 0;
-    op.u.setvcpucontext.ctxt   = &ctxt;
+    SET_XEN_GUEST_HANDLE(op.u.setvcpucontext.ctxt, &ctxt);
     rc = xc_dom0_op(xc_handle, &op);
 
     if (rc != 0) {
tools/libxc/xc_linux_save.c +5 -3
diff -r 96cc994dee76 tools/libxc/xc_linux_save.c
@@ -509,16 +509,18 @@ static unsigned long *xc_map_m2p(int xc_
     privcmd_mmap_entry_t *entries;
     unsigned long m2p_chunks, m2p_size;
     unsigned long *m2p;
+    unsigned long *extent_start;
     int i, rc;
 
     m2p_size   = M2P_SIZE(max_mfn);
     m2p_chunks = M2P_CHUNKS(max_mfn);
 
     xmml.max_extents = m2p_chunks;
-    if (!(xmml.extent_start = malloc(m2p_chunks * sizeof(unsigned long)))) {
+    if (!(extent_start = malloc(m2p_chunks * sizeof(unsigned long)))) {
         ERR("failed to allocate space for m2p mfns");
         return NULL;
     }
+    SET_XEN_GUEST_HANDLE(xmml.extent_start, extent_start);
 
     if (xc_memory_op(xc_handle, XENMEM_machphys_mfn_list, &xmml) ||
         (xmml.nr_extents != m2p_chunks)) {
@@ -543,7 +545,7 @@ static unsigned long *xc_map_m2p(int xc_
 
     for (i=0; i < m2p_chunks; i++) {
         entries[i].va = (unsigned long)(((void *)m2p) + (i * M2P_CHUNK_SIZE));
-        entries[i].mfn = xmml.extent_start[i];
+        entries[i].mfn = extent_start[i];
         entries[i].npages = M2P_CHUNK_SIZE >> PAGE_SHIFT;
     }
 
@@ -552,7 +554,7 @@ static unsigned long *xc_map_m2p(int xc_
         return NULL;
     }
 
-    free(xmml.extent_start);
+    free(extent_start);
     free(entries);
 
     return m2p;
tools/libxc/xc_misc.c +3 -3
diff -r 96cc994dee76 tools/libxc/xc_misc.c
@@ -30,7 +30,7 @@ int xc_readconsolering(int xc_handle,
     unsigned int nr_chars = *pnr_chars;
 
     op.cmd = DOM0_READCONSOLE;
-    op.u.readconsole.buffer = buffer;
+    SET_XEN_GUEST_HANDLE(op.u.readconsole.buffer, buffer);
     op.u.readconsole.count  = nr_chars;
     op.u.readconsole.clear  = clear;
 
@@ -39,7 +39,7 @@ int xc_readconsolering(int xc_handle,
 
     if ( (ret = do_dom0_op(xc_handle, &op)) == 0 )
     {
-        *pbuffer   = op.u.readconsole.buffer;
+        GET_XEN_GUEST_HANDLE(*pbuffer, op.u.readconsole.buffer);
         *pnr_chars = op.u.readconsole.count;
     }
 
@@ -91,7 +91,7 @@ int xc_perfc_control(int xc_handle,
 
     op.cmd = DOM0_PERFCCONTROL;
     op.u.perfccontrol.op   = opcode;
-    op.u.perfccontrol.desc = desc;
+    SET_XEN_GUEST_HANDLE(op.u.perfccontrol.desc, desc);
 
     rc = do_dom0_op(xc_handle, &op);
 
tools/libxc/xc_private.c +26 -15

98 lines not on this page · raw message

xen/include/public/arch-ia64.h +5 -8
diff -r 96cc994dee76 xen/include/public/arch-ia64.h
@@ -7,16 +7,13 @@
 #ifndef __HYPERVISOR_IF_IA64_H__
 #define __HYPERVISOR_IF_IA64_H__
 
-#ifdef __XEN__
 #define __DEFINE_XEN_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
-
-#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
-#define XEN_GUEST_HANDLE(name)        __guest_handle_ ## name
+
+#define DEFINE_XEN_GUEST_HANDLE(name)   __DEFINE_XEN_GUEST_HANDLE(name, name)
+#define XEN_GUEST_HANDLE(name)          __guest_handle_ ## name
+#define SET_XEN_GUEST_HANDLE(hnd, val)  do { (hnd).p = val; } while (0)
+#define GET_XEN_GUEST_HANDLE(val, hnd)  do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
xen/include/public/arch-x86_32.h +4 -7
diff -r 96cc994dee76 xen/include/public/arch-x86_32.h
@@ -9,16 +9,13 @@
 #ifndef __XEN_PUBLIC_ARCH_X86_32_H__
 #define __XEN_PUBLIC_ARCH_X86_32_H__
 
-#ifdef __XEN__
 #define __DEFINE_XEN_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
 
-#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
-#define XEN_GUEST_HANDLE(name)        __guest_handle_ ## name
+#define DEFINE_XEN_GUEST_HANDLE(name)   __DEFINE_XEN_GUEST_HANDLE(name, name)
+#define XEN_GUEST_HANDLE(name)          __guest_handle_ ## name
+#define SET_XEN_GUEST_HANDLE(hnd, val)  do { (hnd).p = val; } while (0)
+#define GET_XEN_GUEST_HANDLE(val, hnd)  do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */
xen/include/public/arch-x86_64.h +5 -8
diff -r 96cc994dee76 xen/include/public/arch-x86_64.h
@@ -9,16 +9,13 @@
 #ifndef __XEN_PUBLIC_ARCH_X86_64_H__
 #define __XEN_PUBLIC_ARCH_X86_64_H__
 
-#ifdef __XEN__
 #define __DEFINE_XEN_GUEST_HANDLE(name, type) \
     typedef struct { type *p; } __guest_handle_ ## name
-#else
-#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
-    typedef type * __guest_handle_ ## name
-#endif
-
-#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
-#define XEN_GUEST_HANDLE(name)        __guest_handle_ ## name
+
+#define DEFINE_XEN_GUEST_HANDLE(name)   __DEFINE_XEN_GUEST_HANDLE(name, name)
+#define XEN_GUEST_HANDLE(name)          __guest_handle_ ## name
+#define SET_XEN_GUEST_HANDLE(hnd, val)  do { (hnd).p = val; } while (0)
+#define GET_XEN_GUEST_HANDLE(val, hnd)  do { val = (hnd).p; } while (0)
 
 #ifndef __ASSEMBLY__
 /* Guest handles for primitive C types. */

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#8 lore raw
In reply to Hollis Blanchard

Hollis Blanchard wrote: [Fri Apr 14 2006, 05:15:25PM EDT]

Review

Quoted 12 lines

For reference, the PPC changes look something like this:

(quoted diff) +9 -1
-    typedef struct { type *p; } __guest_handle_ ## name
+    typedef union { uint64_t u; type *p; } __guest_handle_ ## name
 
+#define SET_HANDLE(hnd, val) do {           \
+        (void)((hnd).p == (val));           \
+        (hnd).u = (uint64_t)(unsigned long)(void *)(val);  \
+    } while (0)
+
+#define GET_HANDLE(val, hnd) do {           \
+        (val) = (hnd).p;                    \
+    } while (0)

Is your final version of this code for PPC, in context, available for reference? I don't see it on the mailing lists or at
http://xenbits.xensource.com/ext/xenppc-unstable.hg

Thanks,
Aron