@@ -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 */
@@ -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 */
@@ -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 */
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(-)