aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/kvm/kvm_main.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 0df0eebc54a9..c01252e84377 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -36,6 +36,8 @@
36#include <asm/desc.h> 36#include <asm/desc.h>
37#include <linux/sysdev.h> 37#include <linux/sysdev.h>
38#include <linux/cpu.h> 38#include <linux/cpu.h>
39#include <linux/fs.h>
40#include <linux/mount.h>
39 41
40#include "x86_emulate.h" 42#include "x86_emulate.h"
41#include "segment_descriptor.h" 43#include "segment_descriptor.h"
@@ -72,6 +74,9 @@ static struct kvm_stats_debugfs_item {
72 74
73static struct dentry *debugfs_dir; 75static struct dentry *debugfs_dir;
74 76
77#define KVMFS_MAGIC 0x19700426
78struct vfsmount *kvmfs_mnt;
79
75#define MAX_IO_MSRS 256 80#define MAX_IO_MSRS 256
76 81
77#define CR0_RESEVED_BITS 0xffffffff1ffaffc0ULL 82#define CR0_RESEVED_BITS 0xffffffff1ffaffc0ULL
@@ -2252,6 +2257,18 @@ static struct sys_device kvm_sysdev = {
2252 2257
2253hpa_t bad_page_address; 2258hpa_t bad_page_address;
2254 2259
2260static int kvmfs_get_sb(struct file_system_type *fs_type, int flags,
2261 const char *dev_name, void *data, struct vfsmount *mnt)
2262{
2263 return get_sb_pseudo(fs_type, "kvm:", NULL, KVMFS_MAGIC, mnt);
2264}
2265
2266static struct file_system_type kvm_fs_type = {
2267 .name = "kvmfs",
2268 .get_sb = kvmfs_get_sb,
2269 .kill_sb = kill_anon_super,
2270};
2271
2255int kvm_init_arch(struct kvm_arch_ops *ops, struct module *module) 2272int kvm_init_arch(struct kvm_arch_ops *ops, struct module *module)
2256{ 2273{
2257 int r; 2274 int r;
@@ -2328,8 +2345,16 @@ void kvm_exit_arch(void)
2328static __init int kvm_init(void) 2345static __init int kvm_init(void)
2329{ 2346{
2330 static struct page *bad_page; 2347 static struct page *bad_page;
2331 int r = 0; 2348 int r;
2349
2350 r = register_filesystem(&kvm_fs_type);
2351 if (r)
2352 goto out3;
2332 2353
2354 kvmfs_mnt = kern_mount(&kvm_fs_type);
2355 r = PTR_ERR(kvmfs_mnt);
2356 if (IS_ERR(kvmfs_mnt))
2357 goto out2;
2333 kvm_init_debug(); 2358 kvm_init_debug();
2334 2359
2335 kvm_init_msr_list(); 2360 kvm_init_msr_list();
@@ -2346,6 +2371,10 @@ static __init int kvm_init(void)
2346 2371
2347out: 2372out:
2348 kvm_exit_debug(); 2373 kvm_exit_debug();
2374 mntput(kvmfs_mnt);
2375out2:
2376 unregister_filesystem(&kvm_fs_type);
2377out3:
2349 return r; 2378 return r;
2350} 2379}
2351 2380
@@ -2353,6 +2382,8 @@ static __exit void kvm_exit(void)
2353{ 2382{
2354 kvm_exit_debug(); 2383 kvm_exit_debug();
2355 __free_page(pfn_to_page(bad_page_address >> PAGE_SHIFT)); 2384 __free_page(pfn_to_page(bad_page_address >> PAGE_SHIFT));
2385 mntput(kvmfs_mnt);
2386 unregister_filesystem(&kvm_fs_type);
2356} 2387}
2357 2388
2358module_init(kvm_init) 2389module_init(kvm_init)