[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 09/13] x86/cpuid: add TCG feature bit trimming
From: |
Andre Przywara |
Subject: |
[Qemu-devel] [PATCH 09/13] x86/cpuid: add TCG feature bit trimming |
Date: |
Thu, 11 Mar 2010 14:39:03 +0100 |
In KVM we trim the user provided CPUID bits to match the host CPU's
one. Introduce a similar feature to QEMU/TCG. Create a mask of TCG's
capabilities and apply it to the user bits.
This allows to let the CPU models reflect their native archetypes.
Signed-off-by: Andre Przywara <address@hidden>
---
target-i386/cpuid.c | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index 14a10e9..a6b2362 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -229,6 +229,20 @@ typedef struct x86_def_t {
CPUID_PAE | CPUID_SEP | CPUID_APIC)
#define EXT2_FEATURE_MASK 0x0183F3FF
+#define TCG_FEATURES (CPUID_FP87 | CPUID_PSE | CPUID_TSC | CPUID_MSR | \
+ CPUID_PAE | CPUID_MCE | CPUID_CX8 | CPUID_APIC | CPUID_SEP | \
+ CPUID_MTRR | CPUID_PGE | CPUID_MCA | CPUID_CMOV | CPUID_PAT | \
+ CPUID_PSE36 | CPUID_CLFLUSH | CPUID_ACPI | CPUID_MMX | \
+ CPUID_FXSR | CPUID_SSE | CPUID_SSE2 | CPUID_SS)
+#define TCG_EXT_FEATURES (CPUID_EXT_SSE3 | CPUID_EXT_MONITOR | \
+ CPUID_EXT_CX16 | CPUID_EXT_POPCNT | CPUID_EXT_XSAVE | \
+ CPUID_EXT_HYPERVISOR)
+#define TCG_EXT2_FEATURES ((TCG_FEATURES & EXT2_FEATURE_MASK) | \
+ CPUID_EXT2_NX | CPUID_EXT2_MMXEXT | CPUID_EXT2_RDTSCP | \
+ CPUID_EXT2_3DNOW | CPUID_EXT2_3DNOWEXT)
+#define TCG_EXT3_FEATURES (CPUID_EXT3_LAHF_LM | CPUID_EXT3_SVM | \
+ CPUID_EXT3_CR8LEG | CPUID_EXT3_ABM | CPUID_EXT3_SSE4A)
+
/* maintains list of cpu model definitions
*/
static x86_def_t *x86_defs = {NULL};
@@ -792,6 +806,16 @@ int cpu_x86_register (CPUX86State *env, const char
*cpu_model)
env->cpuid_ext3_features = def->ext3_features;
env->cpuid_xlevel = def->xlevel;
env->cpuid_kvm_features = def->kvm_features;
+ if (!kvm_enabled()) {
+ env->cpuid_features &= TCG_FEATURES;
+ env->cpuid_ext_features &= TCG_EXT_FEATURES;
+ env->cpuid_ext2_features &= (TCG_EXT2_FEATURES
+#ifdef TARGET_X86_64
+ | CPUID_EXT2_SYSCALL | CPUID_EXT2_LM
+#endif
+ );
+ env->cpuid_ext3_features &= TCG_EXT3_FEATURES;
+ }
{
const char *model_id = def->model_id;
int c, len, i;
--
1.6.4
- [Qemu-devel] [PATCH 00/13] x86/cpuid: cleanups and fixes, Andre Przywara, 2010/03/11
- [Qemu-devel] [PATCH 03/13] x86/cpuid: fix missing feature set bits, Andre Przywara, 2010/03/11
- [Qemu-devel] [PATCH 06/13] x86/cpuid: add "host" to the list of supported CPU models, Andre Przywara, 2010/03/11
- [Qemu-devel] [PATCH 08/13] x86/cpuid: propagate further CPUID leafs when -cpu host, Andre Przywara, 2010/03/11
- [Qemu-devel] [PATCH 12/13] x86/cpuid: fix CPUID levels, Andre Przywara, 2010/03/11
- [Qemu-devel] [PATCH 09/13] x86/cpuid: add TCG feature bit trimming,
Andre Przywara <=
- [Qemu-devel] [PATCH 04/13] x86/cpuid: moved host_cpuid function and remove prototype, Andre Przywara, 2010/03/11
- [Qemu-devel] [PATCH 13/13] x86/cpuid: Update qemu64/32 CPU models, Andre Przywara, 2010/03/11
- [Qemu-devel] [PATCH 10/13] x86/cpuid: Always expose 32 and 64-bit CPUs, Andre Przywara, 2010/03/11
- [Qemu-devel] [PATCH 02/13] x86/cpuid: replace magic number with named constant, Andre Przywara, 2010/03/11
- [Qemu-devel] [PATCH 07/13] x86/cpuid: remove unnecessary kvm_trim function, Andre Przywara, 2010/03/11
- [Qemu-devel] [PATCH 01/13] x86/cpuid: move CPUID functions into separate file, Andre Przywara, 2010/03/11
- [Qemu-devel] [PATCH 05/13] x86/cpuid: add missing CPUID feature flag names, Andre Przywara, 2010/03/11
- [Qemu-devel] [PATCH 11/13] x86/cpuid: Add kvm32 CPU model, Andre Przywara, 2010/03/11
- Re: [Qemu-devel] [PATCH 00/13] x86/cpuid: cleanups and fixes, Aurelien Jarno, 2010/03/13