• P
    KVM: x86: Allow guests to see MSR_IA32_TSX_CTRL even if tsx=off · ec83ed02
    Paolo Bonzini 提交于
    stable inclusion
    from stable-5.10.15
    commit 6c0e069ac6e8db0c49dcc90d37ede5b1da08fe0b
    bugzilla: 48167
    
    --------------------------------
    
    commit 7131636e upstream.
    
    Userspace that does not know about KVM_GET_MSR_FEATURE_INDEX_LIST
    will generally use the default value for MSR_IA32_ARCH_CAPABILITIES.
    When this happens and the host has tsx=on, it is possible to end up with
    virtual machines that have HLE and RTM disabled, but TSX_CTRL available.
    
    If the fleet is then switched to tsx=off, kvm_get_arch_capabilities()
    will clear the ARCH_CAP_TSX_CTRL_MSR bit and it will not be possible to
    use the tsx=off hosts as migration destinations, even though the guests
    do not have TSX enabled.
    
    To allow this migration, allow guests to write to their TSX_CTRL MSR,
    while keeping the host MSR unchanged for the entire life of the guests.
    This ensures that TSX remains disabled and also saves MSR reads and
    writes, and it's okay to do because with tsx=off we know that guests will
    not have the HLE and RTM features in their CPUID.  (If userspace sets
    bogus CPUID data, we do not expect HLE and RTM to work in guests anyway).
    
    Cc: stable@vger.kernel.org
    Fixes: cbbaa272 ("KVM: x86: fix presentation of TSX feature in ARCH_CAPABILITIES")
    Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
    Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
    ec83ed02
vmx.c 222.4 KB