Skip to content

mtrace patch to efficiently record PC #2

@zeldovich

Description

@zeldovich

-------- Original Message --------
Subject: mtrace patch to efficiently record PC
Date: 2015-07-25 17:54
From: Sanketh Nalli sankey@cs.wisc.edu
To: Austin Clements aclements@csail.mit.edu

Hello Dr.Clements,

I have been working with mtrace for about an year
now and you probably don't remember, but I contacted
you sometime in October last year to know how to trace ALL
memory refs using mtrace.

I've done that successfully and I also found a way to efficiently
and easily trace/record guest program counters (PC) of all memory refs
made by the guest. Attached is the patch.

The reason I came up with it is because the current method mtrace
uses to record guest PC makes the kernel RCU barf at some point and we faced
some trouble with it.

Specifically, mtrace proceeds to translate the whole
basic block and regenerate cpu_single_env->eip (aka PC) when it thinks that the
value stored therein is stale. This is evident from the code and also the
comments in mtrace_get_pc(...); And I think translating a basic block
is a heavy wt. process !

I suggest an easier method which is to simply store the value of guest PC
in a temporary variable, in the generated target code stream.

For example, if this is the guest code :

0x3f : mov %%rax, (%%rax)

the target code will be :

...
mov $0x3f, (%rsi) (or some register picked by TCG)
... and the rest of the target code.

/* print out 0x3f to the trace when tracing is enabled */

The patch works and we have been using it so far.
Let me know what you think.

Sanketh Nalli
College of Letters and Sciences
University of Wisconsin-Madison
USA

guest_pc.patch.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions