From patchwork Wed Mar 28 12:52:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 149195 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9D8A5B6EE7 for ; Wed, 28 Mar 2012 23:53:16 +1100 (EST) Received: from localhost ([::1]:38035 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCsND-0005Yp-QS for incoming@patchwork.ozlabs.org; Wed, 28 Mar 2012 08:53:11 -0400 Received: from eggs.gnu.org ([208.118.235.92]:39882) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCsMt-00058E-0Z for qemu-devel@nongnu.org; Wed, 28 Mar 2012 08:52:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SCsMq-0007pN-EP for qemu-devel@nongnu.org; Wed, 28 Mar 2012 08:52:50 -0400 Received: from cantor2.suse.de ([195.135.220.15]:39566 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCsMq-0007nT-4f; Wed, 28 Mar 2012 08:52:48 -0400 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id A73FB912E4; Wed, 28 Mar 2012 14:52:46 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Wed, 28 Mar 2012 14:52:16 +0200 Message-Id: <1332939159-16434-14-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.7 In-Reply-To: <1332939159-16434-1-git-send-email-afaerber@suse.de> References: <1332939159-16434-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.15 Cc: Anthony Liguori , kvm@suse.de, qemu-stable@nongnu.org, Bruce Rogers , Bharata B Rao , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PATCH stable-0.15 13/36] Fix X86 CPU topology in KVM mode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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. Acked-by: Jan Kiszka Signed-off-by: Bharata B Rao Signed-off-by: Anthony Liguori (cherry picked from commit f2209eb854a016eabc444b45f6d6b1636949141f) Signed-off-by: Bruce Rogers Signed-off-by: Andreas Färber --- hw/pc.c | 1 - target-i386/helper.c | 1 + 2 files changed, 1 insertions(+), 1 deletions(-) diff --git a/hw/pc.c b/hw/pc.c index a3e8539..14ce684 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -931,7 +931,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 e9be104..829c1da 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -1258,6 +1258,7 @@ CPUX86State *cpu_x86_init(const char *cpu_model) cpu_x86_close(env); return NULL; } + env->cpuid_apic_id = env->cpu_index; mce_init(env); qemu_init_vcpu(env);