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

[Xen-changelog] GNTTABOP_map_grant_ref returns error status and handle as



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 58d46463413ec97caa0c4301a3d2d350747a5dc5
# Parent  ff95b53bd39a74e17fd3c08f6b50a0c43794ec7c
GNTTABOP_map_grant_ref returns error status and handle as
separate fields. Update callers for new interface. Also
use int16_t as standard error code type on all public
interfaces.

Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>

diff -r ff95b53bd39a -r 58d46463413e 
linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c        Wed Nov 30 
15:03:05 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c        Wed Nov 30 
16:24:27 2005
@@ -88,10 +88,10 @@
  * handle returned must be used to unmap the frame. This is needed to
  * drop the ref count on the frame.
  */
-static u16 pending_grant_handles[MMAP_PAGES];
+static grant_handle_t pending_grant_handles[MMAP_PAGES];
 #define pending_handle(_idx, _i) \
     (pending_grant_handles[((_idx) * BLKIF_MAX_SEGMENTS_PER_REQUEST) + (_i)])
-#define BLKBACK_INVALID_HANDLE (0xFFFF)
+#define BLKBACK_INVALID_HANDLE (~0)
 
 #ifdef CONFIG_XEN_BLKDEV_TAP_BE
 /*
@@ -114,7 +114,7 @@
 {
        struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST];
        unsigned int i, invcount = 0;
-       u16 handle;
+       grant_handle_t handle;
        int ret;
 
        for (i = 0; i < nr_pages; i++) {
@@ -381,7 +381,7 @@
        BUG_ON(ret);
 
        for (i = 0; i < nseg; i++) {
-               if (likely(map[i].handle >= 0)) {
+               if (likely(map[i].status == 0)) {
                        pending_handle(pending_idx, i) = map[i].handle;
 #ifdef __ia64__
                        MMAP_VADDR(pending_idx,i) = gnttab_map_vaddr(map[i]);
diff -r ff95b53bd39a -r 58d46463413e 
linux-2.6-xen-sparse/drivers/xen/blkback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/common.h Wed Nov 30 15:03:05 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/common.h Wed Nov 30 16:24:27 2005
@@ -66,8 +66,8 @@
 
        struct work_struct free_work;
 
-       u16         shmem_handle;
-       grant_ref_t shmem_ref;
+       grant_handle_t shmem_handle;
+       grant_ref_t    shmem_ref;
 } blkif_t;
 
 blkif_t *alloc_blkif(domid_t domid);
diff -r ff95b53bd39a -r 58d46463413e 
linux-2.6-xen-sparse/drivers/xen/blkback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c      Wed Nov 30 
15:03:05 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c      Wed Nov 30 
16:24:27 2005
@@ -43,9 +43,9 @@
        unlock_vm_area(blkif->blk_ring_area);
        BUG_ON(ret);
 
-       if (op.handle < 0) {
+       if (op.status) {
                DPRINTK(" Grant table operation failure !\n");
-               return op.handle;
+               return op.status;
        }
 
        blkif->shmem_ref = shared_page;
diff -r ff95b53bd39a -r 58d46463413e 
linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c  Wed Nov 30 15:03:05 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c  Wed Nov 30 16:24:27 2005
@@ -177,8 +177,8 @@
  */
 struct grant_handle_pair
 {
-       u16  kernel;
-       u16  user;
+       grant_handle_t kernel;
+       grant_handle_t user;
 };
 static struct grant_handle_pair pending_grant_handles[MMAP_PAGES];
 #define pending_handle(_idx, _i) \
@@ -755,17 +755,17 @@
                uvaddr = MMAP_VADDR(user_vstart, pending_idx, i/2);
                kvaddr = MMAP_VADDR(mmap_vstart, pending_idx, i/2);
 
-               if (unlikely(map[i].handle < 0)) {
+               if (unlikely(map[i].status)) {
                        DPRINTK("Error on kernel grant mapping (%d)\n",
-                               map[i].handle);
-                       ret = map[i].handle;
+                               map[i].status);
+                       ret = map[i].status;
                        cancel = 1;
                }
 
-               if (unlikely(map[i+1].handle < 0)) {
+               if (unlikely(map[i+1].status)) {
                        DPRINTK("Error on user grant mapping (%d)\n",
-                               map[i+1].handle);
-                       ret = map[i+1].handle;
+                               map[i+1].status);
+                       ret = map[i+1].status;
                        cancel = 1;
                }
 
diff -r ff95b53bd39a -r 58d46463413e 
linux-2.6-xen-sparse/drivers/xen/blktap/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/common.h  Wed Nov 30 15:03:05 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/common.h  Wed Nov 30 16:24:27 2005
@@ -64,7 +64,7 @@
 
        struct work_struct free_work;
 
-       u16              shmem_handle;
+       grant_handle_t   shmem_handle;
        grant_ref_t      shmem_ref;
 } blkif_t;
 
diff -r ff95b53bd39a -r 58d46463413e 
linux-2.6-xen-sparse/drivers/xen/blktap/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c       Wed Nov 30 
15:03:05 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c       Wed Nov 30 
16:24:27 2005
@@ -43,9 +43,9 @@
        unlock_vm_area(blkif->blk_ring_area);
        BUG_ON(ret);
 
-       if (op.handle < 0) {
+       if (op.status) {
                DPRINTK(" Grant table operation failure !\n");
-               return op.handle;
+               return op.status;
        }
 
        blkif->shmem_ref    = shared_page;
diff -r ff95b53bd39a -r 58d46463413e 
linux-2.6-xen-sparse/drivers/xen/netback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/netback/common.h Wed Nov 30 15:03:05 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/common.h Wed Nov 30 16:24:27 2005
@@ -45,9 +45,9 @@
        u8               fe_dev_addr[6];
 
        /* Physical parameters of the comms window. */
-       u16              tx_shmem_handle;
+       grant_handle_t   tx_shmem_handle;
        grant_ref_t      tx_shmem_ref; 
-       u16              rx_shmem_handle;
+       grant_handle_t   rx_shmem_handle;
        grant_ref_t      rx_shmem_ref; 
        unsigned int     evtchn;
        unsigned int     irq;
diff -r ff95b53bd39a -r 58d46463413e 
linux-2.6-xen-sparse/drivers/xen/netback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c      Wed Nov 30 
15:03:05 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c      Wed Nov 30 
16:24:27 2005
@@ -127,9 +127,9 @@
        unlock_vm_area(netif->comms_area);
        BUG_ON(ret);
 
-       if (op.handle < 0) { 
+       if (op.status) { 
                DPRINTK(" Gnttab failure mapping tx_ring_ref!\n");
-               return op.handle;
+               return op.status;
        }
 
        netif->tx_shmem_ref    = tx_ring_ref;
@@ -145,9 +145,9 @@
        unlock_vm_area(netif->comms_area);
        BUG_ON(ret);
 
-       if (op.handle < 0) { 
+       if (op.status) {
                DPRINTK(" Gnttab failure mapping rx_ring_ref!\n");
-               return op.handle;
+               return op.status;
        }
 
        netif->rx_shmem_ref    = rx_ring_ref;
diff -r ff95b53bd39a -r 58d46463413e 
linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c        Wed Nov 30 
15:03:05 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c        Wed Nov 30 
16:24:27 2005
@@ -68,7 +68,7 @@
 
 static struct sk_buff_head tx_queue;
 
-static u16 grant_tx_ref[MAX_PENDING_REQS];
+static grant_handle_t grant_tx_handle[MAX_PENDING_REQS];
 static gnttab_unmap_grant_ref_t tx_unmap_ops[MAX_PENDING_REQS];
 static gnttab_map_grant_ref_t tx_map_ops[MAX_PENDING_REQS];
 
@@ -412,7 +412,7 @@
                pending_idx = dealloc_ring[MASK_PEND_IDX(dc++)];
                gop->host_addr    = MMAP_VADDR(pending_idx);
                gop->dev_bus_addr = 0;
-               gop->handle       = grant_tx_ref[pending_idx];
+               gop->handle       = grant_tx_handle[pending_idx];
                gop++;
        }
        ret = HYPERVISOR_grant_table_op(
@@ -592,7 +592,7 @@
                       sizeof(txreq));
 
                /* Check the remap error code. */
-               if (unlikely(mop->handle < 0)) {
+               if (unlikely(mop->status)) {
                        printk(KERN_ALERT "#### netback grant fails\n");
                        make_tx_response(netif, txreq.id, NETIF_RSP_ERROR);
                        netif_put(netif);
@@ -605,7 +605,7 @@
                set_phys_to_machine(
                        __pa(MMAP_VADDR(pending_idx)) >> PAGE_SHIFT,
                        FOREIGN_FRAME(mop->dev_bus_addr >> PAGE_SHIFT));
-               grant_tx_ref[pending_idx] = mop->handle;
+               grant_tx_handle[pending_idx] = mop->handle;
 
                data_len = (txreq.size > PKT_PROT_LEN) ?
                        PKT_PROT_LEN : txreq.size;
diff -r ff95b53bd39a -r 58d46463413e 
linux-2.6-xen-sparse/drivers/xen/tpmback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/common.h Wed Nov 30 15:03:05 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/common.h Wed Nov 30 16:24:27 2005
@@ -54,7 +54,7 @@
 
        struct work_struct work;
 
-       u16 shmem_handle;
+       grant_handle_t shmem_handle;
        grant_ref_t shmem_ref;
 } tpmif_t;
 
diff -r ff95b53bd39a -r 58d46463413e 
linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c      Wed Nov 30 
15:03:05 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c      Wed Nov 30 
16:24:27 2005
@@ -91,9 +91,9 @@
        unlock_vm_area(tpmif->tx_area);
        BUG_ON(ret);
 
-       if (op.handle < 0) {
+       if (op.status) {
                DPRINTK(" Grant table operation failure !\n");
-               return op.handle;
+               return op.status;
        }
 
        tpmif->shmem_ref = shared_page;
diff -r ff95b53bd39a -r 58d46463413e 
linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c        Wed Nov 30 
15:03:05 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c        Wed Nov 30 
16:24:27 2005
@@ -249,7 +249,7 @@
         * and send it to the front end.
         */
        tpmif_t *tpmif = pak->tpmif;
-       u16 handle;
+       grant_handle_t handle;
        int rc = 0;
        unsigned int i = 0;
        unsigned int offset = 0;
@@ -290,7 +290,7 @@
 
                handle = map_op.handle;
 
-               if (map_op.handle < 0) {
+               if (map_op.status) {
                        DPRINTK(" Grant table operation failure !\n");
                        return 0;
                }
@@ -427,7 +427,7 @@
        u32 i = (last_read / PAGE_SIZE);
        u32 pg_offset = last_read & (PAGE_SIZE - 1);
        u32 to_copy;
-       u16 handle;
+       grant_handle_t handle;
 
        tpmif_tx_request_t *tx;
        tx = &tpmif->tx->ring[0].req;
@@ -455,7 +455,7 @@
                        BUG();
                }
 
-               if (map_op.handle < 0) {
+               if (map_op.status) {
                        DPRINTK(" Grant table operation failure !\n");
                        return -EFAULT;
                }
diff -r ff95b53bd39a -r 58d46463413e tools/libxc/xc_domain.c
--- a/tools/libxc/xc_domain.c   Wed Nov 30 15:03:05 2005
+++ b/tools/libxc/xc_domain.c   Wed Nov 30 16:24:27 2005
@@ -365,9 +365,9 @@
 
 int xc_domain_ioport_permission(int xc_handle,
                                 uint32_t domid,
-                                uint16_t first_port,
-                                uint16_t nr_ports,
-                                uint16_t allow_access)
+                                uint32_t first_port,
+                                uint32_t nr_ports,
+                                uint32_t allow_access)
 {
     DECLARE_DOM0_OP;
 
diff -r ff95b53bd39a -r 58d46463413e tools/libxc/xc_gnttab.c
--- a/tools/libxc/xc_gnttab.c   Wed Nov 30 15:03:05 2005
+++ b/tools/libxc/xc_gnttab.c   Wed Nov 30 16:24:27 2005
@@ -42,9 +42,10 @@
 int xc_gnttab_map_grant_ref(int         xc_handle,
                             uint64_t    host_virt_addr,
                             uint32_t    dom,
-                            uint16_t    ref,
+                            grant_ref_t ref,
                             uint16_t    flags,
-                            int16_t    *handle,
+                            int16_t    *status,
+                            grant_handle_t *handle,
                             uint64_t   *dev_bus_addr)
 {
     struct gnttab_map_grant_ref op;
@@ -58,6 +59,7 @@
     if ( (rc = do_gnttab_op(xc_handle, GNTTABOP_map_grant_ref,
                             &op, 1)) == 0 )
     {
+        *status         = op.status;
         *handle         = op.handle;
         *dev_bus_addr   = op.dev_bus_addr;
     }
@@ -69,7 +71,7 @@
 int xc_gnttab_unmap_grant_ref(int       xc_handle,
                               uint64_t  host_virt_addr,
                               uint64_t  dev_bus_addr,
-                              uint16_t  handle,
+                              grant_handle_t handle,
                               int16_t  *status)
 {
     struct gnttab_unmap_grant_ref op;
diff -r ff95b53bd39a -r 58d46463413e tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Wed Nov 30 15:03:05 2005
+++ b/tools/libxc/xenctrl.h     Wed Nov 30 16:24:27 2005
@@ -13,6 +13,7 @@
 #include <sys/ptrace.h>
 #include <xen/xen.h>
 #include <xen/dom0_ops.h>
+#include <xen/grant_table.h>
 #include <xen/version.h>
 #include <xen/event_channel.h>
 #include <xen/sched.h>
@@ -374,9 +375,9 @@
 
 int xc_domain_ioport_permission(int xc_handle,
                                 uint32_t domid,
-                                uint16_t first_port,
-                                uint16_t nr_ports,
-                                uint16_t allow_access);
+                                uint32_t first_port,
+                                uint32_t nr_ports,
+                                uint32_t allow_access);
 
 unsigned long xc_make_page_below_4G(int xc_handle, uint32_t domid, 
                                    unsigned long mfn);
@@ -475,15 +476,16 @@
 int xc_gnttab_map_grant_ref(int      xc_handle,
                             uint64_t host_virt_addr,
                             uint32_t dom,
-                            uint16_t ref,
+                            grant_ref_t ref,
                             uint16_t flags,
-                            int16_t *handle,
+                            int16_t *status,
+                            grant_handle_t *handle,
                             uint64_t *dev_bus_addr);
 
 int xc_gnttab_unmap_grant_ref(int  xc_handle,
                               uint64_t  host_virt_addr,
                               uint64_t  dev_bus_addr,
-                              uint16_t  handle,
+                              grant_handle_t handle,
                               int16_t *status);
 
 int xc_gnttab_setup_table(int        xc_handle,
diff -r ff95b53bd39a -r 58d46463413e xen/common/grant_table.c
--- a/xen/common/grant_table.c  Wed Nov 30 15:03:05 2005
+++ b/xen/common/grant_table.c  Wed Nov 30 16:24:27 2005
@@ -114,13 +114,13 @@
                    (GNTMAP_device_map|GNTMAP_host_map)) == 0) )
     {
         DPRINTK("Bad ref (%d) or flags (%x).\n", ref, dev_hst_ro_flags);
-        (void)__put_user(GNTST_bad_gntref, &uop->handle);
+        (void)__put_user(GNTST_bad_gntref, &uop->status);
         return GNTST_bad_gntref;
     }
 
     if ( acm_pre_grant_map_ref(dom) )
     {
-        (void)__put_user(GNTST_permission_denied, &uop->handle);
+        (void)__put_user(GNTST_permission_denied, &uop->status);
         return GNTST_permission_denied;
     }
 
@@ -130,7 +130,7 @@
         if ( rd != NULL )
             put_domain(rd);
         DPRINTK("Could not find domain %d\n", dom);
-        (void)__put_user(GNTST_bad_domain, &uop->handle);
+        (void)__put_user(GNTST_bad_domain, &uop->status);
         return GNTST_bad_domain;
     }
 
@@ -145,7 +145,7 @@
         {
             put_domain(rd);
             DPRINTK("Maptrack table is at maximum size.\n");
-            (void)__put_user(GNTST_no_device_space, &uop->handle);
+            (void)__put_user(GNTST_no_device_space, &uop->status);
             return GNTST_no_device_space;
         }
 
@@ -155,7 +155,7 @@
         {
             put_domain(rd);
             DPRINTK("No more map handles available.\n");
-            (void)__put_user(GNTST_no_device_space, &uop->handle);
+            (void)__put_user(GNTST_no_device_space, &uop->status);
             return GNTST_no_device_space;
         }
 
@@ -370,6 +370,7 @@
 
     (void)__put_user((u64)frame << PAGE_SHIFT, &uop->dev_bus_addr);
     (void)__put_user(handle, &uop->handle);
+    (void)__put_user(GNTST_okay, &uop->status);
 
     put_domain(rd);
     return rc;
@@ -377,7 +378,7 @@
 
  unlock_out:
     spin_unlock(&rd->grant_table->lock);
-    (void)__put_user(rc, &uop->handle);
+    (void)__put_user(rc, &uop->status);
     put_maptrack_handle(ld->grant_table, handle);
     return rc;
 }
@@ -400,7 +401,7 @@
 {
     domid_t          dom;
     grant_ref_t      ref;
-    u16              handle;
+    grant_handle_t   handle;
     struct domain   *ld, *rd;
     active_grant_entry_t *act;
     grant_entry_t   *sha;
@@ -957,7 +958,7 @@
     grant_table_t        *gt = d->grant_table;
     grant_mapping_t      *map;
     grant_ref_t           ref;
-    u16                   handle;
+    grant_handle_t        handle;
     struct domain        *rd;
     active_grant_entry_t *act;
     grant_entry_t        *sha;
diff -r ff95b53bd39a -r 58d46463413e xen/include/public/dom0_ops.h
--- a/xen/include/public/dom0_ops.h     Wed Nov 30 15:03:05 2005
+++ b/xen/include/public/dom0_ops.h     Wed Nov 30 16:24:27 2005
@@ -19,7 +19,7 @@
  * This makes sure that old versions of dom0 tools will stop working in a
  * well-defined way (rather than crashing the machine, for instance).
  */
-#define DOM0_INTERFACE_VERSION   0xAAAA1013
+#define DOM0_INTERFACE_VERSION   0xAAAA1014
 
 /************************************************************************/
 
diff -r ff95b53bd39a -r 58d46463413e xen/include/public/grant_table.h
--- a/xen/include/public/grant_table.h  Wed Nov 30 15:03:05 2005
+++ b/xen/include/public/grant_table.h  Wed Nov 30 16:24:27 2005
@@ -134,6 +134,11 @@
 typedef uint32_t grant_ref_t;
 
 /*
+ * Handle to track a mapping created via a grant reference.
+ */
+typedef uint32_t grant_handle_t;
+
+/*
  * GNTTABOP_map_grant_ref: Map the grant entry (<dom>,<ref>) for access
  * by devices and/or host CPUs. If successful, <handle> is a tracking number
  * that must be presented later to destroy the mapping(s). On error, <handle>
@@ -154,11 +159,12 @@
 typedef struct gnttab_map_grant_ref {
     /* IN parameters. */
     uint64_t host_addr;
+    uint32_t flags;               /* GNTMAP_* */
+    grant_ref_t ref;
     domid_t  dom;
-    grant_ref_t ref;
-    uint32_t flags;               /* GNTMAP_* */
-    /* OUT parameters. */
-    int32_t  handle;              /* +ve: handle; -ve: GNTST_* */
+    /* OUT parameters. */
+    int16_t  status;              /* GNTST_* */
+    grant_handle_t handle;
     uint64_t dev_bus_addr;
 } gnttab_map_grant_ref_t;
 
@@ -178,9 +184,9 @@
     /* IN parameters. */
     uint64_t host_addr;
     uint64_t dev_bus_addr;
-    uint32_t handle;
-    /* OUT parameters. */
-    int32_t  status;              /* GNTST_* */
+    grant_handle_t handle;
+    /* OUT parameters. */
+    int16_t  status;              /* GNTST_* */
 } gnttab_unmap_grant_ref_t;
 
 /*
@@ -198,7 +204,7 @@
     domid_t  dom;
     uint32_t nr_frames;
     /* OUT parameters. */
-    int32_t  status;              /* GNTST_* */
+    int16_t  status;              /* GNTST_* */
     unsigned long *frame_list;
 } gnttab_setup_table_t;
 
@@ -211,7 +217,7 @@
     /* IN parameters. */
     domid_t dom;
     /* OUT parameters. */
-    int32_t status;               /* GNTST_* */
+    int16_t status;               /* GNTST_* */
 } gnttab_dump_table_t;
 
 /*
@@ -229,7 +235,7 @@
     domid_t       domid;
     grant_ref_t   ref;
     /* OUT parameters. */
-    int32_t       status;
+    int16_t       status;
 } gnttab_transfer_t;
 
 /*
diff -r ff95b53bd39a -r 58d46463413e xen/include/public/io/blkif.h
--- a/xen/include/public/io/blkif.h     Wed Nov 30 15:03:05 2005
+++ b/xen/include/public/io/blkif.h     Wed Nov 30 16:24:27 2005
@@ -43,7 +43,7 @@
 typedef struct blkif_response {
     uint64_t        id;              /* copied from request */
     uint8_t         operation;       /* copied from request */
-    int32_t         status;          /* BLKIF_RSP_???       */
+    int16_t         status;          /* BLKIF_RSP_???       */
 } blkif_response_t;
 
 #define BLKIF_RSP_ERROR  -1 /* non-specific 'error' */

_______________________________________________
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®.