Skip to contentSkip to conversation

V3, Move stuff out of xenfs

PATCH In review Bastian Blank 4 participants 13 messages Dec 10, 2011 – Dec 14, 2011 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

cover V3, Move stuff out of xenfs

Changes from v2:
- Rename xenbusd to xenbus_backend
- Register xenbus_backend device only if ring is local
- Use more correct error value: EPERM

Bastian

#1 lore raw

PATCH 1/6 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.

---
 drivers/xen/Kconfig               |    7 ++++++
 drivers/xen/Makefile              |    2 +
 drivers/xen/{xenfs => }/privcmd.c |   39 ++++++++++++++++++++++++++++++++++++-
 drivers/xen/privcmd.h             |    3 ++
 drivers/xen/xenfs/Makefile        |    2 +-
 drivers/xen/xenfs/super.c         |    3 +-
 drivers/xen/xenfs/xenfs.h         |    1 -
 7 files changed, 53 insertions(+), 4 deletions(-)
 rename drivers/xen/{xenfs => }/privcmd.c (92%)
 create mode 100644 drivers/xen/privcmd.h
drivers/xen/Kconfig +7 -0
index 8795480..a1ced52 100644
@@ -86,6 +86,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
@@ -171,4 +172,10 @@ config XEN_PCIDEV_BACKEND
 	  xen-pciback.hide=(03:00.0)(04:00.0)
 
 	  If in doubt, say m.
+
+config XEN_PRIVCMD
+	tristate
+	depends on XEN
+	default m
+
 endmenu
drivers/xen/Makefile +2 -0
index 974fffd..aa31337 100644
@@ -19,7 +19,9 @@ obj-$(CONFIG_XEN_TMEM)			+= tmem.o
 obj-$(CONFIG_SWIOTLB_XEN)		+= swiotlb-xen.o
 obj-$(CONFIG_XEN_DOM0)			+= pci.o
 obj-$(CONFIG_XEN_PCIDEV_BACKEND)	+= xen-pciback/
+obj-$(CONFIG_XEN_PRIVCMD)		+= xen-privcmd.o
 
 xen-evtchn-y				:= evtchn.o
 xen-gntdev-y				:= gntdev.o
 xen-gntalloc-y				:= gntalloc.o
+xen-privcmd-y				:= privcmd.o
drivers/xen/privcmd.c renamed from drivers/xen/xenfs/privcmd.c +38 -1
similarity index 92%
rename from drivers/xen/xenfs/privcmd.c
rename to drivers/xen/privcmd.c
index dbd3b16..4e8d3da 100644
@@ -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>
@@ -32,6 +34,10 @@
 #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);
drivers/xen/privcmd.h new file +3 -0
new file mode 100644
index 0000000..14facae
@@ -0,0 +1,3 @@
+#include <linux/fs.h>
+
+extern const struct file_operations xen_privcmd_fops;
drivers/xen/xenfs/Makefile +1 -1
index 4fde944..5d45ff1 100644
@@ -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
drivers/xen/xenfs/super.c +2 -1
index 1aa3897..a55fbf9 100644
@@ -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;
drivers/xen/xenfs/xenfs.h +0 -1
index b68aa62..5056306 100644
@@ -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;
 
Signature · 1 line
1.7.7.3
#2 lore raw

Re: [PATCH 1/6] xen: Add privcmd device driver

Quoted 3 lines · Bastian Blank

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.

Bastian Blank (5):
xen: Add privcmd device driver
xen: Add xenbus device driver
xen: Add xenbus_backend device
xen/privcmd: Remove unused support for arch specific privcmp mmap xen/xenbus-frontend: Make error message more clear

Will wait for the re-worked sixth patch from you.

#3 lore raw

PATCH 2/6 xen: Add xenbus device driver

In reply to Bastian Blank

Access to xenbus is currently handled via xenfs. This adds a device driver for xenbus and makes xenfs use this code.

---
 drivers/xen/xenbus/Makefile                        |    1 +
 drivers/xen/xenbus/xenbus_comms.h                  |    4 ++
 .../xenbus.c => xenbus/xenbus_dev_frontend.c}      |   37 ++++++++++++++++++--
 drivers/xen/xenfs/Makefile                         |    2 +-
 drivers/xen/xenfs/super.c                          |    3 +-
 drivers/xen/xenfs/xenfs.h                          |    1 -
 6 files changed, 42 insertions(+), 6 deletions(-)
 rename drivers/xen/{xenfs/xenbus.c => xenbus/xenbus_dev_frontend.c} (95%)
drivers/xen/xenbus/Makefile +1 -0
index 8dca685..a2ea363 100644
@@ -1,4 +1,5 @@
 obj-y	+= xenbus.o
+obj-y	+= xenbus_dev_frontend.o
 
 xenbus-objs =
 xenbus-objs += xenbus_client.o
drivers/xen/xenbus/xenbus_comms.h +4 -0
index c21db75..6e42800 100644
@@ -31,6 +31,8 @@
 #ifndef _XENBUS_COMMS_H
 #define _XENBUS_COMMS_H
 
+#include <linux/fs.h>
+
 int xs_init(void);
 int xb_init_comms(void);
 
@@ -43,4 +45,6 @@ int xs_input_avail(void);
 extern struct xenstore_domain_interface *xen_store_interface;
 extern int xen_store_evtchn;
 
+extern const struct file_operations xen_xenbus_fops;
+
 #endif /* _XENBUS_COMMS_H */
drivers/xen/xenbus/xenbus_dev_frontend.c renamed from drivers/xen/xenfs/xenbus.c +34 -3
similarity index 95%
rename from drivers/xen/xenfs/xenbus.c
rename to drivers/xen/xenbus/xenbus_dev_frontend.c
index bbd000f..fb30cff 100644
@@ -52,13 +52,16 @@
 #include <linux/namei.h>
 #include <linux/string.h>
 #include <linux/slab.h>
+#include <linux/miscdevice.h>
+#include <linux/module.h>
 
-#include "xenfs.h"
-#include "../xenbus/xenbus_comms.h"
+#include "xenbus_comms.h"
 
 #include <xen/xenbus.h>
 #include <asm/xen/hypervisor.h>
 
+MODULE_LICENSE("GPL");
+
 /*
  * An element of a list of outstanding transactions, for which we're
  * still waiting a reply.
@@ -583,7 +586,7 @@ static unsigned int xenbus_file_poll(struct file *file, poll_table *wait)
 	return 0;
 }
 
-const struct file_operations xenbus_file_ops = {
+const struct file_operations xen_xenbus_fops = {
 	.read = xenbus_file_read,
 	.write = xenbus_file_write,
 	.open = xenbus_file_open,
@@ -591,3 +594,31 @@ const struct file_operations xenbus_file_ops = {
 	.poll = xenbus_file_poll,
 	.llseek = no_llseek,
 };
+EXPORT_SYMBOL_GPL(xen_xenbus_fops);
+
+static struct miscdevice xenbus_dev = {
+	.minor = MISC_DYNAMIC_MINOR,
+	.name = "xen/xenbus",
+	.fops = &xen_xenbus_fops,
+};
+
+static int __init xenbus_init(void)
+{
+	int err;
+
+	if (!xen_domain())
+		return -ENODEV;
+
+	err = misc_register(&xenbus_dev);
+	if (err)
+		printk(KERN_ERR "Could not register xenbus device\n");
+	return err;
+}
+
+static void __exit xenbus_exit(void)
+{
+	misc_deregister(&xenbus_dev);
+}
+
+module_init(xenbus_init);
+module_exit(xenbus_exit);
drivers/xen/xenfs/Makefile +1 -1
index 5d45ff1..b019865 100644
@@ -1,4 +1,4 @@
 obj-$(CONFIG_XENFS) += xenfs.o
 
-xenfs-y			  = super.o xenbus.o
+xenfs-y			  = super.o
 xenfs-$(CONFIG_XEN_DOM0) += xenstored.o
drivers/xen/xenfs/super.c +2 -1
index a55fbf9..a84b53c 100644
@@ -17,6 +17,7 @@
 
 #include "xenfs.h"
 #include "../privcmd.h"
+#include "../xenbus/xenbus_comms.h"
 
 #include <asm/xen/hypervisor.h>
 
@@ -83,7 +84,7 @@ static int xenfs_fill_super(struct super_block *sb, void *data, int silent)
 {
 	static struct tree_descr xenfs_files[] = {
 		[1] = {},
-		{ "xenbus", &xenbus_file_ops, S_IRUSR|S_IWUSR },
+		{ "xenbus", &xen_xenbus_fops, S_IRUSR|S_IWUSR },
 		{ "capabilities", &capabilities_file_ops, S_IRUGO },
 		{ "privcmd", &xen_privcmd_fops, S_IRUSR|S_IWUSR },
 		{""},
drivers/xen/xenfs/xenfs.h +0 -1
index 5056306..6b80c77 100644
@@ -1,7 +1,6 @@
 #ifndef _XENFS_XENBUS_H
 #define _XENFS_XENBUS_H
 
-extern const struct file_operations xenbus_file_ops;
 extern const struct file_operations xsd_kva_file_ops;
 extern const struct file_operations xsd_port_file_ops;
 
Signature · 1 line
1.7.7.3
#4 lore raw

PATCH 3/6 xen: Add xenbus_backend device

In reply to Bastian Blank

Access for xenstored to the event channel and pre-allocated ring is managed via xenfs. This adds its own character device featuring mmap for the ring and an ioctl for the event channel.

---
 drivers/xen/xenbus/Makefile             |    1 +
 drivers/xen/xenbus/xenbus_dev_backend.c |   89 +++++++++++++++++++++++++++++++
 include/xen/xenbus_dev.h                |   41 ++++++++++++++
 3 files changed, 131 insertions(+), 0 deletions(-)
 create mode 100644 drivers/xen/xenbus/xenbus_dev_backend.c
 create mode 100644 include/xen/xenbus_dev.h
drivers/xen/xenbus/Makefile +1 -0
index a2ea363..31e2e90 100644
@@ -10,4 +10,5 @@ xenbus-objs += xenbus_probe.o
 xenbus-be-objs-$(CONFIG_XEN_BACKEND) += xenbus_probe_backend.o
 xenbus-objs += $(xenbus-be-objs-y)
 
+obj-$(CONFIG_XEN_BACKEND) += xenbus_dev_backend.o
 obj-$(CONFIG_XEN_XENBUS_FRONTEND) += xenbus_probe_frontend.o
drivers/xen/xenbus/xenbus_dev_backend.c new file +89 -0

89 lines not on this page · raw message

include/xen/xenbus_dev.h new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
1.7.7.3
#5 lore raw

PATCH 4/6 xen/privcmd: Remove unused support for arch specific privcmp mmap

In reply to Bastian Blank

This was used for ia64. But there is no working ia64 support in sight, so remove it for now.

---
 drivers/xen/privcmd.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/xen/privcmd.c +0 -2
index 4e8d3da..ccee0f1 100644
@@ -365,7 +365,6 @@ static long privcmd_ioctl(struct file *file,
 	return ret;
 }
 
-#ifndef HAVE_ARCH_PRIVCMD_MMAP
 static int privcmd_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 {
 	printk(KERN_DEBUG "privcmd_fault: vma=%p %lx-%lx, pgoff=%lx, uv=%p\n",
@@ -398,7 +397,6 @@ static int privcmd_enforce_singleshot_mapping(struct vm_area_struct *vma)
 {
 	return (xchg(&vma->vm_private_data, (void *)1) == NULL);
 }
-#endif
 
 const struct file_operations xen_privcmd_fops = {
 	.owner = THIS_MODULE,
Signature · 1 line
1.7.7.3
#6 lore raw

PATCH 5/6 xen/xenbus-frontend: Make error message more clear

In reply to Bastian Blank

Add the work frontend to the error message because we now also have a backend device.

---
 drivers/xen/xenbus/xenbus_dev_frontend.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/xen/xenbus/xenbus_dev_frontend.c +1 -1
index fb30cff..9f6be7d 100644
@@ -611,7 +611,7 @@ static int __init xenbus_init(void)
 
 	err = misc_register(&xenbus_dev);
 	if (err)
-		printk(KERN_ERR "Could not register xenbus device\n");
+		printk(KERN_ERR "Could not register xenbus frontend device\n");
 	return err;
 }
 
Signature · 1 line
1.7.7.3
Acked-by on v1 5/6
#7 lore raw

Re: [Xen-devel] [PATCH 5/6] xen/xenbus-frontend: Make error message more clear

Quoted 4 lines · Bastian Blank

Add the work frontend to the error message because we now also have a backend device.

Quoted 17 lines
---
 drivers/xen/xenbus/xenbus_dev_frontend.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/xen/xenbus/xenbus_dev_frontend.c +1 -1
index fb30cff..9f6be7d 100644
@@ -611,7 +611,7 @@ static int __init xenbus_init(void)
 
 	err = misc_register(&xenbus_dev);
 	if (err)
-		printk(KERN_ERR "Could not register xenbus device\n");
+		printk(KERN_ERR "Could not register xenbus frontend device\n");
 	return err;
 }
 
#8 lore raw

PATCH 6/6 xen/xenbus-backend: Only register device if communication ring is local

In reply to Bastian Blank
---
 drivers/xen/xenbus/Makefile             |    2 +-
 drivers/xen/xenbus/xenbus_dev_backend.c |   13 ++-----------
 drivers/xen/xenbus/xenbus_dev_backend.h |    2 ++
 drivers/xen/xenbus/xenbus_probe.c       |   18 ++++++++++++++++++
 4 files changed, 23 insertions(+), 12 deletions(-)
 create mode 100644 drivers/xen/xenbus/xenbus_dev_backend.h
drivers/xen/xenbus/Makefile +1 -1
index 31e2e90..d751f45 100644
@@ -7,8 +7,8 @@ xenbus-objs += xenbus_comms.o
 xenbus-objs += xenbus_xs.o
 xenbus-objs += xenbus_probe.o
 
+xenbus-be-objs-$(CONFIG_XEN_BACKEND) += xenbus_dev_backend.o
 xenbus-be-objs-$(CONFIG_XEN_BACKEND) += xenbus_probe_backend.o
 xenbus-objs += $(xenbus-be-objs-y)
 
-obj-$(CONFIG_XEN_BACKEND) += xenbus_dev_backend.o
 obj-$(CONFIG_XEN_XENBUS_FRONTEND) += xenbus_probe_frontend.o
drivers/xen/xenbus/xenbus_dev_backend.c +2 -11
index a2092bd..fb87f1b 100644
@@ -3,7 +3,6 @@
 #include <linux/mm.h>
 #include <linux/fs.h>
 #include <linux/miscdevice.h>
-#include <linux/module.h>
 #include <linux/capability.h>
 
 #include <xen/page.h>
@@ -11,8 +10,6 @@
 
 #include "xenbus_comms.h"
 
-MODULE_LICENSE("GPL");
-
 static int xenbus_backend_open(struct inode *inode, struct file *filp)
 {
 	if (!capable(CAP_SYS_ADMIN))
@@ -67,23 +64,17 @@ static struct miscdevice xenbus_backend_dev = {
 	.fops = &xenbus_backend_fops,
 };
 
-static int __init xenbus_backend_init(void)
+int __init xenbus_backend_init(void)
 {
 	int err;
 
-	if (!xen_initial_domain())
-		return -ENODEV;
-
 	err = misc_register(&xenbus_backend_dev);
 	if (err)
 		printk(KERN_ERR "Could not register xenbus backend device\n");
 	return err;
 }
 
-static void __exit xenbus_backend_exit(void)
+void __exit xenbus_backend_exit(void)
 {
 	misc_deregister(&xenbus_backend_dev);
 }
-
-module_init(xenbus_backend_init);
-module_exit(xenbus_backend_exit);
drivers/xen/xenbus/xenbus_dev_backend.h new file +2 -0
new file mode 100644
index 0000000..d986853
@@ -0,0 +1,2 @@
+int xenbus_backend_init(void);
+void xenbus_backend_exit(void);
drivers/xen/xenbus/xenbus_probe.c +18 -0
index 1b178c6..4eff095 100644
@@ -60,6 +60,7 @@
 #include <xen/hvm.h>
 
 #include "xenbus_comms.h"
+#include "xenbus_dev_backend.h"
 #include "xenbus_probe.h"
 
 
@@ -641,6 +642,10 @@ EXPORT_SYMBOL_GPL(xenbus_dev_cancel);
 /* A flag to determine if xenstored is 'ready' (i.e. has started) */
 int xenstored_ready;
 
+/* A flag to determine if xenstored is 'local' */
+#ifdef CONFIG_XEN_BACKEND
+static int xenstored_local;
+#endif
 
 int register_xenstore_notifier(struct notifier_block *nb)
 {
@@ -675,6 +680,14 @@ static int __init xenbus_probe_initcall(void)
 	if (!xen_domain())
 		return -ENODEV;
 
+#ifdef CONFIG_XEN_BACKEND
+	if (xenstored_local) {
+		int ret = xenbus_backend_init();
+		if (ret)
+			return ret;
+	}
+#endif
+
 	if (xen_initial_domain() || xen_hvm_domain())
 		return 0;
 
@@ -747,9 +760,14 @@ static int __init xenbus_init(void)
 		if (xen_store_evtchn)
 			xenstored_ready = 1;
 		else {
+#ifdef CONFIG_XEN_BACKEND
+			xenstored_local = 1;
 			err = xenstored_local_init();
 			if (err)
 				goto out_error;
+#else
+			BUG();
+#endif
 		}
 		xen_store_interface = mfn_to_virt(xen_store_mfn);
 	}
Signature · 1 line
1.7.7.3
#9 lore raw

Re: [Xen-devel] [PATCH 6/6] xen/xenbus-backend: Only register device if communication ring is local

drivers/xen/xenbus/xenbus_probe.c EXPORT_SYMBOL_GPL(xenbus_dev_cancel); · line 648

Quoted 4 lines · Bastian Blank
drivers/xen/xenbus/xenbus_probe.c +4 -0
+/* A flag to determine if xenstored is 'local' */
+#ifdef CONFIG_XEN_BACKEND
+static int xenstored_local;
+#endif

I think this can be __initdata since all the users are __init.

drivers/xen/xenbus/xenbus_probe.c static int __init xenbus_init(void) · line 764

Quoted 2 lines
drivers/xen/xenbus/xenbus_probe.c +2 -0
+#ifdef CONFIG_XEN_BACKEND
+			xenstored_local = 1;

I would push this down into xenstore_local_init() and only set it on success.

Quoted 1 line

err = xenstored_local_init();

This is now only called if CONFIG_XEN_BACKEND. You should add a similar #ifdef around the function definition.

Ian.

Quoted 8 lines
drivers/xen/xenbus/xenbus_probe.c +3 -0
 			if (err)
 				goto out_error;
+#else
+			BUG();
+#endif
 		}
 		xen_store_interface = mfn_to_virt(xen_store_mfn);
 	}
#10 lore raw

Re: [PATCH 6/6] xen/xenbus-backend: Only register device if communication ring is local

In reply to Bastian Blank
Quoted 60 lines · Bastian Blank
---
 drivers/xen/xenbus/Makefile             |    2 +-
 drivers/xen/xenbus/xenbus_dev_backend.c |   13 ++-----------
 drivers/xen/xenbus/xenbus_dev_backend.h |    2 ++
 drivers/xen/xenbus/xenbus_probe.c       |   18 ++++++++++++++++++
 4 files changed, 23 insertions(+), 12 deletions(-)
 create mode 100644 drivers/xen/xenbus/xenbus_dev_backend.h
drivers/xen/xenbus/Makefile +1 -1
index 31e2e90..d751f45 100644
@@ -7,8 +7,8 @@ xenbus-objs += xenbus_comms.o
 xenbus-objs += xenbus_xs.o
 xenbus-objs += xenbus_probe.o
 
+xenbus-be-objs-$(CONFIG_XEN_BACKEND) += xenbus_dev_backend.o
 xenbus-be-objs-$(CONFIG_XEN_BACKEND) += xenbus_probe_backend.o
 xenbus-objs += $(xenbus-be-objs-y)
 
-obj-$(CONFIG_XEN_BACKEND) += xenbus_dev_backend.o
 obj-$(CONFIG_XEN_XENBUS_FRONTEND) += xenbus_probe_frontend.o
drivers/xen/xenbus/xenbus_dev_backend.c +1 -7
index a2092bd..fb87f1b 100644
@@ -3,7 +3,6 @@
 #include <linux/mm.h>
 #include <linux/fs.h>
 #include <linux/miscdevice.h>
-#include <linux/module.h>
 #include <linux/capability.h>
 
 #include <xen/page.h>
@@ -11,8 +10,6 @@
 
 #include "xenbus_comms.h"
 
-MODULE_LICENSE("GPL");
-
 static int xenbus_backend_open(struct inode *inode, struct file *filp)
 {
 	if (!capable(CAP_SYS_ADMIN))
@@ -67,23 +64,17 @@ static struct miscdevice xenbus_backend_dev = {
 	.fops = &xenbus_backend_fops,
 };
 
-static int __init xenbus_backend_init(void)
+int __init xenbus_backend_init(void)
 {
 	int err;
 
-	if (!xen_initial_domain())
-		return -ENODEV;
-
 	err = misc_register(&xenbus_backend_dev);
 	if (err)
 		printk(KERN_ERR "Could not register xenbus backend device\n");
 	return err;

drivers/xen/xenbus/xenbus_dev_backend.c static struct miscdevice xenbus_backend_dev = { · line 89

Quoted 10 lines
drivers/xen/xenbus/xenbus_dev_backend.c +1 -4
 }
 
-static void __exit xenbus_backend_exit(void)
+void __exit xenbus_backend_exit(void)
 {
 	misc_deregister(&xenbus_backend_dev);
 }
-
-module_init(xenbus_backend_init);
-module_exit(xenbus_backend_exit);

Why are we removing the module functionality?
Can't this [the purpose of this patch] be done while still maintaining the module functionality?

Quoted 21 lines
drivers/xen/xenbus/xenbus_dev_backend.h new file +2 -0
new file mode 100644
index 0000000..d986853
@@ -0,0 +1,2 @@
+int xenbus_backend_init(void);
+void xenbus_backend_exit(void);
drivers/xen/xenbus/xenbus_probe.c +1 -0
index 1b178c6..4eff095 100644
@@ -60,6 +60,7 @@
 #include <xen/hvm.h>
 
 #include "xenbus_comms.h"
+#include "xenbus_dev_backend.h"
 #include "xenbus_probe.h"
 
 

drivers/xen/xenbus/xenbus_probe.c EXPORT_SYMBOL_GPL(xenbus_dev_cancel); · line 647

Quoted 6 lines
drivers/xen/xenbus/xenbus_probe.c +3 -0
@@ -641,6 +642,10 @@ EXPORT_SYMBOL_GPL(xenbus_dev_cancel);
 /* A flag to determine if xenstored is 'ready' (i.e. has started) */
 int xenstored_ready;
 
+/* A flag to determine if xenstored is 'local' */
+#ifdef CONFIG_XEN_BACKEND
+static int xenstored_local;

bool?

Quoted 20 lines
drivers/xen/xenbus/xenbus_probe.c +9 -0
+#endif
 
 int register_xenstore_notifier(struct notifier_block *nb)
 {
@@ -675,6 +680,14 @@ static int __init xenbus_probe_initcall(void)
 	if (!xen_domain())
 		return -ENODEV;
 
+#ifdef CONFIG_XEN_BACKEND
+	if (xenstored_local) {
+		int ret = xenbus_backend_init();
+		if (ret)
+			return ret;
+	}
+#endif
+
 	if (xen_initial_domain() || xen_hvm_domain())
 		return 0;
 

drivers/xen/xenbus/xenbus_probe.c static int __init xenbus_init(void) · line 769

Quoted 10 lines
drivers/xen/xenbus/xenbus_probe.c +4 -0
@@ -747,9 +760,14 @@ static int __init xenbus_init(void)
 		if (xen_store_evtchn)
 			xenstored_ready = 1;
 		else {
+#ifdef CONFIG_XEN_BACKEND
+			xenstored_local = 1;
 			err = xenstored_local_init();
 			if (err)
 				goto out_error;
+#else
+			BUG();

No way. A WARN, sure - but BUG() is way too intense for this.

Quoted 12 lines
drivers/xen/xenbus/xenbus_probe.c +1 -0
+#endif
 		}
 		xen_store_interface = mfn_to_virt(xen_store_mfn);
 	}
Signature · 7 lines
1.7.7.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
#11 lore raw

Re: [Xen-devel] [PATCH 6/6] xen/xenbus-backend: Only register device if communication ring is local

Quoted 6 lines · Konrad Rzeszutek Wilk

drivers/xen/xenbus/xenbus_dev_backend.c static struct miscdevice xenbus_backend_dev = { · line 89

Quoted 2 lines · Bastian Blank
drivers/xen/xenbus/xenbus_dev_backend.c +0 -2
-module_init(xenbus_backend_init);
-module_exit(xenbus_backend_exit);

Why are we removing the module functionality?
Can't this [the purpose of this patch] be done while still maintaining the module functionality?

Not really. The purpose is to register the device only if the ring is local. This information is not available to modules.

However we could just move the whole xenbus ring setup into a "module". Or is there any reason for this to be in a postcore_initcall, even if it is only operational after a userspace process works?

Quoted 7 lines

drivers/xen/xenbus/xenbus_probe.c EXPORT_SYMBOL_GPL(xenbus_dev_cancel); · line 647

Quoted 5 lines

int xenstored_ready;

drivers/xen/xenbus/xenbus_probe.c +3 -0
+/* A flag to determine if xenstored is 'local' */
+#ifdef CONFIG_XEN_BACKEND
+static int xenstored_local;

bool?

Well. The other flags are int also.

Quoted 2 lines

drivers/xen/xenbus/xenbus_probe.c static int __init xenbus_init(void) · line 769

Quoted 1 line
drivers/xen/xenbus/xenbus_probe.c +1 -0
+			BUG();

No way. A WARN, sure - but BUG() is way too intense for this.

Okay.

Bastian

Signature · 2 lines
The sight of death frightens them [Earthers].
		-- Kras the Klingon, "Friday's Child", stardate 3497.2
#12 lore raw

Re: [Xen-devel] [PATCH 6/6] xen/xenbus-backend: Only register device if communication ring is local

Quoted 8 lines · Bastian Blank
Quoted 6 lines · Konrad Rzeszutek Wilk

drivers/xen/xenbus/xenbus_dev_backend.c static struct miscdevice xenbus_backend_dev = { · line 89

Quoted 2 lines · Bastian Blank
drivers/xen/xenbus/xenbus_dev_backend.c +0 -2
-module_init(xenbus_backend_init);
-module_exit(xenbus_backend_exit);

Why are we removing the module functionality?
Can't this [the purpose of this patch] be done while still maintaining the module functionality?

Quoted 6 lines

Not really. The purpose is to register the device only if the ring is local. This information is not available to modules.

However we could just move the whole xenbus ring setup into a "module". Or is there any reason for this to be in a postcore_initcall, even if it is only operational after a userspace process works?

My thinking is that we do not want to use memory space if the kernel is booted as baremetal (as there is no point of having Xen pieces around). Modules work great for that.

But then part of this code is __init so some does get evicted, but not sure how much. Could you measure this on baremetal please?

Quoted 10 lines
Quoted 8 lines

drivers/xen/xenbus/xenbus_probe.c EXPORT_SYMBOL_GPL(xenbus_dev_cancel); · line 647

Quoted 6 lines

int xenstored_ready;

drivers/xen/xenbus/xenbus_probe.c +3 -0
+/* A flag to determine if xenstored is 'local' */
+#ifdef CONFIG_XEN_BACKEND
+static int xenstored_local;

bool?

Well. The other flags are int also.

Sure.. and they ought to be modified to bool too now that I think of it.

Quoted 11 lines
Quoted 3 lines

drivers/xen/xenbus/xenbus_probe.c static int __init xenbus_init(void) · line 769

Quoted 2 lines
drivers/xen/xenbus/xenbus_probe.c +1 -0
+			BUG();

No way. A WARN, sure - but BUG() is way too intense for this.

Okay.

Bastian

Signature · 2 lines
The sight of death frightens them [Earthers].
		-- Kras the Klingon, "Friday's Child", stardate 3497.2