From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JhYzk-00022p-OK for qemu-devel@nongnu.org; Thu, 03 Apr 2008 19:37:24 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JhYzk-00022d-7b for qemu-devel@nongnu.org; Thu, 03 Apr 2008 19:37:24 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JhYzk-00022a-0X for qemu-devel@nongnu.org; Thu, 03 Apr 2008 19:37:24 -0400 Received: from e36.co.us.ibm.com ([32.97.110.154]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JhYzj-0001rK-HX for qemu-devel@nongnu.org; Thu, 03 Apr 2008 19:37:23 -0400 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e36.co.us.ibm.com (8.13.8/8.13.8) with ESMTP id m33NbI3r012113 for ; Thu, 3 Apr 2008 19:37:18 -0400 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v8.7) with ESMTP id m33NbILc220836 for ; Thu, 3 Apr 2008 17:37:18 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m33NbI8t009537 for ; Thu, 3 Apr 2008 17:37:18 -0600 From: Anthony Liguori Date: Thu, 3 Apr 2008 18:37:16 -0500 Message-Id: <1207265836-12156-1-git-send-email-aliguori@us.ibm.com> Subject: [Qemu-devel] [PATCH] Fix vmmouse with -smp Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kvm-devel@lists.sourceforge.net, Anthony Liguori The vmport code is very broken for SMP guests. It uses a global CPUState that's initialized multiple times? At any rate, since it needs to know CPU registers for the current CPU in a PIO handler, it needs to use cpu_single_env. This patch makes vmmouse when using -smp > 1 Signed-off-by: Anthony Liguori diff --git a/hw/pc.c b/hw/pc.c index 4fec2d4..e126f92 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -748,9 +748,10 @@ static void pc_init1(int ram_size, int vga_ram_size, if (pci_enabled) { apic_init(env); } - vmport_init(env); } + vmport_init(); + /* allocate RAM */ ram_addr = qemu_ram_alloc(ram_size); cpu_register_physical_memory(0, ram_size, ram_addr); diff --git a/hw/pc.h b/hw/pc.h index 9f83050..8626599 100644 --- a/hw/pc.h +++ b/hw/pc.h @@ -59,7 +59,7 @@ int pit_get_mode(PITState *pit, int channel); int pit_get_out(PITState *pit, int channel, int64_t current_time); /* vmport.c */ -void vmport_init(CPUState *env); +void vmport_init(void); void vmport_register(unsigned char command, IOPortReadFunc *func, void *opaque); /* vmmouse.c */ diff --git a/hw/vmport.c b/hw/vmport.c index 8044c9f..3655ad1 100644 --- a/hw/vmport.c +++ b/hw/vmport.c @@ -34,7 +34,6 @@ typedef struct _VMPortState { - CPUState *env; IOPortReadFunc *func[VMPORT_ENTRIES]; void *opaque[VMPORT_ENTRIES]; } VMPortState; @@ -53,14 +52,15 @@ void vmport_register(unsigned char command, IOPortReadFunc *func, void *opaque) static uint32_t vmport_ioport_read(void *opaque, uint32_t addr) { VMPortState *s = opaque; + CPUState *env = cpu_single_env; unsigned char command; uint32_t eax; - eax = s->env->regs[R_EAX]; + eax = env->regs[R_EAX]; if (eax != VMPORT_MAGIC) return eax; - command = s->env->regs[R_ECX]; + command = env->regs[R_ECX]; if (command >= VMPORT_ENTRIES) return eax; if (!s->func[command]) @@ -74,25 +74,23 @@ static uint32_t vmport_ioport_read(void *opaque, uint32_t addr) static uint32_t vmport_cmd_get_version(void *opaque, uint32_t addr) { - CPUState *env = opaque; + CPUState *env = cpu_single_env; env->regs[R_EBX] = VMPORT_MAGIC; return 6; } static uint32_t vmport_cmd_ram_size(void *opaque, uint32_t addr) { - CPUState *env = opaque; + CPUState *env = cpu_single_env; env->regs[R_EBX] = 0x1177; return ram_size; } -void vmport_init(CPUState *env) +void vmport_init(void) { - port_state.env = env; - register_ioport_read(0x5658, 1, 4, vmport_ioport_read, &port_state); /* Register some generic port commands */ - vmport_register(VMPORT_CMD_GETVERSION, vmport_cmd_get_version, env); - vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, env); + vmport_register(VMPORT_CMD_GETVERSION, vmport_cmd_get_version, NULL); + vmport_register(VMPORT_CMD_GETRAMSIZE, vmport_cmd_ram_size, NULL); }