• Oliver Upton's avatar
    KVM: x86: Expose TSC offset controls to userspace · 828ca896
    Oliver Upton authored
    To date, VMM-directed TSC synchronization and migration has been a bit
    messy. KVM has some baked-in heuristics around TSC writes to infer if
    the VMM is attempting to synchronize. This is problematic, as it depends
    on host userspace writing to the guest's TSC within 1 second of the last
    write.
    
    A much cleaner approach to configuring the guest's views of the TSC is to
    simply migrate the TSC offset for every vCPU. Offsets are idempotent,
    and thus not subject to change depending on when the VMM actually
    reads/writes values from/to KVM. The VMM can then read the TSC once with
    KVM_GET_CLOCK to capture a (realtime, host_tsc) pair at the instant when
    the guest is paused.
    
    Cc: David Matlack <dmatlack@google.com>
    Cc: Sean Christopherson <seanjc@google.com>
    Signed-off-by: default avatarOliver Upton <oupton@google.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    Message-Id: <20210916181538.968978-8-oupton@google.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    828ca896
x86.c 328 KB