From patchwork Mon Aug 17 15:45:57 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: 31525 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 91642B7087 for ; Tue, 18 Aug 2009 01:46:41 +1000 (EST) Received: from localhost ([127.0.0.1]:47234 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Md4Pt-0004gm-Ov for incoming@patchwork.ozlabs.org; Mon, 17 Aug 2009 11:46:37 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Md4PO-0004f8-NP for qemu-devel@nongnu.org; Mon, 17 Aug 2009 11:46:06 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Md4PK-0004dY-A9 for qemu-devel@nongnu.org; Mon, 17 Aug 2009 11:46:06 -0400 Received: from [199.232.76.173] (port=51734 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Md4PK-0004dV-2P for qemu-devel@nongnu.org; Mon, 17 Aug 2009 11:46:02 -0400 Received: from mail.gmx.net ([213.165.64.20]:44979) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1Md4PJ-0005s3-Dx for qemu-devel@nongnu.org; Mon, 17 Aug 2009 11:46:01 -0400 Received: (qmail invoked by alias); 17 Aug 2009 15:45:58 -0000 Received: from p5B1345D1.dip.t-dialin.net (EHLO localhost) [91.19.69.209] by mail.gmx.net (mp039) with SMTP; 17 Aug 2009 17:45:58 +0200 X-Authenticated: #11956158 X-Provags-ID: V01U2FsdGVkX18RKoodDe0ResI18g85aFVjqf59Arzj6Cmk/9rUDH MBtanTR93Iw5cc Date: Mon, 17 Aug 2009 17:45:57 +0200 From: Reimar =?iso-8859-1?Q?D=F6ffinger?= To: qemu-devel@nongnu.org Subject: Re: [Qemu-devel] [HACK] make vmmouse work with KVM Message-ID: <20090817154557.GB365@1und1.de> References: <20090817144754.GA31553@1und1.de> <4A89730F.7090206@codemonkey.ws> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4A89730F.7090206@codemonkey.ws> User-Agent: Mutt/1.5.20 (2009-06-14) X-Y-GMX-Trusted: 0 X-FuHaFi: 0.65 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) 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 10:11:11AM -0500, Anthony Liguori wrote: > Reimar Döffinger wrote: > > Hello, > > vmmouse uses a giant hack: it uses io ports (in instruction) but passes > > data via registers. > > This currently does not work since the qemu CPU registers are > > (understandably) not kept in sync with the real KVM registers for this > > operation. > > Attached patch detects access to the vmmouse port and loads/stores CPU > > registers into/from the QEMU state. > > > > Should use cpu_synchronize_state() in vmport.c Ah, missed that function... Does attached patch look good? diff --git a/hw/vmport.c b/hw/vmport.c index 884af3f..9dc94a3 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 @@ -57,6 +58,9 @@ static uint32_t vmport_ioport_read(void *opaque, uint32_t addr) CPUState *env = cpu_single_env; unsigned char command; uint32_t eax; + uint32_t result; + + cpu_synchronize_state(env, 0); eax = env->regs[R_EAX]; if (eax != VMPORT_MAGIC) @@ -73,14 +77,19 @@ static uint32_t vmport_ioport_read(void *opaque, uint32_t addr) return eax; } - return s->func[command](s->opaque[command], addr); + result = s->func[command](s->opaque[command], 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; + cpu_synchronize_state(env, 0); env->regs[R_EAX] = vmport_ioport_read(opaque, addr); + cpu_synchronize_state(env, 1); } static uint32_t vmport_cmd_get_version(void *opaque, uint32_t addr)