Received: from eggs.gnu.org ([2001:4830:134:3::10]:33038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahhnB-0006fj-Qu for qemu-devel@nongnu.org; Sun, 20 Mar 2016 14:09:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ahhn8-0000rR-Ko for qemu-devel@nongnu.org; Sun, 20 Mar 2016 14:09:33 -0400 Received: from roura.ac.upc.edu ([147.83.33.10]:39895 helo=roura.ac.upc.es) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahhn8-0000rB-8X for qemu-devel@nongnu.org; Sun, 20 Mar 2016 14:09:30 -0400 From: =?utf-8?Q?Llu=C3=ADs_Vilanova?= References: <145625172744.12025.2350972792125742783.stgit@localhost> <145625173880.12025.6630606700468410319.stgit@localhost> <8737rorjsj.fsf@fimbulvetr.bsc.es> <87k2kzlixf.fsf@fimbulvetr.bsc.es> Date: Sun, 20 Mar 2016 19:09:20 +0100 In-Reply-To: (Peter Maydell's message of "Sat, 19 Mar 2016 13:59:56 +0000") Message-ID: <87lh5dggxb.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 2/5] trace: [all] Add "guest_vmem" event List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Paolo Bonzini , Richard Henderson , QEMU Developers , Stefan Hajnoczi , Peter Crosthwaite Peter Maydell writes: > On 18 March 2016 at 18:50, Llu=C3=ADs Vilanova wrot= e: >> Peter Maydell writes: >>> Trying to trace physaddrs is very tricky -- in the case of >>> a TLB hit there is no guarantee you can still identify the >>> physaddr of what you're accessing (the guest might have >>> changed the page tables and not invalidated the TLB). >>=20 >> I was looking at how to modify the soft TLB code to generate that inform= ation >> for the trace event, but it requires changes at every TCG target. But in= any >> case, that should always provide the same phys address used by QEMU, so = the >> event info is "correct" in that sense. Or did I miss something? > Consider the sequence: > * guest makes access to vaddr V, currently mapped to physaddr P1 > (which is host address H) > * we put the mapping V -> H into QEMU's TLB > * guest changes its page tables so V now maps to P2, > but doesn't do a TLB flush > * guest makes another access to vaddr V > * we hit in QEMU's TLB, so we know V and H; but we don't > know P1 (because we don't record that in the TLB) and we > can't even get it by walking the page table because > at this point V maps to P2, not P1. (And for sw-TLB > guest archs like MIPS you can't even do a V-to-P lookup > in QEMU non-intrusively.) > (This is often defined to be unpredictable or similar in the guest > architecture. But a buggy guest might do it, and tracing the > wrong thing would be pretty confusing if you were trying to > track down that bug.) Oh! Yes, I seem to remember that code path now, I checked it a really long = time ago. I was assuming that whenever this event is enabled at compile time, I = would have to modify QEMU's TLB to store the guest physical address (then used by= the tracing event). Cheers, Lluis