From: Yuchen <yu.chen@h3c.com>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "pbonzini@redhat.com" <pbonzini@redhat.com>,
"rth@twiddle.net" <rth@twiddle.net>,
"ehabkost@redhat.com" <ehabkost@redhat.com>,
Chengchiwen <chengchiwen@h3c.com>
Subject: [PATCH] target/i386: Clear xsave pkru bit when KVM XCR0 not support
Date: Wed, 17 May 2023 10:55:13 +0000 [thread overview]
Message-ID: <914d4bfc6901485c9f029ce26ceb7d10@h3c.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2221 bytes --]
Migrating guest from Intel new CPU (as Gold 6230) to old CPU (as
E5-2650 v4) will pause on the destination host. Because old CPU
not support xsave pkru feature, and KVM KVM_SET_XSAVE ioctl
return EINVAL.
This kernel commit introduces the problem:
ea4d6938d4c0 x86/fpu: Replace KVMs home brewed FPU copy from user
Signed-off-by: YuChen <yu.chen@h3c.com>
---
target/i386/xsave_helper.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/target/i386/xsave_helper.c b/target/i386/xsave_helper.c
index 996e9f3bfe..64e2b969fe 100644
--- a/target/i386/xsave_helper.c
+++ b/target/i386/xsave_helper.c
@@ -6,6 +6,8 @@
#include "cpu.h"
+static bool has_xsave_pkru;
+
void x86_cpu_xsave_all_areas(X86CPU *cpu, void *buf, uint32_t buflen)
{
CPUX86State *env = &cpu->env;
@@ -47,6 +49,9 @@ void x86_cpu_xsave_all_areas(X86CPU *cpu, void *buf, uint32_t buflen)
stq_p(xmm + 8, env->xmm_regs[i].ZMM_Q(1));
}
+ if (!has_xsave_pkru) {
+ env->xstate_bv &= ~XSTATE_PKRU_MASK;
+ }
header->xstate_bv = env->xstate_bv;
e = &x86_ext_save_areas[XSTATE_YMM_BIT];
@@ -181,6 +186,9 @@ void x86_cpu_xrstor_all_areas(X86CPU *cpu, const void *buf, uint32_t buflen)
env->xmm_regs[i].ZMM_Q(1) = ldq_p(xmm + 8);
}
+ if (xsave->header.xstate_bv & XSTATE_PKRU_MASK) {
+ has_xsave_pkru = true;
+ }
env->xstate_bv = header->xstate_bv;
e = &x86_ext_save_areas[XSTATE_YMM_BIT];
--
2.34.1
-------------------------------------------------------------------------------------------------------------------------------------
?????????????????????????????????
????????????????????????????????????????
????????????????????????????????????????
???
This e-mail and its attachments contain confidential information from New H3C, which is
intended only for the person or entity whose address is listed above. Any use of the
information contained herein in any way (including, but not limited to, total or partial
disclosure, reproduction, or dissemination) by persons other than the intended
recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender
by phone or email immediately and delete it!
[-- Attachment #2: Type: text/html, Size: 12205 bytes --]
next reply other threads:[~2023-05-17 10:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-17 10:55 Yuchen [this message]
2023-05-17 17:08 ` [PATCH] target/i386: Clear xsave pkru bit when KVM XCR0 not support Paolo Bonzini
[not found] ` <6c64f1b84cbf4dd1a75301fc4615f351@h3c.com>
[not found] ` <e7c5d527-2461-332e-638f-38c95ff2602d@redhat.com>
2023-05-20 1:57 ` 回复: 回复: " Yuchen
2023-05-20 6:21 ` Yuchen
2023-05-17 17:17 ` Dongli Zhang
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=914d4bfc6901485c9f029ce26ceb7d10@h3c.com \
--to=yu.chen@h3c.com \
--cc=chengchiwen@h3c.com \
--cc=ehabkost@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).