Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1479239

Re: [PATCH] x86, clock: Fix kvm guest tsc initialization

From Prarit Bhargava <prarit@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH] x86, clock: Fix kvm guest tsc initialization
Date 2016-09-08 15:50 +0200
Message-ID <sf7Sh-6qK-13@gated-at.bofh.it> (permalink)
References <sf7fA-6dR-27@gated-at.bofh.it> <sf7IC-6nq-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



On 09/08/2016 09:33 AM, Paolo Bonzini wrote:
> 
> 
> On 08/09/2016 15:07, 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). [...]
>>
>> 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.  Setting x86_platform.calibrate_cpu to NULL is not
>> appropriate as cpu_khz_from_cpuid() must be called to get the correct
>> value of cpu_khz on Intel KVM guests.
>>
>> This patch resolves this issue by setting x86_platform.calibrate_cpu to
>> cpu_khz_from_cpuid() for KVM guests, which allows Intel KVM guests to get
>> the right cpu frequency.
> 
> KVM guests don't have that CPUID leaf at all.  kvm_get_tsc_khz can
> double as x86_platform.calibrate_cpu too for KVM guests, restoring the
> behavior prior to aa297292d708.

Thanks Paolo -- v2 coming shortly.

P.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] x86, clock: Fix kvm guest tsc initialization Prarit Bhargava <prarit@redhat.com> - 2016-09-08 15:10 +0200
  Re: [PATCH] x86, clock: Fix kvm guest tsc initialization Paolo Bonzini <pbonzini@redhat.com> - 2016-09-08 15:40 +0200
    Re: [PATCH] x86, clock: Fix kvm guest tsc initialization Prarit Bhargava <prarit@redhat.com> - 2016-09-08 15:50 +0200
    [PATCH v2] x86, clock: Fix kvm guest tsc initialization Prarit Bhargava <prarit@redhat.com> - 2016-09-08 16:20 +0200
      Re: [PATCH v2] x86, clock: Fix kvm guest tsc initialization Paolo Bonzini <pbonzini@redhat.com> - 2016-09-08 16:50 +0200

csiph-web