From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35914) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xbaf0-0000NZ-Fy for qemu-devel@nongnu.org; Tue, 07 Oct 2014 15:43:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xbaeu-0005T1-6i for qemu-devel@nongnu.org; Tue, 07 Oct 2014 15:43:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9377) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xbaet-0005Sx-UF for qemu-devel@nongnu.org; Tue, 07 Oct 2014 15:42:56 -0400 Message-ID: <5434423D.8030701@redhat.com> Date: Tue, 07 Oct 2014 14:42:53 -0500 From: Wei Huang MIME-Version: 1.0 References: <1412709453-11940-1-git-send-email-wei@redhat.com> In-Reply-To: <1412709453-11940-1-git-send-email-wei@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/1] target-i386: prevent users from setting threads>1 for AMD CPUs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: afaerber@suse.de Cc: qemu-devel@nongnu.org Sorry, please skip this version. I am sending out a updated one. -Wei On 10/07/2014 02:17 PM, Wei Huang wrote: > AMD CPU doesn't support hyperthreading. Even though QEMU fixes > this issue by setting CPUID_0000_0001_EBX and CPUID_8000_0008_ECX > via conversion, it is better to stop end-users in the first place > with a warning message. > > Signed-off-by: Wei Huang > --- > target-i386/cpu.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/target-i386/cpu.c b/target-i386/cpu.c > index e7bf9de..01bbcaf 100644 > --- a/target-i386/cpu.c > +++ b/target-i386/cpu.c > @@ -2742,6 +2742,24 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) > mce_init(cpu); > qemu_init_vcpu(cs); > > + /* AMD CPU doesn't support hyperthreading. Even though QEMU does fix > + * this issue by setting CPUID_0000_0001_EBX and CPUID_8000_0008_ECX > + * correctly, it is still better to stop end-users in the first place > + * by giving out a warning message. > + * > + * NOTE: cs->nr_threads is initialized in qemu_init_vcpu(). So the > + * following code has to follow qemu_init_vcpu(). > + */ > + if (env->cpuid_vendor1 == CPUID_VENDOR_AMD_1 && > + env->cpuid_vendor2 == CPUID_VENDOR_AMD_2 && > + env->cpuid_vendor3 == CPUID_VENDOR_AMD_3 && > + (cs->nr_threads > 1)) { > + error_setg(&local_err, > + "AMD CPU doesn't support hyperthreading. Please configure " > + "-smp options correctly."); > + goto out; > + } > + > x86_cpu_apic_realize(cpu, &local_err); > if (local_err != NULL) { > goto out; >