@@ -19,6 +19,12 @@
#include <assert.h>
#include "bbv_profiler.h"
+/* Magic number, which is set as bits 16-31 of the target of a branch which
+ * causes an exception to send a signal to the plugin.
+ */
+#define BBV_MAGIC_NUM 0xdead
+#define BBV_PRINT_STATS 0x0
+
static BasicBlockTraceHandle trace = NULL;
static uint32_t mode = 0;
static uint64_t pid = 0;
@@ -75,3 +81,12 @@ void bb_context_check_pid(uint64_t IC, uint64_t new_pid)
bbvec_pid_change(trace, new_pid, IC);
}
}
+
+/* Check if the bbv plugin is being signaled to do something by an exception */
+void bb_check_exception(uint64_t pc) {
+ if (((pc >> 16) & 0xffff) == BBV_MAGIC_NUM) {
+ uint16_t value = pc & 0xffff;
+ if (value == BBV_PRINT_STATS)
+ bbvec_print_stats(trace);
+ }
+}
@@ -31,5 +31,6 @@ int bbtrace_initialized(void);
void bb_process(uint64_t PC, uint64_t IC);
void bb_context_check_mode(uint64_t IC, uint32_t mode);
void bb_context_check_pid(uint64_t IC, uint64_t tpid);
+void bb_check_exception(uint64_t pc);
#endif
@@ -27,6 +27,10 @@
#include "qemu/crc32c.h"
#include <zlib.h> /* For crc32 */
+#ifdef CONFIG_BBVEC
+#include "bbv_profiler.h"
+#endif // CONFIG_BBVEC
+
/* C2.4.7 Multiply and divide */
/* special cases for 0 and LLONG_MIN are mandated by the standard */
uint64_t HELPER(udiv64)(uint64_t num, uint64_t den)
@@ -470,6 +474,12 @@ void aarch64_cpu_do_interrupt(CPUState *cs)
uint64_t mask;
#endif
+#ifdef CONFIG_BBVEC
+ if (bbtrace_initialized()) {
+ bb_check_exception(is_a64(env) ? env->pc : env->regs[15]);
+ }
+#endif
+
uint32_t syndrome =
cs->exception_index == EXCP_ARMV8_HLT ?
env->exception.syndrome & ~0xffff :
@@ -4773,6 +4773,12 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
arm_log_exception(cs->exception_index);
+#ifdef CONFIG_BBVEC
+ if (bbtrace_initialized()) {
+ bb_check_exception(env->regs[15]);
+ }
+#endif
+
lr = 0xfffffff1;
if (env->v7m.current_sp)
lr |= 4;
@@ -5074,6 +5080,12 @@ void arm_cpu_do_interrupt(CPUState *cs)
return;
}
+#ifdef CONFIG_BBVEC
+ if (bbtrace_initialized()) {
+ bb_check_exception(env->regs[15]);
+ }
+#endif
+
/* If this is a debug exception we must update the DBGDSCR.MOE bits */
switch (env->exception.syndrome >> ARM_EL_EC_SHIFT) {
case EC_BREAKPOINT:
This is necessary because we need a way to differentiate between instructions executed in a PID by the benchmark we care about and those executed by CRIU. Written by Aaron Lindsay. Signed-off-by: Christopher Covington <cov@codeaurora.org> --- bbv_profiler.c | 15 +++++++++++++++ bbv_profiler.h | 1 + target-arm/helper-a64.c | 10 ++++++++++ target-arm/helper.c | 12 ++++++++++++ 4 files changed, 38 insertions(+)