[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [qom-cpu PATCH 04/10] target-i386: Isolate KVM-specific cod
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [qom-cpu PATCH 04/10] target-i386: Isolate KVM-specific code on CPU feature filtering logic |
Date: |
Fri, 28 Feb 2014 17:21:47 -0300 |
This will allow us to re-use the feature filtering logic (and the
check/enforce flag logic) for TCG.
Signed-off-by: Eduardo Habkost <address@hidden>
---
target-i386/cpu.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index af82289..7fc0539 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1770,26 +1770,29 @@ 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
*
* Returns 0 if all flags are supported by the host, non-zero otherwise.
*
* This function may be called only if KVM is enabled.
*/
-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];
@@ -2528,7 +2531,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;
--
1.8.5.3
- [Qemu-devel] [qom-cpu PATCH 00/10] target-i386: Support check/enforce flags in TCG mode, too, Eduardo Habkost, 2014/02/28
- [Qemu-devel] [qom-cpu PATCH 01/10] target-i386: Simplify reporting of unavailable features, Eduardo Habkost, 2014/02/28
- [Qemu-devel] [qom-cpu PATCH 02/10] target-i386: Merge feature filtering/checking functions, Eduardo Habkost, 2014/02/28
- [Qemu-devel] [qom-cpu PATCH 04/10] target-i386: Isolate KVM-specific code on CPU feature filtering logic,
Eduardo Habkost <=
- [Qemu-devel] [qom-cpu PATCH 03/10] target-i386: Pass FeatureWord argument to report_unavailable_features(), Eduardo Habkost, 2014/02/28
- [Qemu-devel] [qom-cpu PATCH 05/10] target-i386: Make TCG feature filtering more readable, Eduardo Habkost, 2014/02/28
- [Qemu-devel] [qom-cpu PATCH 06/10] target-i386: Filter FEAT_7_0_EBX TCG features too, Eduardo Habkost, 2014/02/28
- [Qemu-devel] [qom-cpu PATCH 07/10] target-i386: Filter KVM and 0xC0000001 features on TCG, Eduardo Habkost, 2014/02/28
- [Qemu-devel] [qom-cpu PATCH 08/10] target-i386: Define TCG_*_FEATURES earlier on cpu.c, Eduardo Habkost, 2014/02/28
- [Qemu-devel] [qom-cpu PATCH 10/10] target-i386: Support check/enforce flags in TCG mode, too, Eduardo Habkost, 2014/02/28
- [Qemu-devel] [qom-cpu PATCH 09/10] target-i386: Loop-based feature word filtering in TCG mode, Eduardo Habkost, 2014/02/28
- Re: [Qemu-devel] [qom-cpu PATCH 00/10] target-i386: Support check/enforce flags in TCG mode, too, Richard Henderson, 2014/02/28