Skip to contentSkip to conversation

testing needed: "xenif" dom0_ops

PATCH New Hollis Blanchard 1 participant 2 messages Oct 7, 2005 – Oct 11, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 testing needed: "xenif" dom0_ops

This patch changes the dom0_ops structures as discussed in the thread "32/64-bit hypercall interface". Keir, I added a struct inside XENIF_PTR() to catch direct users in the general code; it was quite useful to have the compiler identify those spots.

I have compiled x86_32 and run it with xm-test[1] under qemu. There are 63 passed tests, so that's good. I still need to verify that the 6 failures were not caused by this patch.

I would really appreciate people testing this patch. It should cause no functional changes at all. Some areas, such as the "microcode" op, likely don't see much testing ordinarily...

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

Signature · 4 lines
Hollis Blanchard
IBM Linux Technology Center

Signed-off-by: Hollis Blanchard <[email protected]>
linux-2.6-xen-sparse/arch/xen/i386/kernel/microcode.c +1 -1
diff -r 85f92475b943 linux-2.6-xen-sparse/arch/xen/i386/kernel/microcode.c
@@ -68,7 +68,7 @@
 		return err;
 
 	op.cmd = DOM0_MICROCODE;
-	op.u.microcode.data = user_buffer;
+	xenif_pack_ptr(op.u.microcode.data, user_buffer);
 	op.u.microcode.length = user_buffer_size;
 	err = HYPERVISOR_dom0_op(&op);
 
linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c +1 -1
diff -r 85f92475b943 linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c
@@ -1250,7 +1250,7 @@
 #ifdef CONFIG_XEN
 	map = alloc_bootmem_low_pages(PAGE_SIZE);
 	op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
-	op.u.physical_memory_map.memory_map = map;
+	xenif_pack_ptr(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));
tools/debugger/libxendebug/xendebug.c +1 -1
diff -r 85f92475b943 tools/debugger/libxendebug/xendebug.c
@@ -142,7 +142,7 @@
     op.cmd = DOM0_SETDOMAININFO;
     op.u.setdomaininfo.domain = ctxt->domid;
     op.u.setdomaininfo.vcpu = vcpu;
-    op.u.setdomaininfo.ctxt = &ctxt->context[vcpu];
+    xenif_pack_ptr(op.u.setdomaininfo.ctxt, &ctxt->context[vcpu]);
 
     if ( (rc = mlock(&ctxt->context[vcpu], sizeof(vcpu_guest_context_t))) )
         return rc;
tools/libxc/xc_domain.c +4 -4
diff -r 85f92475b943 tools/libxc/xc_domain.c
@@ -65,7 +65,7 @@
     op.cmd = DOM0_PINCPUDOMAIN;
     op.u.pincpudomain.domain  = (domid_t)domid;
     op.u.pincpudomain.vcpu    = vcpu;
-    op.u.pincpudomain.cpumap  = cpumap;
+    xenif_pack_ptr(op.u.pincpudomain.cpumap, cpumap);
     return do_dom0_op(xc_handle, &op);
 }
 
@@ -140,7 +140,7 @@
     op.cmd = DOM0_GETDOMAININFOLIST;
     op.u.getdomaininfolist.first_domain = first_domain;
     op.u.getdomaininfolist.max_domains  = max_domains;
-    op.u.getdomaininfolist.buffer       = info;
+    xenif_pack_ptr(op.u.getdomaininfolist.buffer, info);
 
     if ( xc_dom0_op(xc_handle, &op) < 0 )
         ret = -1;
@@ -164,7 +164,7 @@
     op.cmd = DOM0_GETVCPUCONTEXT;
     op.u.getvcpucontext.domain = (domid_t)domid;
     op.u.getvcpucontext.vcpu   = (u16)vcpu;
-    op.u.getvcpucontext.ctxt   = ctxt;
+    xenif_pack_ptr(op.u.getvcpucontext.ctxt, ctxt);
 
     if ( (ctxt != NULL) &&
          ((rc = mlock(ctxt, sizeof(*ctxt))) != 0) )
@@ -194,7 +194,7 @@
     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;
+    xenif_pack_ptr(op.u.shadow_control.dirty_bitmap, dirty_bitmap);
     op.u.shadow_control.pages  = pages;
 
     rc = do_dom0_op(xc_handle, &op);
tools/libxc/xc_linux_build.c +1 -1
diff -r 85f92475b943 tools/libxc/xc_linux_build.c
@@ -847,7 +847,7 @@
 
     launch_op.u.setdomaininfo.domain = (domid_t)domid;
     launch_op.u.setdomaininfo.vcpu   = 0;
-    launch_op.u.setdomaininfo.ctxt   = ctxt;
+    xenif_pack_ptr(launch_op.u.setdomaininfo.ctxt, ctxt);
 
     launch_op.cmd = DOM0_SETDOMAININFO;
     rc = xc_dom0_op(xc_handle, &launch_op);
tools/libxc/xc_linux_restore.c +1 -1
diff -r 85f92475b943 tools/libxc/xc_linux_restore.c
@@ -631,7 +631,7 @@
     op.cmd = DOM0_SETDOMAININFO;
     op.u.setdomaininfo.domain = (domid_t)dom;
     op.u.setdomaininfo.vcpu   = 0;
-    op.u.setdomaininfo.ctxt   = &ctxt;
+    xenif_pack_ptr(op.u.setdomaininfo.ctxt, &ctxt);
     rc = xc_dom0_op(xc_handle, &op);
 
     if ( rc != 0 )
tools/libxc/xc_misc.c +3 -3
diff -r 85f92475b943 tools/libxc/xc_misc.c
@@ -30,7 +30,7 @@
     unsigned int nr_chars = *pnr_chars;
 
     op.cmd = DOM0_READCONSOLE;
-    op.u.readconsole.buffer = buffer;
+    xenif_pack_ptr(op.u.readconsole.buffer, buffer);
     op.u.readconsole.count  = nr_chars;
     op.u.readconsole.clear  = clear;
 
@@ -39,7 +39,7 @@
 
     if ( (ret = do_dom0_op(xc_handle, &op)) == 0 )
     {
-        *pbuffer   = op.u.readconsole.buffer;
+        xenif_unpack_ptr(*pbuffer, op.u.readconsole.buffer);
         *pnr_chars = op.u.readconsole.count;
     }
 
@@ -91,7 +91,7 @@
 
     dop.cmd = DOM0_PERFCCONTROL;
     dop.u.perfccontrol.op   = op;
-    dop.u.perfccontrol.desc = desc;
+    xenif_pack_ptr(dop.u.perfccontrol.desc, desc);
 
     rc = do_dom0_op(xc_handle, &dop);
 
tools/libxc/xc_private.c +6 -5
diff -r 85f92475b943 tools/libxc/xc_private.c
@@ -72,7 +72,7 @@
     op.cmd = DOM0_GETPAGEFRAMEINFO2;
     op.u.getpageframeinfo2.domain = (domid_t)dom;
     op.u.getpageframeinfo2.num    = num;
-    op.u.getpageframeinfo2.array  = arr;
+    xenif_pack_ptr(op.u.getpageframeinfo2.array, arr);
     return do_dom0_op(xc_handle, &op);
 }
 
@@ -259,7 +259,8 @@
     op.cmd = DOM0_GETVCPUCONTEXT;
     op.u.getvcpucontext.domain = (domid_t)domid;
     op.u.getvcpucontext.vcpu   = (u16)vcpu;
-    op.u.getvcpucontext.ctxt   = NULL;
+    xenif_pack_ptr(op.u.getvcpucontext.ctxt, NULL);
+
     if ( (do_dom0_op(xc_handle, &op) < 0) )
     {
         PERROR("Could not get info on domain");
@@ -291,8 +292,8 @@
     op.cmd = DOM0_GETMEMLIST;
     op.u.getmemlist.domain   = (domid_t)domid;
     op.u.getmemlist.max_pfns = max_pfns;
-    op.u.getmemlist.buffer   = pfn_buf;
-
+
+    xenif_pack_ptr(op.u.getmemlist.buffer, pfn_buf);
 
     if ( mlock(pfn_buf, max_pfns * sizeof(unsigned long)) != 0 )
     {
@@ -335,7 +336,7 @@
     op.cmd = DOM0_GETMEMLIST;
     op.u.getmemlist.domain   = (domid_t)domid;
     op.u.getmemlist.max_pfns = ((unsigned long)start_page << 32) | nr_pages;
-    op.u.getmemlist.buffer   = pfn_buf;
+    xenif_pack_ptr(op.u.getmemlist.buffer, pfn_buf);
 
     if ( mlock(pfn_buf, nr_pages * sizeof(unsigned long)) != 0 )
     {
tools/libxc/xc_ptrace.c +3 -3
diff -r 85f92475b943 tools/libxc/xc_ptrace.c
@@ -385,7 +385,7 @@
         op.u.setdomaininfo.domain = domid;
         /* XXX need to understand multiple vcpus */
         op.u.setdomaininfo.vcpu = cpu;
-        op.u.setdomaininfo.ctxt = &ctxt[cpu];
+        xenif_pack_ptr(op.u.setdomaininfo.ctxt, &ctxt[cpu]);
         retval = do_dom0_op(xc_handle, &op);
         if (retval)
             goto error_out;
@@ -416,7 +416,7 @@
         op.cmd = DOM0_SETDOMAININFO;
         op.u.setdomaininfo.domain = domid;
         op.u.setdomaininfo.vcpu = 0;
-        op.u.setdomaininfo.ctxt = &ctxt[cpu];
+        xenif_pack_ptr(op.u.setdomaininfo.ctxt, &ctxt[cpu]);
         retval = do_dom0_op(xc_handle, &op); 
         if ( retval )
         {
@@ -437,7 +437,7 @@
                 op.cmd = DOM0_SETDOMAININFO;
                 op.u.setdomaininfo.domain = domid;
                 op.u.setdomaininfo.vcpu = cpu;
-                op.u.setdomaininfo.ctxt = &ctxt[cpu];
+                xenif_pack_ptr(op.u.setdomaininfo.ctxt, &ctxt[cpu]);
                 retval = do_dom0_op(xc_handle, &op); 
                 if ( retval )
                 {
tools/libxc/xc_vmx_build.c +1 -1
diff -r 85f92475b943 tools/libxc/xc_vmx_build.c
@@ -700,7 +700,7 @@
 
     launch_op.u.setdomaininfo.domain = (domid_t)domid;
     launch_op.u.setdomaininfo.vcpu   = 0;
-    launch_op.u.setdomaininfo.ctxt   = ctxt;
+    xenif_pack_ptr(launch_op.u.setdomaininfo.ctxt, ctxt);
 
     launch_op.cmd = DOM0_SETDOMAININFO;
     rc = xc_dom0_op(xc_handle, &launch_op);
tools/xenstat/libxenstat/src/xen-interface.c +2 -2
diff -r 85f92475b943 tools/xenstat/libxenstat/src/xen-interface.c
@@ -160,7 +160,7 @@
 	dom0_op_t op;
 	op.u.getdomaininfolist.first_domain = first_domain;
 	op.u.getdomaininfolist.max_domains = max_domains;
-	op.u.getdomaininfolist.buffer = info;
+	xenif_pack_ptr(op.u.getdomaininfolist.buffer, info);
 
 	if (mlock( info, max_domains * sizeof(dom0_getdomaininfo_t)) < 0) {
 		perror("Failed to mlock domaininfo array");
@@ -182,7 +182,7 @@
 	dom0_op_t op;
 	op.u.getvcpucontext.domain = domain;
 	op.u.getvcpucontext.vcpu = vcpu;
-	op.u.getvcpucontext.ctxt = NULL;
+	xenif_pack_ptr(op.u.getvcpucontext.ctxt, NULL);
 
 	if (xi_make_dom0_op(handle, &op, DOM0_GETVCPUCONTEXT) < 0) {
 		perror("DOM0_GETVCPUCONTEXT Hypercall failed");
xen/arch/ia64/xen/dom0_ops.c +6 -2
diff -r 85f92475b943 xen/arch/ia64/xen/dom0_ops.c
@@ -73,10 +73,12 @@
         int n,j;
         int num = op->u.getpageframeinfo2.num;
         domid_t dom = op->u.getpageframeinfo2.domain;
-        unsigned long *s_ptr = (unsigned long*) op->u.getpageframeinfo2.array;
+        unsigned long *s_ptr;
         struct domain *d;
         unsigned long *l_arr;
         ret = -ESRCH;
+
+        xenif_unpack_ptr(s_ptr, op->u.getpageframeinfo2.array);
 
         if ( unlikely((d = find_domain_by_id(dom)) == NULL) )
             break;
@@ -159,8 +161,10 @@
         unsigned long start_page = op->u.getmemlist.max_pfns >> 32;
         unsigned long nr_pages = op->u.getmemlist.max_pfns & 0xffffffff;
         unsigned long pfn;
-        unsigned long *buffer = op->u.getmemlist.buffer;
+        unsigned long *buffer;
         struct page *page;
+
+        xenif_unpack_ptr(buffer, op->u.getmemlist.buffer);
 
         ret = -EINVAL;
         if ( d != NULL )
xen/arch/x86/dom0_ops.c +14 -6
diff -r 85f92475b943 xen/arch/x86/dom0_ops.c
@@ -132,7 +132,10 @@
     case DOM0_MICROCODE:
     {
         extern int microcode_update(void *buf, unsigned long len);
-        ret = microcode_update(op->u.microcode.data, op->u.microcode.length);
+        void *data;
+
+        xenif_unpack_ptr(data, op->u.microcode.data);
+        ret = microcode_update(data, op->u.microcode.length);
     }
     break;
 
@@ -252,10 +255,12 @@
         int n,j;
         int num = op->u.getpageframeinfo2.num;
         domid_t dom = op->u.getpageframeinfo2.domain;
-        unsigned long *s_ptr = (unsigned long*) op->u.getpageframeinfo2.array;
+        unsigned long *s_ptr;
         struct domain *d;
         unsigned long *l_arr;
         ret = -ESRCH;
+
+        xenif_unpack_ptr(s_ptr, op->u.getpageframeinfo2.array);
 
         if ( unlikely((d = find_domain_by_id(dom)) == NULL) )
             break;
@@ -343,8 +348,10 @@
         struct domain *d = find_domain_by_id(op->u.getmemlist.domain);
         unsigned long max_pfns = op->u.getmemlist.max_pfns;
         unsigned long pfn;
-        unsigned long *buffer = op->u.getmemlist.buffer;
+        unsigned long *buffer;
         struct list_head *list_ent;
+
+        xenif_unpack_ptr(buffer, op->u.getmemlist.buffer);
 
         ret = -EINVAL;
         if ( d != NULL )
@@ -395,7 +402,10 @@
     case DOM0_PHYSICAL_MEMORY_MAP:
     {
         struct dom0_memory_map_entry entry;
+        struct dom0_memory_map_entry *memory_map;
         int i;
+
+        xenif_unpack_ptr(memory_map, op->u.physical_memory_map.memory_map);
 
         for ( i = 0; i < e820.nr_map; i++ )
         {
@@ -404,9 +414,7 @@
             entry.start  = e820.map[i].addr;
             entry.end    = e820.map[i].addr + e820.map[i].size;
             entry.is_ram = (e820.map[i].type == E820_RAM);
-            (void)copy_to_user(
-                &op->u.physical_memory_map.memory_map[i],
-                &entry, sizeof(entry));
+            (void)copy_to_user(&memory_map[i], &entry, sizeof(entry));
         }
 
         op->u.physical_memory_map.nr_map_entries = i;
xen/arch/x86/shadow32.c +7 -4
diff -r 85f92475b943 xen/arch/x86/shadow32.c
@@ -1224,6 +1224,9 @@
     unsigned int      op = sc->op;
     int               i, rc = 0;
     struct vcpu *v;
+    unsigned long *dirty_bitmap;
+
+    xenif_unpack_ptr(dirty_bitmap, sc->dirty_bitmap);
 
     ASSERT(shadow_lock_is_acquired(d));
 
@@ -1260,7 +1263,7 @@
         d->arch.shadow_dirty_block_count = 0;
  
         if ( (d->max_pages > sc->pages) || 
-             (sc->dirty_bitmap == NULL) || 
+             (dirty_bitmap == NULL) || 
              (d->arch.shadow_dirty_bitmap == NULL) )
         {
             rc = -EINVAL;
@@ -1276,7 +1279,7 @@
                           chunk : (d->max_pages - i)) + 7) / 8;
      
             if (copy_to_user(
-                    sc->dirty_bitmap + (i/(8*sizeof(unsigned long))),
+                    dirty_bitmap + (i/(8*sizeof(unsigned long))),
                     d->arch.shadow_dirty_bitmap +(i/(8*sizeof(unsigned long))),
                     bytes))
             {
@@ -1304,7 +1307,7 @@
         sc->stats.dirty_block_count = d->arch.shadow_dirty_block_count;
  
         if ( (d->max_pages > sc->pages) || 
-             (sc->dirty_bitmap == NULL) || 
+             (dirty_bitmap == NULL) || 
              (d->arch.shadow_dirty_bitmap == NULL) )
         {
             rc = -EINVAL;
@@ -1313,7 +1316,7 @@
  
         sc->pages = d->max_pages;
         if (copy_to_user(
-            sc->dirty_bitmap, d->arch.shadow_dirty_bitmap, (d->max_pages+7)/8))
+            dirty_bitmap, d->arch.shadow_dirty_bitmap, (d->max_pages+7)/8))
         {
             rc = -EINVAL;
             break;
xen/arch/x86/shadow_public.c +7 -4
diff -r 85f92475b943 xen/arch/x86/shadow_public.c
@@ -1143,6 +1143,9 @@
     unsigned int      op = sc->op;
     int               i, rc = 0;
     struct vcpu *v;
+    unsigned long *dirty_bitmap;
+
+    xenif_unpack_ptr(dirty_bitmap, sc->dirty_bitmap);
 
     ASSERT(shadow_lock_is_acquired(d));
 
@@ -1179,7 +1182,7 @@
         d->arch.shadow_dirty_block_count = 0;
  
         if ( (d->max_pages > sc->pages) || 
-             (sc->dirty_bitmap == NULL) || 
+             (dirty_bitmap == NULL) || 
              (d->arch.shadow_dirty_bitmap == NULL) )
         {
             rc = -EINVAL;
@@ -1195,7 +1198,7 @@
                           chunk : (d->max_pages - i)) + 7) / 8;
 
             if (copy_to_user(
-                sc->dirty_bitmap + (i/(8*sizeof(unsigned long))),
+                dirty_bitmap + (i/(8*sizeof(unsigned long))),
                 d->arch.shadow_dirty_bitmap +(i/(8*sizeof(unsigned long))),
                 bytes))
             {
@@ -1222,7 +1225,7 @@
         sc->stats.dirty_block_count = d->arch.shadow_dirty_block_count;
  
         if ( (d->max_pages > sc->pages) || 
-             (sc->dirty_bitmap == NULL) || 
+             (dirty_bitmap == NULL) || 
              (d->arch.shadow_dirty_bitmap == NULL) )
         {
             rc = -EINVAL;
@@ -1231,7 +1234,7 @@
  
         sc->pages = d->max_pages;
         if (copy_to_user(
-            sc->dirty_bitmap, d->arch.shadow_dirty_bitmap, (d->max_pages+7)/8))
+            dirty_bitmap, d->arch.shadow_dirty_bitmap, (d->max_pages+7)/8))
         {
             rc = -EINVAL;
             break;
xen/common/dom0_ops.c +15 -6
diff -r 85f92475b943 xen/common/dom0_ops.c
@@ -249,8 +249,10 @@
         domid_t dom = op->u.pincpudomain.domain;
         struct domain *d = find_domain_by_id(dom);
         struct vcpu *v;
+        cpumap_t *cpumap_ptr;
         cpumap_t cpumap;
 
+        xenif_unpack_ptr(cpumap_ptr, op->u.pincpudomain.cpumap);
 
         if ( d == NULL )
         {
@@ -281,8 +283,7 @@
             break;
         }
 
-        if ( copy_from_user(&cpumap, op->u.pincpudomain.cpumap,
-                            sizeof(cpumap)) )
+        if ( copy_from_user(&cpumap, cpumap_ptr, sizeof(cpumap)) )
         {
             ret = -EFAULT;
             put_domain(d);
@@ -359,8 +360,10 @@
     { 
         struct domain *d;
         dom0_getdomaininfo_t info;
-        dom0_getdomaininfo_t *buffer = op->u.getdomaininfolist.buffer;
+        dom0_getdomaininfo_t *buffer;
         u32 num_domains = 0;
+
+        xenif_unpack_ptr(buffer, op->u.getdomaininfolist.buffer);
 
         read_lock(&domlist_lock);
 
@@ -405,10 +408,13 @@
     case DOM0_GETVCPUCONTEXT:
     { 
         struct vcpu_guest_context *c;
+        struct vcpu_guest_context *ctxt;
         struct domain             *d;
         struct vcpu               *v;
         int i;
 
+        xenif_unpack_ptr(ctxt, op->u.getvcpucontext.ctxt);
+
         d = find_domain_by_id(op->u.getvcpucontext.domain);
         if ( d == NULL )
         {
@@ -441,7 +447,7 @@
 
         op->u.getvcpucontext.cpu_time = v->cpu_time;
 
-        if ( op->u.getvcpucontext.ctxt != NULL )
+        if ( ctxt != NULL )
         {
             if ( (c = xmalloc(struct vcpu_guest_context)) == NULL )
             {
@@ -458,7 +464,7 @@
             if ( v != current )
                 vcpu_unpause(v);
 
-            if ( copy_to_user(op->u.getvcpucontext.ctxt, c, sizeof(*c)) )
+            if ( copy_to_user(ctxt, c, sizeof(*c)) )
                 ret = -EINVAL;
 
             xfree(c);
@@ -491,10 +497,13 @@
     
     case DOM0_READCONSOLE:
     {
+        char *buffer;
+        xenif_unpack_ptr(buffer, op->u.readconsole.buffer);
         ret = read_console_ring(
-            &op->u.readconsole.buffer, 
+            &buffer,
             &op->u.readconsole.count,
             op->u.readconsole.clear); 
+        xenif_pack_ptr(op->u.readconsole.buffer, buffer);
         copy_to_user(u_dom0_op, op, sizeof(*op));
     }
     break;
xen/common/domain.c +4 -1
diff -r 85f92475b943 xen/common/domain.c
@@ -338,8 +338,11 @@
 {
     int rc = 0;
     struct vcpu_guest_context *c = NULL;
+    struct vcpu_guest_context *ctxt;
     unsigned long vcpu = setdomaininfo->vcpu;
     struct vcpu *v; 
+
+    xenif_unpack_ptr(ctxt, setdomaininfo->ctxt);
 
     if ( (vcpu >= MAX_VIRT_CPUS) || ((v = d->vcpu[vcpu]) == NULL) )
         return -EINVAL;
@@ -351,7 +354,7 @@
     if ( (c = xmalloc(struct vcpu_guest_context)) == NULL )
         return -ENOMEM;
 
-    if ( copy_from_user(c, setdomaininfo->ctxt, sizeof(*c)) )
+    if ( copy_from_user(c, ctxt, sizeof(*c)) )
     {
         rc = -EFAULT;
         goto out;
xen/common/perfc.c +5 -2
diff -r 85f92475b943 xen/common/perfc.c
@@ -203,10 +203,13 @@
 /* Dom0 control of perf counters */
 int perfc_control(dom0_perfccontrol_t *pc)
 {
+    dom0_perfc_desc_t *desc;
     static spinlock_t lock = SPIN_LOCK_UNLOCKED;
     u32 op = pc->op;
     int rc;
 
+    xenif_unpack_ptr(pc->desc, desc);
+
     pc->nr_counters = NR_PERFCTRS;
 
     spin_lock(&lock);
@@ -214,13 +217,13 @@
     switch ( op )
     {
     case DOM0_PERFCCONTROL_OP_RESET:
-        perfc_copy_info(pc->desc);
+        perfc_copy_info(desc);
         perfc_reset(0);
         rc = 0;
         break;
 
     case DOM0_PERFCCONTROL_OP_QUERY:
-        perfc_copy_info(pc->desc);
+        perfc_copy_info(desc);
         rc = 0;
         break;
 
xen/include/public/arch-x86_32.h +5 -0
diff -r 85f92475b943 xen/include/public/arch-x86_32.h
@@ -62,6 +62,11 @@
 #define MAX_VIRT_CPUS 32
 
 #ifndef __ASSEMBLY__
+
+#define XENIF_PTR(type, field) struct { type val; } field ## _struct
+#define xenif_pack_ptr(field, var) do { field ## _struct.val = var; } while (0)
+#define xenif_unpack_ptr(var, field) do { var = field ## _struct.val; } while (0)
+typedef unsigned long xenif_ulong_t;
 
 /*
  * Send an array of these to HYPERVISOR_set_trap_table()
xen/include/public/dom0_ops.h +44 -32

198 lines not on this page · raw message

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

#1 lore raw

PATCH 1/1 "xenif" dom0_ops

This patch changes the dom0_ops structures as discussed in the thread "32/64-bit hypercall interface". Keir, I added a struct inside XENIF_PTR() to catch direct users in the general code; it was quite useful to have the compiler identify those spots, and it also protects against swapping arguments to pack/unpack.

Dave Barrera helped me test this patch on x86_32 hardware, with both LTP and xm-test (which stresses the dom0_ops a fair amount). There was an additional
failure: the save/restore/migrate tests timed out. As I understand it though, those tests frequently time out, so may not be related to this patch.

Keir, is this patch ok?

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

Signature · 4 lines
Hollis Blanchard
IBM Linux Technology Center

Signed-off-by: Hollis Blanchard <[email protected]>
linux-2.6-xen-sparse/arch/xen/i386/kernel/microcode.c +1 -1
diff -r 85f92475b943 linux-2.6-xen-sparse/arch/xen/i386/kernel/microcode.c
@@ -68,7 +68,7 @@
 		return err;
 
 	op.cmd = DOM0_MICROCODE;
-	op.u.microcode.data = user_buffer;
+	xenif_pack_ptr(op.u.microcode.data, user_buffer);
 	op.u.microcode.length = user_buffer_size;
 	err = HYPERVISOR_dom0_op(&op);
 
linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c +1 -1
diff -r 85f92475b943 linux-2.6-xen-sparse/arch/xen/i386/kernel/setup.c
@@ -1250,7 +1250,7 @@
 #ifdef CONFIG_XEN
 	map = alloc_bootmem_low_pages(PAGE_SIZE);
 	op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
-	op.u.physical_memory_map.memory_map = map;
+	xenif_pack_ptr(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));
tools/debugger/libxendebug/xendebug.c +1 -1
diff -r 85f92475b943 tools/debugger/libxendebug/xendebug.c
@@ -142,7 +142,7 @@
     op.cmd = DOM0_SETDOMAININFO;
     op.u.setdomaininfo.domain = ctxt->domid;
     op.u.setdomaininfo.vcpu = vcpu;
-    op.u.setdomaininfo.ctxt = &ctxt->context[vcpu];
+    xenif_pack_ptr(op.u.setdomaininfo.ctxt, &ctxt->context[vcpu]);
 
     if ( (rc = mlock(&ctxt->context[vcpu], sizeof(vcpu_guest_context_t))) )
         return rc;
tools/libxc/xc_domain.c +4 -4
diff -r 85f92475b943 tools/libxc/xc_domain.c
@@ -65,7 +65,7 @@
     op.cmd = DOM0_PINCPUDOMAIN;
     op.u.pincpudomain.domain  = (domid_t)domid;
     op.u.pincpudomain.vcpu    = vcpu;
-    op.u.pincpudomain.cpumap  = cpumap;
+    xenif_pack_ptr(op.u.pincpudomain.cpumap, cpumap);
     return do_dom0_op(xc_handle, &op);
 }
 
@@ -140,7 +140,7 @@
     op.cmd = DOM0_GETDOMAININFOLIST;
     op.u.getdomaininfolist.first_domain = first_domain;
     op.u.getdomaininfolist.max_domains  = max_domains;
-    op.u.getdomaininfolist.buffer       = info;
+    xenif_pack_ptr(op.u.getdomaininfolist.buffer, info);
 
     if ( xc_dom0_op(xc_handle, &op) < 0 )
         ret = -1;
@@ -164,7 +164,7 @@
     op.cmd = DOM0_GETVCPUCONTEXT;
     op.u.getvcpucontext.domain = (domid_t)domid;
     op.u.getvcpucontext.vcpu   = (u16)vcpu;
-    op.u.getvcpucontext.ctxt   = ctxt;
+    xenif_pack_ptr(op.u.getvcpucontext.ctxt, ctxt);
 
     if ( (ctxt != NULL) &&
          ((rc = mlock(ctxt, sizeof(*ctxt))) != 0) )
@@ -194,7 +194,7 @@
     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;
+    xenif_pack_ptr(op.u.shadow_control.dirty_bitmap, dirty_bitmap);
     op.u.shadow_control.pages  = pages;
 
     rc = do_dom0_op(xc_handle, &op);
tools/libxc/xc_linux_build.c +1 -1
diff -r 85f92475b943 tools/libxc/xc_linux_build.c
@@ -847,7 +847,7 @@
 
     launch_op.u.setdomaininfo.domain = (domid_t)domid;
     launch_op.u.setdomaininfo.vcpu   = 0;
-    launch_op.u.setdomaininfo.ctxt   = ctxt;
+    xenif_pack_ptr(launch_op.u.setdomaininfo.ctxt, ctxt);
 
     launch_op.cmd = DOM0_SETDOMAININFO;
     rc = xc_dom0_op(xc_handle, &launch_op);
tools/libxc/xc_linux_restore.c +1 -1
diff -r 85f92475b943 tools/libxc/xc_linux_restore.c
@@ -631,7 +631,7 @@
     op.cmd = DOM0_SETDOMAININFO;
     op.u.setdomaininfo.domain = (domid_t)dom;
     op.u.setdomaininfo.vcpu   = 0;
-    op.u.setdomaininfo.ctxt   = &ctxt;
+    xenif_pack_ptr(op.u.setdomaininfo.ctxt, &ctxt);
     rc = xc_dom0_op(xc_handle, &op);
 
     if ( rc != 0 )
tools/libxc/xc_misc.c +3 -3
diff -r 85f92475b943 tools/libxc/xc_misc.c
@@ -30,7 +30,7 @@
     unsigned int nr_chars = *pnr_chars;
 
     op.cmd = DOM0_READCONSOLE;
-    op.u.readconsole.buffer = buffer;
+    xenif_pack_ptr(op.u.readconsole.buffer, buffer);
     op.u.readconsole.count  = nr_chars;
     op.u.readconsole.clear  = clear;
 
@@ -39,7 +39,7 @@
 
     if ( (ret = do_dom0_op(xc_handle, &op)) == 0 )
     {
-        *pbuffer   = op.u.readconsole.buffer;
+        xenif_unpack_ptr(*pbuffer, op.u.readconsole.buffer);
         *pnr_chars = op.u.readconsole.count;
     }
 
@@ -91,7 +91,7 @@
 
     dop.cmd = DOM0_PERFCCONTROL;
     dop.u.perfccontrol.op   = op;
-    dop.u.perfccontrol.desc = desc;
+    xenif_pack_ptr(dop.u.perfccontrol.desc, desc);
 
     rc = do_dom0_op(xc_handle, &dop);
 
tools/libxc/xc_private.c +6 -5
diff -r 85f92475b943 tools/libxc/xc_private.c
@@ -72,7 +72,7 @@
     op.cmd = DOM0_GETPAGEFRAMEINFO2;
     op.u.getpageframeinfo2.domain = (domid_t)dom;
     op.u.getpageframeinfo2.num    = num;
-    op.u.getpageframeinfo2.array  = arr;
+    xenif_pack_ptr(op.u.getpageframeinfo2.array, arr);
     return do_dom0_op(xc_handle, &op);
 }
 
@@ -259,7 +259,8 @@
     op.cmd = DOM0_GETVCPUCONTEXT;
     op.u.getvcpucontext.domain = (domid_t)domid;
     op.u.getvcpucontext.vcpu   = (u16)vcpu;
-    op.u.getvcpucontext.ctxt   = NULL;
+    xenif_pack_ptr(op.u.getvcpucontext.ctxt, NULL);
+
     if ( (do_dom0_op(xc_handle, &op) < 0) )
     {
         PERROR("Could not get info on domain");
@@ -291,8 +292,8 @@
     op.cmd = DOM0_GETMEMLIST;
     op.u.getmemlist.domain   = (domid_t)domid;
     op.u.getmemlist.max_pfns = max_pfns;
-    op.u.getmemlist.buffer   = pfn_buf;
-
+
+    xenif_pack_ptr(op.u.getmemlist.buffer, pfn_buf);
 
     if ( mlock(pfn_buf, max_pfns * sizeof(unsigned long)) != 0 )
     {
@@ -335,7 +336,7 @@
     op.cmd = DOM0_GETMEMLIST;
     op.u.getmemlist.domain   = (domid_t)domid;
     op.u.getmemlist.max_pfns = ((unsigned long)start_page << 32) | nr_pages;
-    op.u.getmemlist.buffer   = pfn_buf;
+    xenif_pack_ptr(op.u.getmemlist.buffer, pfn_buf);
 
     if ( mlock(pfn_buf, nr_pages * sizeof(unsigned long)) != 0 )
     {
tools/libxc/xc_ptrace.c +3 -3
diff -r 85f92475b943 tools/libxc/xc_ptrace.c
@@ -385,7 +385,7 @@
         op.u.setdomaininfo.domain = domid;
         /* XXX need to understand multiple vcpus */
         op.u.setdomaininfo.vcpu = cpu;
-        op.u.setdomaininfo.ctxt = &ctxt[cpu];
+        xenif_pack_ptr(op.u.setdomaininfo.ctxt, &ctxt[cpu]);
         retval = do_dom0_op(xc_handle, &op);
         if (retval)
             goto error_out;
@@ -416,7 +416,7 @@
         op.cmd = DOM0_SETDOMAININFO;
         op.u.setdomaininfo.domain = domid;
         op.u.setdomaininfo.vcpu = 0;
-        op.u.setdomaininfo.ctxt = &ctxt[cpu];
+        xenif_pack_ptr(op.u.setdomaininfo.ctxt, &ctxt[cpu]);
         retval = do_dom0_op(xc_handle, &op); 
         if ( retval )
         {
@@ -437,7 +437,7 @@
                 op.cmd = DOM0_SETDOMAININFO;
                 op.u.setdomaininfo.domain = domid;
                 op.u.setdomaininfo.vcpu = cpu;
-                op.u.setdomaininfo.ctxt = &ctxt[cpu];
+                xenif_pack_ptr(op.u.setdomaininfo.ctxt, &ctxt[cpu]);
                 retval = do_dom0_op(xc_handle, &op); 
                 if ( retval )
                 {
tools/libxc/xc_vmx_build.c +1 -1
diff -r 85f92475b943 tools/libxc/xc_vmx_build.c
@@ -700,7 +700,7 @@
 
     launch_op.u.setdomaininfo.domain = (domid_t)domid;
     launch_op.u.setdomaininfo.vcpu   = 0;
-    launch_op.u.setdomaininfo.ctxt   = ctxt;
+    xenif_pack_ptr(launch_op.u.setdomaininfo.ctxt, ctxt);
 
     launch_op.cmd = DOM0_SETDOMAININFO;
     rc = xc_dom0_op(xc_handle, &launch_op);
tools/xenstat/libxenstat/src/xen-interface.c +2 -2
diff -r 85f92475b943 tools/xenstat/libxenstat/src/xen-interface.c
@@ -160,7 +160,7 @@
 	dom0_op_t op;
 	op.u.getdomaininfolist.first_domain = first_domain;
 	op.u.getdomaininfolist.max_domains = max_domains;
-	op.u.getdomaininfolist.buffer = info;
+	xenif_pack_ptr(op.u.getdomaininfolist.buffer, info);
 
 	if (mlock( info, max_domains * sizeof(dom0_getdomaininfo_t)) < 0) {
 		perror("Failed to mlock domaininfo array");
@@ -182,7 +182,7 @@
 	dom0_op_t op;
 	op.u.getvcpucontext.domain = domain;
 	op.u.getvcpucontext.vcpu = vcpu;
-	op.u.getvcpucontext.ctxt = NULL;
+	xenif_pack_ptr(op.u.getvcpucontext.ctxt, NULL);
 
 	if (xi_make_dom0_op(handle, &op, DOM0_GETVCPUCONTEXT) < 0) {
 		perror("DOM0_GETVCPUCONTEXT Hypercall failed");
xen/arch/ia64/xen/dom0_ops.c +6 -2
diff -r 85f92475b943 xen/arch/ia64/xen/dom0_ops.c
@@ -73,10 +73,12 @@
         int n,j;
         int num = op->u.getpageframeinfo2.num;
         domid_t dom = op->u.getpageframeinfo2.domain;
-        unsigned long *s_ptr = (unsigned long*) op->u.getpageframeinfo2.array;
+        unsigned long *s_ptr;
         struct domain *d;
         unsigned long *l_arr;
         ret = -ESRCH;
+
+        xenif_unpack_ptr(s_ptr, op->u.getpageframeinfo2.array);
 
         if ( unlikely((d = find_domain_by_id(dom)) == NULL) )
             break;
@@ -159,8 +161,10 @@
         unsigned long start_page = op->u.getmemlist.max_pfns >> 32;
         unsigned long nr_pages = op->u.getmemlist.max_pfns & 0xffffffff;
         unsigned long pfn;
-        unsigned long *buffer = op->u.getmemlist.buffer;
+        unsigned long *buffer;
         struct page *page;
+
+        xenif_unpack_ptr(buffer, op->u.getmemlist.buffer);
 
         ret = -EINVAL;
         if ( d != NULL )
xen/arch/x86/dom0_ops.c +14 -6
diff -r 85f92475b943 xen/arch/x86/dom0_ops.c
@@ -132,7 +132,10 @@
     case DOM0_MICROCODE:
     {
         extern int microcode_update(void *buf, unsigned long len);
-        ret = microcode_update(op->u.microcode.data, op->u.microcode.length);
+        void *data;
+
+        xenif_unpack_ptr(data, op->u.microcode.data);
+        ret = microcode_update(data, op->u.microcode.length);
     }
     break;
 
@@ -252,10 +255,12 @@
         int n,j;
         int num = op->u.getpageframeinfo2.num;
         domid_t dom = op->u.getpageframeinfo2.domain;
-        unsigned long *s_ptr = (unsigned long*) op->u.getpageframeinfo2.array;
+        unsigned long *s_ptr;
         struct domain *d;
         unsigned long *l_arr;
         ret = -ESRCH;
+
+        xenif_unpack_ptr(s_ptr, op->u.getpageframeinfo2.array);
 
         if ( unlikely((d = find_domain_by_id(dom)) == NULL) )
             break;
@@ -343,8 +348,10 @@
         struct domain *d = find_domain_by_id(op->u.getmemlist.domain);
         unsigned long max_pfns = op->u.getmemlist.max_pfns;
         unsigned long pfn;
-        unsigned long *buffer = op->u.getmemlist.buffer;
+        unsigned long *buffer;
         struct list_head *list_ent;
+
+        xenif_unpack_ptr(buffer, op->u.getmemlist.buffer);
 
         ret = -EINVAL;
         if ( d != NULL )
@@ -395,7 +402,10 @@
     case DOM0_PHYSICAL_MEMORY_MAP:
     {
         struct dom0_memory_map_entry entry;
+        struct dom0_memory_map_entry *memory_map;
         int i;
+
+        xenif_unpack_ptr(memory_map, op->u.physical_memory_map.memory_map);
 
         for ( i = 0; i < e820.nr_map; i++ )
         {
@@ -404,9 +414,7 @@
             entry.start  = e820.map[i].addr;
             entry.end    = e820.map[i].addr + e820.map[i].size;
             entry.is_ram = (e820.map[i].type == E820_RAM);
-            (void)copy_to_user(
-                &op->u.physical_memory_map.memory_map[i],
-                &entry, sizeof(entry));
+            (void)copy_to_user(&memory_map[i], &entry, sizeof(entry));
         }
 
         op->u.physical_memory_map.nr_map_entries = i;
xen/arch/x86/shadow32.c +7 -4
diff -r 85f92475b943 xen/arch/x86/shadow32.c
@@ -1224,6 +1224,9 @@
     unsigned int      op = sc->op;
     int               i, rc = 0;
     struct vcpu *v;
+    unsigned long *dirty_bitmap;
+
+    xenif_unpack_ptr(dirty_bitmap, sc->dirty_bitmap);
 
     ASSERT(shadow_lock_is_acquired(d));
 
@@ -1260,7 +1263,7 @@
         d->arch.shadow_dirty_block_count = 0;
  
         if ( (d->max_pages > sc->pages) || 
-             (sc->dirty_bitmap == NULL) || 
+             (dirty_bitmap == NULL) || 
              (d->arch.shadow_dirty_bitmap == NULL) )
         {
             rc = -EINVAL;
@@ -1276,7 +1279,7 @@
                           chunk : (d->max_pages - i)) + 7) / 8;
      
             if (copy_to_user(
-                    sc->dirty_bitmap + (i/(8*sizeof(unsigned long))),
+                    dirty_bitmap + (i/(8*sizeof(unsigned long))),
                     d->arch.shadow_dirty_bitmap +(i/(8*sizeof(unsigned long))),
                     bytes))
             {
@@ -1304,7 +1307,7 @@
         sc->stats.dirty_block_count = d->arch.shadow_dirty_block_count;
  
         if ( (d->max_pages > sc->pages) || 
-             (sc->dirty_bitmap == NULL) || 
+             (dirty_bitmap == NULL) || 
              (d->arch.shadow_dirty_bitmap == NULL) )
         {
             rc = -EINVAL;
@@ -1313,7 +1316,7 @@
  
         sc->pages = d->max_pages;
         if (copy_to_user(
-            sc->dirty_bitmap, d->arch.shadow_dirty_bitmap, (d->max_pages+7)/8))
+            dirty_bitmap, d->arch.shadow_dirty_bitmap, (d->max_pages+7)/8))
         {
             rc = -EINVAL;
             break;
xen/arch/x86/shadow_public.c +7 -4
diff -r 85f92475b943 xen/arch/x86/shadow_public.c
@@ -1143,6 +1143,9 @@
     unsigned int      op = sc->op;
     int               i, rc = 0;
     struct vcpu *v;
+    unsigned long *dirty_bitmap;
+
+    xenif_unpack_ptr(dirty_bitmap, sc->dirty_bitmap);
 
     ASSERT(shadow_lock_is_acquired(d));
 
@@ -1179,7 +1182,7 @@
         d->arch.shadow_dirty_block_count = 0;
  
         if ( (d->max_pages > sc->pages) || 
-             (sc->dirty_bitmap == NULL) || 
+             (dirty_bitmap == NULL) || 
              (d->arch.shadow_dirty_bitmap == NULL) )
         {
             rc = -EINVAL;
@@ -1195,7 +1198,7 @@
                           chunk : (d->max_pages - i)) + 7) / 8;
 
             if (copy_to_user(
-                sc->dirty_bitmap + (i/(8*sizeof(unsigned long))),
+                dirty_bitmap + (i/(8*sizeof(unsigned long))),
                 d->arch.shadow_dirty_bitmap +(i/(8*sizeof(unsigned long))),
                 bytes))
             {
@@ -1222,7 +1225,7 @@
         sc->stats.dirty_block_count = d->arch.shadow_dirty_block_count;
  
         if ( (d->max_pages > sc->pages) || 
-             (sc->dirty_bitmap == NULL) || 
+             (dirty_bitmap == NULL) || 
              (d->arch.shadow_dirty_bitmap == NULL) )
         {
             rc = -EINVAL;
@@ -1231,7 +1234,7 @@
  
         sc->pages = d->max_pages;
         if (copy_to_user(
-            sc->dirty_bitmap, d->arch.shadow_dirty_bitmap, (d->max_pages+7)/8))
+            dirty_bitmap, d->arch.shadow_dirty_bitmap, (d->max_pages+7)/8))
         {
             rc = -EINVAL;
             break;
xen/common/dom0_ops.c +15 -6
diff -r 85f92475b943 xen/common/dom0_ops.c
@@ -249,8 +249,10 @@
         domid_t dom = op->u.pincpudomain.domain;
         struct domain *d = find_domain_by_id(dom);
         struct vcpu *v;
+        cpumap_t *cpumap_ptr;
         cpumap_t cpumap;
 
+        xenif_unpack_ptr(cpumap_ptr, op->u.pincpudomain.cpumap);
 
         if ( d == NULL )
         {
@@ -281,8 +283,7 @@
             break;
         }
 
-        if ( copy_from_user(&cpumap, op->u.pincpudomain.cpumap,
-                            sizeof(cpumap)) )
+        if ( copy_from_user(&cpumap, cpumap_ptr, sizeof(cpumap)) )
         {
             ret = -EFAULT;
             put_domain(d);
@@ -359,8 +360,10 @@
     { 
         struct domain *d;
         dom0_getdomaininfo_t info;
-        dom0_getdomaininfo_t *buffer = op->u.getdomaininfolist.buffer;
+        dom0_getdomaininfo_t *buffer;
         u32 num_domains = 0;
+
+        xenif_unpack_ptr(buffer, op->u.getdomaininfolist.buffer);
 
         read_lock(&domlist_lock);
 
@@ -405,10 +408,13 @@
     case DOM0_GETVCPUCONTEXT:
     { 
         struct vcpu_guest_context *c;
+        struct vcpu_guest_context *ctxt;
         struct domain             *d;
         struct vcpu               *v;
         int i;
 
+        xenif_unpack_ptr(ctxt, op->u.getvcpucontext.ctxt);
+
         d = find_domain_by_id(op->u.getvcpucontext.domain);
         if ( d == NULL )
         {
@@ -441,7 +447,7 @@
 
         op->u.getvcpucontext.cpu_time = v->cpu_time;
 
-        if ( op->u.getvcpucontext.ctxt != NULL )
+        if ( ctxt != NULL )
         {
             if ( (c = xmalloc(struct vcpu_guest_context)) == NULL )
             {
@@ -458,7 +464,7 @@
             if ( v != current )
                 vcpu_unpause(v);
 
-            if ( copy_to_user(op->u.getvcpucontext.ctxt, c, sizeof(*c)) )
+            if ( copy_to_user(ctxt, c, sizeof(*c)) )
                 ret = -EINVAL;
 
             xfree(c);
@@ -491,10 +497,13 @@
     
     case DOM0_READCONSOLE:
     {
+        char *buffer;
+        xenif_unpack_ptr(buffer, op->u.readconsole.buffer);
         ret = read_console_ring(
-            &op->u.readconsole.buffer, 
+            &buffer,
             &op->u.readconsole.count,
             op->u.readconsole.clear); 
+        xenif_pack_ptr(op->u.readconsole.buffer, buffer);
         copy_to_user(u_dom0_op, op, sizeof(*op));
     }
     break;
xen/common/domain.c +4 -1
diff -r 85f92475b943 xen/common/domain.c
@@ -338,8 +338,11 @@
 {
     int rc = 0;
     struct vcpu_guest_context *c = NULL;
+    struct vcpu_guest_context *ctxt;
     unsigned long vcpu = setdomaininfo->vcpu;
     struct vcpu *v; 
+
+    xenif_unpack_ptr(ctxt, setdomaininfo->ctxt);
 
     if ( (vcpu >= MAX_VIRT_CPUS) || ((v = d->vcpu[vcpu]) == NULL) )
         return -EINVAL;
@@ -351,7 +354,7 @@
     if ( (c = xmalloc(struct vcpu_guest_context)) == NULL )
         return -ENOMEM;
 
-    if ( copy_from_user(c, setdomaininfo->ctxt, sizeof(*c)) )
+    if ( copy_from_user(c, ctxt, sizeof(*c)) )
     {
         rc = -EFAULT;
         goto out;
xen/common/perfc.c +5 -2
diff -r 85f92475b943 xen/common/perfc.c
@@ -203,10 +203,13 @@
 /* Dom0 control of perf counters */
 int perfc_control(dom0_perfccontrol_t *pc)
 {
+    dom0_perfc_desc_t *desc;
     static spinlock_t lock = SPIN_LOCK_UNLOCKED;
     u32 op = pc->op;
     int rc;
 
+    xenif_unpack_ptr(desc, pc->desc);
+
     pc->nr_counters = NR_PERFCTRS;
 
     spin_lock(&lock);
@@ -214,13 +217,13 @@
     switch ( op )
     {
     case DOM0_PERFCCONTROL_OP_RESET:
-        perfc_copy_info(pc->desc);
+        perfc_copy_info(desc);
         perfc_reset(0);
         rc = 0;
         break;
 
     case DOM0_PERFCCONTROL_OP_QUERY:
-        perfc_copy_info(pc->desc);
+        perfc_copy_info(desc);
         rc = 0;
         break;
 
xen/include/public/arch-ia64.h +5 -0
diff -r 85f92475b943 xen/include/public/arch-ia64.h
@@ -12,6 +12,11 @@
 #define MAX_VIRT_CPUS 1
 
 #ifndef __ASSEMBLY__
+
+#define XENIF_PTR(type, field) struct { type val; } field ## _struct
+#define xenif_pack_ptr(field, var) do { field ## _struct.val = var; } while (0)
+#define xenif_unpack_ptr(var, field) do { var = field ## _struct.val; } while (0)
+typedef unsigned long xenif_ulong_t;
 
 #define MAX_NR_SECTION  32  // at most 32 memory holes
 typedef struct {
xen/include/public/arch-x86_32.h +5 -0
diff -r 85f92475b943 xen/include/public/arch-x86_32.h
@@ -62,6 +62,11 @@
 #define MAX_VIRT_CPUS 32
 
 #ifndef __ASSEMBLY__
+
+#define XENIF_PTR(type, field) struct { type val; } field ## _struct
+#define xenif_pack_ptr(field, var) do { field ## _struct.val = var; } while (0)
+#define xenif_unpack_ptr(var, field) do { var = field ## _struct.val; } while (0)
+typedef unsigned long xenif_ulong_t;
 
 /*
  * Send an array of these to HYPERVISOR_set_trap_table()
xen/include/public/arch-x86_64.h +5 -0
diff -r 85f92475b943 xen/include/public/arch-x86_64.h
@@ -68,6 +68,11 @@
 #define MAX_VIRT_CPUS 32
 
 #ifndef __ASSEMBLY__
+
+#define XENIF_PTR(type, field) struct { type val; } field ## _struct
+#define xenif_pack_ptr(field, var) do { field ## _struct.val = var; } while (0)
+#define xenif_unpack_ptr(var, field) do { var = field ## _struct.val; } while (0)
+typedef unsigned long xenif_ulong_t;
 
 /* The machine->physical mapping table starts at this address, read-only. */
 #ifndef machine_to_phys_mapping
xen/include/public/dom0_ops.h +44 -32

198 lines not on this page · raw message

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