aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/x86.c
diff options
context:
space:
mode:
authorZhang Xiantao <xiantao.zhang@intel.com>2007-11-18 07:43:21 -0500
committerAvi Kivity <avi@qumranet.com>2008-01-30 10:53:05 -0500
commit56c6d28a9afdca0d48dd618276e055f19c0306bb (patch)
treeca06fb0be0c107ab3031c66bfd5ecfaf651d0e04 /drivers/kvm/x86.c
parent5bb064dcdeb7ab341e2f8a3e2fc34faa63b1662c (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.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
index 935e2769b787..2257a0aab32f 100644
--- a/drivers/kvm/x86.c
+++ b/drivers/kvm/x86.c
@@ -1711,33 +1711,47 @@ EXPORT_SYMBOL_GPL(kvm_emulate_pio_string);
1711 1711
1712int kvm_arch_init(void *opaque) 1712int kvm_arch_init(void *opaque)
1713{ 1713{
1714 int r;
1714 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque; 1715 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
1715 1716
1717 r = kvm_mmu_module_init();
1718 if (r)
1719 goto out_fail;
1720
1716 kvm_init_msr_list(); 1721 kvm_init_msr_list();
1717 1722
1718 if (kvm_x86_ops) { 1723 if (kvm_x86_ops) {
1719 printk(KERN_ERR "kvm: already loaded the other module\n"); 1724 printk(KERN_ERR "kvm: already loaded the other module\n");
1720 return -EEXIST; 1725 r = -EEXIST;
1726 goto out;
1721 } 1727 }
1722 1728
1723 if (!ops->cpu_has_kvm_support()) { 1729 if (!ops->cpu_has_kvm_support()) {
1724 printk(KERN_ERR "kvm: no hardware support\n"); 1730 printk(KERN_ERR "kvm: no hardware support\n");
1725 return -EOPNOTSUPP; 1731 r = -EOPNOTSUPP;
1732 goto out;
1726 } 1733 }
1727 if (ops->disabled_by_bios()) { 1734 if (ops->disabled_by_bios()) {
1728 printk(KERN_ERR "kvm: disabled by bios\n"); 1735 printk(KERN_ERR "kvm: disabled by bios\n");
1729 return -EOPNOTSUPP; 1736 r = -EOPNOTSUPP;
1737 goto out;
1730 } 1738 }
1731 1739
1732 kvm_x86_ops = ops; 1740 kvm_x86_ops = ops;
1733 1741 kvm_mmu_set_nonpresent_ptes(0ull, 0ull);
1734 return 0; 1742 return 0;
1743
1744out:
1745 kvm_mmu_module_exit();
1746out_fail:
1747 return r;
1735} 1748}
1736 1749
1737void kvm_arch_exit(void) 1750void kvm_arch_exit(void)
1738{ 1751{
1739 kvm_x86_ops = NULL; 1752 kvm_x86_ops = NULL;
1740 } 1753 kvm_mmu_module_exit();
1754}
1741 1755
1742int kvm_emulate_halt(struct kvm_vcpu *vcpu) 1756int kvm_emulate_halt(struct kvm_vcpu *vcpu)
1743{ 1757{