diff options
author | Bastian Blank <waldi@debian.org> | 2011-12-16 11:34:33 -0500 |
---|---|---|
committer | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2011-12-16 13:29:31 -0500 |
commit | d8414d3c157dc1f83e73c17447ba41fe5afa9d3d (patch) | |
tree | 02195ebb0b1dd0b026b257825f02cddc3617df55 | |
parent | 243082e0d59f169a1fa502f51ee5a820889fae93 (diff) |
xen: Add privcmd device driver
Access to arbitrary hypercalls is currently provided via xenfs. This
adds a standard character device to handle this. The support in xenfs
remains for backward compatibility and uses the device driver code.
Signed-off-by: Bastian Blank <waldi@debian.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
-rw-r--r-- | drivers/xen/Kconfig | 7 | ||||
-rw-r--r-- | drivers/xen/Makefile | 2 | ||||
-rw-r--r-- | drivers/xen/privcmd.c (renamed from drivers/xen/xenfs/privcmd.c) | 39 | ||||
-rw-r--r-- | drivers/xen/privcmd.h | 3 | ||||
-rw-r--r-- | drivers/xen/xenfs/Makefile | 2 | ||||
-rw-r--r-- | drivers/xen/xenfs/super.c | 3 | ||||
-rw-r--r-- | drivers/xen/xenfs/xenfs.h | 1 |
7 files changed, 53 insertions, 4 deletions
diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig index 8795480c2350..a1ced521cf74 100644 --- a/drivers/xen/Kconfig +++ b/drivers/xen/Kconfig | |||
@@ -86,6 +86,7 @@ config XEN_BACKEND | |||
86 | 86 | ||
87 | config XENFS | 87 | config XENFS |
88 | tristate "Xen filesystem" | 88 | tristate "Xen filesystem" |
89 | select XEN_PRIVCMD | ||
89 | default y | 90 | default y |
90 | help | 91 | help |
91 | The xen filesystem provides a way for domains to share | 92 | The xen filesystem provides a way for domains to share |
@@ -171,4 +172,10 @@ config XEN_PCIDEV_BACKEND | |||
171 | xen-pciback.hide=(03:00.0)(04:00.0) | 172 | xen-pciback.hide=(03:00.0)(04:00.0) |
172 | 173 | ||
173 | If in doubt, say m. | 174 | If in doubt, say m. |
175 | |||
176 | config XEN_PRIVCMD | ||
177 | tristate | ||
178 | depends on XEN | ||
179 | default m | ||
180 | |||
174 | endmenu | 181 | endmenu |
diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile index 974fffdf22b2..aa31337192cc 100644 --- a/drivers/xen/Makefile +++ b/drivers/xen/Makefile | |||
@@ -19,7 +19,9 @@ obj-$(CONFIG_XEN_TMEM) += tmem.o | |||
19 | obj-$(CONFIG_SWIOTLB_XEN) += swiotlb-xen.o | 19 | obj-$(CONFIG_SWIOTLB_XEN) += swiotlb-xen.o |
20 | obj-$(CONFIG_XEN_DOM0) += pci.o | 20 | obj-$(CONFIG_XEN_DOM0) += pci.o |
21 | obj-$(CONFIG_XEN_PCIDEV_BACKEND) += xen-pciback/ | 21 | obj-$(CONFIG_XEN_PCIDEV_BACKEND) += xen-pciback/ |
22 | obj-$(CONFIG_XEN_PRIVCMD) += xen-privcmd.o | ||
22 | 23 | ||
23 | xen-evtchn-y := evtchn.o | 24 | xen-evtchn-y := evtchn.o |
24 | xen-gntdev-y := gntdev.o | 25 | xen-gntdev-y := gntdev.o |
25 | xen-gntalloc-y := gntalloc.o | 26 | xen-gntalloc-y := gntalloc.o |
27 | xen-privcmd-y := privcmd.o | ||
diff --git a/drivers/xen/xenfs/privcmd.c b/drivers/xen/privcmd.c index dbd3b16fd131..4e8d3da89ad5 100644 --- a/drivers/xen/xenfs/privcmd.c +++ b/drivers/xen/privcmd.c | |||
@@ -7,6 +7,7 @@ | |||
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
10 | #include <linux/module.h> | ||
10 | #include <linux/sched.h> | 11 | #include <linux/sched.h> |
11 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
12 | #include <linux/string.h> | 13 | #include <linux/string.h> |
@@ -18,6 +19,7 @@ | |||
18 | #include <linux/highmem.h> | 19 | #include <linux/highmem.h> |
19 | #include <linux/pagemap.h> | 20 | #include <linux/pagemap.h> |
20 | #include <linux/seq_file.h> | 21 | #include <linux/seq_file.h> |
22 | #include <linux/miscdevice.h> | ||
21 | 23 | ||
22 | #include <asm/pgalloc.h> | 24 | #include <asm/pgalloc.h> |
23 | #include <asm/pgtable.h> | 25 | #include <asm/pgtable.h> |
@@ -32,6 +34,10 @@ | |||
32 | #include <xen/page.h> | 34 | #include <xen/page.h> |
33 | #include <xen/xen-ops.h> | 35 | #include <xen/xen-ops.h> |
34 | 36 | ||
37 | #include "privcmd.h" | ||
38 | |||
39 | MODULE_LICENSE("GPL"); | ||
40 | |||
35 | #ifndef HAVE_ARCH_PRIVCMD_MMAP | 41 | #ifndef HAVE_ARCH_PRIVCMD_MMAP |
36 | static int privcmd_enforce_singleshot_mapping(struct vm_area_struct *vma); | 42 | static int privcmd_enforce_singleshot_mapping(struct vm_area_struct *vma); |
37 | #endif | 43 | #endif |
@@ -394,7 +400,38 @@ static int privcmd_enforce_singleshot_mapping(struct vm_area_struct *vma) | |||
394 | } | 400 | } |
395 | #endif | 401 | #endif |
396 | 402 | ||
397 | const struct file_operations privcmd_file_ops = { | 403 | const struct file_operations xen_privcmd_fops = { |
404 | .owner = THIS_MODULE, | ||
398 | .unlocked_ioctl = privcmd_ioctl, | 405 | .unlocked_ioctl = privcmd_ioctl, |
399 | .mmap = privcmd_mmap, | 406 | .mmap = privcmd_mmap, |
400 | }; | 407 | }; |
408 | EXPORT_SYMBOL_GPL(xen_privcmd_fops); | ||
409 | |||
410 | static struct miscdevice privcmd_dev = { | ||
411 | .minor = MISC_DYNAMIC_MINOR, | ||
412 | .name = "xen/privcmd", | ||
413 | .fops = &xen_privcmd_fops, | ||
414 | }; | ||
415 | |||
416 | static int __init privcmd_init(void) | ||
417 | { | ||
418 | int err; | ||
419 | |||
420 | if (!xen_domain()) | ||
421 | return -ENODEV; | ||
422 | |||
423 | err = misc_register(&privcmd_dev); | ||
424 | if (err != 0) { | ||
425 | printk(KERN_ERR "Could not register Xen privcmd device\n"); | ||
426 | return err; | ||
427 | } | ||
428 | return 0; | ||
429 | } | ||
430 | |||
431 | static void __exit privcmd_exit(void) | ||
432 | { | ||
433 | misc_deregister(&privcmd_dev); | ||
434 | } | ||
435 | |||
436 | module_init(privcmd_init); | ||
437 | module_exit(privcmd_exit); | ||
diff --git a/drivers/xen/privcmd.h b/drivers/xen/privcmd.h new file mode 100644 index 000000000000..14facaeed36f --- /dev/null +++ b/drivers/xen/privcmd.h | |||
@@ -0,0 +1,3 @@ | |||
1 | #include <linux/fs.h> | ||
2 | |||
3 | extern const struct file_operations xen_privcmd_fops; | ||
diff --git a/drivers/xen/xenfs/Makefile b/drivers/xen/xenfs/Makefile index 4fde9440fe1f..5d45ff13cc01 100644 --- a/drivers/xen/xenfs/Makefile +++ b/drivers/xen/xenfs/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | obj-$(CONFIG_XENFS) += xenfs.o | 1 | obj-$(CONFIG_XENFS) += xenfs.o |
2 | 2 | ||
3 | xenfs-y = super.o xenbus.o privcmd.o | 3 | xenfs-y = super.o xenbus.o |
4 | xenfs-$(CONFIG_XEN_DOM0) += xenstored.o | 4 | xenfs-$(CONFIG_XEN_DOM0) += xenstored.o |
diff --git a/drivers/xen/xenfs/super.c b/drivers/xen/xenfs/super.c index 1aa389719846..a55fbf9a1519 100644 --- a/drivers/xen/xenfs/super.c +++ b/drivers/xen/xenfs/super.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <xen/xen.h> | 16 | #include <xen/xen.h> |
17 | 17 | ||
18 | #include "xenfs.h" | 18 | #include "xenfs.h" |
19 | #include "../privcmd.h" | ||
19 | 20 | ||
20 | #include <asm/xen/hypervisor.h> | 21 | #include <asm/xen/hypervisor.h> |
21 | 22 | ||
@@ -84,7 +85,7 @@ static int xenfs_fill_super(struct super_block *sb, void *data, int silent) | |||
84 | [1] = {}, | 85 | [1] = {}, |
85 | { "xenbus", &xenbus_file_ops, S_IRUSR|S_IWUSR }, | 86 | { "xenbus", &xenbus_file_ops, S_IRUSR|S_IWUSR }, |
86 | { "capabilities", &capabilities_file_ops, S_IRUGO }, | 87 | { "capabilities", &capabilities_file_ops, S_IRUGO }, |
87 | { "privcmd", &privcmd_file_ops, S_IRUSR|S_IWUSR }, | 88 | { "privcmd", &xen_privcmd_fops, S_IRUSR|S_IWUSR }, |
88 | {""}, | 89 | {""}, |
89 | }; | 90 | }; |
90 | int rc; | 91 | int rc; |
diff --git a/drivers/xen/xenfs/xenfs.h b/drivers/xen/xenfs/xenfs.h index b68aa6200003..5056306e7aa8 100644 --- a/drivers/xen/xenfs/xenfs.h +++ b/drivers/xen/xenfs/xenfs.h | |||
@@ -2,7 +2,6 @@ | |||
2 | #define _XENFS_XENBUS_H | 2 | #define _XENFS_XENBUS_H |
3 | 3 | ||
4 | extern const struct file_operations xenbus_file_ops; | 4 | extern const struct file_operations xenbus_file_ops; |
5 | extern const struct file_operations privcmd_file_ops; | ||
6 | extern const struct file_operations xsd_kva_file_ops; | 5 | extern const struct file_operations xsd_kva_file_ops; |
7 | extern const struct file_operations xsd_port_file_ops; | 6 | extern const struct file_operations xsd_port_file_ops; |
8 | 7 | ||