diff options
author | Zhang Xiantao <xiantao.zhang@intel.com> | 2007-11-14 07:39:31 -0500 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-01-30 10:53:02 -0500 |
commit | cb498ea2ce1d3f3c0bc0a2522241dca10263e437 (patch) | |
tree | 255eeaa3581a79ceb77772c1350faa95ce4706a6 /drivers/kvm | |
parent | e9b11c17552afe684e9e5d0444309a3ddf410116 (diff) |
KVM: Portability: Combine kvm_init and kvm_init_x86
Will be called once arch module registers itself.
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Acked-by: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm')
-rw-r--r-- | drivers/kvm/kvm.h | 4 | ||||
-rw-r--r-- | drivers/kvm/kvm_main.c | 61 | ||||
-rw-r--r-- | drivers/kvm/svm.c | 4 | ||||
-rw-r--r-- | drivers/kvm/vmx.c | 4 |
4 files changed, 28 insertions, 45 deletions
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h index bca07c6d046..5e7be150466 100644 --- a/drivers/kvm/kvm.h +++ b/drivers/kvm/kvm.h | |||
@@ -495,9 +495,9 @@ void vcpu_put(struct kvm_vcpu *vcpu); | |||
495 | void decache_vcpus_on_cpu(int cpu); | 495 | void decache_vcpus_on_cpu(int cpu); |
496 | 496 | ||
497 | 497 | ||
498 | int kvm_init_x86(struct kvm_x86_ops *ops, unsigned int vcpu_size, | 498 | int kvm_init(struct kvm_x86_ops *ops, unsigned int vcpu_size, |
499 | struct module *module); | 499 | struct module *module); |
500 | void kvm_exit_x86(void); | 500 | void kvm_exit(void); |
501 | 501 | ||
502 | int kvm_mmu_module_init(void); | 502 | int kvm_mmu_module_init(void); |
503 | void kvm_mmu_module_exit(void); | 503 | void kvm_mmu_module_exit(void); |
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 7fdfed52dbe..2b3736e7483 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c | |||
@@ -1434,12 +1434,27 @@ static void kvm_sched_out(struct preempt_notifier *pn, | |||
1434 | kvm_arch_vcpu_put(vcpu); | 1434 | kvm_arch_vcpu_put(vcpu); |
1435 | } | 1435 | } |
1436 | 1436 | ||
1437 | int kvm_init_x86(struct kvm_x86_ops *ops, unsigned int vcpu_size, | 1437 | int kvm_init(struct kvm_x86_ops *ops, unsigned int vcpu_size, |
1438 | struct module *module) | 1438 | struct module *module) |
1439 | { | 1439 | { |
1440 | int r; | 1440 | int r; |
1441 | int cpu; | 1441 | int cpu; |
1442 | 1442 | ||
1443 | r = kvm_mmu_module_init(); | ||
1444 | if (r) | ||
1445 | goto out4; | ||
1446 | |||
1447 | kvm_init_debug(); | ||
1448 | |||
1449 | kvm_arch_init(); | ||
1450 | |||
1451 | bad_page = alloc_page(GFP_KERNEL | __GFP_ZERO); | ||
1452 | |||
1453 | if (bad_page == NULL) { | ||
1454 | r = -ENOMEM; | ||
1455 | goto out; | ||
1456 | } | ||
1457 | |||
1443 | if (kvm_x86_ops) { | 1458 | if (kvm_x86_ops) { |
1444 | printk(KERN_ERR "kvm: already loaded the other module\n"); | 1459 | printk(KERN_ERR "kvm: already loaded the other module\n"); |
1445 | return -EEXIST; | 1460 | return -EEXIST; |
@@ -1520,11 +1535,14 @@ out_free_0: | |||
1520 | kvm_arch_hardware_unsetup(); | 1535 | kvm_arch_hardware_unsetup(); |
1521 | out: | 1536 | out: |
1522 | kvm_x86_ops = NULL; | 1537 | kvm_x86_ops = NULL; |
1538 | kvm_exit_debug(); | ||
1539 | kvm_mmu_module_exit(); | ||
1540 | out4: | ||
1523 | return r; | 1541 | return r; |
1524 | } | 1542 | } |
1525 | EXPORT_SYMBOL_GPL(kvm_init_x86); | 1543 | EXPORT_SYMBOL_GPL(kvm_init); |
1526 | 1544 | ||
1527 | void kvm_exit_x86(void) | 1545 | void kvm_exit(void) |
1528 | { | 1546 | { |
1529 | misc_deregister(&kvm_dev); | 1547 | misc_deregister(&kvm_dev); |
1530 | kmem_cache_destroy(kvm_vcpu_cache); | 1548 | kmem_cache_destroy(kvm_vcpu_cache); |
@@ -1535,43 +1553,8 @@ void kvm_exit_x86(void) | |||
1535 | on_each_cpu(hardware_disable, NULL, 0, 1); | 1553 | on_each_cpu(hardware_disable, NULL, 0, 1); |
1536 | kvm_arch_hardware_unsetup(); | 1554 | kvm_arch_hardware_unsetup(); |
1537 | kvm_x86_ops = NULL; | 1555 | kvm_x86_ops = NULL; |
1538 | } | ||
1539 | EXPORT_SYMBOL_GPL(kvm_exit_x86); | ||
1540 | |||
1541 | static __init int kvm_init(void) | ||
1542 | { | ||
1543 | int r; | ||
1544 | |||
1545 | r = kvm_mmu_module_init(); | ||
1546 | if (r) | ||
1547 | goto out4; | ||
1548 | |||
1549 | kvm_init_debug(); | ||
1550 | |||
1551 | kvm_arch_init(); | ||
1552 | |||
1553 | bad_page = alloc_page(GFP_KERNEL | __GFP_ZERO); | ||
1554 | |||
1555 | if (bad_page == NULL) { | ||
1556 | r = -ENOMEM; | ||
1557 | goto out; | ||
1558 | } | ||
1559 | |||
1560 | return 0; | ||
1561 | |||
1562 | out: | ||
1563 | kvm_exit_debug(); | ||
1564 | kvm_mmu_module_exit(); | ||
1565 | out4: | ||
1566 | return r; | ||
1567 | } | ||
1568 | |||
1569 | static __exit void kvm_exit(void) | ||
1570 | { | ||
1571 | kvm_exit_debug(); | 1556 | kvm_exit_debug(); |
1572 | __free_page(bad_page); | 1557 | __free_page(bad_page); |
1573 | kvm_mmu_module_exit(); | 1558 | kvm_mmu_module_exit(); |
1574 | } | 1559 | } |
1575 | 1560 | EXPORT_SYMBOL_GPL(kvm_exit); | |
1576 | module_init(kvm_init) | ||
1577 | module_exit(kvm_exit) | ||
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c index 97863f8fd00..0ccbef18476 100644 --- a/drivers/kvm/svm.c +++ b/drivers/kvm/svm.c | |||
@@ -1723,13 +1723,13 @@ static struct kvm_x86_ops svm_x86_ops = { | |||
1723 | 1723 | ||
1724 | static int __init svm_init(void) | 1724 | static int __init svm_init(void) |
1725 | { | 1725 | { |
1726 | return kvm_init_x86(&svm_x86_ops, sizeof(struct vcpu_svm), | 1726 | return kvm_init(&svm_x86_ops, sizeof(struct vcpu_svm), |
1727 | THIS_MODULE); | 1727 | THIS_MODULE); |
1728 | } | 1728 | } |
1729 | 1729 | ||
1730 | static void __exit svm_exit(void) | 1730 | static void __exit svm_exit(void) |
1731 | { | 1731 | { |
1732 | kvm_exit_x86(); | 1732 | kvm_exit(); |
1733 | } | 1733 | } |
1734 | 1734 | ||
1735 | module_init(svm_init) | 1735 | module_init(svm_init) |
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c index c3bde753271..529162345c1 100644 --- a/drivers/kvm/vmx.c +++ b/drivers/kvm/vmx.c | |||
@@ -2677,7 +2677,7 @@ static int __init vmx_init(void) | |||
2677 | memset(iova, 0xff, PAGE_SIZE); | 2677 | memset(iova, 0xff, PAGE_SIZE); |
2678 | kunmap(vmx_io_bitmap_b); | 2678 | kunmap(vmx_io_bitmap_b); |
2679 | 2679 | ||
2680 | r = kvm_init_x86(&vmx_x86_ops, sizeof(struct vcpu_vmx), THIS_MODULE); | 2680 | r = kvm_init(&vmx_x86_ops, sizeof(struct vcpu_vmx), THIS_MODULE); |
2681 | if (r) | 2681 | if (r) |
2682 | goto out1; | 2682 | goto out1; |
2683 | 2683 | ||
@@ -2698,7 +2698,7 @@ static void __exit vmx_exit(void) | |||
2698 | __free_page(vmx_io_bitmap_b); | 2698 | __free_page(vmx_io_bitmap_b); |
2699 | __free_page(vmx_io_bitmap_a); | 2699 | __free_page(vmx_io_bitmap_a); |
2700 | 2700 | ||
2701 | kvm_exit_x86(); | 2701 | kvm_exit(); |
2702 | } | 2702 | } |
2703 | 2703 | ||
2704 | module_init(vmx_init) | 2704 | module_init(vmx_init) |