From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34832) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXFVW-0000P9-E1 for qemu-devel@nongnu.org; Thu, 25 Sep 2014 16:19:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XXFVQ-0004vy-Au for qemu-devel@nongnu.org; Thu, 25 Sep 2014 16:19:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9700) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXFVP-0004uO-S3 for qemu-devel@nongnu.org; Thu, 25 Sep 2014 16:19:12 -0400 From: Eduardo Habkost Date: Thu, 25 Sep 2014 17:18:27 -0300 Message-Id: <1411676309-20218-9-git-send-email-ehabkost@redhat.com> In-Reply-To: <1411676309-20218-1-git-send-email-ehabkost@redhat.com> References: <1411676309-20218-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [RFC 08/10] target-i386: Isolate enabled-by-default features to a separate array List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Igor Mammedov , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Paolo Bonzini This will make it easier to write unit tests for the feature initialization logic. Signed-off-by: Eduardo Habkost --- 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 90d0a05..8d1af64 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -464,6 +464,11 @@ static uint32_t kvm_default_unset_features[FEATURE_WORDS] = { [FEAT_1_ECX] = CPUID_EXT_MONITOR, }; +/* Features that are added by default to all CPU models in any accelerator: */ +FeatureWordArray default_features_all = { + [FEAT_1_ECX] = CPUID_EXT_HYPERVISOR, +}; + void x86_cpu_compat_disable_kvm_features(FeatureWord w, uint32_t features) { kvm_default_features[w] &= ~features; @@ -1993,15 +1998,14 @@ static void x86_cpu_load_def(X86CPU *cpu, X86CPUDefinition *def, Error **errp) } /* Special cases not set in the X86CPUDefinition structs: */ - if (kvm_enabled()) { - FeatureWord w; - for (w = 0; w < FEATURE_WORDS; w++) { + for (w = 0; w < FEATURE_WORDS; w++) { + if (kvm_enabled()) { env->features[w] |= kvm_default_features[w]; env->features[w] &= ~kvm_default_unset_features[w]; } + env->features[w] |= default_features_all[w]; } - env->features[FEAT_1_ECX] |= CPUID_EXT_HYPERVISOR; /* sysenter isn't supported in compatibility mode on AMD, * syscall isn't supported in compatibility mode on Intel. -- 1.9.3