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-changelog

[Xen-changelog] Fix mapping of shared ring pages into backend drivers.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Fix mapping of shared ring pages into backend drivers.
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 21 Sep 2005 16:38:11 +0000
Delivery-date: Wed, 21 Sep 2005 16:36:41 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID f71bb61e0500decbe074239f21cca9be2c6e210e
# Parent  55fc0ecc19c3a0dc8838a3b5f0405170246bd702
Fix mapping of shared ring pages into backend drivers.
This should fix observed problems when creating a domain,
causing Xen to print "Could not find PTE entry for
address ...".

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

diff -r 55fc0ecc19c3 -r f71bb61e0500 linux-2.6-xen-sparse/drivers/xen/Makefile
--- a/linux-2.6-xen-sparse/drivers/xen/Makefile Wed Sep 21 14:25:58 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/Makefile Wed Sep 21 16:36:46 2005
@@ -1,4 +1,5 @@
 
+obj-y  += util.o
 
 obj-y  += console/
 obj-y  += evtchn/
diff -r 55fc0ecc19c3 -r f71bb61e0500 
linux-2.6-xen-sparse/drivers/xen/blkback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c      Wed Sep 21 
14:25:58 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c      Wed Sep 21 
16:36:46 2005
@@ -8,6 +8,7 @@
 
 #include "common.h"
 #include <asm-xen/evtchn.h>
+#include <asm-xen/driver_util.h>
 
 static kmem_cache_t *blkif_cachep;
 
@@ -69,12 +70,12 @@
 
     BUG_ON(blkif->remote_evtchn);
 
-    if ( (vma = get_vm_area(PAGE_SIZE, VM_IOREMAP)) == NULL )
+    if ( (vma = prepare_vm_area(PAGE_SIZE)) == NULL )
        return -ENOMEM;
 
     err = map_frontend_page(blkif, (unsigned long)vma->addr, shared_page);
     if (err) {
-        vfree(vma->addr);
+        vunmap(vma->addr);
        return err;
     }
 
@@ -85,7 +86,7 @@
     err = HYPERVISOR_event_channel_op(&op);
     if (err) {
        unmap_frontend_page(blkif);
-       vfree(vma->addr);
+       vunmap(vma->addr);
        return err;
     }
 
@@ -123,7 +124,7 @@
 
     if (blkif->blk_ring.sring) {
        unmap_frontend_page(blkif);
-       vfree(blkif->blk_ring.sring);
+       vunmap(blkif->blk_ring.sring);
        blkif->blk_ring.sring = NULL;
     }
 
diff -r 55fc0ecc19c3 -r f71bb61e0500 
linux-2.6-xen-sparse/drivers/xen/blktap/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c       Wed Sep 21 
14:25:58 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c       Wed Sep 21 
16:36:46 2005
@@ -8,6 +8,7 @@
 
 #include "common.h"
 #include <asm-xen/evtchn.h>
+#include <asm-xen/driver_util.h>
 
 static kmem_cache_t *blkif_cachep;
 
@@ -69,12 +70,12 @@
 
     BUG_ON(blkif->remote_evtchn);
 
-    if ( (vma = get_vm_area(PAGE_SIZE, VM_IOREMAP)) == NULL )
+    if ( (vma = prepare_vm_area(PAGE_SIZE)) == NULL )
        return -ENOMEM;
 
     err = map_frontend_page(blkif, (unsigned long)vma->addr, shared_page);
     if (err) {
-        vfree(vma->addr);
+        vunmap(vma->addr);
        return err;
     }
 
@@ -85,7 +86,7 @@
     err = HYPERVISOR_event_channel_op(&op);
     if (err) {
        unmap_frontend_page(blkif);
-       vfree(vma->addr);
+       vunmap(vma->addr);
        return err;
     }
 
@@ -121,7 +122,7 @@
 
     if (blkif->blk_ring.sring) {
        unmap_frontend_page(blkif);
-       vfree(blkif->blk_ring.sring);
+       vunmap(blkif->blk_ring.sring);
        blkif->blk_ring.sring = NULL;
     }
 
diff -r 55fc0ecc19c3 -r f71bb61e0500 
linux-2.6-xen-sparse/drivers/xen/netback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c      Wed Sep 21 
14:25:58 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c      Wed Sep 21 
16:36:46 2005
@@ -8,6 +8,7 @@
 
 #include "common.h"
 #include <linux/rtnetlink.h>
+#include <asm-xen/driver_util.h>
 
 static void __netif_up(netif_t *netif)
 {
@@ -198,14 +199,14 @@
        evtchn_op_t op = { .cmd = EVTCHNOP_bind_interdomain };
        int err;
 
-       vma = get_vm_area(2*PAGE_SIZE, VM_IOREMAP);
+       vma = prepare_vm_area(2*PAGE_SIZE);
        if (vma == NULL)
                return -ENOMEM;
 
        err = map_frontend_pages(
                netif, (unsigned long)vma->addr, tx_ring_ref, rx_ring_ref);
        if (err) {
-               vfree(vma->addr);
+               vunmap(vma->addr);
                return err;
        }
 
@@ -216,7 +217,7 @@
        err = HYPERVISOR_event_channel_op(&op);
        if (err) {
                unmap_frontend_pages(netif);
-               vfree(vma->addr);
+               vunmap(vma->addr);
                return err;
        }
 
@@ -261,7 +262,7 @@
 
        if (netif->tx) {
                unmap_frontend_pages(netif);
-               vfree(netif->tx); /* Frees netif->rx as well. */
+               vunmap(netif->tx); /* Frees netif->rx as well. */
        }
 
        free_netdev(netif->dev);
diff -r 55fc0ecc19c3 -r f71bb61e0500 
linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c      Wed Sep 21 
14:25:58 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c      Wed Sep 21 
16:36:46 2005
@@ -1,4 +1,4 @@
- 
/******************************************************************************
+ /*****************************************************************************
  * drivers/xen/tpmback/interface.c
  *
  * Vritual TPM interface management.
@@ -13,6 +13,7 @@
 
 #include "common.h"
 #include <asm-xen/balloon.h>
+#include <asm-xen/driver_util.h>
 
 #define VMALLOC_VMADDR(x) ((unsigned long)(x))
 
@@ -122,12 +123,12 @@
 
        BUG_ON(tpmif->remote_evtchn);
 
-       if ((vma = get_vm_area(PAGE_SIZE, VM_IOREMAP)) == NULL)
+       if ((vma = prepare_vm_area(PAGE_SIZE)) == NULL)
                return -ENOMEM;
 
        err = map_frontend_page(tpmif, VMALLOC_VMADDR(vma->addr), shared_page);
        if (err) {
-               vfree(vma->addr);
+               vunmap(vma->addr);
                return err;
        }
 
@@ -138,7 +139,7 @@
        err = HYPERVISOR_event_channel_op(&op);
        if (err) {
                unmap_frontend_page(tpmif);
-               vfree(vma->addr);
+               vunmap(vma->addr);
                return err;
        }
 
@@ -174,7 +175,7 @@
 
        if (tpmif->tx) {
                unmap_frontend_page(tpmif);
-               vfree(tpmif->tx);
+               vunmap(tpmif->tx);
        }
 
        free_tpmif(tpmif);
diff -r 55fc0ecc19c3 -r f71bb61e0500 
linux-2.6-xen-sparse/drivers/xen/usbback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/usbback/interface.c      Wed Sep 21 
14:25:58 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/usbback/interface.c      Wed Sep 21 
16:36:46 2005
@@ -7,6 +7,7 @@
  */
 
 #include "common.h"
+#include <asm-xen/driver_util.h>
 
 #define USBIF_HASHSZ 1024
 #define USBIF_HASH(_d) (((int)(_d))&(USBIF_HASHSZ-1))
@@ -33,7 +34,7 @@
      * may be outstanding requests at the device whose asynchronous responses
      * must still be notified to the remote driver.
      */
-    vfree(usbif->usb_ring.sring);
+    vunmap(usbif->usb_ring.sring);
 
     /* Construct the deferred response message. */
     cmsg.type         = CMSG_USBIF_BE;
@@ -154,7 +155,7 @@
         return;
     }
 
-    if ( (vma = get_vm_area(PAGE_SIZE, VM_IOREMAP)) == NULL )
+    if ( (vma = prepare_vm_area(PAGE_SIZE)) == NULL )
     {
         connect->status = USBIF_BE_STATUS_OUT_OF_MEMORY;
         return;
@@ -172,14 +173,14 @@
             connect->status = USBIF_BE_STATUS_MAPPING_ERROR;
         else
             connect->status = USBIF_BE_STATUS_ERROR;
-        vfree(vma->addr);
+        vunmap(vma->addr);
         return;
     }
 
     if ( up->status != DISCONNECTED )
     {
         connect->status = USBIF_BE_STATUS_INTERFACE_CONNECTED;
-        vfree(vma->addr);
+        vunmap(vma->addr);
         return;
     }
 
diff -r 55fc0ecc19c3 -r f71bb61e0500 linux-2.6-xen-sparse/drivers/xen/util.c
--- /dev/null   Wed Sep 21 14:25:58 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/util.c   Wed Sep 21 16:36:46 2005
@@ -0,0 +1,46 @@
+#include <linux/config.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/vmalloc.h>
+#include <asm/uaccess.h>
+
+static int touch_fn(
+       pte_t *pte, struct page *pte_page, unsigned long addr, void *data)
+{
+       char c;
+       BUG_ON(!__get_user(c, (char *)addr));
+       return 0;
+}
+
+struct vm_struct *prepare_vm_area(unsigned long size)
+{
+       struct vm_struct *area;
+
+       area = get_vm_area(size, VM_IOREMAP);
+       if (area == NULL)
+               return NULL;
+
+       /*
+         * This ensures that page tables are constructed for this region
+         * of kernel virtual address space. Furthermore, by touching each
+         * memory page (in touch_fn()) we ensure that the page tables are
+         * mapped into the current mm as well as init_mm.
+         */
+       if (generic_page_range(&init_mm, (unsigned long)area->addr,
+                              area->size, touch_fn, NULL)) {
+               vunmap(area->addr);
+               return NULL;
+       }
+
+       return area;
+}
+
+/*
+ * Local variables:
+ *  c-file-style: "linux"
+ *  indent-tabs-mode: t
+ *  c-indent-level: 8
+ *  c-basic-offset: 8
+ *  tab-width: 8
+ * End:
+ */
diff -r 55fc0ecc19c3 -r f71bb61e0500 
linux-2.6-xen-sparse/include/asm-xen/driver_util.h
--- /dev/null   Wed Sep 21 14:25:58 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/driver_util.h        Wed Sep 21 
16:36:46 2005
@@ -0,0 +1,10 @@
+
+#ifndef __ASM_XEN_DRIVER_UTIL_H__
+#define __ASM_XEN_DRIVER_UTIL_H__
+
+#include <linux/config.h>
+#include <linux/vmalloc.h>
+
+extern struct vm_struct *prepare_vm_area(unsigned long size);
+
+#endif /* __ASM_XEN_DRIVER_UTIL_H__ */

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Fix mapping of shared ring pages into backend drivers., Xen patchbot -unstable <=