From patchwork Fri Jun 19 17:11:39 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 31378 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n5JHCBYp024091 for ; Fri, 19 Jun 2009 17:12:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753613AbZFSRL6 (ORCPT ); Fri, 19 Jun 2009 13:11:58 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753236AbZFSRL6 (ORCPT ); Fri, 19 Jun 2009 13:11:58 -0400 Received: from gecko.sbs.de ([194.138.37.40]:19041 "EHLO gecko.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752672AbZFSRL6 (ORCPT ); Fri, 19 Jun 2009 13:11:58 -0400 Received: from mail2.sbs.de (localhost [127.0.0.1]) by gecko.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id n5JHBdm0023743; Fri, 19 Jun 2009 19:11:41 +0200 Received: from [139.25.109.167] (mchn012c.mchp.siemens.de [139.25.109.167] (may be forged)) by mail2.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id n5JHBdbs018506; Fri, 19 Jun 2009 19:11:39 +0200 Message-ID: <4A3BC6CB.402@siemens.com> Date: Fri, 19 Jun 2009 19:11:39 +0200 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Avi Kivity CC: kvm-devel Subject: [PATCH] qemu-kvm: x86: Fix CPU initialization References: <4A3BA861.6040601@siemens.com> In-Reply-To: <4A3BA861.6040601@siemens.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Fix regression in CPU initialization caused by merge a5b526135d and try to avoid this in the future by dropping qemu-kvm specific pc_new_cpu. If such refactoring is desired, it should go through upstream first. Signed-off-by: Jan Kiszka --- hw/pc.c | 44 ++++++++++++++++++-------------------------- 1 files changed, 18 insertions(+), 26 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/hw/pc.c b/hw/pc.c index 6c19f55..c4117e5 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -839,31 +839,6 @@ int cpu_is_bsp(CPUState *env) return env->cpuid_apic_id == 0; } -CPUState *pc_new_cpu(int cpu, const char *cpu_model, int pci_enabled) -{ - CPUState *env = cpu_init(cpu_model); - if (!env) { - fprintf(stderr, "Unable to find x86 CPU definition\n"); - exit(1); - } - if (cpu != 0) - env->halted = 1; - if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) { - env->cpuid_apic_id = env->cpu_index; - apic_init(env); - } - qemu_register_reset(main_cpu_reset, 0, env); - if (pci_enabled) { - apic_init(env); - } - - /* kvm needs this to run after the apic is initialized. Otherwise, - * it can access invalid state and crash. - */ - qemu_init_vcpu(env); - return env; -} - /* PC hardware initialisation */ static void pc_init1(ram_addr_t ram_size, const char *boot_device, @@ -906,7 +881,24 @@ static void pc_init1(ram_addr_t ram_size, } for(i = 0; i < smp_cpus; i++) { - env = pc_new_cpu(i, cpu_model, pci_enabled); + env = cpu_init(cpu_model); + if (!env) { + fprintf(stderr, "Unable to find x86 CPU definition\n"); + exit(1); + } + if (cpu != 0) + env->halted = 1; + if ((env->cpuid_features & CPUID_APIC) || smp_cpus > 1) { + env->cpuid_apic_id = env->cpu_index; + apic_init(env); + } + qemu_register_reset(main_cpu_reset, 0, env); + + /* + * FIXME: qemu-kvm needs this after apic_init as it accesses APIC + * structures. + */ + qemu_init_vcpu(env); } vmport_init();