WARNING - OLD ARCHIVES

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

xen-devel

Re: [Xen-devel] [patch] 32/64-bit hypercall interface revisited

On Tue, 2006-04-25 at 09:01 +0100, Keir Fraser wrote:
> On 24 Apr 2006, at 20:24, Hollis Blanchard wrote:
> 
> > 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.

-- 
Hollis Blanchard
IBM Linux Technology Center


Introduce wrappers to access GUEST_HANDLES in libxc and Linux.

Signed-off-by: Hollis Blanchard <hollisb@xxxxxxxxxx>
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   Tue Apr 25 15:17:52 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 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        Tue Apr 25 15:17:52 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 56e1802303e5 tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c      Wed Apr 12 15:41:55 2006 -0500
+++ b/tools/libxc/xc_linux_build.c      Tue Apr 25 15:17:52 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 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    Tue Apr 25 15:17:52 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 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       Tue Apr 25 15:17:52 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 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     Tue Apr 25 15:17:52 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 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  Tue Apr 25 15:17:52 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 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    Tue Apr 25 15:17:52 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 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  Tue Apr 25 15:17:52 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 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  Tue Apr 25 15:17:52 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. */
diff -r 3c49a47b866f arch/i386/kernel/microcode-xen.c
--- a/arch/i386/kernel/microcode-xen.c  Mon Mar 27 18:20:10 2006 +0100
+++ b/arch/i386/kernel/microcode-xen.c  Tue Apr 25 13:17:40 2006 -0500
@@ -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);
 
diff -r 3c49a47b866f arch/i386/kernel/setup-xen.c
--- a/arch/i386/kernel/setup-xen.c      Mon Mar 27 18:20:10 2006 +0100
+++ b/arch/i386/kernel/setup-xen.c      Tue Apr 25 13:17:40 2006 -0500
@@ -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));
diff -r 3c49a47b866f arch/i386/mm/hypervisor.c
--- a/arch/i386/mm/hypervisor.c Mon Mar 27 18:20:10 2006 +0100
+++ b/arch/i386/mm/hypervisor.c Tue Apr 25 13:17:40 2006 -0500
@@ -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;
diff -r 3c49a47b866f arch/x86_64/kernel/e820-xen.c
--- a/arch/x86_64/kernel/e820-xen.c     Mon Mar 27 18:20:10 2006 +0100
+++ b/arch/x86_64/kernel/e820-xen.c     Tue Apr 25 13:17:40 2006 -0500
@@ -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));
diff -r 3c49a47b866f drivers/xen/balloon/balloon.c
--- a/drivers/xen/balloon/balloon.c     Mon Mar 27 18:20:10 2006 +0100
+++ b/drivers/xen/balloon/balloon.c     Tue Apr 25 13:17:40 2006 -0500
@@ -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);
diff -r 3c49a47b866f drivers/xen/core/gnttab.c
--- a/drivers/xen/core/gnttab.c Mon Mar 27 18:20:10 2006 +0100
+++ b/drivers/xen/core/gnttab.c Tue Apr 25 13:17:40 2006 -0500
@@ -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);
diff -r 3c49a47b866f drivers/xen/netback/netback.c
--- a/drivers/xen/netback/netback.c     Mon Mar 27 18:20:10 2006 +0100
+++ b/drivers/xen/netback/netback.c     Tue Apr 25 13:17:40 2006 -0500
@@ -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(
diff -r 3c49a47b866f drivers/xen/netfront/netfront.c
--- a/drivers/xen/netfront/netfront.c   Mon Mar 27 18:20:10 2006 +0100
+++ b/drivers/xen/netfront/netfront.c   Tue Apr 25 13:17:40 2006 -0500
@@ -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;
diff -r 3c49a47b866f include/asm-i386/hypercall.h
--- a/include/asm-i386/hypercall.h      Mon Mar 27 18:20:10 2006 +0100
+++ b/include/asm-i386/hypercall.h      Tue Apr 25 13:17:40 2006 -0500
@@ -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);
 
diff -r 3c49a47b866f include/xen/interface/arch-ia64.h
--- a/include/xen/interface/arch-ia64.h Mon Mar 27 18:20:10 2006 +0100
+++ b/include/xen/interface/arch-ia64.h Tue Apr 25 13:17:40 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 3c49a47b866f include/xen/interface/arch-x86_32.h
--- a/include/xen/interface/arch-x86_32.h       Mon Mar 27 18:20:10 2006 +0100
+++ b/include/xen/interface/arch-x86_32.h       Tue Apr 25 13:17:40 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 3c49a47b866f include/xen/interface/arch-x86_64.h
--- a/include/xen/interface/arch-x86_64.h       Mon Mar 27 18:20:10 2006 +0100
+++ b/include/xen/interface/arch-x86_64.h       Tue Apr 25 13:17:40 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. */
diff -r 61d8ff110da9 linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c     Tue Apr 25 
13:44:12 2006 -0500
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c     Tue Apr 25 
15:17:37 2006 -0500
@@ -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);
 
diff -r 61d8ff110da9 linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c
--- a/linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c Tue Apr 25 13:44:12 
2006 -0500
+++ b/linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c Tue Apr 25 15:17:37 
2006 -0500
@@ -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));
diff -r 61d8ff110da9 linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c
--- a/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c    Tue Apr 25 13:44:12 
2006 -0500
+++ b/linux-2.6-xen-sparse/arch/i386/mm/hypervisor.c    Tue Apr 25 15:17:37 
2006 -0500
@@ -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;
diff -r 61d8ff110da9 linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c
--- a/linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c        Tue Apr 25 
13:44:12 2006 -0500
+++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c        Tue Apr 25 
15:17:37 2006 -0500
@@ -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));
diff -r 61d8ff110da9 linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c
--- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Tue Apr 25 
13:44:12 2006 -0500
+++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c        Tue Apr 25 
15:17:37 2006 -0500
@@ -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);
diff -r 61d8ff110da9 linux-2.6-xen-sparse/drivers/xen/core/gnttab.c
--- a/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c    Tue Apr 25 13:44:12 
2006 -0500
+++ b/linux-2.6-xen-sparse/drivers/xen/core/gnttab.c    Tue Apr 25 15:17:37 
2006 -0500
@@ -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)
diff -r 61d8ff110da9 linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c        Tue Apr 25 
13:44:12 2006 -0500
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c        Tue Apr 25 
15:17:37 2006 -0500
@@ -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(
diff -r 61d8ff110da9 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Tue Apr 25 
13:44:12 2006 -0500
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Tue Apr 25 
15:17:37 2006 -0500
@@ -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;
diff -r 61d8ff110da9 
linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h
--- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h   Tue Apr 
25 13:44:12 2006 -0500
+++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/hypervisor.h   Tue Apr 
25 15:17:37 2006 -0500
@@ -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
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel