diff --git a/exec-all.h b/exec-all.h index b5713b5..f4fb3af 100644 --- a/exec-all.h +++ b/exec-all.h @@ -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 */ }; diff --git a/exec.c b/exec.c index 5dfb798..12fcb8c 100644 --- a/exec.c +++ b/exec.c @@ -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 */ diff --git a/shared/DECAF_callback.c b/shared/DECAF_callback.c index a23c18d..f25c492 100644 --- a/shared/DECAF_callback.c +++ b/shared/DECAF_callback.c @@ -1124,7 +1124,9 @@ 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) { @@ -1132,7 +1134,7 @@ PUSH_ALL() if (!cb_struct->enabled || *cb_struct->enabled) cb_struct->callback(¶ms); } -POP_ALL() +//POP_ALL() } #endif /* CONFIG_TCG_LLVM */ void DECAF_callback_init(void) diff --git a/target-arm/translate.c b/target-arm/translate.c index f4e492d..a5d88f6 100644 --- a/target-arm/translate.c +++ b/target-arm/translate.c @@ -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 */ diff --git a/target-i386/translate.c b/target-i386/translate.c index 42e971c..7117e28 100644 --- a/target-i386/translate.c +++ b/target-i386/translate.c @@ -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; @@ -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 */ @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/target-mips/translate.c b/target-mips/translate.c index 9943e1b..a140712 100644 --- a/target-mips/translate.c +++ b/target-mips/translate.c @@ -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 */