Received: from eggs.gnu.org ([2001:4830:134:3::10]:34487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aiRtV-0002R2-TT for qemu-devel@nongnu.org; Tue, 22 Mar 2016 15:23:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aiRtS-0007xe-LY for qemu-devel@nongnu.org; Tue, 22 Mar 2016 15:23:09 -0400 Received: from roura.ac.upc.es ([147.83.33.10]:34204) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aiRtS-0007xF-8r for qemu-devel@nongnu.org; Tue, 22 Mar 2016 15:23:06 -0400 From: =?utf-8?Q?Llu=C3=ADs_Vilanova?= References: <145625172744.12025.2350972792125742783.stgit@localhost> <20160302105553.GB11268@stefanha-x1.localdomain> <20160322125502.GH29248@stefanha-x1.localdomain> <877fgud30q.fsf@fimbulvetr.bsc.es> Date: Tue, 22 Mar 2016 20:23:01 +0100 In-Reply-To: (Peter Maydell's message of "Tue, 22 Mar 2016 14:47:01 +0000") Message-ID: <87mvpqb9m2.fsf@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 0/5] trace: Add events for vCPU memory accesses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Stefan Hajnoczi , QEMU Developers , Stefan Hajnoczi , Richard Henderson Peter Maydell writes: > On 22 March 2016 at 14:02, Llu=C3=ADs Vilanova wrot= e: >> Stefan Hajnoczi writes: >>=20 >>> On Wed, Mar 16, 2016 at 03:10:01PM +0000, Peter Maydell wrote: >>>> The first two patches which add TCG guest data access tracing look >>>> OK to me, but I'm much less sure about the last three which are >>>> adding tracing into linux-user syscall emulation. I'm not sure >>>> that lock_user is the right place to put that tracepoint. >>=20 >>> Any thoughts on this, Llu=C3=ADs? >>=20 >> Mmmm, I was struggling to find a place to easily add the tracing events >> whenever the syscall emulation code accesses guest memory. >>=20 >> The lock_user function is used precisely for that, but it can be a bit >> heavy-handed as to what memory is actually read/written, since it only m= arks the >> "potential" ability of doing so (it's a sort of acquire/release interfac= e that >> differentiates between read and write acquires). > Well, that's why I'm not certain about it. I would prefer us to > not trace the accesses rather than put a trace in a wrong > position. Theoretically, that's what DEBUG_REMAP is for. A temporary host buffer is allocated and data is copied in/out of it according to 'type' (VERIFY_READ/VERIFY_WRITE) and 'copy'; so if the lock_user/unlock_user call= s are incorrect, QEMU will not read/write the correct guest memory values for sys= call emulation. I used the logic when DEBUG_REMAP is used to understand when guest memory is declared to be read/written. So the current approach for tracing is never i= n a wrong position. The only problem I see is that the syscall emulation code can declare it wa= nts read & write access to some guest memory while a real system would only do = one of the two (or even none). Tracing this is not incorrect either, since it's= just how QEMU is emulating that syscall, but it could be sub-optimal compared to= a real syscall implementation. Cheers, Lluis