[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 08/11] target-i386: Move warning code outside x86
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [PATCH v4 08/11] target-i386: Move warning code outside x86_cpu_filter_features() |
Date: |
Thu, 29 Sep 2016 18:14:56 -0300 |
x86_cpu_filter_features() will be reused by code that shouldn't
print any warning. Move the warning code to a new
x86_cpu_report_filtered_features() function, and call it from
x86_cpu_realizefn().
Signed-off-by: Eduardo Habkost <address@hidden>
---
Changes v3 -> v4:
* Made x86_cpu_filter_features() void, make
x86_cpu_report_filtered_features() return true if
some features were filtered
---
target-i386/cpu.c | 41 ++++++++++++++++++++++++-----------------
1 file changed, 24 insertions(+), 17 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index b36388e..b25657b 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -2163,14 +2163,11 @@ static uint32_t
x86_cpu_get_supported_feature_word(FeatureWord w,
/*
* Filters CPU feature words based on host availability of each feature.
- *
- * Returns: 0 if all flags are supported by the host, non-zero otherwise.
*/
-static int x86_cpu_filter_features(X86CPU *cpu)
+static void x86_cpu_filter_features(X86CPU *cpu)
{
CPUX86State *env = &cpu->env;
FeatureWord w;
- int rv = 0;
for (w = 0; w < FEATURE_WORDS; w++) {
uint32_t host_feat =
@@ -2178,15 +2175,22 @@ static int x86_cpu_filter_features(X86CPU *cpu)
uint32_t requested_features = env->features[w];
env->features[w] &= host_feat;
cpu->filtered_features[w] = requested_features & ~env->features[w];
- if (cpu->filtered_features[w]) {
- if (cpu->check_cpuid || cpu->enforce_cpuid) {
- report_unavailable_features(w, cpu->filtered_features[w]);
- }
- rv = 1;
- }
}
+}
- return rv;
+/* Report list of filtered features to stderr.
+ * Returns true if some features were found to be filtered, false otherwise
+ */
+static bool x86_cpu_report_filtered_features(X86CPU *cpu)
+{
+ FeatureWord w;
+ uint32_t filtered = 0;
+
+ for (w = 0; w < FEATURE_WORDS; w++) {
+ filtered |= cpu->filtered_features[w];
+ report_unavailable_features(w, cpu->filtered_features[w]);
+ }
+ return filtered;
}
static void x86_cpu_apply_props(X86CPU *cpu, PropValue *props)
@@ -3082,12 +3086,15 @@ static void x86_cpu_realizefn(DeviceState *dev, Error
**errp)
env->cpuid_xlevel2 = env->cpuid_min_xlevel2;
}
- if (x86_cpu_filter_features(cpu) && cpu->enforce_cpuid) {
- error_setg(&local_err,
- kvm_enabled() ?
- "Host doesn't support requested features" :
- "TCG doesn't support requested features");
- goto out;
+ x86_cpu_filter_features(cpu);
+ if (cpu->check_cpuid || cpu->enforce_cpuid) {
+ if (x86_cpu_report_filtered_features(cpu) && cpu->enforce_cpuid) {
+ error_setg(&local_err,
+ kvm_enabled() ?
+ "Host doesn't support requested features" :
+ "TCG doesn't support requested features");
+ goto out;
+ }
}
/* On AMD CPUs, some CPUID[8000_0001].EDX bits must match the bits on
--
2.7.4
- Re: [Qemu-devel] [PATCH v4 01/11] tests: Add test case for x86 feature parsing compatibility, (continued)
- [Qemu-devel] [PATCH v4 03/11] target-i386: Disable VME by default with TCG, Eduardo Habkost, 2016/09/29
- [Qemu-devel] [PATCH v4 04/11] target-i386: Make plus_features/minus_features QOM-based, Eduardo Habkost, 2016/09/29
- [Qemu-devel] [PATCH v4 07/11] target-i386: xsave: Add FP and SSE bits to x86_ext_save_areas, Eduardo Habkost, 2016/09/29
- [Qemu-devel] [PATCH v4 05/11] target-i386: Remove underscores from property names, Eduardo Habkost, 2016/09/29
- [Qemu-devel] [PATCH v4 02/11] target-i386: List CPU models using subclass list, Eduardo Habkost, 2016/09/29
- [Qemu-devel] [PATCH v4 08/11] target-i386: Move warning code outside x86_cpu_filter_features(),
Eduardo Habkost <=
- [Qemu-devel] [PATCH v4 06/11] target-i386: Register properties for feature aliases manually, Eduardo Habkost, 2016/09/29
- [Qemu-devel] [PATCH v4 11/11] target-i386: Return runnability information on query-cpu-definitions, Eduardo Habkost, 2016/09/29
- [Qemu-devel] [PATCH v4 10/11] qmp: Add runnability information to query-cpu-definitions, Eduardo Habkost, 2016/09/29
- [Qemu-devel] [PATCH v4 09/11] target-i386: x86_cpu_load_features() function, Eduardo Habkost, 2016/09/29