From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:59297) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R24fV-0000m9-0j for qemu-devel@nongnu.org; Fri, 09 Sep 2011 13:15:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R24fT-0004PW-Mm for qemu-devel@nongnu.org; Fri, 09 Sep 2011 13:15:08 -0400 Received: from mail-gw0-f52.google.com ([74.125.83.52]:46780) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R24fT-0004OO-Gw for qemu-devel@nongnu.org; Fri, 09 Sep 2011 13:15:07 -0400 Received: by gwj15 with SMTP id 15so1583067gwj.11 for ; Fri, 09 Sep 2011 10:15:06 -0700 (PDT) Message-ID: <4E6A4983.4010507@codemonkey.ws> Date: Fri, 09 Sep 2011 12:14:43 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1315460008-22657-1-git-send-email-bharata.rao@gmail.com> In-Reply-To: <1315460008-22657-1-git-send-email-bharata.rao@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v2] Fix X86 CPU topology in KVM mode List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: bharata.rao@gmail.com Cc: jan.kiszka@siemens.com, qemu-devel@nongnu.org, avi@redhat.com On 09/08/2011 12:33 AM, bharata.rao@gmail.com wrote: > From: Bharata B Rao > > apic id returned to guest kernel in ebx for cpuid(function=1) depends on > CPUX86State->cpuid_apic_id which gets populated after the cpuid information > is cached in the host kernel. This results in broken CPU topology in guest. > > Fix this by setting cpuid_apic_id before cpuid information is passed to > the host kernel. This is done by moving the setting of cpuid_apic_id > to cpu_x86_init() where it will work for both KVM as well as TCG modes. > > Signed-off-by: Bharata B Rao This breaks the build: CC i386-linux-user/helper.o /home/anthony/git/qemu/target-i386/helper.c: In function ‘cpu_x86_init’: /home/anthony/git/qemu/target-i386/helper.c:1260:47: error: ‘smp_cpus’ undeclared (first use in this function) /home/anthony/git/qemu/target-i386/helper.c:1260:47: note: each undeclared identifier is reported only once for each function it appears in make[1]: *** [helper.o] Error 1 make: *** [subdir-i386-linux-user] Error 2 Please do a full build before submitting patches. Regards, Anthony Liguori > --- > This is the next post of the fix that addresses Jan's comment about > bringing back (smp_cpus> 1) check. > > The previous version was posted here: > http://lists.gnu.org/archive/html/qemu-devel/2011-09/msg00892.html > > I coudn't boot a 486 kernel successfully with qemu and hence not > sure if and how this fix breaks i486. Any help from Jan or others > who might have easy means to boot 486 would be good. > > hw/pc.c | 1 - > target-i386/helper.c | 5 +++++ > 2 files changed, 5 insertions(+), 1 deletions(-) > > diff --git a/hw/pc.c b/hw/pc.c > index 5bc845a..f9cca4d 100644 > --- a/hw/pc.c > +++ b/hw/pc.c > @@ -933,7 +933,6 @@ static CPUState *pc_new_cpu(const char *cpu_model) > exit(1); > } > if ((env->cpuid_features& CPUID_APIC) || smp_cpus> 1) { > - env->cpuid_apic_id = env->cpu_index; > env->apic_state = apic_init(env, env->cpuid_apic_id); > } > qemu_register_reset(pc_cpu_reset, env); > diff --git a/target-i386/helper.c b/target-i386/helper.c > index 5df40d4..139a193 100644 > --- a/target-i386/helper.c > +++ b/target-i386/helper.c > @@ -1256,6 +1256,11 @@ CPUX86State *cpu_x86_init(const char *cpu_model) > cpu_x86_close(env); > return NULL; > } > + > + if ((env->cpuid_features& CPUID_APIC) || smp_cpus> 1) { > + env->cpuid_apic_id = env->cpu_index; > + } > + > mce_init(env); > > qemu_init_vcpu(env);