Hi all, appreciate any comments or feedbacks on the patch. Thanks, Eiichi > On Nov 1, 2023, at 23:04, Vitaly Kuznetsov <vkuznets@xxxxxxxxxx> wrote: > > Eiichi Tsukata <eiichi.tsukata@xxxxxxxxxxx> writes: > >> FYI: The EINVAL in vmx_set_nested_state() is caused by the following condition: >> * vcpu->arch.hflags == 0 >> * kvm_state->hdr.vmx.smm.flags == KVM_STATE_NESTED_SMM_VMXON > > This is a weird state indeed, > > 'vcpu->arch.hflags == 0' means we're not in SMM and not in guest mode > but kvm_state->hdr.vmx.smm.flags == KVM_STATE_NESTED_SMM_VMXON is a > reflection of vmx->nested.smm.vmxon (see > vmx_get_nested_state()). vmx->nested.smm.vmxon gets set (conditioally) > in vmx_enter_smm() and gets cleared in vmx_leave_smm() which means the > vCPU must be in SMM to have it set. > > In case the vCPU is in SMM upon migration, HF_SMM_MASK must be set from > kvm_vcpu_ioctl_x86_set_vcpu_events() -> kvm_smm_changed() but QEMU's > kvm_put_vcpu_events() calls kvm_put_nested_state() _before_ > kvm_put_vcpu_events(). This can explain "vcpu->arch.hflags == 0". > > Paolo, Max, any idea how this is supposed to work? > > -- > Vitaly >