Re: [PATCH v3 0/5] KVM_{GET,SET}_TSC_OFFSET ioctls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 17/08/20 21:40, Oliver Upton wrote:
>> If you don't have time to work on it I can try to find some for 5.10,
>> but I'm not sure exactly when.
>
> Shouldn't be an issue, I'll futz around with some changes to the
> series and send them out in the coming weeks.

Ok, after looking more at the code with Maxim I can confidently say that
it's a total mess.  And a lot of the synchronization code is dead
because 1) as far as we could see no guest synchronizes the TSC using
MSR_IA32_TSC; and 2) writing to MSR_IA32_TSC_ADJUST does not trigger the
synchronization code in kvm_write_tsc.

Your patch works not by some sort of miracle, but rather because it
bypasses the mess and that's the smart thing to do.

The plan is now as follows:

1) guest-initiated MSR_IA32_TSC write never goes through the sync
heuristics.  I'll shortly send a patch for this, and it will fix the
testcase issue

2) to have a new KVM_X86_DISABLE_QUIRKS value, that will toggle between
"magic" and "vanilla" semantics for host-initiated TSC and TSC_ADJUST writes

3) if the quirk is present we still want existing userspace to work so:

- host-initiated MSR_IA32_TSC write always returns the L1 TSC as in
Maxim's recent patch.  They will also always go through the sync heuristics.

- host-initiated MSR_IA32_TSC_ADJUST write don't make the TSC jump, they
only write to vcpu->arch.ia32_tsc_adjust_msr (as in the current kernel)

4) if the quirk is disabled however:

- the sync heuristics are never used except in kvm_arch_vcpu_postcreate

- host-initiated MSR_IA32_TSC and MSR_IA32_TSC_ADJUST accesses work like
in the guest: reads of MSR_IA32_TSC return the "right" TSC, writes of
MSR_IA32_TSC_ADJUST writes make the TSC jump.

- for live migration, userspace is expected to use the new
KVM_GET/SET_TSC_PRECISE (or whatever the name will be) to get/set a
(nanosecond, TSC, TSC_ADJUST) tuple.  The sync heuristics will be
bypassed and it will just set the right value for the MSRs.  Setting
MSR_IA32_TSC_ADJUST is optional and controlled by a flag in the struct,
and the flag will be set by KVM_GET_TSC_PRECISE based on the guest CPUID.

Paolo




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux