diff options
Diffstat (limited to 'drivers/kvm/kvm_main.c')
-rw-r--r-- | drivers/kvm/kvm_main.c | 61 |
1 files changed, 22 insertions, 39 deletions
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) | ||