Patchwork [17/18] instrument: Add PLVL point

login
register
mail settings
Submitter =?utf-8?Q?Llu=C3=ADs?=
Date Oct. 19, 2010, 9:36 p.m.
Message ID <598ad25fcb00a293e90d37e8827685b37ebfd4b9.1287772676.git.vilanova@ac.upc.edu>
Download mbox | patch
Permalink /patch/68951/
State New
Headers show

Comments

=?utf-8?Q?Llu=C3=ADs?= - Oct. 19, 2010, 9:36 p.m.
Signed-off-by: LluĂ­s Vilanova <vilanova@ac.upc.edu>
---
 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(-)

Patch

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 */