Skip to content

Commit ddbe5be

Browse files
cube0x8rmalmain
andcommitted
add a flag for edge TB so we can unlink it completely (#53)
* add a flag for edge TB so we can unlink it completely * Call tb_phys_invalidate on edge's TBs. Added libafl code comments * Edge flag is now applied to cflags instead of flags --------- Co-authored-by: Romain Malmain <[email protected]>
1 parent 9ae7139 commit ddbe5be

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

accel/tcg/tb-maint.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,11 @@ static inline void tb_jmp_unlink(TranslationBlock *dest)
866866

867867
TB_FOR_EACH_JMP(dest, tb, n) {
868868
tb_reset_jump(tb, n);
869+
//// --- Begin LibAFL code ---
870+
if (tb->cflags & CF_IS_EDGE) {
871+
tb_phys_invalidate(tb, -1);
872+
}
873+
//// --- End LibAFL code ---
869874
qatomic_and(&tb->jmp_dest[n], (uintptr_t)NULL | 1);
870875
/* No need to clear the list entry; setting the dest ptr is enough */
871876
}

accel/tcg/translate-all.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ TranslationBlock *libafl_gen_edge(CPUState *cpu, target_ulong src_block,
403403
}
404404
tb->cs_base = cs_base;
405405
tb->flags = flags;
406-
tb->cflags = cflags;
406+
tb->cflags = cflags | CF_IS_EDGE;
407407
//tb_set_page_addr0(tb, phys_pc);
408408
//tb_set_page_addr1(tb, -1);
409409
tcg_ctx->gen_tb = tb;

include/exec/translation-block.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ struct TranslationBlock {
7777
#define CF_PARALLEL 0x00008000 /* Generate code for a parallel context */
7878
#define CF_NOIRQ 0x00010000 /* Generate an uninterruptible TB */
7979
#define CF_PCREL 0x00020000 /* Opcodes in TB are PC-relative */
80+
//// --- Begin LibAFL code ---
81+
#define CF_IS_EDGE 0x00800000 /* The current TB is an edge */
82+
//// --- End LibAFL code ---
8083
#define CF_CLUSTER_MASK 0xff000000 /* Top 8 bits are cluster ID */
8184
#define CF_CLUSTER_SHIFT 24
8285

0 commit comments

Comments
 (0)