Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mobzn-0007tH-Kk for qemu-devel@nongnu.org; Fri, 18 Sep 2009 07:51:24 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mobze-0007q4-8W for qemu-devel@nongnu.org; Fri, 18 Sep 2009 07:51:19 -0400 Received: from [199.232.76.173] (port=38461 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mobze-0007pz-2V for qemu-devel@nongnu.org; Fri, 18 Sep 2009 07:51:14 -0400 Received: from va3ehsobe002.messaging.microsoft.com ([216.32.180.12]:21011 helo=VA3EHSOBE002.bigfish.com) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_MD5:16) (Exim 4.60) (envelope-from ) id 1Mobzd-0003L5-Mk for qemu-devel@nongnu.org; Fri, 18 Sep 2009 07:51:13 -0400 Received: from mail109-va3 (localhost.localdomain [127.0.0.1]) by mail109-va3-R.bigfish.com (Postfix) with ESMTP id 633631570191 for ; Fri, 18 Sep 2009 11:51:10 +0000 (UTC) Received: from svlb1extmailp02.amd.com (unknown [139.95.251.11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail109-va3.bigfish.com (Postfix) with ESMTP id AC33F14D8068 for ; Fri, 18 Sep 2009 11:51:08 +0000 (UTC) Received: from svlb1twp01.amd.com ([139.95.250.34]) by svlb1extmailp02.amd.com (Switch-3.2.7/Switch-3.2.7) with ESMTP id n8IBoxD1032266 for ; Fri, 18 Sep 2009 04:51:05 -0700 Received: from SSVLEXBH2.amd.com (ssvlexbh2.amd.com [139.95.53.183]) by svlb1twp01.amd.com (Tumbleweed MailGate 3.7.0) with ESMTP id 2DA5019A0145 for ; Fri, 18 Sep 2009 04:51:04 -0700 (PDT) From: Andre Przywara Date: Fri, 18 Sep 2009 13:48:06 +0200 Message-ID: <1253274494-13244-14-git-send-email-andre.przywara@amd.com> In-Reply-To: <1253274494-13244-1-git-send-email-andre.przywara@amd.com> References: <1253274494-13244-1-git-send-email-andre.przywara@amd.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH v2 13/21] cpuid: add TCG feature bit trimming List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Andre Przywara 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. (which will be send in a later patch). Signed-off-by: Andre Przywara --- target-i386/cpuid.c | 27 ++++++++++++++++++++++++--- 1 files changed, 24 insertions(+), 3 deletions(-) diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c index e76457c..9f43ccd 100644 --- a/target-i386/cpuid.c +++ b/target-i386/cpuid.c @@ -131,6 +131,19 @@ 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_3DNOW | \ + CPUID_EXT2_3DNOWEXT) +#define TCG_EXT3_FEATURES (CPUID_EXT3_LAHF_LM | CPUID_EXT3_SVM) + static x86_def_t x86_defs[] = { #ifdef TARGET_X86_64 { @@ -598,6 +611,17 @@ int cpu_x86_register (CPUX86State *env, const char *cpu_model) env->cpuid_ext2_features = def->ext2_features; env->cpuid_xlevel = def->xlevel; env->cpuid_ext3_features = def->ext3_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); +#else + ); +#endif + env->cpuid_ext3_features &= TCG_EXT3_FEATURES; + } { const char *model_id = def->model_id; int c, len, i; @@ -778,9 +802,6 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, if (kvm_enabled()) { /* Nested SVM not yet supported in upstream QEMU */ *ecx &= ~CPUID_EXT3_SVM; - } else { - /* AMD 3DNow! is not supported in QEMU */ - *edx &= ~(CPUID_EXT2_3DNOW | CPUID_EXT2_3DNOWEXT); } break; case 0x80000002: -- 1.6.1.3