aboutsummaryrefslogtreecommitdiff
path: root/target-i386
diff options
context:
space:
mode:
authorEduardo Habkost <ehabkost@redhat.com>2014-04-30 13:48:32 -0300
committerAndreas Färber <afaerber@suse.de>2014-06-25 18:04:15 +0200
commit27418adf32b9cd164d464fffc4fc0505d6b2b15d (patch)
treefd1c0c189c6691b10283064a7543880972983126 /target-i386
parent8459e3961eb5519cb16d5950020ef7010f4b8a6f (diff)
target-i386: Isolate KVM-specific code on CPU feature filtering logic
This will allow us to re-use the feature filtering logic (and the check/enforce flag logic) for TCG. Reviewed-by: Richard Henderson <rth@twiddle.net> 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.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index f2c3583d6a..5e12556aa6 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1815,6 +1815,16 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
return cpu_list;
}
+static uint32_t x86_cpu_get_supported_feature_word(FeatureWord w)
+{
+ FeatureWordInfo *wi = &feature_word_info[w];
+
+ assert(kvm_enabled());
+ return kvm_arch_get_supported_cpuid(kvm_state, wi->cpuid_eax,
+ wi->cpuid_ecx,
+ wi->cpuid_reg);
+}
+
/*
* Filters CPU feature words based on host availability of each feature.
*
@@ -1822,20 +1832,14 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
*
* Returns: 0 if all flags are supported by the host, non-zero otherwise.
*/
-static int filter_features_for_kvm(X86CPU *cpu)
+static int x86_cpu_filter_features(X86CPU *cpu)
{
CPUX86State *env = &cpu->env;
- KVMState *s = kvm_state;
FeatureWord w;
int rv = 0;
- assert(kvm_enabled());
-
for (w = 0; w < FEATURE_WORDS; w++) {
- FeatureWordInfo *wi = &feature_word_info[w];
- uint32_t host_feat = kvm_arch_get_supported_cpuid(s, wi->cpuid_eax,
- wi->cpuid_ecx,
- wi->cpuid_reg);
+ uint32_t host_feat = x86_cpu_get_supported_feature_word(w);
uint32_t requested_features = env->features[w];
env->features[w] &= host_feat;
cpu->filtered_features[w] = requested_features & ~env->features[w];
@@ -2598,7 +2602,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
env->features[FEAT_8000_0001_ECX] &= TCG_EXT3_FEATURES;
env->features[FEAT_SVM] &= TCG_SVM_FEATURES;
} else {
- if (filter_features_for_kvm(cpu) && cpu->enforce_cpuid) {
+ if (x86_cpu_filter_features(cpu) && cpu->enforce_cpuid) {
error_setg(&local_err,
"Host's CPU doesn't support requested features");
goto out;