mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-22 10:41:08 +00:00
i386: Don't override -cpu options on -cpu host/max
The existing code for "host" and "max" CPU models overrides every single feature in the CPU object at realize time, even the ones that were explicitly enabled or disabled by the user using "feat=on" or "feat=off", while features set using +feat/-feat are kept. This means "-cpu host,+invtsc" works as expected, while "-cpu host,invtsc=on" doesn't. This was a known bug, already documented in a comment inside x86_cpu_expand_features(). What makes this bug worse now is that libvirt 3.0.0 and newer now use "feat=on|off" instead of +feat/-feat when it detects a QEMU version that supports it (see libvirt commit d47db7b16dd5422c7e487c8c8ee5b181a2f9cd66). Change the feature property getter/setter to set a env->user_features field, to keep track of features that were explicitly changed using QOM properties. Then make the max_features code not override user features when handling "-cpu host" and "-cpu max". This will also allow us to remove the plus_features/minus_features hack in the future, but I plan to do that after 2.9.0 is released. Backports commit d4a606b38b5d4b3689b86cc1575908e82179ecfb from qemu
This commit is contained in:
parent
31b977ab3e
commit
e71c7b7819
|
@ -3111,15 +3111,19 @@ static void x86_cpu_expand_features(struct uc_struct *uc, X86CPU *cpu, Error **e
|
|||
FeatureWord w;
|
||||
Error *local_err = NULL;
|
||||
|
||||
/*TODO: cpu->max_features incorrectly overwrites features
|
||||
* set using "feat=on|off". Once we fix this, we can convert
|
||||
/*TODO: Now cpu->max_features doesn't overwrite features
|
||||
* set using QOM properties, and we can convert
|
||||
* plus_features & minus_features to global properties
|
||||
* inside x86_cpu_parse_featurestr() too.
|
||||
*/
|
||||
if (cpu->max_features) {
|
||||
for (w = 0; w < FEATURE_WORDS; w++) {
|
||||
env->features[w] =
|
||||
x86_cpu_get_supported_feature_word(uc, w, cpu->migratable);
|
||||
/* Override only features that weren't set explicitly
|
||||
* by the user.
|
||||
*/
|
||||
env->features[w] |=
|
||||
x86_cpu_get_supported_feature_word(uc, w, cpu->migratable) &
|
||||
~env->user_features[w];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1133,6 +1133,8 @@ typedef struct CPUX86State {
|
|||
uint32_t cpuid_version;
|
||||
FeatureWordArray features;
|
||||
uint64_t xsave_components;
|
||||
/* Features that were explicitly enabled/disabled */
|
||||
FeatureWordArray user_features;
|
||||
uint32_t cpuid_model[12];
|
||||
|
||||
/* MTRRs */
|
||||
|
|
Loading…
Reference in a new issue