From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42370) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W5MCd-0007xa-PK for qemu-devel@nongnu.org; Mon, 20 Jan 2014 16:16:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W5MCW-0003NS-G7 for qemu-devel@nongnu.org; Mon, 20 Jan 2014 16:16:15 -0500 Received: from cantor2.suse.de ([195.135.220.15]:45718 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W5MCW-0003NO-8x for qemu-devel@nongnu.org; Mon, 20 Jan 2014 16:16:08 -0500 Message-ID: <52DD9213.7070500@suse.de> Date: Mon, 20 Jan 2014 22:16:03 +0100 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1390236074-21533-1-git-send-email-ehabkost@redhat.com> <1390236074-21533-5-git-send-email-ehabkost@redhat.com> In-Reply-To: <1390236074-21533-5-git-send-email-ehabkost@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 4/7] target-i386: kvm_cpu_fill_host(): No need to check xlevel2 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost , qemu-devel@nongnu.org Cc: Igor Mammedov , "Michael S. Tsirkin" Am 20.01.2014 17:41, schrieb Eduardo Habkost: > There's no need to check CPU xlevel2 before calling > kvm_arch_get_supported_cpuid(s, 0xC0000001, 0, R_EDX), because: >=20 > * The kernel won't return any entry for 0xC0000000 if host CPU vendor > is not Centaur (See kvm_dev_ioctl_get_supported_cpuid() on the kerne= l > code) > * Similarly, the kernel won't return any entry for 0xC0000001 if > CPUID[0xC0000000].EAX is < 0xC0000001 > * kvm_arch_get_supported_cpuid() will return 0 if no entry is returned > by the kernel for the requested leaf >=20 > For similar reasons, we can simply set x86_cpu_def->xlevel2 directly > instead of making it conditional, because it will be set to 0 CPU vendo= r > is not Centaur. Commented on the wrong version: "... if CPU vendor is not ..." I guess. :) >=20 > This will simplify the kvm_cpu_fill_host() code a little. >=20 > Signed-off-by: Eduardo Habkost > --- > target-i386/cpu.c | 12 +++++------- > 1 file changed, 5 insertions(+), 7 deletions(-) >=20 > diff --git a/target-i386/cpu.c b/target-i386/cpu.c > index 1a86bcf..8bc72c2 100644 > --- a/target-i386/cpu.c > +++ b/target-i386/cpu.c > @@ -1173,13 +1173,11 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cp= u_def) > cpu_x86_fill_model_id(x86_cpu_def->model_id); > =20 > /* Call Centaur's CPUID instruction. */ > - eax =3D kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX); > - if (eax >=3D 0xC0000001) { > - /* Support VIA max extended level */ > - x86_cpu_def->xlevel2 =3D eax; > - x86_cpu_def->features[FEAT_C000_0001_EDX] =3D > - kvm_arch_get_supported_cpuid(s, 0xC0000001, 0, R_EDX); > - } > + x86_cpu_def->xlevel2 =3D > + kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX); > + /* Support VIA max extended level */ > + x86_cpu_def->features[FEAT_C000_0001_EDX] =3D > + kvm_arch_get_supported_cpuid(s, 0xC0000001, 0, R_EDX); > =20 > /* Other KVM-specific feature fields: */ > x86_cpu_def->features[FEAT_SVM] =3D Otherwise looks okay to me. Andreas --=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