qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: Eiichi Tsukata <eiichi.tsukata@nutanix.com>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	Maxim Levitsky <mlevitsk@redhat.com>
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"mtosatti@redhat.com" <mtosatti@redhat.com>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
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	[thread overview]
Message-ID: <87cyu1bp4o.fsf@redhat.com> (raw)
In-Reply-To: <585D19C7-80BD-4599-ABBD-A0FE25F0ACB9@nutanix.com>

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



      reply	other threads:[~2024-01-16  9:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-26  5:42 [PATCH] target/i386/kvm: call kvm_put_vcpu_events() before kvm_put_nested_state() Eiichi Tsukata
2023-10-26  5:49 ` Eiichi Tsukata
2023-10-26  5:52   ` Philippe Mathieu-Daudé
2023-10-26  8:52     ` Vitaly Kuznetsov
2023-11-01  2:09       ` Eiichi Tsukata
2023-11-01 14:04         ` Vitaly Kuznetsov
2023-11-08  1:12           ` Eiichi Tsukata
2024-01-16  0:13             ` Eiichi Tsukata
2024-01-16  9:31               ` Vitaly Kuznetsov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87cyu1bp4o.fsf@redhat.com \
    --to=vkuznets@redhat.com \
    --cc=eiichi.tsukata@nutanix.com \
    --cc=kvm@vger.kernel.org \
    --cc=mlevitsk@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).