]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
xen: Add privcmd device driver
authorBastian Blank <waldi@debian.org>
Fri, 16 Dec 2011 16:34:33 +0000 (11:34 -0500)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Thu, 2 Feb 2012 19:08:24 +0000 (14:08 -0500)
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>
Conflicts:

drivers/xen/Kconfig
drivers/xen/Makefile

drivers/xen/Kconfig
drivers/xen/Makefile
drivers/xen/privcmd.c [moved from drivers/xen/xenfs/privcmd.c with 92% similarity]
drivers/xen/privcmd.h [new file with mode: 0644]
drivers/xen/xenfs/Makefile
drivers/xen/xenfs/super.c
drivers/xen/xenfs/xenfs.h

index a59638b37c1add565887e30feba7aebc7c3b54be..e5d14a3409ac8be1690e5b4a2f1107fffdd9e1e9 100644 (file)
@@ -39,6 +39,7 @@ config XEN_BACKEND
 
 config XENFS
        tristate "Xen filesystem"
+       select XEN_PRIVCMD
        default y
        help
          The xen filesystem provides a way for domains to share
@@ -105,4 +106,10 @@ config SWIOTLB_XEN
        depends on PCI
        select SWIOTLB
 
+
+config XEN_PRIVCMD
+       tristate
+       depends on XEN
+       default m
+
 endmenu
index bbc18258ecc5419ec2210b83684afc528fecd0da..69f54ff18f404948b7049bca24081289adf2b8b6 100644 (file)
@@ -17,9 +17,10 @@ obj-$(CONFIG_XEN_SYS_HYPERVISOR)     += sys-hypervisor.o
 obj-$(CONFIG_XEN_PLATFORM_PCI)         += xen-platform-pci.o
 obj-$(CONFIG_SWIOTLB_XEN)              += swiotlb-xen.o
 obj-$(CONFIG_XEN_DOM0)                 += pci.o
+obj-$(CONFIG_XEN_PRIVCMD)              += xen-privcmd.o
 
 xen-evtchn-y                           := evtchn.o
 xen-gntdev-y                           := gntdev.o
 xen-gntalloc-y                         := gntalloc.o
-
+sxen-privcmd-y                         := privcmd.o
 xen-platform-pci-y                     := platform-pci.o
similarity index 92%
rename from drivers/xen/xenfs/privcmd.c
rename to drivers/xen/privcmd.c
index dbd3b16fd1317adc9f1fa8afedfd0e6d3fc53400..4e8d3da89ad558c9277e9e4e500bac799278c37d 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/string.h>
@@ -18,6 +19,7 @@
 #include <linux/highmem.h>
 #include <linux/pagemap.h>
 #include <linux/seq_file.h>
+#include <linux/miscdevice.h>
 
 #include <asm/pgalloc.h>
 #include <asm/pgtable.h>
 #include <xen/page.h>
 #include <xen/xen-ops.h>
 
+#include "privcmd.h"
+
+MODULE_LICENSE("GPL");
+
 #ifndef HAVE_ARCH_PRIVCMD_MMAP
 static int privcmd_enforce_singleshot_mapping(struct vm_area_struct *vma);
 #endif
@@ -394,7 +400,38 @@ static int privcmd_enforce_singleshot_mapping(struct vm_area_struct *vma)
 }
 #endif
 
-const struct file_operations privcmd_file_ops = {
+const struct file_operations xen_privcmd_fops = {
+       .owner = THIS_MODULE,
        .unlocked_ioctl = privcmd_ioctl,
        .mmap = privcmd_mmap,
 };
+EXPORT_SYMBOL_GPL(xen_privcmd_fops);
+
+static struct miscdevice privcmd_dev = {
+       .minor = MISC_DYNAMIC_MINOR,
+       .name = "xen/privcmd",
+       .fops = &xen_privcmd_fops,
+};
+
+static int __init privcmd_init(void)
+{
+       int err;
+
+       if (!xen_domain())
+               return -ENODEV;
+
+       err = misc_register(&privcmd_dev);
+       if (err != 0) {
+               printk(KERN_ERR "Could not register Xen privcmd device\n");
+               return err;
+       }
+       return 0;
+}
+
+static void __exit privcmd_exit(void)
+{
+       misc_deregister(&privcmd_dev);
+}
+
+module_init(privcmd_init);
+module_exit(privcmd_exit);
diff --git a/drivers/xen/privcmd.h b/drivers/xen/privcmd.h
new file mode 100644 (file)
index 0000000..14facae
--- /dev/null
@@ -0,0 +1,3 @@
+#include <linux/fs.h>
+
+extern const struct file_operations xen_privcmd_fops;
index 4fde9440fe1f453aad9a4d6e4a98dceecbf6dbe4..5d45ff13cc01515f6c4362b0ad54c8b48dae3078 100644 (file)
@@ -1,4 +1,4 @@
 obj-$(CONFIG_XENFS) += xenfs.o
 
-xenfs-y                          = super.o xenbus.o privcmd.o
+xenfs-y                          = super.o xenbus.o
 xenfs-$(CONFIG_XEN_DOM0) += xenstored.o
index 1aa3897198462112a3bc1db479986653cf0a716f..a55fbf9a1519e5507cc3f368e70aa2a1b337a58d 100644 (file)
@@ -16,6 +16,7 @@
 #include <xen/xen.h>
 
 #include "xenfs.h"
+#include "../privcmd.h"
 
 #include <asm/xen/hypervisor.h>
 
@@ -84,7 +85,7 @@ static int xenfs_fill_super(struct super_block *sb, void *data, int silent)
                [1] = {},
                { "xenbus", &xenbus_file_ops, S_IRUSR|S_IWUSR },
                { "capabilities", &capabilities_file_ops, S_IRUGO },
-               { "privcmd", &privcmd_file_ops, S_IRUSR|S_IWUSR },
+               { "privcmd", &xen_privcmd_fops, S_IRUSR|S_IWUSR },
                {""},
        };
        int rc;
index b68aa6200003575549e7a5844ae7b43b6bec135f..5056306e7aa8efc547377049b28ba416c0fe8365 100644 (file)
@@ -2,7 +2,6 @@
 #define _XENFS_XENBUS_H
 
 extern const struct file_operations xenbus_file_ops;
-extern const struct file_operations privcmd_file_ops;
 extern const struct file_operations xsd_kva_file_ops;
 extern const struct file_operations xsd_port_file_ops;