Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Bastian Blank and committed by
Konrad Rzeszutek Wilk
d8414d3c 243082e0

+53 -4
+7
drivers/xen/Kconfig
··· 86 86 87 87 config XENFS 88 88 tristate "Xen filesystem" 89 + select XEN_PRIVCMD 89 90 default y 90 91 help 91 92 The xen filesystem provides a way for domains to share ··· 172 171 xen-pciback.hide=(03:00.0)(04:00.0) 173 172 174 173 If in doubt, say m. 174 + 175 + config XEN_PRIVCMD 176 + tristate 177 + depends on XEN 178 + default m 179 + 175 180 endmenu
+2
drivers/xen/Makefile
··· 19 19 obj-$(CONFIG_SWIOTLB_XEN) += swiotlb-xen.o 20 20 obj-$(CONFIG_XEN_DOM0) += pci.o 21 21 obj-$(CONFIG_XEN_PCIDEV_BACKEND) += xen-pciback/ 22 + obj-$(CONFIG_XEN_PRIVCMD) += xen-privcmd.o 22 23 23 24 xen-evtchn-y := evtchn.o 24 25 xen-gntdev-y := gntdev.o 25 26 xen-gntalloc-y := gntalloc.o 27 + xen-privcmd-y := privcmd.o
+3
drivers/xen/privcmd.h
··· 1 + #include <linux/fs.h> 2 + 3 + extern const struct file_operations xen_privcmd_fops;
+1 -1
drivers/xen/xenfs/Makefile
··· 1 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 4 xenfs-$(CONFIG_XEN_DOM0) += xenstored.o
+38 -1
drivers/xen/xenfs/privcmd.c drivers/xen/privcmd.c
··· 7 7 */ 8 8 9 9 #include <linux/kernel.h> 10 + #include <linux/module.h> 10 11 #include <linux/sched.h> 11 12 #include <linux/slab.h> 12 13 #include <linux/string.h> ··· 19 18 #include <linux/highmem.h> 20 19 #include <linux/pagemap.h> 21 20 #include <linux/seq_file.h> 21 + #include <linux/miscdevice.h> 22 22 23 23 #include <asm/pgalloc.h> 24 24 #include <asm/pgtable.h> ··· 33 31 #include <xen/features.h> 34 32 #include <xen/page.h> 35 33 #include <xen/xen-ops.h> 34 + 35 + #include "privcmd.h" 36 + 37 + MODULE_LICENSE("GPL"); 36 38 37 39 #ifndef HAVE_ARCH_PRIVCMD_MMAP 38 40 static int privcmd_enforce_singleshot_mapping(struct vm_area_struct *vma); ··· 400 394 } 401 395 #endif 402 396 403 - const struct file_operations privcmd_file_ops = { 397 + const struct file_operations xen_privcmd_fops = { 398 + .owner = THIS_MODULE, 404 399 .unlocked_ioctl = privcmd_ioctl, 405 400 .mmap = privcmd_mmap, 406 401 }; 402 + EXPORT_SYMBOL_GPL(xen_privcmd_fops); 403 + 404 + static struct miscdevice privcmd_dev = { 405 + .minor = MISC_DYNAMIC_MINOR, 406 + .name = "xen/privcmd", 407 + .fops = &xen_privcmd_fops, 408 + }; 409 + 410 + static int __init privcmd_init(void) 411 + { 412 + int err; 413 + 414 + if (!xen_domain()) 415 + return -ENODEV; 416 + 417 + err = misc_register(&privcmd_dev); 418 + if (err != 0) { 419 + printk(KERN_ERR "Could not register Xen privcmd device\n"); 420 + return err; 421 + } 422 + return 0; 423 + } 424 + 425 + static void __exit privcmd_exit(void) 426 + { 427 + misc_deregister(&privcmd_dev); 428 + } 429 + 430 + module_init(privcmd_init); 431 + module_exit(privcmd_exit);
+2 -1
drivers/xen/xenfs/super.c
··· 16 16 #include <xen/xen.h> 17 17 18 18 #include "xenfs.h" 19 + #include "../privcmd.h" 19 20 20 21 #include <asm/xen/hypervisor.h> 21 22 ··· 85 84 [1] = {}, 86 85 { "xenbus", &xenbus_file_ops, S_IRUSR|S_IWUSR }, 87 86 { "capabilities", &capabilities_file_ops, S_IRUGO }, 88 - { "privcmd", &privcmd_file_ops, S_IRUSR|S_IWUSR }, 87 + { "privcmd", &xen_privcmd_fops, S_IRUSR|S_IWUSR }, 89 88 {""}, 90 89 }; 91 90 int rc;
-1
drivers/xen/xenfs/xenfs.h
··· 2 2 #define _XENFS_XENBUS_H 3 3 4 4 extern const struct file_operations xenbus_file_ops; 5 - extern const struct file_operations privcmd_file_ops; 6 5 extern const struct file_operations xsd_kva_file_ops; 7 6 extern const struct file_operations xsd_port_file_ops; 8 7