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

[Xen-devel] [PATCH] mmap on /dev/mem support in stubdoms

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] mmap on /dev/mem support in stubdoms
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Wed, 21 Oct 2009 15:00:27 +0100
Delivery-date: Wed, 21 Oct 2009 07:00:33 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)
Hi all,
this patch adds support for mmap on /dev/mem in a stubdom; it is secure
because it only works for memory areas that have been explicitly
allowed by the toolstack (xc_domain_iomem_permission).
Incidentally this is all that is needed to make MSI-X passthrough work
with stubdoms.


Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>

---


diff -r eaa7d75a82b6 extras/mini-os/include/lib.h
--- a/extras/mini-os/include/lib.h      Tue Oct 20 16:18:43 2009 +0100
+++ b/extras/mini-os/include/lib.h      Wed Oct 21 11:08:39 2009 +0100
@@ -145,6 +145,7 @@
     FTYPE_BLK,
     FTYPE_KBD,
     FTYPE_FB,
+    FTYPE_MEM,
 };
 
 #define MAX_EVTCHN_PORTS 16
diff -r eaa7d75a82b6 extras/mini-os/lib/sys.c
--- a/extras/mini-os/lib/sys.c  Tue Oct 20 16:18:43 2009 +0100
+++ b/extras/mini-os/lib/sys.c  Wed Oct 21 11:08:39 2009 +0100
@@ -188,6 +188,11 @@
     if (!strncmp(pathname,LOG_PATH,strlen(LOG_PATH))) {
        fd = alloc_fd(FTYPE_CONSOLE);
         printk("open(%s) -> %d\n", pathname, fd);
+        return fd;
+    }
+    if (!strncmp(pathname, "/dev/mem", strlen("/dev/mem"))) {
+        fd = alloc_fd(FTYPE_MEM);
+        printk("open(/dev/mem) -> %d\n", fd);
         return fd;
     }
     if (!strncmp(pathname, "/dev/ptmx", strlen("/dev/ptmx")))
@@ -1244,13 +1249,18 @@
     ASSERT(prot == (PROT_READ|PROT_WRITE));
     ASSERT((fd == -1 && (flags == (MAP_SHARED|MAP_ANON) || flags == 
(MAP_PRIVATE|MAP_ANON)))
         || (fd != -1 && flags == MAP_SHARED));
-    ASSERT(offset == 0);
 
     if (fd == -1)
         return map_zero(n, 1);
     else if (files[fd].type == FTYPE_XC) {
         unsigned long zero = 0;
         return map_frames_ex(&zero, n, 0, 0, 1, DOMID_SELF, 0, 0);
+    } else if (files[fd].type == FTYPE_MEM) {
+        int i;
+        unsigned long mfns[n];
+        for (i = 0; i < n; i++)
+            mfns[i] = ((unsigned long) offset + (i * PAGE_SIZE)) >> PAGE_SHIFT;
+        return map_frames_ex(mfns, n, 1, 0, 1, DOMID_IO, 0, 
_PAGE_PRESENT|_PAGE_RW);
     } else ASSERT(0);
 }
 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] mmap on /dev/mem support in stubdoms, Stefano Stabellini <=