From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M1iRU-0005Gv-2e for qemu-devel@nongnu.org; Wed, 06 May 2009 10:49:52 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M1iRO-0005Ey-UO for qemu-devel@nongnu.org; Wed, 06 May 2009 10:49:51 -0400 Received: from [199.232.76.173] (port=60946 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M1iRO-0005Eh-FQ for qemu-devel@nongnu.org; Wed, 06 May 2009 10:49:46 -0400 Received: from mx2.redhat.com ([66.187.237.31]:38805) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M1iRN-0000YZ-NT for qemu-devel@nongnu.org; Wed, 06 May 2009 10:49:46 -0400 From: Glauber Costa Date: Wed, 6 May 2009 10:49:39 -0400 Message-Id: <1241621382-21577-2-git-send-email-glommer@redhat.com> In-Reply-To: <1241621382-21577-1-git-send-email-glommer@redhat.com> References: <1241621382-21577-1-git-send-email-glommer@redhat.com> Subject: [Qemu-devel] [PATCH 1/4] move registering of cpu_reset to inside cpu_init List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com This is not pc specific by any means. So we can be moved to inside cpu_x86_init(). This is part of an attempt to only initialize kvm state after everything is already properly initialized. If we don't do that, we can race against, for example, APIC state if kvm vcpus are ran in threads (happens in qemu-kvm.git, soon to happen here too) Signed-off-by: Glauber Costa --- hw/pc.c | 7 ------- target-i386/helper.c | 8 ++++++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/hw/pc.c b/hw/pc.c index 61f6e7b..351de83 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -725,12 +725,6 @@ static void load_linux(target_phys_addr_t option_rom, generate_bootsect(option_rom, gpr, seg, 0); } -static void main_cpu_reset(void *opaque) -{ - CPUState *env = opaque; - cpu_reset(env); -} - static const int ide_iobase[2] = { 0x1f0, 0x170 }; static const int ide_iobase2[2] = { 0x3f6, 0x376 }; static const int ide_irq[2] = { 14, 15 }; @@ -861,7 +855,6 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size, /* XXX: enable it in all cases */ env->cpuid_features |= CPUID_APIC; } - qemu_register_reset(main_cpu_reset, env); if (pci_enabled) { apic_init(env); } diff --git a/target-i386/helper.c b/target-i386/helper.c index a070e08..2210412 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -29,6 +29,7 @@ #include "exec-all.h" #include "qemu-common.h" #include "kvm.h" +#include "hw/hw.h" //#define DEBUG_MMU @@ -507,6 +508,11 @@ void cpu_reset(CPUX86State *env) cpu_watchpoint_remove_all(env, BP_CPU); } +static void main_cpu_reset(void *_env) +{ + cpu_reset((CPUState *)_env); +} + void cpu_x86_close(CPUX86State *env) { qemu_free(env); @@ -1689,6 +1695,8 @@ CPUX86State *cpu_x86_init(const char *cpu_model) return NULL; } cpu_reset(env); + qemu_register_reset(main_cpu_reset, env); + #ifdef CONFIG_KQEMU kqemu_init(env); #endif -- 1.5.6.6