diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2008-04-03 18:37:16 -0500 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-04-05 00:21:53 +0300 |
commit | 69d4cbe4444a5b2e8e234e17d3146ebe7937ab18 (patch) | |
tree | 722ae158a738a1514cf169bb8c59b3e0e3e17697 | |
parent | dc1fe4244826046c29caba17b88783a8e2a549a2 (diff) |
Fix vmmouse with -smp
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 <aliguori@us.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
-rw-r--r-- | hw/pc.c | 2 | ||||
-rw-r--r-- | hw/pc.h | 2 | ||||
-rw-r--r-- | hw/vmport.c | 22 |
3 files changed, 12 insertions, 14 deletions
@@ -755,7 +755,7 @@ CPUState *pc_new_cpu(int cpu, const char *cpu_model, int pci_enabled) if (pci_enabled) { apic_init(env); } - vmport_init(env); + vmport_init(); return env; } @@ -63,7 +63,7 @@ int pit_get_out(PITState *pit, int channel, int64_t current_time); PITState *kvm_pit_init(int base, qemu_irq irq); /* 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 c09227d05..83fcbcb07 100644 --- a/hw/vmport.c +++ b/hw/vmport.c @@ -36,7 +36,6 @@ typedef struct _VMPortState { - CPUState *env; IOPortReadFunc *func[VMPORT_ENTRIES]; void *opaque[VMPORT_ENTRIES]; } VMPortState; @@ -55,18 +54,19 @@ 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; uint32_t ret; if (kvm_enabled()) - kvm_save_registers(s->env); + kvm_save_registers(env); - 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]) @@ -78,32 +78,30 @@ static uint32_t vmport_ioport_read(void *opaque, uint32_t addr) ret = s->func[command](s->opaque[command], addr); if (kvm_enabled()) - kvm_load_registers(s->env); + kvm_load_registers(env); return ret; } 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); } |