[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Fix grant-table interface by removing the unnecessary union.



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID abc0a8f65be79d8a82d5a17bf3e44d4d49115554
# Parent  e1fbb7fee1d8e9f944b32fe427d342103a1c916e

Fix grant-table interface by removing the unnecessary union.
This fixes a domU crash introduced over the weekend.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>

diff -r e1fbb7fee1d8 -r abc0a8f65be7 xen/include/public/grant_table.h
--- a/xen/include/public/grant_table.h  Mon Jul  4 15:01:22 2005
+++ b/xen/include/public/grant_table.h  Mon Jul  4 15:34:57 2005
@@ -259,13 +259,4 @@
     "permission denied"                         \
 }
 
-typedef struct gnttab_op {
-    union {
-        gnttab_map_grant_ref_t    map_grant_ref;
-        gnttab_unmap_grant_ref_t  unmap_grant_ref;
-        gnttab_setup_table_t      setup_table;
-        gnttab_dump_table_t       dump_table;
-    } u;
-} gnttab_op_t;
-
 #endif /* __XEN_PUBLIC_GRANT_TABLE_H__ */
diff -r e1fbb7fee1d8 -r abc0a8f65be7 
linux-2.6.11-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6.11-xen-sparse/drivers/xen/blkback/blkback.c     Mon Jul  4 
15:01:22 2005
+++ b/linux-2.6.11-xen-sparse/drivers/xen/blkback/blkback.c     Mon Jul  4 
15:34:57 2005
@@ -116,23 +116,23 @@
 static void fast_flush_area(int idx, int nr_pages)
 {
 #ifdef CONFIG_XEN_BLKDEV_GRANT
-    gnttab_op_t       aop[BLKIF_MAX_SEGMENTS_PER_REQUEST];
-    unsigned int      i, invcount = 0;
-    u16               handle;
+    struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST];
+    unsigned int i, invcount = 0;
+    u16 handle;
 
     for ( i = 0; i < nr_pages; i++ )
     {
         if ( BLKBACK_INVALID_HANDLE != ( handle = pending_handle(idx, i) ) )
         {
-            aop[i].u.unmap_grant_ref.host_virt_addr = MMAP_VADDR(idx, i);
-            aop[i].u.unmap_grant_ref.dev_bus_addr   = 0;
-            aop[i].u.unmap_grant_ref.handle         = handle;
+            unmap[i].host_virt_addr = MMAP_VADDR(idx, i);
+            unmap[i].dev_bus_addr   = 0;
+            unmap[i].handle         = handle;
             pending_handle(idx, i) = BLKBACK_INVALID_HANDLE;
             invcount++;
         }
     }
     if ( unlikely(HYPERVISOR_grant_table_op(
-                    GNTTABOP_unmap_grant_ref, aop, invcount)))
+                    GNTTABOP_unmap_grant_ref, unmap, invcount)))
         BUG();
 #else
 
@@ -387,21 +387,21 @@
 
 #ifdef CONFIG_XEN_BLKDEV_GRANT
     {
-        gnttab_op_t     op;
-
-        op.u.map_grant_ref.host_virt_addr = MMAP_VADDR(pending_idx, 0);
-        op.u.map_grant_ref.flags = GNTMAP_host_map;
-        op.u.map_grant_ref.ref = blkif_gref_from_fas(req->frame_and_sects[0]);
-        op.u.map_grant_ref.dom = blkif->domid;
+        struct gnttab_map_grant_ref map;
+
+        map.host_virt_addr = MMAP_VADDR(pending_idx, 0);
+        map.flags = GNTMAP_host_map;
+        map.ref = blkif_gref_from_fas(req->frame_and_sects[0]);
+        map.dom = blkif->domid;
 
         if ( unlikely(HYPERVISOR_grant_table_op(
-                        GNTTABOP_map_grant_ref, &op, 1)))
+                        GNTTABOP_map_grant_ref, &map, 1)))
             BUG();
 
-        if ( op.u.map_grant_ref.handle < 0 )
+        if ( map.handle < 0 )
             goto out;
 
-        pending_handle(pending_idx, 0) = op.u.map_grant_ref.handle;
+        pending_handle(pending_idx, 0) = map.handle;
     }
 #else /* else CONFIG_XEN_BLKDEV_GRANT */
 
@@ -445,7 +445,7 @@
     int i, pending_idx = pending_ring[MASK_PEND_IDX(pending_cons)];
     pending_req_t *pending_req;
 #ifdef CONFIG_XEN_BLKDEV_GRANT
-    gnttab_op_t       aop[BLKIF_MAX_SEGMENTS_PER_REQUEST];
+    struct gnttab_map_grant_ref map[BLKIF_MAX_SEGMENTS_PER_REQUEST];
 #else
     unsigned long remap_prot;
     multicall_entry_t mcl[BLKIF_MAX_SEGMENTS_PER_REQUEST];
@@ -486,21 +486,21 @@
             goto bad_descriptor;
         preq.nr_sects += seg[i].nsec;
 
-        aop[i].u.map_grant_ref.host_virt_addr = MMAP_VADDR(pending_idx, i);
-        aop[i].u.map_grant_ref.dom = blkif->domid;
-        aop[i].u.map_grant_ref.ref = blkif_gref_from_fas(fas);
-        aop[i].u.map_grant_ref.flags = GNTMAP_host_map;
+        map[i].host_virt_addr = MMAP_VADDR(pending_idx, i);
+        map[i].dom = blkif->domid;
+        map[i].ref = blkif_gref_from_fas(fas);
+        map[i].flags = GNTMAP_host_map;
         if ( operation == WRITE )
-            aop[i].u.map_grant_ref.flags |= GNTMAP_readonly;
+            map[i].flags |= GNTMAP_readonly;
     }
 
     if ( unlikely(HYPERVISOR_grant_table_op(
-                    GNTTABOP_map_grant_ref, aop, nseg)))
+                    GNTTABOP_map_grant_ref, map, nseg)))
         BUG();
 
     for ( i = 0; i < nseg; i++ )
     {
-        if ( unlikely(aop[i].u.map_grant_ref.handle < 0) )
+        if ( unlikely(map[i].handle < 0) )
         {
             DPRINTK("invalid buffer -- could not remap it\n");
             fast_flush_area(pending_idx, nseg);
@@ -508,9 +508,9 @@
         }
 
         phys_to_machine_mapping[__pa(MMAP_VADDR(pending_idx, i))>>PAGE_SHIFT] =
-            FOREIGN_FRAME(aop[i].u.map_grant_ref.dev_bus_addr);
-
-        pending_handle(pending_idx, i) = aop[i].u.map_grant_ref.handle;
+            FOREIGN_FRAME(map[i].dev_bus_addr);
+
+        pending_handle(pending_idx, i) = map[i].handle;
     }
 #endif
 
@@ -518,7 +518,7 @@
     {
         fas         = req->frame_and_sects[i];
 #ifdef CONFIG_XEN_BLKDEV_GRANT
-        seg[i].buf  = (aop[i].u.map_grant_ref.dev_bus_addr << PAGE_SHIFT) |
+        seg[i].buf  = (map[i].dev_bus_addr << PAGE_SHIFT) |
                       (blkif_first_sect(fas) << 9);
 #else
         seg[i].buf  = (fas & PAGE_MASK) | (blkif_first_sect(fas) << 9);
diff -r e1fbb7fee1d8 -r abc0a8f65be7 tools/libxc/xc_gnttab.c
--- a/tools/libxc/xc_gnttab.c   Mon Jul  4 15:01:22 2005
+++ b/tools/libxc/xc_gnttab.c   Mon Jul  4 15:34:57 2005
@@ -11,20 +11,20 @@
 #include "xen/grant_table.h"
 
 static int
-do_gnttab_op( int xc_handle,
-              unsigned long cmd,
-              gnttab_op_t *op,
-              unsigned long count )
+do_gnttab_op(int xc_handle,
+             unsigned long cmd,
+             void *op,
+             unsigned long count)
 {
     int ret = -1;
     privcmd_hypercall_t hypercall;
 
     hypercall.op     = __HYPERVISOR_grant_table_op;
     hypercall.arg[0] = cmd;
-    hypercall.arg[1] = (unsigned long)(op);
+    hypercall.arg[1] = (unsigned long)op;
     hypercall.arg[2] = count;
 
-    if ( mlock(op, sizeof(*op)) != 0 )
+    if ( mlock(op, 64) )
     {
         PERROR("do_gnttab_op: op mlock failed");
         goto out;
@@ -33,7 +33,7 @@
     if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 )
         ERROR("do_gnttab_op: HYPERVISOR_grant_table_op failed: %d", ret);
 
-    safe_munlock(op, sizeof(*op));
+    safe_munlock(op, 64);
  out:
     return ret;
 }
@@ -47,18 +47,19 @@
                             s16        *handle,
                             memory_t   *dev_bus_addr)
 {
-    gnttab_op_t     op;
-    int             rc;
+    struct gnttab_map_grant_ref op;
+    int rc;
 
-    op.u.map_grant_ref.host_virt_addr = host_virt_addr;
-    op.u.map_grant_ref.dom            = (domid_t)dom;
-    op.u.map_grant_ref.ref            = ref;
-    op.u.map_grant_ref.flags          = flags;
+    op.host_virt_addr = host_virt_addr;
+    op.dom            = (domid_t)dom;
+    op.ref            = ref;
+    op.flags          = flags;
  
-    if ( (rc = do_gnttab_op(xc_handle, GNTTABOP_map_grant_ref, &op, 1)) == 0 )
+    if ( (rc = do_gnttab_op(xc_handle, GNTTABOP_map_grant_ref,
+                            &op, 1)) == 0 )
     {
-        *handle         = op.u.map_grant_ref.handle;
-        *dev_bus_addr   = op.u.map_grant_ref.dev_bus_addr;
+        *handle         = op.handle;
+        *dev_bus_addr   = op.dev_bus_addr;
     }
 
     return rc;
@@ -71,15 +72,18 @@
                               u16       handle,
                               s16      *status)
 {
-    gnttab_op_t     op;
-    int             rc;
+    struct gnttab_unmap_grant_ref op;
+    int rc;
 
-    op.u.unmap_grant_ref.host_virt_addr = host_virt_addr;
-    op.u.unmap_grant_ref.dev_bus_addr   = dev_bus_addr;
-    op.u.unmap_grant_ref.handle         = handle;
+    op.host_virt_addr = host_virt_addr;
+    op.dev_bus_addr   = dev_bus_addr;
+    op.handle         = handle;
  
-    if ( (rc = do_gnttab_op(xc_handle, GNTTABOP_unmap_grant_ref, &op, 1)) == 0 
)
-        *status = op.u.unmap_grant_ref.status;
+    if ( (rc = do_gnttab_op(xc_handle, GNTTABOP_unmap_grant_ref,
+                            &op, 1)) == 0 )
+    {
+        *status = op.status;
+    }
 
     return rc;
 }
@@ -90,20 +94,17 @@
                           s16       *status,
                           memory_t **frame_list)
 {
-    gnttab_op_t     op;
-    int             rc;
-    int             i;
+    struct gnttab_setup_table op;
+    int rc, i;
 
-    op.u.setup_table.dom        = (domid_t)dom;
-    op.u.setup_table.nr_frames  = nr_frames;
+    op.dom       = (domid_t)dom;
+    op.nr_frames = nr_frames;
  
     if ( (rc = do_gnttab_op(xc_handle, GNTTABOP_setup_table, &op, 1)) == 0 )
     {
-        *status = op.u.setup_table.status;
+        *status = op.status;
         for ( i = 0; i < nr_frames; i++ )
-        {
-            (*frame_list)[i] = op.u.setup_table.frame_list[i];
-        }
+            (*frame_list)[i] = op.frame_list[i];
     }
 
     return rc;
@@ -113,15 +114,13 @@
                          u32        dom,
                          s16       *status)
 {
-    gnttab_op_t     op;
-    int             rc;
+    struct gnttab_dump_table op;
+    int rc;
 
-    op.u.dump_table.dom = (domid_t)dom;
- 
-    printf("xc_gnttab_dump_table: domain %d\n", dom);
+    op.dom = (domid_t)dom;
 
     if ( (rc = do_gnttab_op(xc_handle, GNTTABOP_dump_table, &op, 1)) == 0 )
-        *status = op.u.dump_table.status;
+        *status = op.status;
 
     return rc;
 }

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.