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

[Xen-changelog] Attached is a patch that fully 'grant-table-ifies' the block front and



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 287583627544a984c89ff5ec6b44ec2c73187838
# Parent  bc8cab40719714cd2bc56f002046e3cd09725071

Attached is a patch that fully 'grant-table-ifies' the block front and 
backends.  It is necessary to do a make clean in the tools directory and 
then rebuild the tree.

Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxx>

diff -r bc8cab407197 -r 287583627544 tools/python/xen/lowlevel/xu/xu.c
--- a/tools/python/xen/lowlevel/xu/xu.c Wed Jul  6 08:47:34 2005
+++ b/tools/python/xen/lowlevel/xu/xu.c Wed Jul  6 08:50:11 2005
@@ -594,6 +594,7 @@
     case TYPE(CMSG_BLKIF_FE, CMSG_BLKIF_FE_INTERFACE_CONNECT):
         C2P(blkif_fe_interface_connect_t, handle,      Int, Long);
         C2P(blkif_fe_interface_connect_t, shmem_frame, Int, Long);
+        C2P(blkif_fe_interface_connect_t, shmem_ref  , Int, Long);
         return dict;
     case TYPE(CMSG_BLKIF_FE, CMSG_BLKIF_FE_INTERFACE_DISCONNECT):
         C2P(blkif_fe_interface_disconnect_t, handle, Int, Long);
@@ -612,6 +613,7 @@
         C2P(blkif_be_connect_t, domid,        Int, Long);
         C2P(blkif_be_connect_t, blkif_handle, Int, Long);
         C2P(blkif_be_connect_t, shmem_frame,  Int, Long);
+        C2P(blkif_be_connect_t, shmem_ref,    Int, Long);
         C2P(blkif_be_connect_t, evtchn,       Int, Long);
         C2P(blkif_be_connect_t, status,       Int, Long);
         return dict;
@@ -842,6 +844,7 @@
         P2C(blkif_be_connect_t, domid,        u32);
         P2C(blkif_be_connect_t, blkif_handle, u32);
         P2C(blkif_be_connect_t, shmem_frame,  memory_t);
+        P2C(blkif_be_connect_t, shmem_ref,    u32);
         P2C(blkif_be_connect_t, evtchn,       u16);
         break;
     case TYPE(CMSG_BLKIF_BE, CMSG_BLKIF_BE_DISCONNECT):
diff -r bc8cab407197 -r 287583627544 
linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c   Wed Jul  6 
08:47:34 2005
+++ b/linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c   Wed Jul  6 
08:50:11 2005
@@ -1136,6 +1136,12 @@
     msg->handle      = 0;
     msg->shmem_frame = (virt_to_machine(blk_ring.sring) >> PAGE_SHIFT);
     
+#ifdef CONFIG_XEN_BLKDEV_GRANT
+    msg->shmem_ref   = gnttab_claim_grant_reference( &gref_head, gref_terminal 
);
+    ASSERT( msg->shmem_ref != -ENOSPC );
+    gnttab_grant_foreign_access_ref ( msg->shmem_ref , rdomid, 
msg->shmem_frame, 0 );
+#endif
+
     ctrl_if_send_message_block(&cmsg, NULL, 0, TASK_UNINTERRUPTIBLE);
 }
 
@@ -1261,9 +1267,6 @@
 
     blkif_evtchn = status->evtchn;
     blkif_irq    = bind_evtchn_to_irq(blkif_evtchn);
-#ifdef CONFIG_XEN_BLKDEV_GRANT
-    rdomid       = status->domid;
-#endif
 
     err = request_irq(blkif_irq, blkif_int, SA_SAMPLE_RANDOM, "blkif", NULL);
     if ( err )
@@ -1300,6 +1303,10 @@
 
 static void blkif_status(blkif_fe_interface_status_t *status)
 {
+#ifdef CONFIG_XEN_BLKDEV_GRANT
+    rdomid       = status->domid; /* need to set rdomid early */
+#endif
+
     if ( status->handle != blkif_handle )
     {
         WPRINTK(" Invalid blkif: handle=%u\n", status->handle);
diff -r bc8cab407197 -r 287583627544 xen/include/public/io/domain_controller.h
--- a/xen/include/public/io/domain_controller.h Wed Jul  6 08:47:34 2005
+++ b/xen/include/public/io/domain_controller.h Wed Jul  6 08:50:11 2005
@@ -140,6 +140,7 @@
 typedef struct blkif_fe_interface_connect {
     u32      handle;
     memory_t shmem_frame;
+    int      shmem_ref;
 } blkif_fe_interface_connect_t;
 
 /*
@@ -249,6 +250,7 @@
     domid_t    domid;         /* Domain attached to new interface.   */
     u32        blkif_handle;  /* Domain-specific interface handle.   */
     memory_t   shmem_frame;   /* Page cont. shared comms window.     */
+    int        shmem_ref;     /* Grant table reference.              */
     u32        evtchn;        /* Event channel for notifications.    */
     /* OUT */
     u32        status;
diff -r bc8cab407197 -r 287583627544 tools/python/xen/xend/server/blkif.py
--- a/tools/python/xen/xend/server/blkif.py     Wed Jul  6 08:47:34 2005
+++ b/tools/python/xen/xend/server/blkif.py     Wed Jul  6 08:50:11 2005
@@ -126,7 +126,8 @@
                       { 'domid'        : self.frontendDomain,
                         'blkif_handle' : self.id,
                         'evtchn'       : self.getEventChannelBackend(),
-                        'shmem_frame'  : val['shmem_frame'] })
+                        'shmem_frame'  : val['shmem_frame'],
+                        'shmem_ref'    : val['shmem_ref'] })
         msg = self.backendChannel.requestResponse(msg)
         #todo: check return status
         val = unpackMsg('blkif_be_connect_t', msg)
diff -r bc8cab407197 -r 287583627544 xen/include/public/dom0_ops.h
--- a/xen/include/public/dom0_ops.h     Wed Jul  6 08:47:34 2005
+++ b/xen/include/public/dom0_ops.h     Wed Jul  6 08:50:11 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   0xAAAA100B
+#define DOM0_INTERFACE_VERSION   0xAAAA100C
 
 /************************************************************************/
 
diff -r bc8cab407197 -r 287583627544 
linux-2.6.11-xen-sparse/drivers/xen/blkback/interface.c
--- a/linux-2.6.11-xen-sparse/drivers/xen/blkback/interface.c   Wed Jul  6 
08:47:34 2005
+++ b/linux-2.6.11-xen-sparse/drivers/xen/blkback/interface.c   Wed Jul  6 
08:50:11 2005
@@ -39,6 +39,23 @@
      * must still be notified to the remote driver.
      */
     unbind_evtchn_from_irq(blkif->evtchn);
+
+#ifdef CONFIG_XEN_BLKDEV_GRANT
+    {
+        /*
+         * Release the shared memory page.
+         */
+        struct gnttab_unmap_grant_ref op;
+
+        op.host_virt_addr = blkif->shmem_vaddr;
+        op.handle         = blkif->shmem_handle;
+        op.dev_bus_addr   = 0;
+
+        if(unlikely(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 
1))) {
+            BUG();
+        }
+    }
+#endif
     vfree(blkif->blk_ring.sring);
 
     /* Construct the deferred response message. */
@@ -154,8 +171,12 @@
     unsigned int   evtchn = connect->evtchn;
     unsigned long  shmem_frame = connect->shmem_frame;
     struct vm_struct *vma;
+#ifdef CONFIG_XEN_BLKDEV_GRANT
+    int ref = connect->shmem_ref;
+#else
     pgprot_t       prot;
     int            error;
+#endif
     blkif_t       *blkif;
     blkif_sring_t *sring;
 
@@ -174,6 +195,7 @@
         return;
     }
 
+#ifndef CONFIG_XEN_BLKDEV_GRANT
     prot = __pgprot(_KERNPG_TABLE);
     error = direct_remap_area_pages(&init_mm, VMALLOC_VMADDR(vma->addr),
                                     shmem_frame<<PAGE_SHIFT, PAGE_SIZE,
@@ -189,6 +211,36 @@
         vfree(vma->addr);
         return;
     }
+#else
+    { /* Map: Use the Grant table reference */
+        struct gnttab_map_grant_ref op;
+        op.host_virt_addr = VMALLOC_VMADDR(vma->addr);
+        op.flags          = GNTMAP_host_map;
+        op.ref            = ref;
+        op.dom            = domid;
+       
+        if(unlikely(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 
1))) {
+            BUG();
+        }
+       
+        handle = op.handle;
+       
+        if (op.handle < 0) {
+            DPRINTK(" Grant table operation failure !\n");
+            connect->status = BLKIF_BE_STATUS_MAPPING_ERROR;
+            vfree(vma->addr);
+            return;
+        }
+
+        phys_to_machine_mapping[__pa(VMALLOC_VMADDR(vma->addr)) >>
+                                PAGE_SHIFT] =
+                      FOREIGN_FRAME(shmem_frame);
+
+        blkif->shmem_ref = ref;
+        blkif->shmem_handle = handle;
+        blkif->shmem_vaddr = VMALLOC_VMADDR(vma->addr);
+    }
+#endif
 
     if ( blkif->status != DISCONNECTED )
     {
diff -r bc8cab407197 -r 287583627544 
linux-2.6.11-xen-sparse/drivers/xen/blkback/common.h
--- a/linux-2.6.11-xen-sparse/drivers/xen/blkback/common.h      Wed Jul  6 
08:47:34 2005
+++ b/linux-2.6.11-xen-sparse/drivers/xen/blkback/common.h      Wed Jul  6 
08:50:11 2005
@@ -65,6 +65,11 @@
     atomic_t         refcnt;
 
     struct work_struct work;
+#ifdef CONFIG_XEN_BLKDEV_GRANT
+    u16 shmem_handle;
+    memory_t shmem_vaddr;
+    grant_ref_t shmem_ref;
+#endif
 } blkif_t;
 
 void blkif_create(blkif_be_create_t *create);

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