Signed-off-by: Lluís Vilanova <[email protected]>
---
instrument/examples/dynprint/guest/test.c | 1 +
.../examples/dynprint/host/instrument-host.h | 21 ++++++++++++++++---
instrument/host-stub.h | 7 ++++++
3 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/instrument/examples/dynprint/guest/test.c
b/instrument/examples/dynprint/guest/test.c
index b6b5788..ce43a48 100644
--- a/instrument/examples/dynprint/guest/test.c
+++ b/instrument/examples/dynprint/guest/test.c
@@ -31,6 +31,7 @@ main ()
int i;
BACKDOOR_i8(0x01); /* enable instrumentation */
+ BACKDOOR_i8_V(0x01, INSTR_TYPE_USER);
printf("start\n");
BACKDOOR_i8_V(0x01, INSTR_TYPE_PC); /* show executed PCs */
diff --git a/instrument/examples/dynprint/host/instrument-host.h
b/instrument/examples/dynprint/host/instrument-host.h
index 30eb7d4..24b6ece 100644
--- a/instrument/examples/dynprint/host/instrument-host.h
+++ b/instrument/examples/dynprint/host/instrument-host.h
@@ -32,6 +32,7 @@ typedef enum {
* global state of tracing is wasteful, but hey, this
is
* just an example.
*/
+ INSTR_TYPE_USER, /* Executing at user-level */
INSTR_TYPE_PC, /* Print fetched PC */
INSTR_TYPE_ALL, /* Print all instruction information */
INSTR_TYPE_COUNT /* Total number of instrumentation types (mandatory) */
@@ -41,10 +42,10 @@ typedef enum {
#define INSTR_GEN_FETCH(taddr, addr, tlength, length, \
tused, used, tdefined, defined) \
do { \
- if (INSTR_TYPE(ENABLED) && INSTR_TYPE(PC)) { \
+ if (INSTR_TYPE(ENABLED) && INSTR_TYPE(PC) && INSTR_TYPE(USER)) { \
INSTR_GEN_1(pc, taddr, addr); \
} \
- if (INSTR_TYPE(ENABLED) && INSTR_TYPE(ALL)) { \
+ if (INSTR_TYPE(ENABLED) && INSTR_TYPE(ALL) && INSTR_TYPE(USER)) { \
INSTR_GEN_4(all_fetch, taddr, addr, tlength, length, \
tused, used, tdefined, defined); \
} \
@@ -52,7 +53,7 @@ typedef enum {
#define INSTR_GEN_VMEM(taddr, addr, tlength, length, tmode, mode) \
do { \
- if (INSTR_TYPE(ENABLED) && INSTR_TYPE(ALL)) { \
+ if (INSTR_TYPE(ENABLED) && INSTR_TYPE(ALL) && INSTR_TYPE(USER)) { \
INSTR_GEN_3(all_mem, taddr, addr, tlength, length, \
tmode, mode); \
} \
@@ -60,9 +61,21 @@ typedef enum {
#define INSTR_DO_VMEM(cpu, addr, length, mode) \
do { \
- if (INSTR_TYPE(ENABLED) && INSTR_TYPE(ALL)) { \
+ if (INSTR_TYPE(ENABLED) && INSTR_TYPE(ALL) && INSTR_TYPE(USER)) { \
helper_all_mem_direct(addr, length, mode); \
} \
} while (0)
+#define INSTR_DO_PLVL(cpu, plvl) \
+ do { \
+ if (INSTR_CPU_TYPE(cpu, ENABLED)) { \
+ if (plvl == 0) { \
+ instr_disable_type(INSTR_TYPE_USER); \
+ } \
+ else{ \
+ instr_enable_type(INSTR_TYPE_USER); \
+ } \
+ } \
+ } while (0)
+
#endif /* INSTRUMENT_HOST_H */
diff --git a/instrument/host-stub.h b/instrument/host-stub.h
index bfe5b06..5cba4f2 100644
--- a/instrument/host-stub.h
+++ b/instrument/host-stub.h
@@ -71,4 +71,11 @@ typedef enum {
*/
#define INSTR_DO_VMEM(cpu, addr, length, mode)
+/** Signal a privilege level change.
+ * This is called before actually changing the privilege level.
+ * @param cpu CPU performing the operation (CPUState*)
+ * @param plvl New value for the privilege level (uint32_t)
+ */
+#define INSTR_DO_PLVL(cpu, plvl)
+
#endif /* INSTRUMENT__HOST_STUB_H */
--
1.7.1
--
"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