[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 08/16] target/i386: drop AMD machine check bits from Intel CPUID
From: |
Paolo Bonzini |
Subject: |
[PULL 08/16] target/i386: drop AMD machine check bits from Intel CPUID |
Date: |
Thu, 4 Jul 2024 11:57:58 +0200 |
The recent addition of the SUCCOR bit to kvm_arch_get_supported_cpuid()
causes the bit to be visible when "-cpu host" VMs are started on Intel
processors.
While this should in principle be harmless, it's not tidy and we don't
even know for sure that it doesn't cause any guest OS to take unexpected
paths. Since x86_cpu_get_supported_feature_word() can return different
different values depending on the guest, adjust it to hide the SUCCOR
bit if the guest has non-AMD vendor.
Suggested-by: Xiaoyao Li <xiaoyao.li@intel.com>
Cc: John Allen <john.allen@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
target/i386/cpu.c | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 4364cb0f8e3..5e5bf71702c 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -6039,6 +6039,7 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *cpu,
FeatureWord w)
{
FeatureWordInfo *wi = &feature_word_info[w];
uint64_t r = 0;
+ uint32_t unavail = 0;
if (kvm_enabled()) {
switch (wi->type) {
@@ -6064,19 +6065,33 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU
*cpu, FeatureWord w)
} else {
return ~0;
}
+
+ switch (w) {
#ifndef TARGET_X86_64
- if (w == FEAT_8000_0001_EDX) {
+ case FEAT_8000_0001_EDX:
/*
* 32-bit TCG can emulate 64-bit compatibility mode. If there is no
* way for userspace to get out of its 32-bit jail, we can leave
* the LM bit set.
*/
- uint32_t unavail = tcg_enabled()
+ unavail = tcg_enabled()
? CPUID_EXT2_LM & ~CPUID_EXT2_KERNEL_FEATURES
: CPUID_EXT2_LM;
- r &= ~unavail;
- }
+ break;
#endif
+
+ case FEAT_8000_0007_EBX:
+ if (cpu && !IS_AMD_CPU(&cpu->env)) {
+ /* Disable AMD machine check architecture for Intel CPU. */
+ unavail = ~0;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ r &= ~unavail;
if (cpu && cpu->migratable) {
r &= x86_cpu_get_migratable_flags(w);
}
--
2.45.2
- [PULL 00/16] meson, i386 changes for 2024-07-04, Paolo Bonzini, 2024/07/04
- [PULL 01/16] meson: move shared_module() calls where modules are already walked, Paolo Bonzini, 2024/07/04
- [PULL 02/16] meson: move block.syms dependency out of libblock, Paolo Bonzini, 2024/07/04
- [PULL 03/16] meson: merge plugin_ldflags into emulator_link_args, Paolo Bonzini, 2024/07/04
- [PULL 04/16] meson: Pass objects and dependencies to declare_dependency(), Paolo Bonzini, 2024/07/04
- [PULL 05/16] Revert "meson: Propagate gnutls dependency", Paolo Bonzini, 2024/07/04
- [PULL 06/16] meson: Drop the .fa library suffix, Paolo Bonzini, 2024/07/04
- [PULL 07/16] target/i386: pass X86CPU to x86_cpu_get_supported_feature_word, Paolo Bonzini, 2024/07/04
- [PULL 08/16] target/i386: drop AMD machine check bits from Intel CPUID,
Paolo Bonzini <=
- [PULL 11/16] i386/sev: Fix error message in sev_get_capabilities(), Paolo Bonzini, 2024/07/04
- [PULL 10/16] target/i386: do not include undefined bits in the AMD topoext leaf, Paolo Bonzini, 2024/07/04
- [PULL 13/16] target/i386: add avx-vnni-int16 feature, Paolo Bonzini, 2024/07/04
- [PULL 09/16] target/i386: SEV: fix formatting of CPUID mismatch message, Paolo Bonzini, 2024/07/04
- [PULL 14/16] char-stdio: Restore blocking mode of stdout on exit, Paolo Bonzini, 2024/07/04
- [PULL 12/16] i386/sev: Fallback to the default SEV device if none provided in sev_get_capabilities(), Paolo Bonzini, 2024/07/04
- [PULL 15/16] target/i386: add support for masking CPUID features in confidential guests, Paolo Bonzini, 2024/07/04
- [PULL 16/16] target/i386/SEV: implement mask_cpuid_features, Paolo Bonzini, 2024/07/04
- Re: [PULL 00/16] meson, i386 changes for 2024-07-04, Richard Henderson, 2024/07/04