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

[Xen-changelog] [xen-3.4-testing] stubdom: mmap on /dev/mem support



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1256290137 -3600
# Node ID 2d8e3fca36df6dc0ba3d14d753f64c66d4763a72
# Parent  4156fbc48a4508c26ca61a32ab767b050565bd2d
stubdom: mmap on /dev/mem support

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>
xen-unstable changeset:   20354:37829fd7c1e3
xen-unstable date:        Wed Oct 21 16:08:28 2009 +0100

minios: Optimize mmap(open("/dev/mem"))

Set map_frames_ex's stride parameter to 0 and increment to 1 to avoid
building an explicit list of mfns.

Signed-Off-By: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>
xen-unstable changeset:   20355:4a65bd76e09b
xen-unstable date:        Fri Oct 23 09:59:45 2009 +0100
---
 extras/mini-os/include/lib.h |    1 +
 extras/mini-os/lib/sys.c     |    9 ++++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff -r 4156fbc48a45 -r 2d8e3fca36df extras/mini-os/include/lib.h
--- a/extras/mini-os/include/lib.h      Fri Oct 23 10:25:10 2009 +0100
+++ b/extras/mini-os/include/lib.h      Fri Oct 23 10:28:57 2009 +0100
@@ -145,6 +145,7 @@ enum fd_type {
     FTYPE_BLK,
     FTYPE_KBD,
     FTYPE_FB,
+    FTYPE_MEM,
 };
 
 #define MAX_EVTCHN_PORTS 16
diff -r 4156fbc48a45 -r 2d8e3fca36df extras/mini-os/lib/sys.c
--- a/extras/mini-os/lib/sys.c  Fri Oct 23 10:25:10 2009 +0100
+++ b/extras/mini-os/lib/sys.c  Fri Oct 23 10:28:57 2009 +0100
@@ -174,6 +174,11 @@ int open(const char *pathname, int flags
     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;
     }
     printk("open(%s, %x)", pathname, flags);
@@ -1198,13 +1203,15 @@ void *mmap(void *start, size_t length, i
     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) {
+        unsigned long first_mfn = offset >> PAGE_SHIFT;
+        return map_frames_ex(&first_mfn, n, 0, 1, 1, DOMID_IO, 0, 
_PAGE_PRESENT|_PAGE_RW);
     } else ASSERT(0);
 }
 

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