From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39318) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPahs-0003dl-Qx for qemu-devel@nongnu.org; Thu, 04 Sep 2014 13:20:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XPahm-0005NU-9v for qemu-devel@nongnu.org; Thu, 04 Sep 2014 13:20:24 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Thu, 4 Sep 2014 19:20:12 +0200 Message-Id: <1409851213-14330-3-git-send-email-afaerber@suse.de> In-Reply-To: <1409851213-14330-1-git-send-email-afaerber@suse.de> References: <1409851213-14330-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL v2 2/3] target-i386: Support migratable=no properly List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Eduardo Habkost , =?UTF-8?q?Andreas=20F=C3=A4rber?= , qemu-stable@nongnu.org From: Eduardo Habkost When the "migratable" property was implemented, the behavior was tested by changing the default on the code, but actually using the option on the command-line (e.g. "-cpu host,migratable=3Dfalse") doesn't work as expected. This is a regression for a common use case of "-cpu host", which is to enable features that are supported by the host CPU + kernel before feature-specific code is added to QEMU. Fix this by initializing the feature words for "-cpu host" on x86_cpu_parse_featurestr(), right after parsing the CPU options. Signed-off-by: Eduardo Habkost Reviewed-by: Michael Roth Cc: qemu-stable@nongnu.org Signed-off-by: Andreas F=C3=A4rber --- target-i386/cpu-qom.h | 1 + target-i386/cpu.c | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h index 71a1b97..7755466 100644 --- a/target-i386/cpu-qom.h +++ b/target-i386/cpu-qom.h @@ -92,6 +92,7 @@ typedef struct X86CPU { bool enforce_cpuid; bool expose_kvm; bool migratable; + bool host_features; =20 /* if true the CPUID code directly forward host cache leaves to the = guest */ bool cache_info_passthrough; diff --git a/target-i386/cpu.c b/target-i386/cpu.c index fa811a0..60d0dd5 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -1318,18 +1318,18 @@ static void host_x86_cpu_initfn(Object *obj) X86CPU *cpu =3D X86_CPU(obj); CPUX86State *env =3D &cpu->env; KVMState *s =3D kvm_state; - FeatureWord w; =20 assert(kvm_enabled()); =20 + /* We can't fill the features array here because we don't know yet i= f + * "migratable" is true or false. + */ + cpu->host_features =3D true; + env->cpuid_level =3D kvm_arch_get_supported_cpuid(s, 0x0, 0, R_EAX); env->cpuid_xlevel =3D kvm_arch_get_supported_cpuid(s, 0x80000000, 0,= R_EAX); env->cpuid_xlevel2 =3D kvm_arch_get_supported_cpuid(s, 0xC0000000, 0= , R_EAX); =20 - for (w =3D 0; w < FEATURE_WORDS; w++) { - env->features[w] =3D - x86_cpu_get_supported_feature_word(w, cpu->migratable); - } object_property_set_bool(OBJECT(cpu), true, "pmu", &error_abort); } =20 @@ -1828,6 +1828,13 @@ static void x86_cpu_parse_featurestr(CPUState *cs,= char *features, featurestr =3D strtok(NULL, ","); } =20 + if (cpu->host_features) { + for (w =3D 0; w < FEATURE_WORDS; w++) { + env->features[w] =3D + x86_cpu_get_supported_feature_word(w, cpu->migratable); + } + } + for (w =3D 0; w < FEATURE_WORDS; w++) { env->features[w] |=3D plus_features[w]; env->features[w] &=3D ~minus_features[w]; --=20 1.8.4.5