target-i386: Don't cpu->migratable field when filtering features
PATCH 1/1 target-i386: Don't cpu->migratable field when filtering features
When explicitly enabling unmigratable flags using "-cpu host" (e.g. "-cpu host,+invtsc"), the requested feature won't be enabled because cpu->migratable is true by default.
This is inconsistent with all other CPU models, which don't have the "migratable" option, making "+invtsc" work without the need for extra options.
This happens because x86_cpu_filter_features() uses cpu->migratable as argument for x86_cpu_get_supported_feature_word(). This is not useful because:
2) on "-cpu host" it only makes QEMU disable features that were explicitly enabled in the command-line;
1) on all the other CPU models, cpu->migratable is already false.
The fix is to just use 'false' as argument tox86_cpu_get_supported_feature_word() inx86_cpu_filter_features().
Note that:
* This won't change anything for people using using
"-cpu host" or "-cpu host,migratable=<on|off>" (with no extra features) because the x86_cpu_get_supported_feature_word() call on the cpu->host_features check uses cpu->migratable as argument.
* This won't change anything for any CPU model except "host" because they all have cpu->migratable == false (and only "host" has the "migratable" property that allows it to be changed).
* This will only cange things for people using "-cpu host,+<feature>", where <feature> is a non-migratable feature. The only existing named migratable feature is "invtsc".
In other words, this change will only affect people using "-cpu host,+invtsc" (that will now get what they asked for: the invtsc flag will be enabled). All other use cases are unaffected.
--- target-i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target-i386/cpu.c +1 -1
@@ -2248,7 +2248,7 @@ static int x86_cpu_filter_features(X86CPU *cpu)for (w =0 ; w <FEATURE_WORDS ; w++) {uint32_t host_feat = -x86_cpu_get_supported_feature_word (w, cpu->migratable); +x86_cpu_get_supported_feature_word (w, false);uint32_t requested_features = env->features[w]; env->features[w] &= host_feat; cpu->filtered_features[w] = requested_features & ~env->features[w];
Signature · 1 line
2.7.4
On 10/14/2016 02:28 PM, Eduardo Habkost wrote:
Subject line is missing a word; perhaps s/don't/don't read/
Quoted 10 lines
When explicitly enabling unmigratable flags using "-cpu host" (e.g. "-cpu host,+invtsc"), the requested feature won't be enabled because
cpu->migratableis true by default.This is inconsistent with all other CPU models, which don't have the "migratable" option, making "+invtsc" work without the need for extra options.
This happens because
x86_cpu_filter_features()usescpu->migratableas argument for
s/as/as an/
Quoted 12 lines
x86_cpu_get_supported_feature_word(). This is not useful because:
2) on "-cpu host" it only makes QEMU disable features that were explicitly enabled in the command-line;
1) on all the other CPU models,cpu->migratableis already false.The fix is to just use 'false' as argument to
x86_cpu_get_supported_feature_word()inx86_cpu_filter_features().Note that:
Quoted 9 lines
* This won't change anything for people using using
"-cpu host" or "-cpu host,migratable=<on|off>" (with no extra features) because thex86_cpu_get_supported_feature_word()call on thecpu->host_featurescheck usescpu->migratableas argument.
* This won't change anything for any CPU model except "host" because they all havecpu->migratable== false (and only "host" has the "migratable" property that allows it to be changed).
* This will only cange things for people using "-cpu host,+<feature>",
s/cange/change/
Quoted 2 lines
where <feature> is a non-migratable feature. The only existing named migratable feature is "invtsc".
s/migratable/non-migratable/ ?
Quoted 9 lines
In other words, this change will only affect people using "-cpu host,+invtsc" (that will now get what they asked for: the invtsc flag will be enabled). All other use cases are unaffected.
Signed-off-by Eduardo Habkost <[email protected]>--- target-i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Love the commit:patch signal-to-noise ratio :) But the lengthy explanation is vital, so keep it that way.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 3 lines · Eric Blake
On 10/14/2016 02:28 PM, Eduardo Habkost wrote:
Subject line is missing a word; perhaps s/don't/don't read/
Changed to: "target-i386: Don't use cpu->migratable when filtering features".
Quoted 5 lines
Quoted 5 lines
When explicitly enabling unmigratable flags using "-cpu host" (e.g. "-cpu host,+invtsc"), the requested feature won't be enabled because
cpu->migratableis true by default.
Quoted 8 lines
Quoted 6 lines
This is inconsistent with all other CPU models, which don't have the "migratable" option, making "+invtsc" work without the need for extra options.
This happens because
x86_cpu_filter_features()usescpu->migratableas argument fors/as/as an/
Fixed.
Quoted 10 lines
Quoted 10 lines
x86_cpu_get_supported_feature_word(). This is not useful because:
2) on "-cpu host" it only makes QEMU disable features that were explicitly enabled in the command-line;
1) on all the other CPU models,cpu->migratableis already false.The fix is to just use 'false' as argument to
x86_cpu_get_supported_feature_word()inx86_cpu_filter_features().
s/as/as an/ here, too.
Quoted 13 lines
Quoted 12 lines
Note that:
* This won't change anything for people using using
"-cpu host" or "-cpu host,migratable=<on|off>" (with no extra features) because thex86_cpu_get_supported_feature_word()call on thecpu->host_featurescheck usescpu->migratableas argument.
* This won't change anything for any CPU model except "host" because they all havecpu->migratable== false (and only "host" has the "migratable" property that allows it to be changed).
* This will only cange things for people using "-cpu host,+<feature>",
Quoted 1 line
s/cange/change/
Fixed.
Quoted 5 lines
Quoted 3 lines
where <feature> is a non-migratable feature. The only existing named migratable feature is "invtsc".
s/migratable/non-migratable/ ?
Fixed.
Quoted 7 lines
Quoted 7 lines
In other words, this change will only affect people using "-cpu host,+invtsc" (that will now get what they asked for: the invtsc flag will be enabled). All other use cases are unaffected.
Signed-off-by Eduardo Habkost <[email protected]>
Ouch, the hurry to write the commit the message in time submit this patch before the end of the day is noticeable. Thanks for the review!
Quoted 6 lines
Quoted 3 lines
--- target-i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Love the commit:patch signal-to-noise ratio :) But the lengthy explanation is vital, so keep it that way.
Yes, the rules and use cases behind the command-line options are not trivial, so I wanted to be very explicit about the case the patch affects, and the cases it doesn't affect.
Quoted 2 lines
Reviewed-by Eric Blake <[email protected]>
Thanks!
Signature · 1 line
Eduardo
Quoted 4 lines · Eduardo Habkost
When explicitly enabling unmigratable flags using "-cpu host" (e.g. "-cpu host,+invtsc"), the requested feature won't be enabled because
cpu->migratableis true by default.
[...]
Quoted 6 lines
Signed-off-by Eduardo Habkost <[email protected]>---
target-i386/cpu.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)