aboutsummaryrefslogtreecommitdiff
path: root/target-i386
diff options
context:
space:
mode:
authorEduardo Habkost <ehabkost@redhat.com>2014-04-30 13:48:37 -0300
committerAndreas Färber <afaerber@suse.de>2014-06-25 23:54:57 +0200
commite1c224b4eb3b8693c230bb2762a959ae1f531f76 (patch)
tree2f5b64cda32f351567e2a20ad78272d082331963 /target-i386
parent621626ce7d44f008298c7e6cfefa9fbb80a33dc2 (diff)
target-i386: Loop-based copying and setting/unsetting of feature words
Now that we have the feature word arrays, we don't need to manually copy each array item, we can simply iterate through each feature word. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'target-i386')
-rw-r--r--target-i386/cpu.c35
1 files changed, 10 insertions, 25 deletions
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 6eb5f05f40..d05b8ecb1b 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1649,6 +1649,7 @@ static void x86_cpu_parse_featurestr(CPUState *cs, char *features,
{
X86CPU *cpu = X86_CPU(cs);
char *featurestr; /* Single 'key=value" string being parsed */
+ FeatureWord w;
/* Features to be added */
FeatureWordArray plus_features = { 0 };
/* Features to be removed */
@@ -1728,22 +1729,11 @@ static void x86_cpu_parse_featurestr(CPUState *cs, char *features,
}
featurestr = strtok(NULL, ",");
}
- env->features[FEAT_1_EDX] |= plus_features[FEAT_1_EDX];
- env->features[FEAT_1_ECX] |= plus_features[FEAT_1_ECX];
- env->features[FEAT_8000_0001_EDX] |= plus_features[FEAT_8000_0001_EDX];
- env->features[FEAT_8000_0001_ECX] |= plus_features[FEAT_8000_0001_ECX];
- env->features[FEAT_C000_0001_EDX] |= plus_features[FEAT_C000_0001_EDX];
- env->features[FEAT_KVM] |= plus_features[FEAT_KVM];
- env->features[FEAT_SVM] |= plus_features[FEAT_SVM];
- env->features[FEAT_7_0_EBX] |= plus_features[FEAT_7_0_EBX];
- env->features[FEAT_1_EDX] &= ~minus_features[FEAT_1_EDX];
- env->features[FEAT_1_ECX] &= ~minus_features[FEAT_1_ECX];
- env->features[FEAT_8000_0001_EDX] &= ~minus_features[FEAT_8000_0001_EDX];
- env->features[FEAT_8000_0001_ECX] &= ~minus_features[FEAT_8000_0001_ECX];
- env->features[FEAT_C000_0001_EDX] &= ~minus_features[FEAT_C000_0001_EDX];
- env->features[FEAT_KVM] &= ~minus_features[FEAT_KVM];
- env->features[FEAT_SVM] &= ~minus_features[FEAT_SVM];
- env->features[FEAT_7_0_EBX] &= ~minus_features[FEAT_7_0_EBX];
+
+ for (w = 0; w < FEATURE_WORDS; w++) {
+ env->features[w] |= plus_features[w];
+ env->features[w] &= ~minus_features[w];
+ }
}
/* generate a composite string into buf of all cpuid names in featureset
@@ -1872,24 +1862,19 @@ static void x86_cpu_load_def(X86CPU *cpu, X86CPUDefinition *def, Error **errp)
CPUX86State *env = &cpu->env;
const char *vendor;
char host_vendor[CPUID_VENDOR_SZ + 1];
+ FeatureWord w;
object_property_set_int(OBJECT(cpu), def->level, "level", errp);
object_property_set_int(OBJECT(cpu), def->family, "family", errp);
object_property_set_int(OBJECT(cpu), def->model, "model", errp);
object_property_set_int(OBJECT(cpu), def->stepping, "stepping", errp);
- env->features[FEAT_1_EDX] = def->features[FEAT_1_EDX];
- env->features[FEAT_1_ECX] = def->features[FEAT_1_ECX];
- env->features[FEAT_8000_0001_EDX] = def->features[FEAT_8000_0001_EDX];
- env->features[FEAT_8000_0001_ECX] = def->features[FEAT_8000_0001_ECX];
object_property_set_int(OBJECT(cpu), def->xlevel, "xlevel", errp);
- env->features[FEAT_KVM] = def->features[FEAT_KVM];
- env->features[FEAT_SVM] = def->features[FEAT_SVM];
- env->features[FEAT_C000_0001_EDX] = def->features[FEAT_C000_0001_EDX];
- env->features[FEAT_7_0_EBX] = def->features[FEAT_7_0_EBX];
env->cpuid_xlevel2 = def->xlevel2;
cpu->cache_info_passthrough = def->cache_info_passthrough;
-
object_property_set_str(OBJECT(cpu), def->model_id, "model-id", errp);
+ for (w = 0; w < FEATURE_WORDS; w++) {
+ env->features[w] = def->features[w];
+ }
/* Special cases not set in the X86CPUDefinition structs: */
if (kvm_enabled()) {