Received: from eggs.gnu.org ([2001:4830:134:3::10]:54008) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpzVe-0004j1-9h for qemu-devel@nongnu.org; Fri, 30 Sep 2016 11:13:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpzVZ-0004vl-6d for qemu-devel@nongnu.org; Fri, 30 Sep 2016 11:13:58 -0400 Received: from roura.ac.upc.es ([147.83.33.10]:34893) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpzVY-0004u2-Pt for qemu-devel@nongnu.org; Fri, 30 Sep 2016 11:13:53 -0400 From: =?utf-8?Q?Llu=C3=ADs_Vilanova?= References: <874m50yxbk.fsf@fimbulvetr.bsc.es> <3cf0876d-6163-254d-68dd-601a713baccf@twiddle.net> Date: Fri, 30 Sep 2016 17:13:50 +0200 In-Reply-To: <3cf0876d-6163-254d-68dd-601a713baccf@twiddle.net> (Richard Henderson's message of "Wed, 28 Sep 2016 10:18:35 -0700") Message-ID: <87r381ju8h.fsf@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC] Tracing guest register usage List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: qemu-devel@nongnu.org, Paolo Bonzini , Peter Crosthwaite , Stefan Hajnoczi Richard Henderson writes: > On 09/28/2016 06:21 AM, Llu=C3=ADs Vilanova wrote: >> Hi! I've kept working on extending the guest instruction tracing feature= s, and >> added support to trace which registers are read/written by guest instruc= tions >> (when executing with TCG). >>=20 >> I've basically extended "tcg_global_mem_new_*" to associate global TCG r= egisters >> with a guest (vCPU) register number (*), and track all TCG opcodes that = access >> the values of these global TCG registers. >>=20 >> (*) This "mapping" is necessary because targets like i386 have multiple = global >> TCG registers (cc_dst, cc_src, ...) that correspond to a single guest >> register (eflags). > Is tracing all changes to a register something that's actually going to be > useful? If I were to log all changes to EAX, what would that tell me? That's a good question. I'm using it to reconstruct data dependencies in instruction traces, and others have posted other ad-hoc solutions to get th= is type of information before. If QEMU considers this type of information is not useful, I will move it to= my private tree. > As for the CC register split, there will be (1) groups of assignments that > correspond to a single change of the register and I have those covered. Marking a read/write to a guest register is an idempo= tent operation, since I trace those on a bitmask (even if the guest register is = split into multiple global TCG registers, that's what I have the mapping for). The instruction trace events basically have two additional arguments (bitmasks)= : a read set and a write set. > (2) an internal state change > to DisasContext, reflected in INDEX_op_insn_start, with no changes to any= TCG > registers. So you'll not actually be tracking eflags at all. I don't follow what you mean. AFAIK INDEX_op_insn_start does not change the guest eflags. > This seems like something that should actually apply to cpu internal regi= sters, > such as CR4, which are never TCG registers (and moreover are never manipu= lated > from TCG code at all). I'm aware that register accesses would not be traced for instructions implemented in helpers. The information is thus "best effort", but good eno= ugh for the majority of instructions, which are implemented in TCG. Thanks, Lluis