• Z
    KVM: Fix last_guest_tsc / tsc_offset semantics · b183aa58
    Zachary Amsden 提交于
    The variable last_guest_tsc was being used as an ad-hoc indicator
    that guest TSC has been initialized and recorded correctly.  However,
    it may not have been, it could be that guest TSC has been set to some
    large value, the back to a small value (by, say, a software reboot).
    
    This defeats the logic and causes KVM to falsely assume that the
    guest TSC has gone backwards, marking the host TSC unstable, which
    is undesirable behavior.
    
    In addition, rather than try to compute an offset adjustment for the
    TSC on unstable platforms, just recompute the whole offset.  This
    allows us to get rid of one callsite for adjust_tsc_offset, which
    is problematic because the units it takes are in guest units, but
    here, the computation was originally being done in host units.
    
    Doing this, and also recording last_guest_tsc when the TSC is written
    allow us to remove the tricky logic which depended on last_guest_tsc
    being zero to indicate a reset of uninitialized value.
    
    Instead, we now have the guarantee that the guest TSC offset is
    always at least something which will get us last_guest_tsc.
    Signed-off-by: NZachary Amsden <zamsden@gmail.com>
    Signed-off-by: NMarcelo Tosatti <mtosatti@redhat.com>
    Signed-off-by: NAvi Kivity <avi@redhat.com>
    b183aa58
x86.c 158.3 KB