From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41691) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VBQw0-0003QG-Dp for qemu-devel@nongnu.org; Mon, 19 Aug 2013 11:00:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VBQvv-00082P-Qi for qemu-devel@nongnu.org; Mon, 19 Aug 2013 10:59:56 -0400 Received: from cantor2.suse.de ([195.135.220.15]:37845 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VBQvv-00082I-HY for qemu-devel@nongnu.org; Mon, 19 Aug 2013 10:59:51 -0400 Message-ID: <521232E2.2090802@suse.de> Date: Mon, 19 Aug 2013 16:59:46 +0200 From: =?ISO-8859-1?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <5211E3E9.7080507@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Liu, Jinsong" Cc: Gleb Natapov , kvm , Stefan Weil , Marcelo Tosatti , "qemu-devel@nongnu.org" , Paolo Bonzini Am 19.08.2013 16:31, schrieb Liu, Jinsong: > Paolo Bonzini wrote: >> >> The patch looks good. Please repost it with checkpatch.pl failures >> fixed.=20 >> >> Paolo >=20 > Thanks Stefan and Paolo! Updated patch attached. >=20 > Regards, > Jinsong >=20 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > From a0ddf948d40e42de862543157a5668a1c12faae6 Mon Sep 17 00:00:00 2001 > From: Liu Jinsong > Date: Mon, 19 Aug 2013 09:33:30 +0800 > Subject: [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL >=20 > This patch is to fix the bug https://bugs.launchpad.net/qemu-kvm/+bug/1= 207623 >=20 > IA32_FEATURE_CONTROL is pointless if not expose VMX or SMX bits to > cpuid.1.ecx of vcpu. Current qemu-kvm will error return when kvm_put_ms= rs > or kvm_get_msrs. >=20 > Signed-off-by: Liu Jinsong Jinsong, if this is for upstream QEMU, then the commit message needs some small improvements: qemu-kvm is no longer maintained since 1.3 so it should not be occurring any more. Please use a prefix of "target-i386: " (the directory name) to signal where you are changing code, i.e. x86 only. "bugfix" is not a very telling description of what a patch is doing. (Up to Paolo and Gleb whether they'll fix it or whether they require a resend.) Also please use git-send-email to submit patches and use "PATCH v2" etc. for submission as top-level patch: http://wiki.qemu.org/Contribute/SubmitAPatch One question inline... > --- > target-i386/kvm.c | 17 +++++++++++++++-- > 1 files changed, 15 insertions(+), 2 deletions(-) >=20 > diff --git a/target-i386/kvm.c b/target-i386/kvm.c > index 84ac00a..5adeb03 100644 > --- a/target-i386/kvm.c > +++ b/target-i386/kvm.c > @@ -65,6 +65,7 @@ static bool has_msr_star; > static bool has_msr_hsave_pa; > static bool has_msr_tsc_adjust; > static bool has_msr_tsc_deadline; > +static bool has_msr_feature_control; > static bool has_msr_async_pf_en; > static bool has_msr_pv_eoi_en; > static bool has_msr_misc_enable; > @@ -644,6 +645,12 @@ int kvm_arch_init_vcpu(CPUState *cs) > =20 > qemu_add_vm_change_state_handler(cpu_update_state, env); > =20 > + c =3D cpuid_find_entry(&cpuid_data.cpuid, 1, 0); > + if (c) { > + has_msr_feature_control =3D !!(c->ecx & CPUID_EXT_VMX) || > + !!(c->ecx & CPUID_EXT_SMX); > + } > + > cpuid_data.cpuid.padding =3D 0; > r =3D kvm_vcpu_ioctl(cs, KVM_SET_CPUID2, &cpuid_data); > if (r) { > @@ -1121,7 +1128,10 @@ static int kvm_put_msrs(X86CPU *cpu, int level) > if (hyperv_vapic_recommended()) { > kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_APIC_ASSIST_PAGE,= 0); > } > - kvm_msr_entry_set(&msrs[n++], MSR_IA32_FEATURE_CONTROL, env->m= sr_ia32_feature_control); > + if (has_msr_feature_control) { > + kvm_msr_entry_set(&msrs[n++], MSR_IA32_FEATURE_CONTROL, > + env->msr_ia32_feature_control); > + } > } > if (env->mcg_cap) { > int i; > @@ -1346,7 +1356,9 @@ static int kvm_get_msrs(X86CPU *cpu) > if (has_msr_misc_enable) { > msrs[n++].index =3D MSR_IA32_MISC_ENABLE; > } > - msrs[n++].index =3D MSR_IA32_FEATURE_CONTROL; > + if (has_msr_feature_control) { > + msrs[n++].index =3D MSR_IA32_FEATURE_CONTROL; > + } > =20 > if (!env->tsc_valid) { > msrs[n++].index =3D MSR_IA32_TSC; > @@ -1447,6 +1459,7 @@ static int kvm_get_msrs(X86CPU *cpu) > break; > case MSR_IA32_FEATURE_CONTROL: > env->msr_ia32_feature_control =3D msrs[i].data; > + break; Was the fallthrough previously intended? Or is this a second, unmentioned bugfix? Regards, Andreas > default: > if (msrs[i].index >=3D MSR_MC0_CTL && > msrs[i].index < MSR_MC0_CTL + (env->mcg_cap & 0xff) * = 4) { >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg