From: Xiaoyao Li <xiaoyao.li@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, xiaoyao.li@intel.com
Subject: [PATCH 7/9] i386/cpu: Suppress CPUID values not defined by Intel
Date: Wed, 14 Aug 2024 03:54:29 -0400 [thread overview]
Message-ID: <20240814075431.339209-8-xiaoyao.li@intel.com> (raw)
In-Reply-To: <20240814075431.339209-1-xiaoyao.li@intel.com>
Some CPUID leaves are defined by AMD while it also gets exposed to Intel
VMs by QEMU. It causes no issue with current VMs however it will not work
with Intel TDX because these CPUID leaves are enforced by TDX module as
reserved.
Stop to advertise them to Intel VMs when vendor_cpuid_only is true.
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
target/i386/cpu.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 7a4835289760..fed805e04aeb 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -6863,12 +6863,16 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
break;
case 0x80000000:
*eax = env->cpuid_xlevel;
- *ebx = env->cpuid_vendor1;
- *edx = env->cpuid_vendor2;
- *ecx = env->cpuid_vendor3;
+ if (cpu->vendor_cpuid_only && IS_INTEL_CPU(env)) {
+ *ebx = *ecx = *edx = 0;
+ } else {
+ *ebx = env->cpuid_vendor1;
+ *edx = env->cpuid_vendor2;
+ *ecx = env->cpuid_vendor3;
+ }
break;
case 0x80000001:
- *eax = env->cpuid_version;
+ *eax = (cpu->vendor_cpuid_only && IS_INTEL_CPU(env)) ? 0 : env->cpuid_version;
*ebx = 0;
*ecx = env->features[FEAT_8000_0001_ECX];
*edx = env->features[FEAT_8000_0001_EDX];
--
2.34.1
next prev parent reply other threads:[~2024-08-14 8:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-14 7:54 [PATCH 0/9] Misc patches for x86 CPUID Xiaoyao Li
2024-08-14 7:54 ` [PATCH 1/9] i386/cpu: Don't construct a all-zero entry for CPUID[0xD 0x3f] Xiaoyao Li
2024-08-14 7:54 ` [PATCH 2/9] i386/cpu: Enable fdp-excptn-only and zero-fcs-fds Xiaoyao Li
2024-08-14 7:54 ` [PATCH 3/9] i386/cpu: Add support for bits in CPUID.7_2.EDX Xiaoyao Li
2024-08-14 7:54 ` [PATCH 4/9] i386/cpu: Construct valid CPUID leaf 5 iff CPUID_EXT_MONITOR Xiaoyao Li
2024-08-14 7:54 ` [PATCH 5/9] i386/cpu: Construct CPUID 2 as stateful iff times > 1 Xiaoyao Li
2024-08-14 7:54 ` [PATCH 6/9] i386/cpu: Set topology info in 0x80000008.ECX only for AMD CPUs Xiaoyao Li
2024-08-14 11:47 ` Chenyi Qiang
2024-08-14 7:54 ` Xiaoyao Li [this message]
2024-08-14 7:54 ` [PATCH 8/9] i386/cpu: Drop AMD alias bits in FEAT_8000_0001_EDX for non-AMD guests Xiaoyao Li
2024-08-14 7:54 ` [PATCH 9/9] i386/cpu: Make invtsc migratable when user sets tsc-khz explicitly Xiaoyao Li
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=20240814075431.339209-8-xiaoyao.li@intel.com \
--to=xiaoyao.li@intel.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).