diff options
author | Zhang Xiantao <xiantao.zhang@intel.com> | 2007-11-18 20:43:21 +0800 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-01-30 17:53:05 +0200 |
commit | 56c6d28a9afdca0d48dd618276e055f19c0306bb (patch) | |
tree | ca06fb0be0c107ab3031c66bfd5ecfaf651d0e04 /drivers/kvm/x86.c | |
parent | 5bb064dcdeb7ab341e2f8a3e2fc34faa63b1662c (diff) |
KVM: Portability: MMU initialization and teardown split
Move out kvm_mmu init and exit functionality from kvm_main.c
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/x86.c')
-rw-r--r-- | drivers/kvm/x86.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c index 935e2769b78..2257a0aab32 100644 --- a/drivers/kvm/x86.c +++ b/drivers/kvm/x86.c @@ -1711,33 +1711,47 @@ EXPORT_SYMBOL_GPL(kvm_emulate_pio_string); int kvm_arch_init(void *opaque) { + int r; struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque; + r = kvm_mmu_module_init(); + if (r) + goto out_fail; + kvm_init_msr_list(); if (kvm_x86_ops) { printk(KERN_ERR "kvm: already loaded the other module\n"); - return -EEXIST; + r = -EEXIST; + goto out; } if (!ops->cpu_has_kvm_support()) { printk(KERN_ERR "kvm: no hardware support\n"); - return -EOPNOTSUPP; + r = -EOPNOTSUPP; + goto out; } if (ops->disabled_by_bios()) { printk(KERN_ERR "kvm: disabled by bios\n"); - return -EOPNOTSUPP; + r = -EOPNOTSUPP; + goto out; } kvm_x86_ops = ops; - + kvm_mmu_set_nonpresent_ptes(0ull, 0ull); return 0; + +out: + kvm_mmu_module_exit(); +out_fail: + return r; } void kvm_arch_exit(void) { kvm_x86_ops = NULL; - } + kvm_mmu_module_exit(); +} int kvm_emulate_halt(struct kvm_vcpu *vcpu) { |