From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Ake Koomsin <ake@igel.co.jp>
Subject: [PULL 12/14] target/i386: add support for VMX_SECONDARY_EXEC_ENABLE_USER_WAIT_PAUSE
Date: Mon, 28 Aug 2023 12:38:51 +0200 [thread overview]
Message-ID: <20230828103856.46031-13-pbonzini@redhat.com> (raw)
In-Reply-To: <20230828103856.46031-1-pbonzini@redhat.com>
From: Ake Koomsin <ake@igel.co.jp>
Current QEMU can expose waitpkg to guests when it is available. However,
VMX_SECONDARY_EXEC_ENABLE_USER_WAIT_PAUSE is still not recognized and
masked by QEMU. This can lead to an unexpected situation when a L1
hypervisor wants to expose waitpkg to a L2 guest. The L1 hypervisor can
assume that VMX_SECONDARY_EXEC_ENABLE_USER_WAIT_PAUSE exists as waitpkg is
available. The L1 hypervisor then can accidentally expose waitpkg to the
L2 guest. This will cause invalid opcode exception in the L2 guest when
it executes waitpkg related instructions.
This patch adds VMX_SECONDARY_EXEC_ENABLE_USER_WAIT_PAUSE support, and
sets up dependency between the bit and CPUID_7_0_ECX_WAITPKG. QEMU should
not expose waitpkg feature if VMX_SECONDARY_EXEC_ENABLE_USER_WAIT_PAUSE is
not available to avoid unexpected invalid opcode exception in L2 guests.
Signed-off-by: Ake Koomsin <ake@igel.co.jp>
Message-ID: <20230807093339.32091-2-ake@igel.co.jp>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
target/i386/cpu.c | 6 +++++-
target/i386/cpu.h | 1 +
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 97ad229d8ba..00f913b6382 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -1228,7 +1228,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
"vmx-invpcid-exit", "vmx-vmfunc", "vmx-shadow-vmcs", "vmx-encls-exit",
"vmx-rdseed-exit", "vmx-pml", NULL, NULL,
"vmx-xsaves", NULL, NULL, NULL,
- NULL, "vmx-tsc-scaling", NULL, NULL,
+ NULL, "vmx-tsc-scaling", "vmx-enable-user-wait-pause", NULL,
NULL, NULL, NULL, NULL,
},
.msr = {
@@ -1545,6 +1545,10 @@ static FeatureDep feature_dependencies[] = {
.from = { FEAT_8000_0001_ECX, CPUID_EXT3_SVM },
.to = { FEAT_SVM, ~0ull },
},
+ {
+ .from = { FEAT_VMX_SECONDARY_CTLS, VMX_SECONDARY_EXEC_ENABLE_USER_WAIT_PAUSE },
+ .to = { FEAT_7_0_ECX, CPUID_7_0_ECX_WAITPKG },
+ },
};
typedef struct X86RegisterInfo32 {
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index e0771a10433..a6000e93bd8 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1111,6 +1111,7 @@ uint64_t x86_cpu_get_supported_feature_word(FeatureWord w,
#define VMX_SECONDARY_EXEC_ENABLE_PML 0x00020000
#define VMX_SECONDARY_EXEC_XSAVES 0x00100000
#define VMX_SECONDARY_EXEC_TSC_SCALING 0x02000000
+#define VMX_SECONDARY_EXEC_ENABLE_USER_WAIT_PAUSE 0x04000000
#define VMX_PIN_BASED_EXT_INTR_MASK 0x00000001
#define VMX_PIN_BASED_NMI_EXITING 0x00000008
--
2.41.0
next prev parent reply other threads:[~2023-08-28 10:41 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-28 10:38 [PULL 00/14] Python, i386 changes for 2023-08-28 Paolo Bonzini
2023-08-28 10:38 ` [PULL 01/14] configure: fix and complete detection of tricore tools Paolo Bonzini
2023-08-28 10:38 ` [PULL 02/14] dockerfiles: bump tricore cross compiler container to Debian 11 Paolo Bonzini
2023-08-28 10:38 ` [PULL 03/14] python: mkvenv: tweak the matching of --diagnose to depspecs Paolo Bonzini
2023-08-28 10:38 ` [PULL 04/14] python: mkvenv: introduce TOML-like representation of dependencies Paolo Bonzini
2023-08-28 10:38 ` [PULL 05/14] python: mkvenv: add ensuregroup command Paolo Bonzini
2023-08-28 10:38 ` [PULL 06/14] lcitool: bump libvirt-ci submodule and regenerate Paolo Bonzini
2023-08-28 10:38 ` [PULL 07/14] configure: never use PyPI for Meson Paolo Bonzini
2023-08-28 10:38 ` [PULL 08/14] python: use vendored tomli Paolo Bonzini
2023-08-28 10:38 ` [PULL 09/14] configure: switch to ensuregroup Paolo Bonzini
2023-08-28 10:38 ` [PULL 10/14] Revert "tests: Use separate virtual environment for avocado" Paolo Bonzini
2023-08-28 10:38 ` [PULL 11/14] tests/docker: add python3-tomli dependency to containers Paolo Bonzini
2023-08-28 10:38 ` Paolo Bonzini [this message]
2023-08-28 10:38 ` [PULL 13/14] configure: fix container_hosts misspellings and duplications Paolo Bonzini
2023-08-28 10:38 ` [PULL 14/14] configure: remove unnecessary mkdir -p Paolo Bonzini
2023-08-28 21:14 ` [PULL 00/14] Python, i386 changes for 2023-08-28 Stefan Hajnoczi
2023-08-29 13:43 ` Stefan Hajnoczi
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=20230828103856.46031-13-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=ake@igel.co.jp \
--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).