From: Marcelo Tosatti <mtosatti@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Luiz Capitulino <lcapitulino@redhat.com>,
kvm@vger.kernel.org, Marcelo Tosatti <mtosatti@redhat.com>
Subject: [patch 3/3] KVM: x86: zero kvmclock_offset when vcpu0 initializes kvmclock system MSR
Date: Wed, 27 May 2015 22:47:00 -0300 [thread overview]
Message-ID: <20150528014929.546279051@redhat.com> (raw)
In-Reply-To: 20150528014657.367253422@redhat.com
[-- Attachment #1: 03-host-patch --]
[-- Type: text/plain, Size: 1038 bytes --]
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>
---
arch/x86/kvm/x86.c | 5 +++++
1 file changed, 5 insertions(+)
Index: kvm/arch/x86/kvm/x86.c
===================================================================
--- kvm.orig/arch/x86/kvm/x86.c 2015-05-27 17:40:46.948189811 -0300
+++ kvm/arch/x86/kvm/x86.c 2015-05-27 22:43:47.340413347 -0300
@@ -1703,6 +1703,8 @@
/* If the host uses TSC clocksource, then it is stable */
if (use_master_clock)
pvclock_flags |= PVCLOCK_TSC_STABLE_BIT;
+ if (ka->kvmclk_counts_from_zero)
+ pvclock_flags |= PVCLOCK_COUNTS_FROM_ZERO;
vcpu->hv_clock.flags = pvclock_flags;
@@ -2282,6 +2284,9 @@
&vcpu->requests);
ka->boot_vcpu_runs_old_kvmclock = tmp;
+
+ ka->kvmclock_offset = -get_kernel_ns();
+ ka->kvmclk_counts_from_zero = true;
}
vcpu->arch.time = data;
next prev parent reply other threads:[~2015-05-28 1:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-28 1:46 [patch 0/3] kvmclock: allow stable sched clock Marcelo Tosatti
2015-05-28 1:46 ` [patch 1/3] x86: kvmclock: add flag to indicate pvclock counts from zero Marcelo Tosatti
2015-05-28 1:46 ` [patch 2/3] x86: kvmclock: set scheduler clock stable Marcelo Tosatti
2015-05-28 8:39 ` Paolo Bonzini
2015-05-28 1:47 ` Marcelo Tosatti [this message]
2015-05-28 8:52 ` [patch 3/3] KVM: x86: zero kvmclock_offset when vcpu0 initializes kvmclock system MSR 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=20150528014929.546279051@redhat.com \
--to=mtosatti@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=lcapitulino@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).