From a5a49c3292a518fa33644c97a31e0150ededa1fc Mon Sep 17 00:00:00 2001 From: Alwin Berger Date: Tue, 26 Apr 2022 00:29:18 +0200 Subject: [PATCH] add hard-coded libafl_exec_systick_hook --- hw/timer/armv7m_systick.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/hw/timer/armv7m_systick.c b/hw/timer/armv7m_systick.c index 2f192011eb..04db11db00 100644 --- a/hw/timer/armv7m_systick.c +++ b/hw/timer/armv7m_systick.c @@ -39,8 +39,30 @@ static inline int64_t systick_scale(SysTickState *s) } } +/* Begin LibAFL instrumentation */ +extern void libafl_send_irq(int irqn); +extern int64_t libafl_get_clock( void ); +volatile unsigned int libafl_int_offset = 0; +volatile bool libafl_int_done = false; +/* This can be moved to a helper function later */ +inline void libafl_exec_systick_hook(void); +inline void libafl_exec_systick_hook(void) +{ + if (libafl_int_offset!=0 && libafl_int_offset) { + if (libafl_get_clock() >= libafl_int_offset) { + if (!libafl_int_done) { + libafl_int_done = true; + libafl_send_irq(0); + } + } else { + libafl_int_done = false; + } + } +} static void systick_timer_tick(void *opaque) { + libafl_exec_systick_hook(); +/* End LibAFL instrumentation */ SysTickState *s = (SysTickState *)opaque; trace_systick_timer_tick();