All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 12/12] trace: [all] Add "guest_vmem" event
Date: Thu, 06 Feb 2014 08:12:15 -0800	[thread overview]
Message-ID: <52F3B45F.1040009@twiddle.net> (raw)
In-Reply-To: <874n4ey7dj.fsf@fimbulvetr.bsc.es>

On 02/04/2014 12:01 PM, Lluís Vilanova wrote:
> Richard Henderson writes:
> 
>> On 01/31/2014 08:10 AM, Lluís Vilanova wrote:
>>> +#define ldub(p)    ({ trace_guest_vmem(p, 1, 0); ldub_raw(p);    })
> 
>> Are you sure you want to log these here?  Uses of these macros are
>> not restricted to the guest.  Therefore you could wind up with e.g.
>> PCI device accesses being attributed to the target cpu.
> 
> These defines are only enabled in user-level mode.
> 
> But I wrote them really long ago, and I just realized they are not
> up-to-date. The changes should also cover the 'cpu_*_data' and 'cpu_*_kernel'
> variants. These macros are mostly used in helpers (e.g., helper_boundl).

Yes, I know.  But they're also used in non-cpu contexts such as __get_user
(i.e. kernel accesses) or virtio.c (i.e. device accesses).

>> These are going to result in double-logging the same access with
> 
>>> +#define tcg_gen_qemu_ld_i32(val, addr, idx, memop)      \
>>> +    do {                                                \
>>> +        uint8_t _memop_size = _tcg_memop_size(memop);   \
>>> +        trace_guest_vmem_tcg(addr, _memop_size, 0);     \
>>> +        tcg_gen_qemu_ld_i32(val, addr, idx, memop);     \
>>> +    } while (0)
> 
>> ... these.
> 
> I don't see how 'tcg_gen_qemu_ld_i32' gets to call 'cpu_ldl_data'

tcg_gen_qemu_ld_i32 triggers some inline code, with an out of line fallback in
softmmu-template.h.

You're logging both on the main path (before qemu_ld_i32 opcode) and in the
fallback path.  It would be one thing if you logged something different in the
fallback path, but you're not.  You're using the exact same logging routine.

> What do you mean by non-target accesses? Accesses not directly "encoded" in the
> semantics of a guest instruction? If so, I did this in purpose (like the helper
> example on the top).

No, I mean accesses initiated by a device.  Such things are rare, I admit,
since most devices use physical addresses not virtual.  But e.g. old Sparc
hardware used a single mmu to handle both cpu and bus accesses.

> The 'trace_guest_vmem_tcg' function just calls a helper generator function in
> "helper.h", which cannot be included in "tcg.c". Another possibility is to just
> forget about using "helper.h", and instead "manually" generate the call to the
> helper; but using macros seems to me it's easier to maintain.

You simply need to move the declarations somewhere else.  See e.g.
tcg-runtime.h for a set of helpers shared across all translators.


r~

  reply	other threads:[~2014-02-06 16:12 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-31 16:09 [Qemu-devel] [PATCH 00/12] trace: [tcg] Allow tracing guest events in TCG-generated code Lluís Vilanova
2014-01-31 16:09 ` [Qemu-devel] [PATCH 01/12] trace: [tcg] Add documentation Lluís Vilanova
2014-01-31 16:09 ` [Qemu-devel] [PATCH 02/12] trace: [tracetool, tcg] Allow TCG types in trace event declarations Lluís Vilanova
2014-01-31 16:09 ` [Qemu-devel] [PATCH 03/12] trace: [tracetool] Add method 'Event.api' to get the name of public routines Lluís Vilanova
2014-01-31 16:09 ` [Qemu-devel] [PATCH 04/12] trace: [tracetool, tcg] Provide TCG-related type transformation rules Lluís Vilanova
2014-01-31 16:09 ` [Qemu-devel] [PATCH 05/12] trace: [tracetool] Allow argument types to be transformed Lluís Vilanova
2014-01-31 16:09 ` [Qemu-devel] [PATCH 06/12] trace: [tcg] Declare TCG tracing helper routines Lluís Vilanova
2014-01-31 16:09 ` [Qemu-devel] [PATCH 07/12] trace: [tcg] Define " Lluís Vilanova
2014-01-31 16:09 ` [Qemu-devel] [PATCH 08/12] trace: [tcg] Include TCG-tracing helpers on all helper.h Lluís Vilanova
2014-01-31 16:09 ` [Qemu-devel] [PATCH 09/12] trace: [tcg] Generate TCG tracing routines Lluís Vilanova
2014-01-31 16:09 ` [Qemu-devel] [PATCH 10/12] trace: [trivial] Include event definitions in "trace.h" Lluís Vilanova
2014-01-31 16:10 ` [Qemu-devel] [PATCH 11/12] trace: [tcg] Include TCG-tracing header on all targets Lluís Vilanova
2014-01-31 16:10 ` [Qemu-devel] [PATCH 12/12] trace: [all] Add "guest_vmem" event Lluís Vilanova
2014-02-04 15:08   ` Richard Henderson
2014-02-04 20:01     ` Lluís Vilanova
2014-02-06 16:12       ` Richard Henderson [this message]
2014-02-10 13:29         ` Lluís Vilanova
2014-02-03 14:40 ` [Qemu-devel] [PATCH 00/12] trace: [tcg] Allow tracing guest events in TCG-generated code Stefan Hajnoczi
2014-02-03 16:24   ` Lluís Vilanova
2014-02-04 14:57 ` Richard Henderson
2014-02-04 15:02   ` Peter Maydell
2014-02-04 15:17     ` Richard Henderson
2014-02-04 20:44       ` Lluís Vilanova
2014-02-04 20:34     ` Lluís Vilanova
2014-02-04 20:33   ` Lluís Vilanova
2014-02-06 15:57     ` Richard Henderson
2014-02-06 19:26       ` Lluís Vilanova
2014-02-07 14:49         ` Richard Henderson
2014-02-07 15:13           ` Peter Maydell
2014-02-07 15:24             ` Lluís Vilanova

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52F3B45F.1040009@twiddle.net \
    --to=rth@twiddle.net \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.