From: Eiichi Tsukata <eiichi.tsukata@nutanix.com>
To: pbonzini@redhat.com, mtosatti@redhat.com, kvm@vger.kernel.org,
qemu-devel@nongnu.org
Cc: Eiichi Tsukata <eiichi.tsukata@nutanix.com>
Subject: [PATCH] target/i386/kvm: call kvm_put_vcpu_events() before kvm_put_nested_state()
Date: Thu, 26 Oct 2023 05:42:01 +0000 [thread overview]
Message-ID: <20231026054201.87845-1-eiichi.tsukata@nutanix.com> (raw)
kvm_put_vcpu_events() needs to be called before kvm_put_nested_state()
because vCPU's hflag is referred in KVM vmx_get_nested_state()
validation. Otherwise kvm_put_nested_state() can fail with -EINVAL when
a vCPU is in VMX operation and enters SMM mode. This leads to live
migration failure.
Signed-off-by: Eiichi Tsukata <eiichi.tsukata@nutanix.com>
---
target/i386/kvm/kvm.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index e7c054cc16..cd635c9142 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -4741,6 +4741,15 @@ int kvm_arch_put_registers(CPUState *cpu, int level)
return ret;
}
+ /*
+ * must be before kvm_put_nested_state so that HF_SMM_MASK is set during
+ * SMM.
+ */
+ ret = kvm_put_vcpu_events(x86_cpu, level);
+ if (ret < 0) {
+ return ret;
+ }
+
if (level >= KVM_PUT_RESET_STATE) {
ret = kvm_put_nested_state(x86_cpu);
if (ret < 0) {
@@ -4787,10 +4796,6 @@ int kvm_arch_put_registers(CPUState *cpu, int level)
if (ret < 0) {
return ret;
}
- ret = kvm_put_vcpu_events(x86_cpu, level);
- if (ret < 0) {
- return ret;
- }
if (level >= KVM_PUT_RESET_STATE) {
ret = kvm_put_mp_state(x86_cpu);
if (ret < 0) {
--
2.41.0
next reply other threads:[~2023-10-26 5:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-26 5:42 Eiichi Tsukata [this message]
2023-10-26 5:49 ` [PATCH] target/i386/kvm: call kvm_put_vcpu_events() before kvm_put_nested_state() 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
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=20231026054201.87845-1-eiichi.tsukata@nutanix.com \
--to=eiichi.tsukata@nutanix.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--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).