qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Clemens Kolbitsch <ck@iseclab.org>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] TB monitoring
Date: Fri, 5 Feb 2010 16:01:21 +0100	[thread overview]
Message-ID: <201002051601.21927.ck@iseclab.org> (raw)

Guys,

I need a Qemu-internals expert to help me out here:

I'm trying to monitor execution of certain (user-land) TBs in a i386-softmmu 
system. For this, the cpu-main loop has been patched:

Before jumping into a TB's generated code, I first check its guest-virtual 
start  address whether it matches any of my monitored EIPs. Obviously, this 
only works for monitoring function starts (or other locations where a new TB 
is guaranteed to start) and with TB-chaining turned off. So far, this has been 
working great (for years even).

Now I tried to improve the performance of my monitoring system by doing the 
following: Each TB is associated with an additional 2 bits (in the "cflags"): 
"seen-before" and "monitored". Whenever I check a TB, I also set its seen-
before flag and update the monitored bit (if the TB contains a monitored start 
EIP).

Since a TB might be shared between two guest processes (the system is 
monitoring a Windows XP guest), I also save the a guest-process unique ID with 
the TB (using some bits from its CR3).

With this, I can skip checking a TB if its seen-before bit is set, but the 
monitored is clear. If the TB's guest-process-ID is different from the 
currently executing process-ID I just reset the seen-before bit (which forces 
the EIP analysis).

I have tried this on various programs, running inside my guest and it seems to 
be fast and working (almost ;-)). However, sometimes (*very* rarely), the 
above approach misses a monitored TB (skips analysis).

Could someone comment on my approach, maybe including some of the following 
thoughts:

1) is it possible that a TB grows ... i.e., it merges with a second TB where 
the second is monitored but the first one isn't?

2) are there any situations how a TB can be created without going through 
tb_alloc (which internally resets the cflags and thus my bits)?

Note that my code is based on Qemu 0.9.1 (if you wonder why I refer to certain 
old-style Qemu-internals).

Any help would be greatly appreciated!! If you need some more information or 
don't fully understand the problem, please don't hesitate to ask.

Thanks!!
Clemens

                 reply	other threads:[~2010-02-05 15:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=201002051601.21927.ck@iseclab.org \
    --to=ck@iseclab.org \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).