aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
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
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')
-rw-r--r--drivers/kvm/kvm_main.c8
-rw-r--r--drivers/kvm/x86.c24
2 files changed, 19 insertions, 13 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 5f11e6b09458..595ed323fc53 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -1383,10 +1383,6 @@ int kvm_init(void *opaque, unsigned int vcpu_size,
1383 int r; 1383 int r;
1384 int cpu; 1384 int cpu;
1385 1385
1386 r = kvm_mmu_module_init();
1387 if (r)
1388 goto out4;
1389
1390 kvm_init_debug(); 1386 kvm_init_debug();
1391 1387
1392 r = kvm_arch_init(opaque); 1388 r = kvm_arch_init(opaque);
@@ -1446,8 +1442,6 @@ int kvm_init(void *opaque, unsigned int vcpu_size,
1446 kvm_preempt_ops.sched_in = kvm_sched_in; 1442 kvm_preempt_ops.sched_in = kvm_sched_in;
1447 kvm_preempt_ops.sched_out = kvm_sched_out; 1443 kvm_preempt_ops.sched_out = kvm_sched_out;
1448 1444
1449 kvm_mmu_set_nonpresent_ptes(0ull, 0ull);
1450
1451 return 0; 1445 return 0;
1452 1446
1453out_free: 1447out_free:
@@ -1466,7 +1460,6 @@ out_free_0:
1466out: 1460out:
1467 kvm_arch_exit(); 1461 kvm_arch_exit();
1468 kvm_exit_debug(); 1462 kvm_exit_debug();
1469 kvm_mmu_module_exit();
1470out4: 1463out4:
1471 return r; 1464 return r;
1472} 1465}
@@ -1485,6 +1478,5 @@ void kvm_exit(void)
1485 kvm_arch_exit(); 1478 kvm_arch_exit();
1486 kvm_exit_debug(); 1479 kvm_exit_debug();
1487 __free_page(bad_page); 1480 __free_page(bad_page);
1488 kvm_mmu_module_exit();
1489} 1481}
1490EXPORT_SYMBOL_GPL(kvm_exit); 1482EXPORT_SYMBOL_GPL(kvm_exit);
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{