Skip to contentSkip to conversation

Fixes for env->user_features

PATCH In review Xiaoyao Li 4 participants 7 messages Jul 13, 2020 – Jul 27, 2020

lore
Share & tools
lore

Xiaoyao Li

author
#0 lore raw

cover Fixes for env->user_features

Patch 1 fixes the env->features set by versioned CPU model.

Patch 2 fixed the env->features set by unavailable_features due to feature_dependencies[] checking.

Xiaoyao Li (2):
i368/cpu: Clear env->user_features after loading versioned CPU model i386/cpu: Don't add unavailable_features to env->user_features

 target/i386/cpu.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
Signature · 1 line
2.18.4
author
#1 lore raw

PATCH 1/2 i368/cpu: Clear env->user_features after loading versioned CPU model

Features defined in versioned CPU model are recorded in env->user_features since they are updated as property. It's unwated because they are not user specified.

Simply clear env->user_features as a fix. It won't clear user specified features because user specified features are filled to env->user_features later in x86_cpu_expand_features().

---
 target/i386/cpu.c | 6 ++++++
 1 file changed, 6 insertions(+)
target/i386/cpu.c +6 -0
index 1e5123251d74..9812d5747f35 100644
@@ -5159,6 +5159,12 @@ static void x86_cpu_load_model(X86CPU *cpu, X86CPUModel *model)
     object_property_set_str(OBJECT(cpu), "vendor", vendor, &error_abort);
 
     x86_cpu_apply_version_props(cpu, model);
+
+    /* Properties in versioned CPU model are not user specified features.
+     * We can simply clear env->user_features here since it will be filled later
+     * in x86_cpu_expand_features() based on plus_features and minus_features.
+     */
+    memset(&env->user_features, 0, sizeof(env->user_features));
 }
 
 #ifndef CONFIG_USER_ONLY
Signature · 1 line
2.18.4
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] i368/cpu: Clear env->user_features after loading versioned CPU model

Quoted 11 lines · Xiaoyao Li

Features defined in versioned CPU model are recorded in env->user_features since they are updated as property. It's unwated because they are not user specified.

Simply clear env->user_features as a fix. It won't clear user specified features because user specified features are filled to env->user_features later in x86_cpu_expand_features().

Quoted 24 lines
---
 target/i386/cpu.c | 6 ++++++
 1 file changed, 6 insertions(+)
target/i386/cpu.c +6 -0
index 1e5123251d74..9812d5747f35 100644
@@ -5159,6 +5159,12 @@ static void x86_cpu_load_model(X86CPU *cpu, X86CPUModel *model)
     object_property_set_str(OBJECT(cpu), "vendor", vendor, &error_abort);
 
     x86_cpu_apply_version_props(cpu, model);
+
+    /* Properties in versioned CPU model are not user specified features.
+     * We can simply clear env->user_features here since it will be filled later
+     * in x86_cpu_expand_features() based on plus_features and minus_features.
+     */
+    memset(&env->user_features, 0, sizeof(env->user_features));
 }
 
 #ifndef CONFIG_USER_ONLY
Signature · 1 line
2.18.4
Signature · 1 line
Eduardo
author
#3 lore raw

PATCH 2/2 i386/cpu: Don't add unavailable_features to env->user_features

In reply to Xiaoyao Li

Features unavailable due to absent of their dependent features should not be added to env->user_features. env->user_features only contains the feature explicity specified with -feature/+feature by user.

Fixes 99e24dbdaa68 ("target/i386: introduce generic feature dependency mechanism")
---
 target/i386/cpu.c | 1 -
 1 file changed, 1 deletion(-)
target/i386/cpu.c +0 -1
index 9812d5747f35..fb1de1bd6165 100644
@@ -6370,7 +6370,6 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)
                                       unavailable_features & env->user_features[d->to.index],
                                       "This feature depends on other features that were not requested");
 
-            env->user_features[d->to.index] |= unavailable_features;
             env->features[d->to.index] &= ~unavailable_features;
         }
     }
Signature · 1 line
2.18.4
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] i386/cpu: Don't add unavailable_features to env->user_features

Quoted 6 lines · Xiaoyao Li

Features unavailable due to absent of their dependent features should not be added to env->user_features. env->user_features only contains the feature explicity specified with -feature/+feature by user.

Fixes 99e24dbdaa68 ("target/i386: introduce generic feature dependency mechanism")

Paolo, do you remember why that line existed? It doesn't make sense to me.

There are exactly 2 lines of code reading user_features, and both of them are inside x86_cpu_expand_features() above this hunk.

Quoted 19 lines
---
 target/i386/cpu.c | 1 -
 1 file changed, 1 deletion(-)
target/i386/cpu.c +0 -1
index 9812d5747f35..fb1de1bd6165 100644
@@ -6370,7 +6370,6 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)
                                       unavailable_features & env->user_features[d->to.index],
                                       "This feature depends on other features that were not requested");
 
-            env->user_features[d->to.index] |= unavailable_features;
             env->features[d->to.index] &= ~unavailable_features;
         }
     }
Signature · 1 line
2.18.4
Signature · 1 line
Eduardo
#5 lore raw

Re: [PATCH 2/2] i386/cpu: Don't add unavailable_features to env->user_features

Quoted 5 lines · Eduardo Habkost
Quoted 4 lines · Xiaoyao Li

Features unavailable due to absent of their dependent features should not be added to env->user_features. env->user_features only contains the feature explicity specified with -feature/+feature by user.

Quoted 8 lines
Quoted 2 lines
Fixes 99e24dbdaa68 ("target/i386: introduce generic feature dependency mechanism")

Paolo, do you remember why that line existed? It doesn't make sense to me.

There are exactly 2 lines of code reading user_features, and both of them are inside x86_cpu_expand_features() above this hunk.

I think it was just to be safe in case in the future something else adds features automatically, in the same way as the cpu->max_features case:

            env->features[w] |=
                x86_cpu_get_supported_feature_word(w, cpu->migratable) &
                ~env->user_features[w] &
                ~feature_word_info[w].no_autoenable_flags;

It would prevent the unavailable dependent features from being added.

But yeah, it would just be enough to place it above this hunk.

Paolo

Quoted 22 lines
Quoted 19 lines
---
 target/i386/cpu.c | 1 -
 1 file changed, 1 deletion(-)
target/i386/cpu.c +0 -1
index 9812d5747f35..fb1de1bd6165 100644
@@ -6370,7 +6370,6 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)
                                       unavailable_features & env->user_features[d->to.index],
                                       "This feature depends on other features that were not requested");
 
-            env->user_features[d->to.index] |= unavailable_features;
             env->features[d->to.index] &= ~unavailable_features;
         }
     }
Signature · 1 line
2.18.4
#6 lore raw
In reply to Xiaoyao Li
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END ===

TEST iotest-qcow2: 022
TEST check-unit: tests/test-char
**
ERROR:/tmp/qemu-test/src/tests/test-char.c:1204:char_serial_test: 'chr' should not be NULL
ERROR test-char - Bail out! ERROR:/tmp/qemu-test/src/tests/test-char.c:1204:char_serial_test: 'chr' should not be NULL
make: *** [check-unit] Error 1
make: *** Waiting for unfinished jobs....
TEST iotest-qcow2: 024
TEST iotest-qcow2: 025
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=4939dead4d0f403ea41adb4c514af82e', '-u', '1001', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-zqji5law/src/docker-src.2020-07-13-13.53.16.24512:/var/tmp/qemu:z,ro', 'qemu/centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=4939dead4d0f403ea41adb4c514af82e
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-zqji5law/src'
make: *** [docker-run-test-quick@centos7] Error 2

real 14m59.851s
user 0m9.044s

The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]