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

[Xen-changelog] /proc/xen/xsd_kva exports mmap interface that xenstored now uses to map the



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID aefc75f5db5edeb00ed94ba772804642b0bf0038
# Parent  1c46091df7ce2d55f003cef8bde6efa4a41dd8bd
/proc/xen/xsd_kva exports mmap interface that xenstored now uses to map the
domain0 xenbus page.

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

diff -r 1c46091df7ce -r aefc75f5db5e 
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
--- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c    Fri Mar  3 
18:06:50 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c    Fri Mar  3 
18:07:55 2006
@@ -951,9 +951,25 @@
 }
 
 
+static struct file_operations xsd_kva_fops;
 static struct proc_dir_entry *xsd_kva_intf;
 static struct proc_dir_entry *xsd_port_intf;
 
+static int xsd_kva_mmap(struct file *file, struct vm_area_struct *vma)
+{
+       size_t size = vma->vm_end - vma->vm_start;
+
+       if ((size > PAGE_SIZE) || (vma->vm_pgoff != 0))
+               return -EINVAL;
+
+       vma->vm_pgoff = mfn_to_pfn(xen_start_info->store_mfn);
+
+       if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
+                           size, vma->vm_page_prot))
+               return -EAGAIN;
+
+       return 0;
+}
 
 static int xsd_kva_read(char *page, char **start, off_t off,
                         int count, int *eof, void *data)
@@ -1027,9 +1043,14 @@
                xen_start_info->store_evtchn = op.u.alloc_unbound.port;
 
                /* And finally publish the above info in /proc/xen */
-               if((xsd_kva_intf = create_xen_proc_entry("xsd_kva", 0400)))
+               if ((xsd_kva_intf = create_xen_proc_entry("xsd_kva", 0400))) {
+                       memcpy(&xsd_kva_fops, xsd_kva_intf->proc_fops,
+                              sizeof(xsd_kva_fops));
+                       xsd_kva_fops.mmap = xsd_kva_mmap;
+                       xsd_kva_intf->proc_fops = &xsd_kva_fops;
                        xsd_kva_intf->read_proc = xsd_kva_read;
-               if((xsd_port_intf = create_xen_proc_entry("xsd_port", 0400)))
+               }
+               if ((xsd_port_intf = create_xen_proc_entry("xsd_port", 0400)))
                        xsd_port_intf->read_proc = xsd_port_read;
        }
 
diff -r 1c46091df7ce -r aefc75f5db5e tools/xenstore/xenstored_domain.c
--- a/tools/xenstore/xenstored_domain.c Fri Mar  3 18:06:50 2006
+++ b/tools/xenstore/xenstored_domain.c Fri Mar  3 18:07:55 2006
@@ -27,7 +27,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <paths.h>
 
 //#define DEBUG
 #include "utils.h"
@@ -466,21 +465,8 @@
 { 
        int rc, fd;
        evtchn_port_t port; 
-       unsigned long kva; 
        char str[20]; 
        struct domain *dom0; 
-
-       fd = open(XENSTORED_PROC_KVA, O_RDONLY); 
-       if (fd == -1)
-               return -1;
-
-       rc = read(fd, str, sizeof(str)); 
-       if (rc == -1)
-               goto outfd;
-       str[rc] = '\0'; 
-       kva = strtoul(str, NULL, 0); 
-
-       close(fd); 
 
        fd = open(XENSTORED_PROC_PORT, O_RDONLY); 
        if (fd == -1)
@@ -496,12 +482,12 @@
 
        dom0 = new_domain(NULL, 0, port); 
 
-       fd = open(_PATH_KMEM, O_RDWR);
+       fd = open(XENSTORED_PROC_KVA, O_RDWR);
        if (fd == -1)
                return -1;
 
        dom0->interface = mmap(NULL, getpagesize(), PROT_READ|PROT_WRITE,
-                              MAP_SHARED, fd, kva);
+                              MAP_SHARED, fd, 0);
        if (dom0->interface == MAP_FAILED)
                goto outfd;
 

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