From 663e3a6eadf499c0bd62314802ff207392cf544a Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 8 Mar 2017 20:36:13 +0100 Subject: [PATCH 4/4] target-i386: Don't use cpu->migratable when filtering features RH-Author: Eduardo Habkost Message-id: <20170308203613.31478-1-ehabkost@redhat.com> Patchwork-id: 74256 O-Subject: [RHEV-7.3.z qemu-kvm-rhev PATCH] target-i386: Don't use cpu->migratable when filtering features Bugzilla: 1413897 RH-Acked-by: David Hildenbrand RH-Acked-by: Paolo Bonzini RH-Acked-by: Thomas Huth RH-Acked-by: Marcelo Tosatti Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1413897 Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=12719257 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 an 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 an argument to x86_cpu_get_supported_feature_word() in x86_cpu_filter_features(). Note that: * This won't change anything for people using using "-cpu host" or "-cpu host,migratable=" (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 change things for people using "-cpu host,+", where is a non-migratable feature. The only existing named non-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. Reviewed-by: Eric Blake Signed-off-by: Eduardo Habkost (cherry picked from commit 46c032f3afcc05a0123914609f1003906ba63fda) Signed-off-by: Eduardo Habkost Signed-off-by: Miroslav Rezanina --- target-i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 83ebd3c..15b72df 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -2114,7 +2114,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]; -- 1.8.3.1