Received: from eggs.gnu.org ([2001:4830:134:3::10]:49916) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aijSF-0006CM-3U for qemu-devel@nongnu.org; Wed, 23 Mar 2016 10:08:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aijS9-0003xx-9w for qemu-devel@nongnu.org; Wed, 23 Mar 2016 10:08:11 -0400 Received: from roura.ac.upc.es ([147.83.33.10]:39910) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aijS8-0003x7-Ud for qemu-devel@nongnu.org; Wed, 23 Mar 2016 10:08:05 -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> <87mvpqb9m2.fsf@fimbulvetr.bsc.es> Date: Wed, 23 Mar 2016 15:08:01 +0100 In-Reply-To: (Peter Maydell's message of "Tue, 22 Mar 2016 20:23:21 +0000") Message-ID: <877fgt9tj2.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 19:23, Llu=C3=ADs Vilanova wrot= e: >> Peter Maydell writes: >>> 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. >>=20 >> 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 c= alls are >> incorrect, QEMU will not read/write the correct guest memory values for = syscall >> emulation. >>=20 >> I used the logic when DEBUG_REMAP is used to understand when guest memor= y is >> declared to be read/written. So the current approach for tracing is neve= r in a >> wrong position. >>=20 >> The only problem I see is that the syscall emulation code can declare it= wants >> 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 i= t's just >> how QEMU is emulating that syscall, but it could be sub-optimal compared= to a >> real syscall implementation. > Also we sometimes lock an entire buffer but then don't read or write > all of it. And a few places call g2h() directly and accesses via > those code paths won't get traced. > But really, an access to implement a syscall isn't a guest memory > access, it's part of the implementation of the emulated kernel ABIs. > We have tracing for that, it's the strace code (though the strace > code is really very poor currently). > Tracing memory accesses made by the emulated CPU makes total sense; > but I think "what tracing should we do for linux-user code" is > a separate question. I see; I wasn't aware of strace support in QEMU. Maybe tracing that is goin= g to be an easier alternative if there is no clear way to express "guest memory accesses from emulated syscalls". We could just have a very simple pair of events: syscallN_pre(uint64_t num, uint64_t arg1, ..., uint64_t argN) syscallN_post(uint64_t num, uint64_t res, uint64_t arg1, ..., uint64_t ar= gN) hooked into the calls to strace. Cheers, Lluis