qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>, Igor Mammedov <imammedo@redhat.com>
Subject: [Qemu-devel] [PATCH v4 4/6] target-i386: Isolate enabled-by-default features to a separate array
Date: Mon, 15 Dec 2014 16:44:57 -0200	[thread overview]
Message-ID: <1418669099-30322-5-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1418669099-30322-1-git-send-email-ehabkost@redhat.com>

This will make it easier to write unit tests for the feature
initialization logic.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 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 e9df33e..b6b3c4f 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_8000_0001_ECX] = CPUID_EXT3_SVM,
 };
 
+/* 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_kvm_no_autoenable(FeatureWord w, uint32_t features)
 {
     kvm_default_features[w] &= ~features;
@@ -2005,15 +2010,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

  parent reply	other threads:[~2014-12-15 18:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-15 18:44 [Qemu-devel] [PATCH v4 0/6] Target-specific unit test support, add unit tests for target-i386/cpu.c code Eduardo Habkost
2014-12-15 18:44 ` [Qemu-devel] [PATCH v4 1/6] tests: Support target-specific unit tests Eduardo Habkost
2014-12-15 18:44 ` [Qemu-devel] [PATCH v4 2/6] tests: Make test-x86-cpuid target-specific Eduardo Habkost
2014-12-15 18:44 ` [Qemu-devel] [PATCH v4 3/6] tests: Add unit test for X86CPU code Eduardo Habkost
2014-12-15 18:44 ` Eduardo Habkost [this message]
2014-12-15 18:44 ` [Qemu-devel] [PATCH v4 5/6] tests: test-x86-cpu: Add TCG feature bit initialization test Eduardo Habkost
2014-12-15 18:44 ` [Qemu-devel] [PATCH v4 6/6] tests: test-x86-cpu: Add KVM " Eduardo Habkost

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1418669099-30322-5-git-send-email-ehabkost@redhat.com \
    --to=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).