Skip to contentSkip to conversation

static instrumentation

Qemu-devel Lluís 3 participants 5 messages Oct 7, 2010 – Oct 9, 2010

lore
Share & tools
lore

Lluís

author
#0 lore raw

All virtual memory accesses should now be instrumented on all architectures.

Next steps (in order):

* Separately instrument physical memory addresses for executed instructions, regular memory accesses and memory accesses to I/O space (if possible). This will need to add an extra field on CPUTLBEntry with the physical address of the page.

* Instrument memory accesses performed by DMA operations.

* See how it plays with KVM. The objective is to make it switch from KVM to emulation (and the other way around) when a backdoor instruction is found.

* Finish implementation of used/defined register usage in x86.

As always:
git clone https://code.gso.ac.upc.edu/git/qemu-instrument
https://projects.gso.ac.upc.edu/projects/qemu-instrument

Lluis

Signature · 4 lines
 "And it's much the same thing with knowledge, for whenever you learn
 something new, the whole world becomes that much richer."
 -- The Princess of Pure Reason, as told by Norton Juster in The Phantom
 Tollbooth
#1 lore raw
Quoted 16 lines · Lluís

All virtual memory accesses should now be instrumented on all architectures.

Next steps (in order):

 * Separately instrument physical memory addresses for executed instructions, regular memory accesses and memory accesses to I/O space (if possible). This will need to add an extra field on CPUTLBEntry with the physical address of the page.

 * Instrument memory accesses performed by DMA operations.

 * See how it plays with KVM. The objective is to make it switch from KVM to emulation (and the other way around) when a backdoor instruction is found.

Quoted 5 lines

 * Finish implementation of used/defined register usage in x86.

As always:
  git clone https://code.gso.ac.upc.edu/git/qemu-instrument
  https://projects.gso.ac.upc.edu/projects/qemu-instrument

The patches there seem to be fixes or small changes to your other patches. This makes any review very difficult.

But I'm not sure the architecture is what we'd like to see integrated in QEMU, though I may have missed the whole picture because of the patch fragmentation problem. Before doing any work to possibly go further in wrong direction, please try to submit early some preview version for comments and review.

Just as an example, perhaps the existing tracing framework could be extended to cover also your needs.

author
#2 lore raw
Quoted 2 lines · Blue Swirl

The patches there seem to be fixes or small changes to your other patches. This makes any review very difficult.

Sorry, I'm really new to git, so I don't really know how to maintain and "grow" an organized set of patches for review while I keep improving the work.

Quoted 5 lines

But I'm not sure the architecture is what we'd like to see integrated in QEMU, though I may have missed the whole picture because of the patch fragmentation problem. Before doing any work to possibly go further in wrong direction, please try to submit early some preview version for comments and review.

I can try to refactor the changes into a sensible set of patches, but please read first the motivation of this work (below).

Quoted 2 lines

Just as an example, perhaps the existing tracing framework could be extended to cover also your needs.

Well, for what I've seen of the tracing infrastructure ("tracing" from here on), it is geared towards tracing qemu internal events (for analyzing qemu performance), while static instrumentation ("instrumentation" from here on) is geared towards tracing guest events, in order to analyze guest behaviour.

The reason for having static instrumentation points in the form of macros (diverging from the approach taken in tracing) is that the most common instrumentation points are invoked at code generation time. This way the user can dynamically select which extra code to call and/or generate (if any) on each of these points, with the addition that code can be selected for regeneration when the instrumentation points need to produce different code (e.g., no instrumentation, event counting, sketchy trace generation, detailed trace generation, etc.).

So, I think they are geared towards different goals, although they are indeed composable (e.g., the user can expand the instrumentation macros into calls to the tracing infrastructure).

Wether or not this fits into upstream qemu is not for me to say, but it provides the initial stepping stone that is commonly used in computer architecture research (e.g., http://www.ptlsim.org or
http://sesc.sourceforge.net/), with the added bonus that qemu supports multiple ISAs, as well as executing standalone applications and a full-fledged system.

Of course, the simulator itself would be out of qemu, thus the macros :)

Lluis

Signature · 4 lines
 "And it's much the same thing with knowledge, for whenever you learn
 something new, the whole world becomes that much richer."
 -- The Princess of Pure Reason, as told by Norton Juster in The Phantom
 Tollbooth
#3 lore raw
Quoted 8 lines · Lluís
Quoted 2 lines · Blue Swirl

The patches there seem to be fixes or small changes to your other patches. This makes any review very difficult.

Sorry, I'm really new to git, so I don't really know how to maintain and "grow" an organized set of patches for review while I keep improving the work.

Some kind of patch queue or stack tool can help, I use StGit (integrates nicely with QGit) but there are others.

The workflow should aim for a set of committable patches. This means that instead of patch sequence
1 - implement feature A
2 - fix for feature A
3 - implement feature B
4 - more fixes for feature A
5 - fixes for feature B

etc, the patches should be perfected, like this:
1 - implement feature A
2 - implement feature B

This can be achieved by working with the patch stack:
1 - implement feature A
fix for feature A needed: fix, refresh 1
2 - implement feature B
more fixes for feature A needed: pop 2, include fixes to 1 fixes for feature B: push 2, fix and refresh 2

This also makes keeping up with HEAD simpler (though conflicts need to be managed anyway):
pop all patches
git pull
push patches one at a time, fix conflicts if needed.

Quoted 28 lines
Quoted 5 lines

But I'm not sure the architecture is what we'd like to see integrated in QEMU, though I may have missed the whole picture because of the patch fragmentation problem. Before doing any work to possibly go further in wrong direction, please try to submit early some preview version for comments and review.

I can try to refactor the changes into a sensible set of patches, but please read first the motivation of this work (below).

Quoted 2 lines

Just as an example, perhaps the existing tracing framework could be extended to cover also your needs.

Well, for what I've seen of the tracing infrastructure ("tracing" from here on), it is geared towards tracing qemu internal events (for analyzing qemu performance), while static instrumentation ("instrumentation" from here on) is geared towards tracing guest events, in order to analyze guest behaviour.

The reason for having static instrumentation points in the form of macros (diverging from the approach taken in tracing) is that the most common instrumentation points are invoked at code generation time. This way the user can dynamically select which extra code to call and/or generate (if any) on each of these points, with the addition that code can be selected for regeneration when the instrumentation points need to produce different code (e.g., no instrumentation, event counting, sketchy trace generation, detailed trace generation, etc.).

Quoted 3 lines

So, I think they are geared towards different goals, although they are indeed composable (e.g., the user can expand the instrumentation macros into calls to the tracing infrastructure).

Maybe the goals are different, but even with this description, I don't see why tracing could not be extended also to generated code (again, I don't know the instrumentation side). From QEMU code maintenance point of view, a unified approach would be much preferable to two different, overlapping systems.

Quoted 8 lines

Wether or not this fits into upstream qemu is not for me to say, but it provides the initial stepping stone that is commonly used in computer architecture research (e.g., http://www.ptlsim.org or
http://sesc.sourceforge.net/), with the added bonus that qemu supports multiple ISAs, as well as executing standalone applications and a full-fledged system.

Of course, the simulator itself would be out of qemu, thus the macros :)

Is the simulator available? Otherwise testing would be difficult.

#4 lore raw

Re: [Qemu-devel] Handling patch queues (was: [STATUS] static instrumentation)

Am 08.10.2010 um 18:53 schrieb Blue Swirl:

Quoted 32 lines · Lluís
Quoted 8 lines
Quoted 2 lines · Blue Swirl

The patches there seem to be fixes or small changes to your other patches. This makes any review very difficult.

Sorry, I'm really new to git, so I don't really know how to maintain and "grow" an organized set of patches for review while I keep improving the work.

Some kind of patch queue or stack tool can help, I use StGit (integrates nicely with QGit) but there are others.

The workflow should aim for a set of committable patches. This means that instead of patch sequence
1 - implement feature A
2 - fix for feature A
3 - implement feature B
4 - more fixes for feature A
5 - fixes for feature B

etc, the patches should be perfected, like this:
1 - implement feature A
2 - implement feature B

This can be achieved by working with the patch stack:
1 - implement feature A
fix for feature A needed: fix, refresh 1
2 - implement feature B
more fixes for feature A needed: pop 2, include fixes to 1 fixes for feature B: push 2, fix and refresh 2

Quoted 5 lines

This also makes keeping up with HEAD simpler (though conflicts need to be managed anyway):
pop all patches
git pull
push patches one at a time, fix conflicts if needed.

git rebase -i origin/master sometimes works for me.
Commits can then be selected to be reworked, followed by git rebase --continue. This usually works better than manual git am / patch -p1 since you get a three-way merge.

Your last commit can be changed with git commit --amend. Especially handy is -s, which adds the forgotten SOB. ;)

I've used the pop-pull-push model with Mercurial's mq and find it really awful (uncomfortable), but that seems a matter of taste.

Instead I often use two Git branches per topic, one for (unordered) local work and one queue for upstream. On the latter I (cherry-)pick from the work branch, then rebase the work branch against the queue to slim it down. Updating to HEAD means one rebase against origin for the queue and one rebase -i against the queue. While rebasing becomes slightly more complicated, experimenting when you don't know in advance what you'll change next becomes easier and compilation times stay lower compared to frequent checkout of different file versions.

Working with one queue requires some caution, like backing up the branch before reworking (git branch / git format-patch).

HTH,
Andreas