mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
/proc/xen/xsd_kva exports mmap interface that xenstored now uses to map the
domain0 xenbus page. Signed-off-by: Keir Fraser <keir@xensource.com>
This commit is contained in:
1 parent
74bb865dac
commit
262bd587ce
2 files changed
+25
-18
No files matched your search
@@ -951,9 +951,25 @@ void xenbus_probe(void *unused)
|
||||
}
|
||||
|
||||
|
||||
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 @@ static int __init xenbus_probe_init(void)
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <paths.h>
|
||||
|
||||
//#define DEBUG
|
||||
#include "utils.h"
|
||||
@@ -466,22 +465,9 @@ static int dom0_init(void)
|
||||
{
|
||||
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)
|
||||
return -1;
|
||||
@@ -496,12 +482,12 @@ static int dom0_init(void)
|
||||
|
||||
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;
|
||||
|
||||
|
||||