]> www.infradead.org Git - users/jedix/linux-maple.git/commit
KVM: x86: Use adjustment in guest cycles when handling MSR_IA32_TSC_ADJUST
authorHaozhong Zhang <haozhong.zhang@intel.com>
Fri, 7 Aug 2015 03:24:32 +0000 (11:24 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 21 Sep 2015 17:05:41 +0000 (10:05 -0700)
commit49102e956fec3806fb0c7fb7b68b0900feab8ece
tree04c9f9e1909a540b62f74c23e2b3ea8a1893b11f
parent73e56fdc3699efea574812d1116dfebd347ce88e
KVM: x86: Use adjustment in guest cycles when handling MSR_IA32_TSC_ADJUST

commit d7add05458084a5e3d65925764a02ca9c8202c1e upstream.

When kvm_set_msr_common() handles a guest's write to
MSR_IA32_TSC_ADJUST, it will calcuate an adjustment based on the data
written by guest and then use it to adjust TSC offset by calling a
call-back adjust_tsc_offset(). The 3rd parameter of adjust_tsc_offset()
indicates whether the adjustment is in host TSC cycles or in guest TSC
cycles. If SVM TSC scaling is enabled, adjust_tsc_offset()
[i.e. svm_adjust_tsc_offset()] will first scale the adjustment;
otherwise, it will just use the unscaled one. As the MSR write here
comes from the guest, the adjustment is in guest TSC cycles. However,
the current kvm_set_msr_common() uses it as a value in host TSC
cycles (by using true as the 3rd parameter of adjust_tsc_offset()),
which can result in an incorrect adjustment of TSC offset if SVM TSC
scaling is enabled. This patch fixes this problem.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/x86.c