aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c35
1 files changed, 8 insertions, 27 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index b2766723c951..45608a7da9b3 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -5552,9 +5552,10 @@ int kvm_fast_pio_out(struct kvm_vcpu *vcpu, int size, unsigned short port)
5552} 5552}
5553EXPORT_SYMBOL_GPL(kvm_fast_pio_out); 5553EXPORT_SYMBOL_GPL(kvm_fast_pio_out);
5554 5554
5555static void tsc_bad(void *info) 5555static int kvmclock_cpu_down_prep(unsigned int cpu)
5556{ 5556{
5557 __this_cpu_write(cpu_tsc_khz, 0); 5557 __this_cpu_write(cpu_tsc_khz, 0);
5558 return 0;
5558} 5559}
5559 5560
5560static void tsc_khz_changed(void *data) 5561static void tsc_khz_changed(void *data)
@@ -5659,35 +5660,18 @@ static struct notifier_block kvmclock_cpufreq_notifier_block = {
5659 .notifier_call = kvmclock_cpufreq_notifier 5660 .notifier_call = kvmclock_cpufreq_notifier
5660}; 5661};
5661 5662
5662static int kvmclock_cpu_notifier(struct notifier_block *nfb, 5663static int kvmclock_cpu_online(unsigned int cpu)
5663 unsigned long action, void *hcpu)
5664{ 5664{
5665 unsigned int cpu = (unsigned long)hcpu; 5665 tsc_khz_changed(NULL);
5666 5666 return 0;
5667 switch (action) {
5668 case CPU_ONLINE:
5669 case CPU_DOWN_FAILED:
5670 smp_call_function_single(cpu, tsc_khz_changed, NULL, 1);
5671 break;
5672 case CPU_DOWN_PREPARE:
5673 smp_call_function_single(cpu, tsc_bad, NULL, 1);
5674 break;
5675 }
5676 return NOTIFY_OK;
5677} 5667}
5678 5668
5679static struct notifier_block kvmclock_cpu_notifier_block = {
5680 .notifier_call = kvmclock_cpu_notifier,
5681 .priority = -INT_MAX
5682};
5683
5684static void kvm_timer_init(void) 5669static void kvm_timer_init(void)
5685{ 5670{
5686 int cpu; 5671 int cpu;
5687 5672
5688 max_tsc_khz = tsc_khz; 5673 max_tsc_khz = tsc_khz;
5689 5674
5690 cpu_notifier_register_begin();
5691 if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) { 5675 if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) {
5692#ifdef CONFIG_CPU_FREQ 5676#ifdef CONFIG_CPU_FREQ
5693 struct cpufreq_policy policy; 5677 struct cpufreq_policy policy;
@@ -5702,12 +5686,9 @@ static void kvm_timer_init(void)
5702 CPUFREQ_TRANSITION_NOTIFIER); 5686 CPUFREQ_TRANSITION_NOTIFIER);
5703 } 5687 }
5704 pr_debug("kvm: max_tsc_khz = %ld\n", max_tsc_khz); 5688 pr_debug("kvm: max_tsc_khz = %ld\n", max_tsc_khz);
5705 for_each_online_cpu(cpu)
5706 smp_call_function_single(cpu, tsc_khz_changed, NULL, 1);
5707
5708 __register_hotcpu_notifier(&kvmclock_cpu_notifier_block);
5709 cpu_notifier_register_done();
5710 5689
5690 cpuhp_setup_state(CPUHP_AP_X86_KVM_CLK_ONLINE, "AP_X86_KVM_CLK_ONLINE",
5691 kvmclock_cpu_online, kvmclock_cpu_down_prep);
5711} 5692}
5712 5693
5713static DEFINE_PER_CPU(struct kvm_vcpu *, current_vcpu); 5694static DEFINE_PER_CPU(struct kvm_vcpu *, current_vcpu);
@@ -5896,7 +5877,7 @@ void kvm_arch_exit(void)
5896 if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) 5877 if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC))
5897 cpufreq_unregister_notifier(&kvmclock_cpufreq_notifier_block, 5878 cpufreq_unregister_notifier(&kvmclock_cpufreq_notifier_block,
5898 CPUFREQ_TRANSITION_NOTIFIER); 5879 CPUFREQ_TRANSITION_NOTIFIER);
5899 unregister_hotcpu_notifier(&kvmclock_cpu_notifier_block); 5880 cpuhp_remove_state_nocalls(CPUHP_AP_X86_KVM_CLK_ONLINE);
5900#ifdef CONFIG_X86_64 5881#ifdef CONFIG_X86_64
5901 pvclock_gtod_unregister_notifier(&pvclock_gtod_notifier); 5882 pvclock_gtod_unregister_notifier(&pvclock_gtod_notifier);
5902#endif 5883#endif