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>
This commit is contained in:
committed by
Avi Kivity
parent
e9b11c1755
commit
cb498ea2ce
@@ -495,9 +495,9 @@ void vcpu_put(struct kvm_vcpu *vcpu);
|
|||||||
void decache_vcpus_on_cpu(int cpu);
|
void decache_vcpus_on_cpu(int cpu);
|
||||||
|
|
||||||
|
|
||||||
int kvm_init_x86(struct kvm_x86_ops *ops, unsigned int vcpu_size,
|
int kvm_init(struct kvm_x86_ops *ops, unsigned int vcpu_size,
|
||||||
struct module *module);
|
struct module *module);
|
||||||
void kvm_exit_x86(void);
|
void kvm_exit(void);
|
||||||
|
|
||||||
int kvm_mmu_module_init(void);
|
int kvm_mmu_module_init(void);
|
||||||
void kvm_mmu_module_exit(void);
|
void kvm_mmu_module_exit(void);
|
||||||
|
@@ -1434,12 +1434,27 @@ static void kvm_sched_out(struct preempt_notifier *pn,
|
|||||||
kvm_arch_vcpu_put(vcpu);
|
kvm_arch_vcpu_put(vcpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
int kvm_init_x86(struct kvm_x86_ops *ops, unsigned int vcpu_size,
|
int kvm_init(struct kvm_x86_ops *ops, unsigned int vcpu_size,
|
||||||
struct module *module)
|
struct module *module)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
int cpu;
|
int cpu;
|
||||||
|
|
||||||
|
r = kvm_mmu_module_init();
|
||||||
|
if (r)
|
||||||
|
goto out4;
|
||||||
|
|
||||||
|
kvm_init_debug();
|
||||||
|
|
||||||
|
kvm_arch_init();
|
||||||
|
|
||||||
|
bad_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
|
||||||
|
|
||||||
|
if (bad_page == NULL) {
|
||||||
|
r = -ENOMEM;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
if (kvm_x86_ops) {
|
if (kvm_x86_ops) {
|
||||||
printk(KERN_ERR "kvm: already loaded the other module\n");
|
printk(KERN_ERR "kvm: already loaded the other module\n");
|
||||||
return -EEXIST;
|
return -EEXIST;
|
||||||
@@ -1520,11 +1535,14 @@ out_free_0:
|
|||||||
kvm_arch_hardware_unsetup();
|
kvm_arch_hardware_unsetup();
|
||||||
out:
|
out:
|
||||||
kvm_x86_ops = NULL;
|
kvm_x86_ops = NULL;
|
||||||
|
kvm_exit_debug();
|
||||||
|
kvm_mmu_module_exit();
|
||||||
|
out4:
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(kvm_init_x86);
|
EXPORT_SYMBOL_GPL(kvm_init);
|
||||||
|
|
||||||
void kvm_exit_x86(void)
|
void kvm_exit(void)
|
||||||
{
|
{
|
||||||
misc_deregister(&kvm_dev);
|
misc_deregister(&kvm_dev);
|
||||||
kmem_cache_destroy(kvm_vcpu_cache);
|
kmem_cache_destroy(kvm_vcpu_cache);
|
||||||
@@ -1535,43 +1553,8 @@ void kvm_exit_x86(void)
|
|||||||
on_each_cpu(hardware_disable, NULL, 0, 1);
|
on_each_cpu(hardware_disable, NULL, 0, 1);
|
||||||
kvm_arch_hardware_unsetup();
|
kvm_arch_hardware_unsetup();
|
||||||
kvm_x86_ops = NULL;
|
kvm_x86_ops = NULL;
|
||||||
}
|
|
||||||
EXPORT_SYMBOL_GPL(kvm_exit_x86);
|
|
||||||
|
|
||||||
static __init int kvm_init(void)
|
|
||||||
{
|
|
||||||
int r;
|
|
||||||
|
|
||||||
r = kvm_mmu_module_init();
|
|
||||||
if (r)
|
|
||||||
goto out4;
|
|
||||||
|
|
||||||
kvm_init_debug();
|
|
||||||
|
|
||||||
kvm_arch_init();
|
|
||||||
|
|
||||||
bad_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
|
|
||||||
|
|
||||||
if (bad_page == NULL) {
|
|
||||||
r = -ENOMEM;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
out:
|
|
||||||
kvm_exit_debug();
|
|
||||||
kvm_mmu_module_exit();
|
|
||||||
out4:
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
static __exit void kvm_exit(void)
|
|
||||||
{
|
|
||||||
kvm_exit_debug();
|
kvm_exit_debug();
|
||||||
__free_page(bad_page);
|
__free_page(bad_page);
|
||||||
kvm_mmu_module_exit();
|
kvm_mmu_module_exit();
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(kvm_exit);
|
||||||
module_init(kvm_init)
|
|
||||||
module_exit(kvm_exit)
|
|
||||||
|
@@ -1723,13 +1723,13 @@ static struct kvm_x86_ops svm_x86_ops = {
|
|||||||
|
|
||||||
static int __init svm_init(void)
|
static int __init svm_init(void)
|
||||||
{
|
{
|
||||||
return kvm_init_x86(&svm_x86_ops, sizeof(struct vcpu_svm),
|
return kvm_init(&svm_x86_ops, sizeof(struct vcpu_svm),
|
||||||
THIS_MODULE);
|
THIS_MODULE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __exit svm_exit(void)
|
static void __exit svm_exit(void)
|
||||||
{
|
{
|
||||||
kvm_exit_x86();
|
kvm_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
module_init(svm_init)
|
module_init(svm_init)
|
||||||
|
@@ -2677,7 +2677,7 @@ static int __init vmx_init(void)
|
|||||||
memset(iova, 0xff, PAGE_SIZE);
|
memset(iova, 0xff, PAGE_SIZE);
|
||||||
kunmap(vmx_io_bitmap_b);
|
kunmap(vmx_io_bitmap_b);
|
||||||
|
|
||||||
r = kvm_init_x86(&vmx_x86_ops, sizeof(struct vcpu_vmx), THIS_MODULE);
|
r = kvm_init(&vmx_x86_ops, sizeof(struct vcpu_vmx), THIS_MODULE);
|
||||||
if (r)
|
if (r)
|
||||||
goto out1;
|
goto out1;
|
||||||
|
|
||||||
@@ -2698,7 +2698,7 @@ static void __exit vmx_exit(void)
|
|||||||
__free_page(vmx_io_bitmap_b);
|
__free_page(vmx_io_bitmap_b);
|
||||||
__free_page(vmx_io_bitmap_a);
|
__free_page(vmx_io_bitmap_a);
|
||||||
|
|
||||||
kvm_exit_x86();
|
kvm_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
module_init(vmx_init)
|
module_init(vmx_init)
|
||||||
|
Reference in New Issue
Block a user