From: Paolo Bonzini <pbonzini@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>, linux-kernel@vger.kernel.org
Cc: kvm@vger.kernel.org, x86@kernel.org, mtosatti@redhat.com
Subject: Re: [PATCH] ensure guest's kvmclock never goes backwards when TSC jumps backward
Date: Wed, 16 Jul 2014 12:18:37 +0200 [thread overview]
Message-ID: <53C6517D.9090600@redhat.com> (raw)
In-Reply-To: <1405504368-5581-1-git-send-email-imammedo@redhat.com>
Il 16/07/2014 11:52, Igor Mammedov ha scritto:
> There are buggy hosts in the wild that advertise invariant
> TSC and as result host uses TSC as clocksource, but TSC on
> such host sometimes sporadically jumps backwards.
>
> This causes kvmclock to go backwards if host advertises
> PVCLOCK_TSC_STABLE_BIT, which turns off aggregated clock
> accumulator and returns:
> pvclock_vcpu_time_info.system_timestamp + offset
> where 'offset' is calculated using TSC.
> Since TSC is not virtualized in KVM, it makes guest see
> TSC jumped backwards and leads to kvmclock going backwards
> as well.
>
> This is defensive patch that keeps per CPU last clock value
> and ensures that clock will never go backwards even with
> using PVCLOCK_TSC_STABLE_BIT enabled path.
I'm not sure that a per-CPU value is enough; your patch can make the
problem much less frequent of course, but I'm not sure neither detection
nor correction are 100% reliable. Your addition is basically a faster
but less reliable version of the last_value logic.
If may be okay to have detection that is faster but not 100% reliable.
However, once you find that the host is buggy I think the correct thing
to do is to write last_value and kill PVCLOCK_TSC_STABLE_BIT from
valid_flags.
Did you check that the affected host has the latest microcode?
Alternatively, could we simply blacklist some CPU steppings? I'm not
sure who we could ask at AMD :( but perhaps there is an erratum.
Paolo
next prev parent reply other threads:[~2014-07-16 10:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-16 9:52 [PATCH] ensure guest's kvmclock never goes backwards when TSC jumps backward Igor Mammedov
2014-07-16 10:18 ` Paolo Bonzini [this message]
2014-07-16 11:41 ` Marcelo Tosatti
2014-07-16 13:55 ` Igor Mammedov
2014-07-16 14:16 ` Paolo Bonzini
2014-07-16 14:51 ` Igor Mammedov
2014-07-16 14:55 ` Paolo Bonzini
2014-07-16 15:18 ` Igor Mammedov
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=53C6517D.9090600@redhat.com \
--to=pbonzini@redhat.com \
--cc=imammedo@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=x86@kernel.org \
/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.