From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJTxE-0002H0-Rl for qemu-devel@nongnu.org; Fri, 28 Feb 2014 15:22:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WJTx8-0006SR-Ni for qemu-devel@nongnu.org; Fri, 28 Feb 2014 15:22:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39714) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJTx8-0006SN-Fj for qemu-devel@nongnu.org; Fri, 28 Feb 2014 15:22:38 -0500 From: Eduardo Habkost Date: Fri, 28 Feb 2014 17:21:52 -0300 Message-Id: <1393618913-12411-10-git-send-email-ehabkost@redhat.com> In-Reply-To: <1393618913-12411-1-git-send-email-ehabkost@redhat.com> References: <1393618913-12411-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [qom-cpu PATCH 09/10] target-i386: Loop-based feature word filtering in TCG mode List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= Cc: Igor Mammedov , Richard Henderson , Aurelien Jarno , Paolo Bonzini Instead of manually filtering each feature word, add a tcg_features field to FeatureWordInfo, and use that field to filter all feature words in TCG mode. Signed-off-by: Eduardo Habkost --- target-i386/cpu.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index b146d12..f4b2674 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -326,42 +326,51 @@ typedef struct FeatureWordInfo { bool cpuid_needs_ecx; /* CPUID instruction uses ECX as input */ uint32_t cpuid_ecx; /* Input ECX value for CPUID */ int cpuid_reg; /* output register (R_* constant) */ + uint32_t tcg_features; /* Feature flags supported by TCG */ } FeatureWordInfo; static FeatureWordInfo feature_word_info[FEATURE_WORDS] = { [FEAT_1_EDX] = { .feat_names = feature_name, .cpuid_eax = 1, .cpuid_reg = R_EDX, + .tcg_features = TCG_FEATURES, }, [FEAT_1_ECX] = { .feat_names = ext_feature_name, .cpuid_eax = 1, .cpuid_reg = R_ECX, + .tcg_features = TCG_EXT_FEATURES, }, [FEAT_8000_0001_EDX] = { .feat_names = ext2_feature_name, .cpuid_eax = 0x80000001, .cpuid_reg = R_EDX, + .tcg_features = TCG_EXT2_FEATURES, }, [FEAT_8000_0001_ECX] = { .feat_names = ext3_feature_name, .cpuid_eax = 0x80000001, .cpuid_reg = R_ECX, + .tcg_features = TCG_EXT3_FEATURES, }, [FEAT_C000_0001_EDX] = { .feat_names = ext4_feature_name, .cpuid_eax = 0xC0000001, .cpuid_reg = R_EDX, + .tcg_features = TCG_EXT4_FEATURES, }, [FEAT_KVM] = { .feat_names = kvm_feature_name, .cpuid_eax = KVM_CPUID_FEATURES, .cpuid_reg = R_EAX, + .tcg_features = TCG_KVM_FEATURES, }, [FEAT_SVM] = { .feat_names = svm_feature_name, .cpuid_eax = 0x8000000A, .cpuid_reg = R_EDX, + .tcg_features = TCG_SVM_FEATURES, }, [FEAT_7_0_EBX] = { .feat_names = cpuid_7_0_ebx_feature_name, .cpuid_eax = 7, .cpuid_needs_ecx = true, .cpuid_ecx = 0, .cpuid_reg = R_EBX, + .tcg_features = TCG_7_0_EBX_FEATURES, }, }; @@ -2531,14 +2540,10 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) } if (!kvm_enabled()) { - env->features[FEAT_1_EDX] &= TCG_FEATURES; - env->features[FEAT_1_ECX] &= TCG_EXT_FEATURES; - env->features[FEAT_7_0_EBX] &= TCG_7_0_EBX_FEATURES; - env->features[FEAT_8000_0001_EDX] &= TCG_EXT2_FEATURES; - env->features[FEAT_8000_0001_ECX] &= TCG_EXT3_FEATURES; - env->features[FEAT_SVM] &= TCG_SVM_FEATURES; - env->features[FEAT_KVM] &= TCG_KVM_FEATURES; - env->features[FEAT_C000_0001_EDX] &= TCG_EXT4_FEATURES; + FeatureWord w; + for (w = 0; w < FEATURE_WORDS; w++) { + env->features[w] &= feature_word_info[w].tcg_features; + } } else { if (x86_cpu_filter_features(cpu) && cpu->enforce_cpuid) { error_setg(&local_err, -- 1.8.5.3