]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: x86: do not attempt TSC synchronization on guest writes
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 24 Sep 2020 12:45:27 +0000 (14:45 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 28 Sep 2020 11:59:52 +0000 (07:59 -0400)
commitfa817429ea68e78dcc738f50eeadb3f7e2113738
treef88648c3c9ef85bbc14a3da9bb9688ebb386ccef
parentc2c1e8d9adb15386797a8180ab0ea8a7ebb6aba8
KVM: x86: do not attempt TSC synchronization on guest writes

KVM special-cases writes to MSR_IA32_TSC so that all CPUs have
the same base for the TSC.  This logic is complicated, and we
do not want it to have any effect once the VM is started.

In particular, if any guest started to synchronize its TSCs
with writes to MSR_IA32_TSC rather than MSR_IA32_TSC_ADJUST,
the additional effect of kvm_write_tsc code would be uncharted
territory.

Therefore, this patch makes writes to MSR_IA32_TSC behave
essentially the same as writes to MSR_IA32_TSC_ADJUST when
they come from the guest.  A new selftest (which passes
both before and after the patch) checks the current semantics
of writes to MSR_IA32_TSC and MSR_IA32_TSC_ADJUST originating
from both the host and the guest.

Upcoming work to remove the special side effects
of host-initiated writes to MSR_IA32_TSC and MSR_IA32_TSC_ADJUST
will be able to build onto this test, adjusting the host side
to use the new APIs and achieve the same effect.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.c
tools/testing/selftests/kvm/Makefile
tools/testing/selftests/kvm/x86_64/tsc_msrs_test.c [new file with mode: 0644]