Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Jul 16, 2014
1 parent ca26a8c commit 9a1b7e2
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 11 deletions.
5 changes: 4 additions & 1 deletion exec-all.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,10 @@ struct TranslationBlock {
uint32_t DECAF_num_opparam;
unsigned long DECAF_tb_id; /* AWH - offset of this in "tbs" (exec.c) */
uint16_t DECAF_num_temps; /* AWH - number of temp or local registers in this TB */
uint8_t DECAF_temp_type[64]; /* AWH - Bitmap to describe which registers are temp (0) or local (1) */
uint8_t DECAF_temp_type[256]; /* AWH - Bitmap to describe which registers are temp (0) or local (1) */
uint8_t DECAF_temp_size[256]; /* AWH - Bitmap to describe which registers are 32 bits (0) or 64 bits (1) */
uint8_t DECAF_disasm_code[256]; /* AWH - Guest code for this TB */
uint8_t DECAF_disasm_size; /* AWH - Size of guest code for this TB */
#endif /* CONFIG_TCG_IR_LOG */
};

Expand Down
2 changes: 1 addition & 1 deletion exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ uint64_t *gDECAF_gen_opparam_buf;
#endif /* TCG_TARGET_REG_BITS */
#endif /* CONFIG_TCG_IR_LOG */
/* AWH static */ TranslationBlock *tbs;
static int code_gen_max_blocks;
/* AWH static int */ uint32_t code_gen_max_blocks;
TranslationBlock *tb_phys_hash[CODE_GEN_PHYS_HASH_SIZE];
static int nb_tbs;
/* any access to the tbs or the page table must use this lock */
Expand Down
6 changes: 4 additions & 2 deletions shared/DECAF_callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -1124,15 +1124,17 @@ void helper_DECAF_invoke_block_trans_callback(
static DECAF_Callback_Params params;
params.bt.tb = tb;
params.bt.tcg_ctx = tcg_ctx;
PUSH_ALL()
/* AWH - Don't need PUSH/POP here because this callback is called at translation
time, not guest execution time. */
//PUSH_ALL()
// FIXME: not thread safe
LIST_FOREACH(cb_struct, &callback_list_heads[DECAF_BLOCK_TRANS_CB], link)
{
params.cbhandle = (DECAF_Handle)cb_struct;
if (!cb_struct->enabled || *cb_struct->enabled)
cb_struct->callback(&params);
}
POP_ALL()
//POP_ALL()
}
#endif /* CONFIG_TCG_LLVM */
void DECAF_callback_init(void)
Expand Down
11 changes: 11 additions & 0 deletions target-arm/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -9929,6 +9929,17 @@ inline void log_tcg_ir(TranslationBlock *tb)
{
if (tcg_ctx.temps[i].temp_local)
tb->DECAF_temp_type[i>>3] |= (1 << (i % 8));
else
tb->DECAF_temp_type[i>>3] &= ~(1 << (i % 8));
}

/* Store information about the temps at to whether they are 32/64 bit */
for (i=tcg_ctx.nb_globals; i < (tcg_ctx.nb_globals + tcg_ctx.nb_temps); i++)
{
if (tcg_ctx.temps[i].type == TCG_TYPE_I64)
tb->DECAF_temp_size[i>>3] |= (1 << (i % 8));
else
tb->DECAF_temp_size[i>>3] &= ~(1 << (i % 8));
}
}
#endif /* CONFIG_TCG_IR_LOG */
Expand Down
35 changes: 28 additions & 7 deletions target-i386/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -8010,7 +8010,7 @@ void optimize_flags_init(void)
}

#ifdef CONFIG_TCG_IR_LOG
static inline void log_tcg_ir(TranslationBlock *tb)
static inline void log_tcg_ir(TranslationBlock *tb, target_ulong pc_ptr, target_ulong pc_start)
{
int i;

Expand All @@ -8026,7 +8026,28 @@ static inline void log_tcg_ir(TranslationBlock *tb)
{
if (tcg_ctx.temps[i].temp_local)
tb->DECAF_temp_type[i>>3] |= (1 << (i % 8));
}
else
tb->DECAF_temp_type[i>>3] &= ~(1 << (i % 8));
}

/* Store information about the temps at to whether they are 32/64 bit */
for (i=tcg_ctx.nb_globals; i < (tcg_ctx.nb_globals + tcg_ctx.nb_temps); i++)
{
if (tcg_ctx.temps[i].type == TCG_TYPE_I64)
tb->DECAF_temp_size[i>>3] |= (1 << (i % 8));
else
tb->DECAF_temp_size[i>>3] &= ~(1 << (i % 8));
}

#if 0 // AWH
/* Store the guest code */
memcpy((tb->DECAF_disasm_code), pc_ptr, sizeof(pc_ptr - pc_start));
tb->DECAF_disasm_size = pc_ptr - pc_start;
fprintf(stderr, "Storing guest asm (%d bytes)\n", tb->DECAF_disasm_size);
for(i=0; i < tb->DECAF_disasm_size; i++)
fprintf(stderr, "0x02%x ", pc_start + i);
fprintf(stderr, "\n");
#endif // AWH
}
#endif /* CONFIG_TCG_IR_LOG */

Expand Down Expand Up @@ -8153,7 +8174,7 @@ static inline void gen_intermediate_code_internal(CPUState *env,
}
#endif /* CONFIG_TCG_LLVM */
#ifdef CONFIG_TCG_IR_LOG
log_tcg_ir(tb);
log_tcg_ir(tb, pc_ptr, pc_start);
#endif /* CONFIG_TCG_IR_LOG */
#ifdef CONFIG_TCG_TAINT
if (taint_tracking_enabled)
Expand Down Expand Up @@ -8194,7 +8215,7 @@ static inline void gen_intermediate_code_internal(CPUState *env,
}
#endif /* CONFIG_TCG_LLVM */
#ifdef CONFIG_TCG_IR_LOG
log_tcg_ir(tb);
log_tcg_ir(tb, pc_ptr, pc_start);
#endif /* CONFIG_TCG_IR_LOG */
#ifdef CONFIG_TCG_TAINT
if (taint_tracking_enabled)
Expand All @@ -8217,7 +8238,7 @@ static inline void gen_intermediate_code_internal(CPUState *env,
}
#endif /* CONFIG_TCG_LLVM */
#ifdef CONFIG_TCG_IR_LOG
log_tcg_ir(tb);
log_tcg_ir(tb, pc_ptr, pc_start);
#endif /* CONFIG_TCG_IR_LOG */
#ifdef CONFIG_TCG_TAINT
if (taint_tracking_enabled)
Expand All @@ -8239,7 +8260,7 @@ static inline void gen_intermediate_code_internal(CPUState *env,
}
#endif /* CONFIG_TCG_LLVM */
#ifdef CONFIG_TCG_IR_LOG
log_tcg_ir(tb);
log_tcg_ir(tb, pc_ptr, pc_start);
#endif /* CONFIG_TCG_IR_LOG */
#ifdef CONFIG_TCG_TAINT
if (taint_tracking_enabled)
Expand All @@ -8258,7 +8279,7 @@ static inline void gen_intermediate_code_internal(CPUState *env,
}
#endif /* CONFIG_TCG_LLVM */
#ifdef CONFIG_TCG_IR_LOG
log_tcg_ir(tb);
log_tcg_ir(tb, pc_ptr, pc_start);
#endif /* CONFIG_TCG_IR_LOG */
#ifdef CONFIG_TCG_TAINT
if (taint_tracking_enabled)
Expand Down
11 changes: 11 additions & 0 deletions target-mips/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ inline void log_tcg_ir(TranslationBlock *tb)
{
if (tcg_ctx.temps[i].temp_local)
tb->DECAF_temp_type[i>>3] |= (1 << (i % 8));
else
tb->DECAF_temp_type[i>>3] &= ~(1 << (i % 8));
}

/* Store information about the temps at to whether they are 32/64 bit */
for (i=tcg_ctx.nb_globals; i < (tcg_ctx.nb_globals + tcg_ctx.nb_temps); i++)
{
if (tcg_ctx.temps[i].type == TCG_TYPE_I64)
tb->DECAF_temp_size[i>>3] |= (1 << (i % 8));
else
tb->DECAF_temp_size[i>>3] &= ~(1 << (i % 8));
}
}
#endif /* CONFIG_TCG_IR_LOG */
Expand Down

0 comments on commit 9a1b7e2

Please sign in to comment.