|
|
016a62 |
From d7362c761ef55b7f665c4dff61d9e58b153ff11c Mon Sep 17 00:00:00 2001
|
|
|
016a62 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
016a62 |
Date: Fri, 22 Nov 2019 11:53:39 +0000
|
|
|
016a62 |
Subject: [PATCH 06/16] target/i386: handle filtered_features in a new function
|
|
|
016a62 |
mark_unavailable_features
|
|
|
016a62 |
|
|
|
016a62 |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
016a62 |
Message-id: <20191122115348.25000-7-pbonzini@redhat.com>
|
|
|
016a62 |
Patchwork-id: 92600
|
|
|
016a62 |
O-Subject: [RHEL8.2/rhel qemu-kvm PATCH 06/15] target/i386: handle filtered_features in a new function mark_unavailable_features
|
|
|
016a62 |
Bugzilla: 1689270
|
|
|
016a62 |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
016a62 |
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
016a62 |
RH-Acked-by: Maxim Levitsky <mlevitsk@redhat.com>
|
|
|
016a62 |
|
|
|
016a62 |
The next patch will add a different reason for filtering features, unrelated
|
|
|
016a62 |
to host feature support. Extract a new function that takes care of disabling
|
|
|
016a62 |
the features and optionally reporting them.
|
|
|
016a62 |
|
|
|
016a62 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
016a62 |
(cherry picked from commit 245edd0cfb1481b7a0398cce45df23db50f00034)
|
|
|
016a62 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
016a62 |
---
|
|
|
016a62 |
target/i386/cpu.c | 87 ++++++++++++++++++++++++++++++-------------------------
|
|
|
016a62 |
1 file changed, 48 insertions(+), 39 deletions(-)
|
|
|
016a62 |
|
|
|
016a62 |
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
|
|
|
016a62 |
index d0c48c2..b06ce9d 100644
|
|
|
016a62 |
--- a/target/i386/cpu.c
|
|
|
016a62 |
+++ b/target/i386/cpu.c
|
|
|
016a62 |
@@ -3121,17 +3121,41 @@ static char *feature_word_description(FeatureWordInfo *f, uint32_t bit)
|
|
|
016a62 |
return NULL;
|
|
|
016a62 |
}
|
|
|
016a62 |
|
|
|
016a62 |
-static void report_unavailable_features(FeatureWord w, uint32_t mask)
|
|
|
016a62 |
+static bool x86_cpu_have_filtered_features(X86CPU *cpu)
|
|
|
016a62 |
{
|
|
|
016a62 |
+ FeatureWord w;
|
|
|
016a62 |
+
|
|
|
016a62 |
+ for (w = 0; w < FEATURE_WORDS; w++) {
|
|
|
016a62 |
+ if (cpu->filtered_features[w]) {
|
|
|
016a62 |
+ return true;
|
|
|
016a62 |
+ }
|
|
|
016a62 |
+ }
|
|
|
016a62 |
+
|
|
|
016a62 |
+ return false;
|
|
|
016a62 |
+}
|
|
|
016a62 |
+
|
|
|
016a62 |
+static void mark_unavailable_features(X86CPU *cpu, FeatureWord w, uint32_t mask,
|
|
|
016a62 |
+ const char *verbose_prefix)
|
|
|
016a62 |
+{
|
|
|
016a62 |
+ CPUX86State *env = &cpu->env;
|
|
|
016a62 |
FeatureWordInfo *f = &feature_word_info[w];
|
|
|
016a62 |
int i;
|
|
|
016a62 |
char *feat_word_str;
|
|
|
016a62 |
|
|
|
016a62 |
+ if (!cpu->force_features) {
|
|
|
016a62 |
+ env->features[w] &= ~mask;
|
|
|
016a62 |
+ }
|
|
|
016a62 |
+ cpu->filtered_features[w] |= mask;
|
|
|
016a62 |
+
|
|
|
016a62 |
+ if (!verbose_prefix) {
|
|
|
016a62 |
+ return;
|
|
|
016a62 |
+ }
|
|
|
016a62 |
+
|
|
|
016a62 |
for (i = 0; i < 32; ++i) {
|
|
|
016a62 |
if ((1UL << i) & mask) {
|
|
|
016a62 |
feat_word_str = feature_word_description(f, i);
|
|
|
016a62 |
- warn_report("%s doesn't support requested feature: %s%s%s [bit %d]",
|
|
|
016a62 |
- accel_uses_host_cpuid() ? "host" : "TCG",
|
|
|
016a62 |
+ warn_report("%s: %s%s%s [bit %d]",
|
|
|
016a62 |
+ verbose_prefix,
|
|
|
016a62 |
feat_word_str,
|
|
|
016a62 |
f->feat_names[i] ? "." : "",
|
|
|
016a62 |
f->feat_names[i] ? f->feat_names[i] : "", i);
|
|
|
016a62 |
@@ -3577,7 +3601,7 @@ static void x86_cpu_parse_featurestr(const char *typename, char *features,
|
|
|
016a62 |
}
|
|
|
016a62 |
|
|
|
016a62 |
static void x86_cpu_expand_features(X86CPU *cpu, Error **errp);
|
|
|
016a62 |
-static int x86_cpu_filter_features(X86CPU *cpu);
|
|
|
016a62 |
+static void x86_cpu_filter_features(X86CPU *cpu, bool verbose);
|
|
|
016a62 |
|
|
|
016a62 |
/* Build a list with the name of all features on a feature word array */
|
|
|
016a62 |
static void x86_cpu_list_feature_names(FeatureWordArray features,
|
|
|
016a62 |
@@ -3642,7 +3666,7 @@ static void x86_cpu_class_check_missing_features(X86CPUClass *xcc,
|
|
|
016a62 |
next = &new->next;
|
|
|
016a62 |
}
|
|
|
016a62 |
|
|
|
016a62 |
- x86_cpu_filter_features(xc);
|
|
|
016a62 |
+ x86_cpu_filter_features(xc, false);
|
|
|
016a62 |
|
|
|
016a62 |
x86_cpu_list_feature_names(xc->filtered_features, next);
|
|
|
016a62 |
|
|
|
016a62 |
@@ -3811,15 +3835,6 @@ static uint32_t x86_cpu_get_supported_feature_word(FeatureWord w,
|
|
|
016a62 |
return r;
|
|
|
016a62 |
}
|
|
|
016a62 |
|
|
|
016a62 |
-static void x86_cpu_report_filtered_features(X86CPU *cpu)
|
|
|
016a62 |
-{
|
|
|
016a62 |
- FeatureWord w;
|
|
|
016a62 |
-
|
|
|
016a62 |
- for (w = 0; w < FEATURE_WORDS; w++) {
|
|
|
016a62 |
- report_unavailable_features(w, cpu->filtered_features[w]);
|
|
|
016a62 |
- }
|
|
|
016a62 |
-}
|
|
|
016a62 |
-
|
|
|
016a62 |
static void x86_cpu_apply_props(X86CPU *cpu, PropValue *props)
|
|
|
016a62 |
{
|
|
|
016a62 |
PropValue *pv;
|
|
|
016a62 |
@@ -5042,24 +5057,24 @@ out:
|
|
|
016a62 |
*
|
|
|
016a62 |
* Returns: 0 if all flags are supported by the host, non-zero otherwise.
|
|
|
016a62 |
*/
|
|
|
016a62 |
-static int x86_cpu_filter_features(X86CPU *cpu)
|
|
|
016a62 |
+static void x86_cpu_filter_features(X86CPU *cpu, bool verbose)
|
|
|
016a62 |
{
|
|
|
016a62 |
CPUX86State *env = &cpu->env;
|
|
|
016a62 |
FeatureWord w;
|
|
|
016a62 |
- int rv = 0;
|
|
|
016a62 |
+ const char *prefix = NULL;
|
|
|
016a62 |
+
|
|
|
016a62 |
+ if (verbose) {
|
|
|
016a62 |
+ prefix = accel_uses_host_cpuid()
|
|
|
016a62 |
+ ? "host doesn't support requested feature"
|
|
|
016a62 |
+ : "TCG doesn't support requested feature";
|
|
|
016a62 |
+ }
|
|
|
016a62 |
|
|
|
016a62 |
for (w = 0; w < FEATURE_WORDS; w++) {
|
|
|
016a62 |
uint32_t host_feat =
|
|
|
016a62 |
x86_cpu_get_supported_feature_word(w, false);
|
|
|
016a62 |
uint32_t requested_features = env->features[w];
|
|
|
016a62 |
- uint32_t available_features = requested_features & host_feat;
|
|
|
016a62 |
- if (!cpu->force_features) {
|
|
|
016a62 |
- env->features[w] = available_features;
|
|
|
016a62 |
- }
|
|
|
016a62 |
- cpu->filtered_features[w] = requested_features & ~available_features;
|
|
|
016a62 |
- if (cpu->filtered_features[w]) {
|
|
|
016a62 |
- rv = 1;
|
|
|
016a62 |
- }
|
|
|
016a62 |
+ uint32_t unavailable_features = requested_features & ~host_feat;
|
|
|
016a62 |
+ mark_unavailable_features(cpu, w, unavailable_features, prefix);
|
|
|
016a62 |
}
|
|
|
016a62 |
|
|
|
016a62 |
if ((env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT) &&
|
|
|
016a62 |
@@ -5085,13 +5100,9 @@ static int x86_cpu_filter_features(X86CPU *cpu)
|
|
|
016a62 |
* host can't emulate the capabilities we report on
|
|
|
016a62 |
* cpu_x86_cpuid(), intel-pt can't be enabled on the current host.
|
|
|
016a62 |
*/
|
|
|
016a62 |
- env->features[FEAT_7_0_EBX] &= ~CPUID_7_0_EBX_INTEL_PT;
|
|
|
016a62 |
- cpu->filtered_features[FEAT_7_0_EBX] |= CPUID_7_0_EBX_INTEL_PT;
|
|
|
016a62 |
- rv = 1;
|
|
|
016a62 |
+ mark_unavailable_features(cpu, FEAT_7_0_EBX, CPUID_7_0_EBX_INTEL_PT, prefix);
|
|
|
016a62 |
}
|
|
|
016a62 |
}
|
|
|
016a62 |
-
|
|
|
016a62 |
- return rv;
|
|
|
016a62 |
}
|
|
|
016a62 |
|
|
|
016a62 |
static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
|
|
|
016a62 |
@@ -5120,16 +5131,14 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
|
|
|
016a62 |
goto out;
|
|
|
016a62 |
}
|
|
|
016a62 |
|
|
|
016a62 |
- if (x86_cpu_filter_features(cpu) &&
|
|
|
016a62 |
- (cpu->check_cpuid || cpu->enforce_cpuid)) {
|
|
|
016a62 |
- x86_cpu_report_filtered_features(cpu);
|
|
|
016a62 |
- if (cpu->enforce_cpuid) {
|
|
|
016a62 |
- error_setg(&local_err,
|
|
|
016a62 |
- accel_uses_host_cpuid() ?
|
|
|
016a62 |
- "Host doesn't support requested features" :
|
|
|
016a62 |
- "TCG doesn't support requested features");
|
|
|
016a62 |
- goto out;
|
|
|
016a62 |
- }
|
|
|
016a62 |
+ x86_cpu_filter_features(cpu, cpu->check_cpuid || cpu->enforce_cpuid);
|
|
|
016a62 |
+
|
|
|
016a62 |
+ if (cpu->enforce_cpuid && x86_cpu_have_filtered_features(cpu)) {
|
|
|
016a62 |
+ error_setg(&local_err,
|
|
|
016a62 |
+ accel_uses_host_cpuid() ?
|
|
|
016a62 |
+ "Host doesn't support requested features" :
|
|
|
016a62 |
+ "TCG doesn't support requested features");
|
|
|
016a62 |
+ goto out;
|
|
|
016a62 |
}
|
|
|
016a62 |
|
|
|
016a62 |
/* On AMD CPUs, some CPUID[8000_0001].EDX bits must match the bits on
|
|
|
016a62 |
--
|
|
|
016a62 |
1.8.3.1
|
|
|
016a62 |
|