[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] target/i386/kvm: call kvm_put_vcpu_events() before kvm_put_n
From: |
Vitaly Kuznetsov |
Subject: |
Re: [PATCH] target/i386/kvm: call kvm_put_vcpu_events() before kvm_put_nested_state() |
Date: |
Tue, 16 Jan 2024 10:31:51 +0100 |
As I'm the addressee of the ping for some reason ... :-)
the fix looks good to me but I'm not sure about all the consequences of
moving kvm_put_vcpu_events() to an earlier stage. Max, Paolo, please
take a look!
Eiichi Tsukata <eiichi.tsukata@nutanix.com> writes:
> Ping.
>
>> On Nov 8, 2023, at 10:12, Eiichi Tsukata <eiichi.tsukata@nutanix.com> wrote:
>>
>> Hi all, appreciate any comments or feedbacks on the patch.
>>
>> Thanks,
>> Eiichi
>>
>>> On Nov 1, 2023, at 23:04, Vitaly Kuznetsov <vkuznets@redhat.com> wrote:
>>>
>>> Eiichi Tsukata <eiichi.tsukata@nutanix.com> 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
>>>
>>
>
--
Vitaly