From patchwork Mon Aug 17 17:32:32 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Reimar_D=C3=B6ffinger?= X-Patchwork-Id: 31529 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id C27C2B708B for ; Tue, 18 Aug 2009 03:33:19 +1000 (EST) Received: from localhost ([127.0.0.1]:57766 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Md655-0006TZ-O5 for incoming@patchwork.ozlabs.org; Mon, 17 Aug 2009 13:33:15 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Md64Y-0006OY-59 for qemu-devel@nongnu.org; Mon, 17 Aug 2009 13:32:42 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Md64T-0006La-En for qemu-devel@nongnu.org; Mon, 17 Aug 2009 13:32:41 -0400 Received: from [199.232.76.173] (port=47523 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Md64T-0006LX-5t for qemu-devel@nongnu.org; Mon, 17 Aug 2009 13:32:37 -0400 Received: from mail.gmx.net ([213.165.64.20]:55658) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1Md64S-00019u-JC for qemu-devel@nongnu.org; Mon, 17 Aug 2009 13:32:36 -0400 Received: (qmail invoked by alias); 17 Aug 2009 17:32:34 -0000 Received: from p5B1345D1.dip.t-dialin.net (EHLO localhost) [91.19.69.209] by mail.gmx.net (mp008) with SMTP; 17 Aug 2009 19:32:34 +0200 X-Authenticated: #11956158 X-Provags-ID: V01U2FsdGVkX1+IT3QGOaeIv4iXcCoJ9RWKmEs2Xuao+qvwWDuk2J HpXnBah4eqyTeI Date: Mon, 17 Aug 2009 19:32:32 +0200 From: Reimar =?iso-8859-1?Q?D=F6ffinger?= To: Paolo Bonzini Message-ID: <20090817173232.GA1961@1und1.de> References: <20090817144754.GA31553@1und1.de> <4A89730F.7090206@codemonkey.ws> <20090817154557.GB365@1und1.de> <4A8988DB.3040108@gnu.org> <20090817170017.GB1835@1und1.de> <4A899081.9010508@gnu.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4A899081.9010508@gnu.org> User-Agent: Mutt/1.5.20 (2009-06-14) X-Y-GMX-Trusted: 0 X-FuHaFi: 0.59 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: qemu-devel Subject: [Qemu-devel] Re: [HACK] make vmmouse work with KVM X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On Mon, Aug 17, 2009 at 07:16:49PM +0200, Paolo Bonzini wrote: > On 08/17/2009 07:00 PM, Reimar Döffinger wrote: > > On Mon, Aug 17, 2009 at 06:44:11PM +0200, Paolo Bonzini wrote: > >> On 08/17/2009 05:45 PM, Reimar Döffinger wrote: > >>> + cpu_synchronize_state(env, 0); > >>> env->regs[R_EAX] = vmport_ioport_read(opaque, addr); > >>> + cpu_synchronize_state(env, 1); > >> > >> This is not needed because the sync is done in vmport_ioport_read, isn't it? > > > > Well... The cpu_synchronize_state could be dropped you are right, but > > here we write R_EAX so the cpu_synchronize_state(env, 1) is necessary. > > It might be slightly cleaner to rename the vmport_ioport_read (any name > > suggestions?) and add a wrapper for register_ioport_read that does the > > cpu_synchronize_state (so it looks similar to vmport_ioport_write). > > Yes, that would look best and wouldn't have fooled me. Could > vmport_ioport_trigger be a decent name? Since what that function actually does is execute a specific command it gets from ecx I went with vmport_ioport_command, but I'll happily leave the naming to whoever applies it :-) Greetings, Reimar Döffinger diff --git a/hw/vmport.c b/hw/vmport.c index 884af3f..7ba6e2e 100644 --- a/hw/vmport.c +++ b/hw/vmport.c @@ -25,6 +25,7 @@ #include "isa.h" #include "pc.h" #include "sysemu.h" +#include "kvm.h" //#define VMPORT_DEBUG @@ -51,7 +52,7 @@ void vmport_register(unsigned char command, IOPortReadFunc *func, void *opaque) port_state.opaque[command] = opaque; } -static uint32_t vmport_ioport_read(void *opaque, uint32_t addr) +static uint32_t vmport_ioport_command(void *opaque, uint32_t addr) { VMPortState *s = opaque; CPUState *env = cpu_single_env; @@ -76,11 +77,24 @@ static uint32_t vmport_ioport_read(void *opaque, uint32_t addr) return s->func[command](s->opaque[command], addr); } +static uint32_t vmport_ioport_read(void *opaque, uint32_t addr) +{ + CPUState *env = cpu_single_env; + uint32_t result; + + cpu_synchronize_state(env, 0); + result = vmport_ioport_command(opaque, addr); + cpu_synchronize_state(env, 1); + return result; +} + static void vmport_ioport_write(void *opaque, uint32_t addr, uint32_t val) { CPUState *env = cpu_single_env; - env->regs[R_EAX] = vmport_ioport_read(opaque, addr); + cpu_synchronize_state(env, 0); + env->regs[R_EAX] = vmport_ioport_command(opaque, addr); + cpu_synchronize_state(env, 1); } static uint32_t vmport_cmd_get_version(void *opaque, uint32_t addr)