All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: Paolo Bonzini <pbonzini@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm-devel <kvm@vger.kernel.org>
Subject: Re: KVM: x86: disable master clock if TSC is reset during suspend (v3)
Date: Wed, 21 May 2014 10:26:00 +0200	[thread overview]
Message-ID: <537C6318.7050707@suse.de> (raw)
In-Reply-To: <53739333.3040602@redhat.com>


On 14.05.14 18:00, Paolo Bonzini wrote:
> Il 14/05/2014 17:43, Marcelo Tosatti ha scritto:
>>
>> Updating system_time from the kernel clock once master clock
>> has been enabled can result in time backwards event, in case
>> kernel clock frequency is lower than TSC frequency.
>>
>> Disable master clock in case its necessary to update it
>> from the resume path.
>>
>> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
>>
>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>> index de0931c..c098728 100644
>> --- a/arch/x86/kvm/x86.c
>> +++ b/arch/x86/kvm/x86.c
>> @@ -106,6 +106,8 @@ EXPORT_SYMBOL_GPL(kvm_max_guest_tsc_khz);
>>  static u32 tsc_tolerance_ppm = 250;
>>  module_param(tsc_tolerance_ppm, uint, S_IRUGO | S_IWUSR);
>>
>> +static bool backwards_tsc_observed = false;
>> +
>>  #define KVM_NR_SHARED_MSRS 16
>>
>>  struct kvm_shared_msrs_global {
>> @@ -1471,7 +1473,8 @@ static void pvclock_update_vm_gtod_copy(struct 
>> kvm *kvm)
>>                      &ka->master_kernel_ns,
>>                      &ka->master_cycle_now);
>>
>> -    ka->use_master_clock = host_tsc_clocksource & vcpus_matched;
>> +    ka->use_master_clock = host_tsc_clocksource && vcpus_matched
>> +                && !backwards_tsc_observed;
>>
>>      if (ka->use_master_clock)
>>          atomic_set(&kvm_guest_has_master_clock, 1);
>> @@ -6939,6 +6942,7 @@ int kvm_arch_hardware_enable(void *garbage)
>>       */
>>      if (backwards_tsc) {
>>          u64 delta_cyc = max_tsc - local_tsc;
>> +        backwards_tsc_observed = true;
>>          list_for_each_entry(kvm, &vm_list, vm_list) {
>>              kvm_for_each_vcpu(i, vcpu, kvm) {
>>                  vcpu->arch.tsc_offset_adjustment += delta_cyc;
>>
>
> Applying to kvm/master, thanks.

Thanks. Can you please make sure to CC qemu-stable when sending a pull 
request?


Alex


  reply	other threads:[~2014-05-21  8:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-14  7:26 KVM: x86: disable master clock if TSC is reset during suspend Marcelo Tosatti
2014-05-14  9:09 ` Paolo Bonzini
2014-05-14 10:05   ` Marcelo Tosatti
2014-05-14 10:06   ` KVM: x86: disable master clock if TSC is reset during suspend (v2) Marcelo Tosatti
2014-05-14 10:21     ` Paolo Bonzini
2014-05-14 15:43       ` KVM: x86: disable master clock if TSC is reset during suspend (v3) Marcelo Tosatti
2014-05-14 16:00         ` Paolo Bonzini
2014-05-21  8:26           ` Alexander Graf [this message]
2014-05-21 10:01             ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=537C6318.7050707@suse.de \
    --to=agraf@suse.de \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.