All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Sasha Levin <sasha.levin@oracle.com>
Cc: KVM General <kvm@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	lcapitulino@redhat.com
Subject: KVM: x86: zero kvmclock_offset when vcpu0 initializes kvmclock system MSR
Date: Thu, 21 May 2015 21:40:08 -0300	[thread overview]
Message-ID: <20150522004008.GA5242@amt.cnet> (raw)
In-Reply-To: <555A9C2F.7080109@oracle.com>


Initialize kvmclock base, on kvmclock system MSR write time, 
so that the guest sees kvmclock counting from zero.

This matches baremetal behaviour when kvmclock in guest
sets sched clock stable.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index cc2c759..ea40d24 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2188,6 +2188,8 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 					&vcpu->requests);
 
 			ka->boot_vcpu_runs_old_kvmclock = tmp;
+
+			ka->kvmclock_offset = get_kernel_ns();
 		}
 
 		vcpu->arch.time = data;

  reply	other threads:[~2015-05-22  0:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-12 23:17 kvm: odd time values since "kvmclock: set scheduler clock stable" Sasha Levin
2015-05-13 12:58 ` Luiz Capitulino
2015-05-13 15:38   ` Sasha Levin
2015-05-13 17:16   ` Paolo Bonzini
2015-05-18 22:39 ` Marcelo Tosatti
2015-05-18 23:45   ` Sasha Levin
2015-05-19  0:13     ` Marcelo Tosatti
2015-05-19  2:02       ` Sasha Levin
2015-05-19  2:13         ` Sasha Levin
2015-05-22  0:40           ` Marcelo Tosatti [this message]
2015-05-22  0:41           ` Marcelo Tosatti
2015-05-26 13:21             ` Luiz Capitulino
2015-05-26 13:25               ` Sasha Levin
2015-05-22 21:40 KVM: x86: zero kvmclock_offset when vcpu0 initializes kvmclock system MSR Owen Hofmann

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=20150522004008.GA5242@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=lcapitulino@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=sasha.levin@oracle.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.