Message ID | 1473344128-30342-1-git-send-email-prarit@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 08/09/2016 16:15, Prarit Bhargava wrote: > When booting a kvm guest on AMD with the latest kernel the following > messages are displayed in the boot log: > > tsc: Unable to calibrate against PIT > tsc: HPET/PMTIMER calibration failed > > aa297292d708 ("x86/tsc: Enumerate SKL cpu_khz and tsc_khz via CPUID") > introduced a change to account for a difference in cpu and tsc frequencies for > Intel SKL processors. Before this change the native tsc set > x86_platform.calibrate_tsc to native_calibrate_tsc() which is a hardware > calibration of the tsc, and in tsc_init() executed > > tsc_khz = x86_platform.calibrate_tsc(); > cpu_khz = tsc_khz; > > The kvm code changed x86_platform.calibrate_tsc to kvm_get_tsc_khz() and > executed the same tsc_init() function. This meant that KVM guests did not > execute the native hardware calibration function. > > After aa297292d708, there are separate native calibrations for cpu_khz and > tsc_khz. The code sets x86_platform.calibrate_tsc to native_calibrate_tsc() > which is now an Intel specific calibration function, and > x86_platform.calibrate_cpu to native_calibrate_cpu() which is the "old" > native_calibrate_tsc() function (ie, the native hardware calibration > function). > > tsc_init() now does > > cpu_khz = x86_platform.calibrate_cpu(); > tsc_khz = x86_platform.calibrate_tsc(); > if (tsc_khz == 0) > tsc_khz = cpu_khz; > else if (abs(cpu_khz - tsc_khz) * 10 > tsc_khz) > cpu_khz = tsc_khz; > > The kvm code should not call the hardware initialization in > native_calibrate_cpu(), as it isn't applicable for kvm and it didn't do that > prior to aa297292d708. > > This patch resolves this issue by setting x86_platform.calibrate_cpu to > kvm_get_tsc_khz(). > > v2: I had originally set x86_platform.calibrate_cpu to > cpu_khz_from_cpuid(), however, pbonzini pointed out that the CPUID leaf > in that function is not available in KVM. I have changed the function > pointer to kvm_get_tsc_khz(). > > Fixes: aa297292d708 ("x86/tsc: Enumerate SKL cpu_khz and tsc_khz via CPUID") > Signed-off-by: Prarit Bhargava <prarit@redhat.com> > Cc: Paolo Bonzini <pbonzini@redhat.com> > Cc: "Radim Krčmář" <rkrcmar@redhat.com> > Cc: Thomas Gleixner <tglx@linutronix.de> > Cc: Ingo Molnar <mingo@redhat.com> > Cc: "H. Peter Anvin" <hpa@zytor.com> > Cc: x86@kernel.org > Cc: Len Brown <len.brown@intel.com> > Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org> > Cc: Borislav Petkov <bp@suse.de> > Cc: Adrian Hunter <adrian.hunter@intel.com> > Cc: "Christopher S. Hall" <christopher.s.hall@intel.com> > Cc: David Woodhouse <dwmw2@infradead.org> > Cc: kvm@vger.kernel.org > --- > arch/x86/kernel/kvmclock.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c > index 1d39bfbd26bb..3692249a70f1 100644 > --- a/arch/x86/kernel/kvmclock.c > +++ b/arch/x86/kernel/kvmclock.c > @@ -289,6 +289,7 @@ void __init kvmclock_init(void) > put_cpu(); > > x86_platform.calibrate_tsc = kvm_get_tsc_khz; > + x86_platform.calibrate_cpu = kvm_get_tsc_khz; > x86_platform.get_wallclock = kvm_get_wallclock; > x86_platform.set_wallclock = kvm_set_wallclock; > #ifdef CONFIG_X86_LOCAL_APIC > Applied to kvm/master, thanks (commit a4497a86fb9b855c5ac8503fdc959393b00bb643). I'll probably send a pull request to Linus only next week though. Paolo -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c index 1d39bfbd26bb..3692249a70f1 100644 --- a/arch/x86/kernel/kvmclock.c +++ b/arch/x86/kernel/kvmclock.c @@ -289,6 +289,7 @@ void __init kvmclock_init(void) put_cpu(); x86_platform.calibrate_tsc = kvm_get_tsc_khz; + x86_platform.calibrate_cpu = kvm_get_tsc_khz; x86_platform.get_wallclock = kvm_get_wallclock; x86_platform.set_wallclock = kvm_set_wallclock; #ifdef CONFIG_X86_LOCAL_APIC
When booting a kvm guest on AMD with the latest kernel the following messages are displayed in the boot log: tsc: Unable to calibrate against PIT tsc: HPET/PMTIMER calibration failed aa297292d708 ("x86/tsc: Enumerate SKL cpu_khz and tsc_khz via CPUID") introduced a change to account for a difference in cpu and tsc frequencies for Intel SKL processors. Before this change the native tsc set x86_platform.calibrate_tsc to native_calibrate_tsc() which is a hardware calibration of the tsc, and in tsc_init() executed tsc_khz = x86_platform.calibrate_tsc(); cpu_khz = tsc_khz; The kvm code changed x86_platform.calibrate_tsc to kvm_get_tsc_khz() and executed the same tsc_init() function. This meant that KVM guests did not execute the native hardware calibration function. After aa297292d708, there are separate native calibrations for cpu_khz and tsc_khz. The code sets x86_platform.calibrate_tsc to native_calibrate_tsc() which is now an Intel specific calibration function, and x86_platform.calibrate_cpu to native_calibrate_cpu() which is the "old" native_calibrate_tsc() function (ie, the native hardware calibration function). tsc_init() now does cpu_khz = x86_platform.calibrate_cpu(); tsc_khz = x86_platform.calibrate_tsc(); if (tsc_khz == 0) tsc_khz = cpu_khz; else if (abs(cpu_khz - tsc_khz) * 10 > tsc_khz) cpu_khz = tsc_khz; The kvm code should not call the hardware initialization in native_calibrate_cpu(), as it isn't applicable for kvm and it didn't do that prior to aa297292d708. This patch resolves this issue by setting x86_platform.calibrate_cpu to kvm_get_tsc_khz(). v2: I had originally set x86_platform.calibrate_cpu to cpu_khz_from_cpuid(), however, pbonzini pointed out that the CPUID leaf in that function is not available in KVM. I have changed the function pointer to kvm_get_tsc_khz(). Fixes: aa297292d708 ("x86/tsc: Enumerate SKL cpu_khz and tsc_khz via CPUID") Signed-off-by: Prarit Bhargava <prarit@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: "Radim Krčmář" <rkrcmar@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: x86@kernel.org Cc: Len Brown <len.brown@intel.com> Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org> Cc: Borislav Petkov <bp@suse.de> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: "Christopher S. Hall" <christopher.s.hall@intel.com> Cc: David Woodhouse <dwmw2@infradead.org> Cc: kvm@vger.kernel.org --- arch/x86/kernel/kvmclock.c | 1 + 1 file changed, 1 insertion(+)