diff options
Diffstat (limited to 'drivers/kvm/kvm_main.c')
-rw-r--r-- | drivers/kvm/kvm_main.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 4bbd89e03324..4166a08ce500 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c | |||
@@ -53,6 +53,8 @@ static LIST_HEAD(vm_list); | |||
53 | static cpumask_t cpus_hardware_enabled; | 53 | static cpumask_t cpus_hardware_enabled; |
54 | 54 | ||
55 | struct kvm_arch_ops *kvm_arch_ops; | 55 | struct kvm_arch_ops *kvm_arch_ops; |
56 | struct kmem_cache *kvm_vcpu_cache; | ||
57 | EXPORT_SYMBOL_GPL(kvm_vcpu_cache); | ||
56 | 58 | ||
57 | static __read_mostly struct preempt_ops kvm_preempt_ops; | 59 | static __read_mostly struct preempt_ops kvm_preempt_ops; |
58 | 60 | ||
@@ -3104,7 +3106,8 @@ static void kvm_sched_out(struct preempt_notifier *pn, | |||
3104 | kvm_arch_ops->vcpu_put(vcpu); | 3106 | kvm_arch_ops->vcpu_put(vcpu); |
3105 | } | 3107 | } |
3106 | 3108 | ||
3107 | int kvm_init_arch(struct kvm_arch_ops *ops, struct module *module) | 3109 | int kvm_init_arch(struct kvm_arch_ops *ops, unsigned int vcpu_size, |
3110 | struct module *module) | ||
3108 | { | 3111 | { |
3109 | int r; | 3112 | int r; |
3110 | 3113 | ||
@@ -3142,6 +3145,14 @@ int kvm_init_arch(struct kvm_arch_ops *ops, struct module *module) | |||
3142 | if (r) | 3145 | if (r) |
3143 | goto out_free_3; | 3146 | goto out_free_3; |
3144 | 3147 | ||
3148 | /* A kmem cache lets us meet the alignment requirements of fx_save. */ | ||
3149 | kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, | ||
3150 | __alignof__(struct kvm_vcpu), 0, 0); | ||
3151 | if (!kvm_vcpu_cache) { | ||
3152 | r = -ENOMEM; | ||
3153 | goto out_free_4; | ||
3154 | } | ||
3155 | |||
3145 | kvm_chardev_ops.owner = module; | 3156 | kvm_chardev_ops.owner = module; |
3146 | 3157 | ||
3147 | r = misc_register(&kvm_dev); | 3158 | r = misc_register(&kvm_dev); |
@@ -3156,6 +3167,8 @@ int kvm_init_arch(struct kvm_arch_ops *ops, struct module *module) | |||
3156 | return r; | 3167 | return r; |
3157 | 3168 | ||
3158 | out_free: | 3169 | out_free: |
3170 | kmem_cache_destroy(kvm_vcpu_cache); | ||
3171 | out_free_4: | ||
3159 | sysdev_unregister(&kvm_sysdev); | 3172 | sysdev_unregister(&kvm_sysdev); |
3160 | out_free_3: | 3173 | out_free_3: |
3161 | sysdev_class_unregister(&kvm_sysdev_class); | 3174 | sysdev_class_unregister(&kvm_sysdev_class); |
@@ -3173,6 +3186,7 @@ out: | |||
3173 | void kvm_exit_arch(void) | 3186 | void kvm_exit_arch(void) |
3174 | { | 3187 | { |
3175 | misc_deregister(&kvm_dev); | 3188 | misc_deregister(&kvm_dev); |
3189 | kmem_cache_destroy(kvm_vcpu_cache); | ||
3176 | sysdev_unregister(&kvm_sysdev); | 3190 | sysdev_unregister(&kvm_sysdev); |
3177 | sysdev_class_unregister(&kvm_sysdev_class); | 3191 | sysdev_class_unregister(&kvm_sysdev_class); |
3178 | unregister_reboot_notifier(&kvm_reboot_notifier); | 3192 | unregister_reboot_notifier(&kvm_reboot_notifier); |