[PATCH] kvm: fix hyperv tsc page clear wrong address

From: Xiaoming Gao
Date: Thu Jun 19 2014 - 07:14:57 EST


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@xxxxxxxxxxx>
---
arch/x86/kvm/x86.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index f32a025..f644933 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1898,7 +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;
- if (kvm_write_guest(kvm, data,
+ if (kvm_write_guest(kvm, gfn << HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT,
&tsc_ref, sizeof(tsc_ref)))
return 1;
mark_page_dirty(kvm, gfn);
--
1.7.1


--------------010904010501080300020809
Content-Type: text/plain; charset=gb18030;
name="0001-kvm-fix-hyperv-tsc-page-clear-wrong-address.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="0001-kvm-fix-hyperv-tsc-page-clear-wrong-address.patch"