public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Huaitong Han <huaitong.han@intel.com>
To: pbonzini@redhat.com
Cc: kvm@vger.kernel.org, Huaitong Han <huaitong.han@intel.com>
Subject: [PATCH] kvmclock: fix wall clock msr write error
Date: Tue, 10 Jan 2017 18:25:00 +0800	[thread overview]
Message-ID: <1484043900-28111-1-git-send-email-huaitong.han@intel.com> (raw)

kvmclock_offset is negative, it should be timespec64_add intead of
timespec64_sub.

kvm->arch.kvmclock_offset = -ktime_get_boot_ns()

Signed-off-by: Huaitong Han <huaitong.han@intel.com>
---
 arch/x86/kvm/x86.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 2f22810..7668a0e 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1208,7 +1208,7 @@ static void kvm_write_wall_clock(struct kvm *kvm, gpa_t wall_clock)
 
 	if (kvm->arch.kvmclock_offset) {
 		struct timespec64 ts = ns_to_timespec64(kvm->arch.kvmclock_offset);
-		boot = timespec64_sub(boot, ts);
+		boot = timespec64_add(boot, ts);
 	}
 	wc.sec = (u32)boot.tv_sec; /* overflow in 2106 guest time */
 	wc.nsec = boot.tv_nsec;
-- 
1.8.3.1


             reply	other threads:[~2017-01-10 10:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-10 10:25 Huaitong Han [this message]
2017-01-10 10:49 ` [PATCH] kvmclock: fix wall clock msr write error 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=1484043900-28111-1-git-send-email-huaitong.han@intel.com \
    --to=huaitong.han@intel.com \
    --cc=kvm@vger.kernel.org \
    --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