From: Paolo Bonzini <pbonzini@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>, kvm-devel <kvm@vger.kernel.org>
Subject: Re: KVM: x86: workaround SuSE's 2.6.16 pvclock vs masterclock issue
Date: Tue, 20 Jan 2015 20:40:22 +0100 [thread overview]
Message-ID: <54BEAF26.8070303@redhat.com> (raw)
In-Reply-To: <20150120175452.GA32680@amt.cnet>
On 20/01/2015 18:54, Marcelo Tosatti wrote:
>
> SuSE's 2.6.16 kernel fails to boot if the delta between tsc_timestamp
> and rdtsc is larger than a given threshold:
>
> * If we get more than the below threshold into the future, we rerequest
> * the real time from the host again which has only little offset then
> * that we need to adjust using the TSC.
> *
> * For now that threshold is 1/5th of a jiffie. That should be good
> * enough accuracy for completely broken systems, but also give us swing
> * to not call out to the host all the time.
> */
> #define PVCLOCK_DELTA_MAX ((1000000000ULL / HZ) / 5)
>
> Disable masterclock support (which increases said delta) in case the
> boot vcpu does not use MSR_KVM_SYSTEM_TIME_NEW.
Makes sense.
Applied to queue, thanks.
Paolo
> Upstreams kernels which support pvclock vsyscalls (and therefore make
> use of PVCLOCK_STABLE_BIT) use MSR_KVM_SYSTEM_TIME_NEW.
>
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
>
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index 7c492ed..9a099f6 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -613,6 +613,8 @@ struct kvm_arch {
> #ifdef CONFIG_KVM_MMU_AUDIT
> int audit_point;
> #endif
> +
> + bool boot_vcpu_runs_old_kvmclock;
> };
>
> struct kvm_vm_stat {
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 8f1e22d..1d8a4f6 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -1494,7 +1494,8 @@ static void pvclock_update_vm_gtod_copy(struct kvm *kvm)
> &ka->master_cycle_now);
>
> ka->use_master_clock = host_tsc_clocksource && vcpus_matched
> - && !backwards_tsc_observed;
> + && !backwards_tsc_observed
> + && !ka->boot_vcpu_runs_old_kvmclock;
>
> if (ka->use_master_clock)
> atomic_set(&kvm_guest_has_master_clock, 1);
> @@ -2106,8 +2107,20 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
> case MSR_KVM_SYSTEM_TIME_NEW:
> case MSR_KVM_SYSTEM_TIME: {
> u64 gpa_offset;
> + struct kvm_arch *ka = &vcpu->kvm->arch;
> +
> kvmclock_reset(vcpu);
>
> + if (vcpu->vcpu_id == 0 && !msr_info->host_initiated) {
> + bool tmp = (msr == MSR_KVM_SYSTEM_TIME);
> +
> + if (ka->boot_vcpu_runs_old_kvmclock != tmp)
> + set_bit(KVM_REQ_MASTERCLOCK_UPDATE,
> + &vcpu->requests);
> +
> + ka->boot_vcpu_runs_old_kvmclock = tmp;
> + }
> +
> vcpu->arch.time = data;
> kvm_make_request(KVM_REQ_GLOBAL_CLOCK_UPDATE, vcpu);
>
>
next prev parent reply other threads:[~2015-01-20 19:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-20 17:54 KVM: x86: workaround SuSE's 2.6.16 pvclock vs masterclock issue Marcelo Tosatti
2015-01-20 19:40 ` Paolo Bonzini [this message]
2015-01-21 14:09 ` Radim Krčmář
2015-01-21 14:16 ` Marcelo Tosatti
2015-01-21 17:00 ` Radim Krčmář
2015-01-22 1:40 ` Marcelo Tosatti
2015-01-22 13:59 ` Radim Krčmář
2015-01-22 18:12 ` Marcelo Tosatti
2015-01-22 19:33 ` Radim Krčmář
2015-01-22 8:10 ` Paolo Bonzini
2015-01-22 17:02 ` Radim Krčmář
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=54BEAF26.8070303@redhat.com \
--to=pbonzini@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox