• Vitaly Kuznetsov's avatar
    KVM: nVMX: Introduce 'EVMPTR_MAP_PENDING' post-migration state · 27849968
    Vitaly Kuznetsov authored
    Unlike regular set_current_vmptr(), nested_vmx_handle_enlightened_vmptrld()
    can not be called directly from vmx_set_nested_state() as KVM may not have
    all the information yet (e.g. HV_X64_MSR_VP_ASSIST_PAGE MSR may not be
    restored yet). Enlightened VMCS is mapped later while getting nested state
    pages. In the meantime, vmx->nested.hv_evmcs_vmptr remains 'EVMPTR_INVALID'
    and it's indistinguishable from 'evmcs is not in use' case. This leads to
    certain issues, in particular, if KVM_GET_NESTED_STATE is called right
    after KVM_SET_NESTED_STATE, KVM_STATE_NESTED_EVMCS flag in the resulting
    state will be unset (and such state will later fail to load).
    
    Introduce 'EVMPTR_MAP_PENDING' state to detect not-yet-mapped eVMCS after
    restore. With this, the 'is_guest_mode(vcpu)' hack in vmx_has_valid_vmcs12()
    is no longer needed.
    Signed-off-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    Message-Id: <20210526132026.270394-6-vkuznets@redhat.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    27849968
nested.c 205 KB