All of lore.kernel.org
 help / color / mirror / Atom feed
From: =?gb18030?Q?=22newtongao=28=B8=DF=D0=A1=C3=F7=29=22?= <gxm.linux.kernel@gmail.com>
To: gleb@kernel.org, pbonzini@redhat.com, tglx@linutronix.de,
	mingo@redhat.com, hpa@zytor.com
Cc: x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] kvm: fix hyperv tsc page clear wrong address
Date: Thu, 19 Jun 2014 18:31:54 +0800	[thread overview]
Message-ID: <53A2BC1A.4050702@gmail.com> (raw)
In-Reply-To: <53A2BB7B.8070507@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1197 bytes --]

>From 6010e24da995d4161cb879e98fda989e3cdb41c4 Mon Sep 17 00:00:00 2001
From: Xiaoming Gao <newtongao@tencent.com>
Date: Thu, 19 Jun 2014 17:46:05 +0800
Subject: [PATCH] kvm: fix hyperv tsc page clear wrong address

tsc page addr need clear the low HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT bits
before kvm_write_guest write the zero tsc_ref structure to guest, or it will lead
guest to get wrong clocksource.

windows guest will get strong impact, QueryPerformanceCounter will always return 0
,all things in windows rely on clock source will in serious chaos.

Signed-off-by: Xiaoming Gao <newtongao@tencnet.com>
---
 arch/x86/kvm/x86.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index f32a025..ed716cf 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1898,6 +1898,7 @@ static int set_msr_hyperv_pw(struct kvm_vcpu *vcpu, u32 msr, u64 data)
 		if (!(data & HV_X64_MSR_TSC_REFERENCE_ENABLE))
 			break;
 		gfn = data >> HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT;
+		data &= ~((1 << HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT) - 1);
 		if (kvm_write_guest(kvm, data,
 			&tsc_ref, sizeof(tsc_ref)))
 			return 1;
-- 
1.7.1




[-- Attachment #2: 0001-kvm-fix-hyperv-tsc-page-clear-wrong-address.patch --]
[-- Type: text/plain, Size: 1196 bytes --]

>From 6010e24da995d4161cb879e98fda989e3cdb41c4 Mon Sep 17 00:00:00 2001
From: Xiaoming Gao <newtongao@tencent.com>
Date: Thu, 19 Jun 2014 17:46:05 +0800
Subject: [PATCH] kvm: fix hyperv tsc page clear wrong address

tsc page addr need clear the low HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT bits
before kvm_write_guest write the zero tsc_ref structure to guest, or it will lead
guest to get wrong clocksource.

windows guest will get strong impact, QueryPerformanceCounter will always return 0
,all things in windows rely on clock source, will in serious chaos.

Signed-off-by: Xiaoming Gao <newtongao@tencnet.com>
---
 arch/x86/kvm/x86.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index f32a025..ed716cf 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1898,6 +1898,7 @@ static int set_msr_hyperv_pw(struct kvm_vcpu *vcpu, u32 msr, u64 data)
 		if (!(data & HV_X64_MSR_TSC_REFERENCE_ENABLE))
 			break;
 		gfn = data >> HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT;
+		data &= ~((1 << HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT) - 1);
 		if (kvm_write_guest(kvm, data,
 			&tsc_ref, sizeof(tsc_ref)))
 			return 1;
-- 
1.7.1


       reply	other threads:[~2014-06-19 10:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <53A2BB7B.8070507@gmail.com>
2014-06-19 10:31 ` =?gb18030?Q?=22newtongao=28=B8=DF=D0=A1=C3=F7=29=22?= [this message]
2014-06-19 11:17   ` [PATCH] kvm: fix hyperv tsc page clear wrong address =?gb18030?Q?=22newtongao=28=B8=DF=D0=A1=C3=F7=29=22?=
2014-06-19 11:22     ` 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=53A2BC1A.4050702@gmail.com \
    --to=gxm.linux.kernel@gmail.com \
    --cc=gleb@kernel.org \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=tglx@linutronix.de \
    --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.