From 655d406a7c80bffc03263d071b6ba1e0fcf548f9 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Fri, 6 Feb 2009 18:46:48 -0800 Subject: xen: add /proc/xen/xsd_{kva,port} to xenfs These are used by the userspace xenstore daemon, which runs in dom0. Xenstored is what's behind the xenfs "xenbus" filesystem. [ Impact: provide mapping and port to usermode for xenstore ] Signed-off-by: Ian Campbell Signed-off-by: Jeremy Fitzhardinge --- drivers/xen/xenfs/super.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'drivers/xen/xenfs/super.c') diff --git a/drivers/xen/xenfs/super.c b/drivers/xen/xenfs/super.c index 78bfab0700ba..3cf7707217f2 100644 --- a/drivers/xen/xenfs/super.c +++ b/drivers/xen/xenfs/super.c @@ -22,6 +22,46 @@ MODULE_DESCRIPTION("Xen filesystem"); MODULE_LICENSE("GPL"); +static struct inode *xenfs_make_inode(struct super_block *sb, int mode) +{ + struct inode *ret = new_inode(sb); + + if (ret) { + ret->i_mode = mode; + ret->i_uid = ret->i_gid = 0; + ret->i_blocks = 0; + ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME; + } + return ret; +} + +static struct dentry *xenfs_create_file(struct super_block *sb, + struct dentry *parent, + const char *name, + const struct file_operations *fops, + void *data, + int mode) +{ + struct dentry *dentry; + struct inode *inode; + + dentry = d_alloc_name(parent, name); + if (!dentry) + return NULL; + + inode = xenfs_make_inode(sb, S_IFREG | mode); + if (!inode) { + dput(dentry); + return NULL; + } + + inode->i_fop = fops; + inode->i_private = data; + + d_add(dentry, inode); + return dentry; +} + static ssize_t capabilities_read(struct file *file, char __user *buf, size_t size, loff_t *off) { @@ -45,8 +85,20 @@ static int xenfs_fill_super(struct super_block *sb, void *data, int silent) { "capabilities", &capabilities_file_ops, S_IRUGO }, {""}, }; + int rc; + + rc = simple_fill_super(sb, XENFS_SUPER_MAGIC, xenfs_files); + if (rc < 0) + return rc; + + if (xen_initial_domain()) { + xenfs_create_file(sb, sb->s_root, "xsd_kva", + &xsd_kva_file_ops, NULL, S_IRUSR|S_IWUSR); + xenfs_create_file(sb, sb->s_root, "xsd_port", + &xsd_port_file_ops, NULL, S_IRUSR|S_IWUSR); + } - return simple_fill_super(sb, XENFS_SUPER_MAGIC, xenfs_files); + return rc; } static int xenfs_get_sb(struct file_system_type *fs_type, -- cgit v1.2.1 From 1c5de1939c204bde9cce87f4eb3d26e9f9eb732b Mon Sep 17 00:00:00 2001 From: Jeremy Fitzhardinge Date: Mon, 9 Feb 2009 12:05:49 -0800 Subject: xen: add privcmd driver The privcmd interface in xenfs allows the tool stack in the privileged domain to get fairly direct access to the hypervisor in order to do various management things such as domain construction. [ Impact: new xenfs interface for privileged operations ] Signed-off-by: Jeremy Fitzhardinge --- drivers/xen/xenfs/super.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/xen/xenfs/super.c') diff --git a/drivers/xen/xenfs/super.c b/drivers/xen/xenfs/super.c index 3cf7707217f2..8c7462866e90 100644 --- a/drivers/xen/xenfs/super.c +++ b/drivers/xen/xenfs/super.c @@ -96,6 +96,8 @@ static int xenfs_fill_super(struct super_block *sb, void *data, int silent) &xsd_kva_file_ops, NULL, S_IRUSR|S_IWUSR); xenfs_create_file(sb, sb->s_root, "xsd_port", &xsd_port_file_ops, NULL, S_IRUSR|S_IWUSR); + xenfs_create_file(sb, sb->s_root, "privcmd", + &privcmd_file_ops, NULL, S_IRUSR|S_IWUSR); } return rc; -- cgit v1.2.1 From 24a89b5be4cf2b7f1b49b56b6cb4a7b71fccf241 Mon Sep 17 00:00:00 2001 From: Jeremy Fitzhardinge Date: Mon, 9 Feb 2009 12:05:49 -0800 Subject: xen/privcmd: create address space to allow writable mmaps These are necessary to allow writeable mmap of the privcmd node to succeed without being marked read-only for writenotify purposes. Which in turn is necessary to allow mappings of foreign guest pages [ Impact: bugfix: allow writable mappings ] Signed-off-by: Ian Campbell Signed-off-by: Jeremy Fitzhardinge --- drivers/xen/xenfs/super.c | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) (limited to 'drivers/xen/xenfs/super.c') diff --git a/drivers/xen/xenfs/super.c b/drivers/xen/xenfs/super.c index 8c7462866e90..23f1cca5a2e9 100644 --- a/drivers/xen/xenfs/super.c +++ b/drivers/xen/xenfs/super.c @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include @@ -22,12 +24,30 @@ MODULE_DESCRIPTION("Xen filesystem"); MODULE_LICENSE("GPL"); +static int xenfs_set_page_dirty(struct page *page) +{ + if (!PageDirty(page)) + SetPageDirty(page); + return 0; +} + +static const struct address_space_operations xenfs_aops = { + .set_page_dirty = xenfs_set_page_dirty, +}; + +static struct backing_dev_info xenfs_backing_dev_info = { + .ra_pages = 0, /* No readahead */ + .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK, +}; + static struct inode *xenfs_make_inode(struct super_block *sb, int mode) { struct inode *ret = new_inode(sb); if (ret) { ret->i_mode = mode; + ret->i_mapping->a_ops = &xenfs_aops; + ret->i_mapping->backing_dev_info = &xenfs_backing_dev_info; ret->i_uid = ret->i_gid = 0; ret->i_blocks = 0; ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME; @@ -119,11 +139,25 @@ static struct file_system_type xenfs_type = { static int __init xenfs_init(void) { - if (xen_domain()) - return register_filesystem(&xenfs_type); + int err; + if (!xen_domain()) { + printk(KERN_INFO "xenfs: not registering filesystem on non-xen platform\n"); + return 0; + } - printk(KERN_INFO "XENFS: not registering filesystem on non-xen platform\n"); - return 0; + err = register_filesystem(&xenfs_type); + if (err) { + printk(KERN_ERR "xenfs: Unable to register filesystem!\n"); + goto out; + } + + err = bdi_init(&xenfs_backing_dev_info); + if (err) + unregister_filesystem(&xenfs_type); + + out: + + return err; } static void __exit xenfs_exit(void) -- cgit v1.2.1 From 35f8c1c343f2918ea24f05282d14e711887d8278 Mon Sep 17 00:00:00 2001 From: Jeremy Fitzhardinge Date: Fri, 6 Mar 2009 09:56:26 -0800 Subject: xen/xenfs: set_page_dirty is supposed to return true if it dirties I don't think it matters at all in this case (there's only one caller which checks the return value), but may as well be strictly correct. [ Impact: cleanup ] Signed-off-by: Jeremy Fitzhardinge --- drivers/xen/xenfs/super.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/xen/xenfs/super.c') diff --git a/drivers/xen/xenfs/super.c b/drivers/xen/xenfs/super.c index 23f1cca5a2e9..afaa6ede0168 100644 --- a/drivers/xen/xenfs/super.c +++ b/drivers/xen/xenfs/super.c @@ -26,9 +26,7 @@ MODULE_LICENSE("GPL"); static int xenfs_set_page_dirty(struct page *page) { - if (!PageDirty(page)) - SetPageDirty(page); - return 0; + return !TestSetPageDirty(page); } static const struct address_space_operations xenfs_aops = { -- cgit v1.2.1 From 9387377eb79a44f453fd27c3d00a2e5da587e369 Mon Sep 17 00:00:00 2001 From: Jeremy Fitzhardinge Date: Wed, 6 Oct 2010 08:51:32 -0700 Subject: xen/privcmd: make privcmd visible in domU It has its uses in a domU as well as dom0. Xen will prevent an unprivileged domain from doing anything untoward. Signed-off-by: Jeremy Fitzhardinge --- drivers/xen/xenfs/super.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/xen/xenfs/super.c') diff --git a/drivers/xen/xenfs/super.c b/drivers/xen/xenfs/super.c index afaa6ede0168..984891e9a394 100644 --- a/drivers/xen/xenfs/super.c +++ b/drivers/xen/xenfs/super.c @@ -101,6 +101,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 }, {""}, }; int rc; @@ -114,8 +115,6 @@ static int xenfs_fill_super(struct super_block *sb, void *data, int silent) &xsd_kva_file_ops, NULL, S_IRUSR|S_IWUSR); xenfs_create_file(sb, sb->s_root, "xsd_port", &xsd_port_file_ops, NULL, S_IRUSR|S_IWUSR); - xenfs_create_file(sb, sb->s_root, "privcmd", - &privcmd_file_ops, NULL, S_IRUSR|S_IWUSR); } return rc; -- cgit v1.2.1