diff options
Diffstat (limited to 'virt/kvm/kvm_main.c')
-rw-r--r-- | virt/kvm/kvm_main.c | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index ce3d8e5be73e..2e791367c576 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -3155,12 +3155,13 @@ static void hardware_enable_nolock(void *junk) | |||
3155 | } | 3155 | } |
3156 | } | 3156 | } |
3157 | 3157 | ||
3158 | static void hardware_enable(void) | 3158 | static int kvm_starting_cpu(unsigned int cpu) |
3159 | { | 3159 | { |
3160 | raw_spin_lock(&kvm_count_lock); | 3160 | raw_spin_lock(&kvm_count_lock); |
3161 | if (kvm_usage_count) | 3161 | if (kvm_usage_count) |
3162 | hardware_enable_nolock(NULL); | 3162 | hardware_enable_nolock(NULL); |
3163 | raw_spin_unlock(&kvm_count_lock); | 3163 | raw_spin_unlock(&kvm_count_lock); |
3164 | return 0; | ||
3164 | } | 3165 | } |
3165 | 3166 | ||
3166 | static void hardware_disable_nolock(void *junk) | 3167 | static void hardware_disable_nolock(void *junk) |
@@ -3173,12 +3174,13 @@ static void hardware_disable_nolock(void *junk) | |||
3173 | kvm_arch_hardware_disable(); | 3174 | kvm_arch_hardware_disable(); |
3174 | } | 3175 | } |
3175 | 3176 | ||
3176 | static void hardware_disable(void) | 3177 | static int kvm_dying_cpu(unsigned int cpu) |
3177 | { | 3178 | { |
3178 | raw_spin_lock(&kvm_count_lock); | 3179 | raw_spin_lock(&kvm_count_lock); |
3179 | if (kvm_usage_count) | 3180 | if (kvm_usage_count) |
3180 | hardware_disable_nolock(NULL); | 3181 | hardware_disable_nolock(NULL); |
3181 | raw_spin_unlock(&kvm_count_lock); | 3182 | raw_spin_unlock(&kvm_count_lock); |
3183 | return 0; | ||
3182 | } | 3184 | } |
3183 | 3185 | ||
3184 | static void hardware_disable_all_nolock(void) | 3186 | static void hardware_disable_all_nolock(void) |
@@ -3219,21 +3221,6 @@ static int hardware_enable_all(void) | |||
3219 | return r; | 3221 | return r; |
3220 | } | 3222 | } |
3221 | 3223 | ||
3222 | static int kvm_cpu_hotplug(struct notifier_block *notifier, unsigned long val, | ||
3223 | void *v) | ||
3224 | { | ||
3225 | val &= ~CPU_TASKS_FROZEN; | ||
3226 | switch (val) { | ||
3227 | case CPU_DYING: | ||
3228 | hardware_disable(); | ||
3229 | break; | ||
3230 | case CPU_STARTING: | ||
3231 | hardware_enable(); | ||
3232 | break; | ||
3233 | } | ||
3234 | return NOTIFY_OK; | ||
3235 | } | ||
3236 | |||
3237 | static int kvm_reboot(struct notifier_block *notifier, unsigned long val, | 3224 | static int kvm_reboot(struct notifier_block *notifier, unsigned long val, |
3238 | void *v) | 3225 | void *v) |
3239 | { | 3226 | { |
@@ -3500,10 +3487,6 @@ int kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx, | |||
3500 | return r; | 3487 | return r; |
3501 | } | 3488 | } |
3502 | 3489 | ||
3503 | static struct notifier_block kvm_cpu_notifier = { | ||
3504 | .notifier_call = kvm_cpu_hotplug, | ||
3505 | }; | ||
3506 | |||
3507 | static int kvm_debugfs_open(struct inode *inode, struct file *file, | 3490 | static int kvm_debugfs_open(struct inode *inode, struct file *file, |
3508 | int (*get)(void *, u64 *), int (*set)(void *, u64), | 3491 | int (*get)(void *, u64 *), int (*set)(void *, u64), |
3509 | const char *fmt) | 3492 | const char *fmt) |
@@ -3754,7 +3737,8 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align, | |||
3754 | goto out_free_1; | 3737 | goto out_free_1; |
3755 | } | 3738 | } |
3756 | 3739 | ||
3757 | r = register_cpu_notifier(&kvm_cpu_notifier); | 3740 | r = cpuhp_setup_state_nocalls(CPUHP_AP_KVM_STARTING, "AP_KVM_STARTING", |
3741 | kvm_starting_cpu, kvm_dying_cpu); | ||
3758 | if (r) | 3742 | if (r) |
3759 | goto out_free_2; | 3743 | goto out_free_2; |
3760 | register_reboot_notifier(&kvm_reboot_notifier); | 3744 | register_reboot_notifier(&kvm_reboot_notifier); |
@@ -3808,7 +3792,7 @@ out_free: | |||
3808 | kmem_cache_destroy(kvm_vcpu_cache); | 3792 | kmem_cache_destroy(kvm_vcpu_cache); |
3809 | out_free_3: | 3793 | out_free_3: |
3810 | unregister_reboot_notifier(&kvm_reboot_notifier); | 3794 | unregister_reboot_notifier(&kvm_reboot_notifier); |
3811 | unregister_cpu_notifier(&kvm_cpu_notifier); | 3795 | cpuhp_remove_state_nocalls(CPUHP_AP_KVM_STARTING); |
3812 | out_free_2: | 3796 | out_free_2: |
3813 | out_free_1: | 3797 | out_free_1: |
3814 | kvm_arch_hardware_unsetup(); | 3798 | kvm_arch_hardware_unsetup(); |
@@ -3831,7 +3815,7 @@ void kvm_exit(void) | |||
3831 | kvm_async_pf_deinit(); | 3815 | kvm_async_pf_deinit(); |
3832 | unregister_syscore_ops(&kvm_syscore_ops); | 3816 | unregister_syscore_ops(&kvm_syscore_ops); |
3833 | unregister_reboot_notifier(&kvm_reboot_notifier); | 3817 | unregister_reboot_notifier(&kvm_reboot_notifier); |
3834 | unregister_cpu_notifier(&kvm_cpu_notifier); | 3818 | cpuhp_remove_state_nocalls(CPUHP_AP_KVM_STARTING); |
3835 | on_each_cpu(hardware_disable_nolock, NULL, 1); | 3819 | on_each_cpu(hardware_disable_nolock, NULL, 1); |
3836 | kvm_arch_hardware_unsetup(); | 3820 | kvm_arch_hardware_unsetup(); |
3837 | kvm_arch_exit(); | 3821 | kvm_arch_exit(); |