mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-16 08:44:21 +08:00
520045db94
* 'upstream/xenfs' of git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen: xen/privcmd: make privcmd visible in domU xen/privcmd: move remap_domain_mfn_range() to core xen code and export. privcmd: MMAPBATCH: Fix error handling/reporting xenbus: export xen_store_interface for xenfs xen/privcmd: make sure vma is ours before doing anything to it xen/privcmd: print SIGBUS faults xen/xenfs: set_page_dirty is supposed to return true if it dirties xen/privcmd: create address space to allow writable mmaps xen: add privcmd driver xen: add variable hypercall caller xen: add xen_set_domain_pte() xen: add /proc/xen/xsd_{kva,port} to xenfs * 'upstream/core' of git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen: (29 commits) xen: include xen/xen.h for definition of xen_initial_domain() xen: use host E820 map for dom0 xen: correctly rebuild mfn list list after migration. xen: improvements to VIRQ_DEBUG output xen: set up IRQ before binding virq to evtchn xen: ensure that all event channels start off bound to VCPU 0 xen/hvc: only notify if we actually sent something xen: don't add extra_pages for RAM after mem_end xen: add support for PAT xen: make sure xen_max_p2m_pfn is up to date xen: limit extra memory to a certain ratio of base xen: add extra pages for E820 RAM regions, even if beyond mem_end xen: make sure xen_extra_mem_start is beyond all non-RAM e820 xen: implement "extra" memory to reserve space for pages not present at boot xen: Use host-provided E820 map xen: don't map missing memory xen: defer building p2m mfn structures until kernel is mapped xen: add return value to set_phys_to_machine() xen: convert p2m to a 3 level tree xen: make install_p2mtop_page() static ... Fix up trivial conflict in arch/x86/xen/mmu.c, and fix the use of 'reserve_early()' - in the new memblock world order it is now 'memblock_x86_reserve_range()' instead. Pointed out by Jeremy.
170 lines
3.7 KiB
C
170 lines
3.7 KiB
C
/*
|
|
* xenfs.c - a filesystem for passing info between the a domain and
|
|
* the hypervisor.
|
|
*
|
|
* 2008-10-07 Alex Zeffertt Replaced /proc/xen/xenbus with xenfs filesystem
|
|
* and /proc/xen compatibility mount point.
|
|
* Turned xenfs into a loadable module.
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/module.h>
|
|
#include <linux/fs.h>
|
|
#include <linux/magic.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/backing-dev.h>
|
|
|
|
#include <xen/xen.h>
|
|
|
|
#include "xenfs.h"
|
|
|
|
#include <asm/xen/hypervisor.h>
|
|
|
|
MODULE_DESCRIPTION("Xen filesystem");
|
|
MODULE_LICENSE("GPL");
|
|
|
|
static int xenfs_set_page_dirty(struct page *page)
|
|
{
|
|
return !TestSetPageDirty(page);
|
|
}
|
|
|
|
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;
|
|
}
|
|
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)
|
|
{
|
|
char *tmp = "";
|
|
|
|
if (xen_initial_domain())
|
|
tmp = "control_d\n";
|
|
|
|
return simple_read_from_buffer(buf, size, off, tmp, strlen(tmp));
|
|
}
|
|
|
|
static const struct file_operations capabilities_file_ops = {
|
|
.read = capabilities_read,
|
|
.llseek = default_llseek,
|
|
};
|
|
|
|
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 },
|
|
{ "capabilities", &capabilities_file_ops, S_IRUGO },
|
|
{ "privcmd", &privcmd_file_ops, S_IRUSR|S_IWUSR },
|
|
{""},
|
|
};
|
|
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 rc;
|
|
}
|
|
|
|
static int xenfs_get_sb(struct file_system_type *fs_type,
|
|
int flags, const char *dev_name,
|
|
void *data, struct vfsmount *mnt)
|
|
{
|
|
return get_sb_single(fs_type, flags, data, xenfs_fill_super, mnt);
|
|
}
|
|
|
|
static struct file_system_type xenfs_type = {
|
|
.owner = THIS_MODULE,
|
|
.name = "xenfs",
|
|
.get_sb = xenfs_get_sb,
|
|
.kill_sb = kill_litter_super,
|
|
};
|
|
|
|
static int __init xenfs_init(void)
|
|
{
|
|
int err;
|
|
if (!xen_domain()) {
|
|
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)
|
|
{
|
|
if (xen_domain())
|
|
unregister_filesystem(&xenfs_type);
|
|
}
|
|
|
|
module_init(xenfs_init);
|
|
module_exit(xenfs_exit);
|
|
|