fix merge conflict
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
DEF_HELPER_5(uc_tracecode, void, i32, ptr, ptr, i64, ptr)
|
||||
DEF_HELPER_4(uc_tracecode, void, i32, i32, ptr, i64)
|
||||
|
||||
DEF_HELPER_FLAGS_4(cc_compute_all, TCG_CALL_NO_RWG_SE, tl, tl, tl, tl, int)
|
||||
DEF_HELPER_FLAGS_4(cc_compute_c, TCG_CALL_NO_RWG_SE, tl, tl, tl, tl, int)
|
||||
|
@ -945,14 +945,16 @@ void helper_syscall(CPUX86State *env, int next_eip_addend)
|
||||
#else
|
||||
void helper_syscall(CPUX86State *env, int next_eip_addend)
|
||||
{
|
||||
// Unicorn: call interrupt callback if registered
|
||||
struct uc_struct *uc = env->uc;
|
||||
if (uc->hook_syscall_idx) {
|
||||
((uc_cb_insn_syscall_t)uc->hook_callbacks[uc->hook_syscall_idx].callback)(
|
||||
uc, uc->hook_callbacks[uc->hook_syscall_idx].user_data);
|
||||
// Unicorn: call registered syscall hooks
|
||||
struct hook *hook;
|
||||
HOOK_FOREACH(env->uc, hook, UC_HOOK_INSN) {
|
||||
if (!HOOK_BOUND_CHECK(hook, env->eip))
|
||||
continue;
|
||||
if (hook->insn == UC_X86_INS_SYSCALL)
|
||||
((uc_cb_insn_syscall_t)hook->callback)(env->uc, hook->user_data);
|
||||
}
|
||||
env->eip += next_eip_addend;
|
||||
|
||||
env->eip += next_eip_addend;
|
||||
return;
|
||||
|
||||
int selector;
|
||||
@ -2303,14 +2305,16 @@ void helper_lret_protected(CPUX86State *env, int shift, int addend)
|
||||
|
||||
void helper_sysenter(CPUX86State *env, int next_eip_addend)
|
||||
{
|
||||
// Unicorn: call interrupt callback if registered
|
||||
struct uc_struct *uc = env->uc;
|
||||
if (uc->hook_syscall_idx) {
|
||||
((uc_cb_insn_syscall_t)uc->hook_callbacks[uc->hook_syscall_idx].callback)(
|
||||
uc, uc->hook_callbacks[uc->hook_syscall_idx].user_data);
|
||||
// Unicorn: call registered SYSENTER hooks
|
||||
struct hook *hook;
|
||||
HOOK_FOREACH(env->uc, hook, UC_HOOK_INSN) {
|
||||
if (!HOOK_BOUND_CHECK(hook, env->eip))
|
||||
continue;
|
||||
if (hook->insn == UC_X86_INS_SYSENTER)
|
||||
((uc_cb_insn_syscall_t)hook->callback)(env->uc, hook->user_data);
|
||||
}
|
||||
env->eip += next_eip_addend;
|
||||
|
||||
env->eip += next_eip_addend;
|
||||
return;
|
||||
|
||||
if (env->sysenter_cs == 0) {
|
||||
|
@ -516,14 +516,14 @@ static inline void gen_op_addq_A0_reg_sN(TCGContext *s, int shift, int reg)
|
||||
|
||||
static inline void gen_op_ld_v(DisasContext *s, int idx, TCGv t0, TCGv a0)
|
||||
{
|
||||
if (s->uc->hook_mem_read)
|
||||
if (HOOK_EXISTS(s->uc, UC_HOOK_MEM_READ))
|
||||
gen_jmp_im(s, s->prev_pc); // Unicorn: sync EIP
|
||||
tcg_gen_qemu_ld_tl(s->uc, t0, a0, s->mem_index, idx | MO_LE);
|
||||
}
|
||||
|
||||
static inline void gen_op_st_v(DisasContext *s, int idx, TCGv t0, TCGv a0)
|
||||
{
|
||||
if (s->uc->hook_mem_write)
|
||||
if (HOOK_EXISTS(s->uc, UC_HOOK_MEM_WRITE))
|
||||
gen_jmp_im(s, s->prev_pc); // Unicorn: sync EIP
|
||||
tcg_gen_qemu_st_tl(s->uc, t0, a0, s->mem_index, idx | MO_LE);
|
||||
}
|
||||
@ -4745,12 +4745,10 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s,
|
||||
TCGv cpu_tmp4 = *(TCGv *)tcg_ctx->cpu_tmp4;
|
||||
TCGv **cpu_T = (TCGv **)tcg_ctx->cpu_T;
|
||||
TCGv **cpu_regs = (TCGv **)tcg_ctx->cpu_regs;
|
||||
struct hook_struct *trace = NULL;
|
||||
TCGArg *save_opparam_ptr = tcg_ctx->gen_opparam_ptr;
|
||||
bool cc_op_dirty = s->cc_op_dirty;
|
||||
bool changed_cc_op = false;
|
||||
|
||||
|
||||
s->pc = pc_start;
|
||||
|
||||
// end address tells us to stop emulation
|
||||
@ -4768,19 +4766,15 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s,
|
||||
}
|
||||
|
||||
// Unicorn: trace this instruction on request
|
||||
if (env->uc->hook_insn) {
|
||||
trace = hook_find(env->uc, UC_HOOK_CODE, pc_start);
|
||||
if (trace) {
|
||||
if (s->last_cc_op != s->cc_op) {
|
||||
sync_eflags(s, tcg_ctx);
|
||||
s->last_cc_op = s->cc_op;
|
||||
changed_cc_op = true;
|
||||
}
|
||||
// generate code to call callback
|
||||
gen_uc_tracecode(tcg_ctx, 0xf1f1f1f1, trace->callback, env->uc, pc_start, trace->user_data);
|
||||
// the callback might want to stop emulation immediately
|
||||
check_exit_request(tcg_ctx);
|
||||
if (HOOK_EXISTS_BOUNDED(env->uc, UC_HOOK_CODE, pc_start)) {
|
||||
if (s->last_cc_op != s->cc_op) {
|
||||
sync_eflags(s, tcg_ctx);
|
||||
s->last_cc_op = s->cc_op;
|
||||
changed_cc_op = true;
|
||||
}
|
||||
gen_uc_tracecode(tcg_ctx, 0xf1f1f1f1, UC_HOOK_CODE_IDX, env->uc, pc_start);
|
||||
// the callback might want to stop emulation immediately
|
||||
check_exit_request(tcg_ctx);
|
||||
}
|
||||
|
||||
prefixes = 0;
|
||||
@ -8173,7 +8167,7 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s,
|
||||
gen_helper_unlock(tcg_ctx, cpu_env);
|
||||
|
||||
// Unicorn: patch the callback for the instruction size
|
||||
if (trace) {
|
||||
if (HOOK_EXISTS_BOUNDED(env->uc, UC_HOOK_CODE, pc_start)) {
|
||||
// int i;
|
||||
// for(i = 0; i < 20; i++)
|
||||
// printf("=== [%u] = %x\n", i, *(save_opparam_ptr + i));
|
||||
@ -8387,12 +8381,9 @@ static inline void gen_intermediate_code_internal(uint8_t *gen_opc_cc_op,
|
||||
// Unicorn: trace this block on request
|
||||
// Only hook this block if it is not broken from previous translation due to
|
||||
// full translation cache
|
||||
if (env->uc->hook_block && !env->uc->block_full) {
|
||||
struct hook_struct *trace = hook_find(env->uc, UC_HOOK_BLOCK, pc_start);
|
||||
if (trace) {
|
||||
env->uc->block_addr = pc_start;
|
||||
gen_uc_tracecode(tcg_ctx, 0xf8f8f8f8, trace->callback, env->uc, pc_start, trace->user_data);
|
||||
}
|
||||
if (!env->uc->block_full && HOOK_EXISTS_BOUNDED(env->uc, UC_HOOK_BLOCK, pc_start)) {
|
||||
env->uc->block_addr = pc_start;
|
||||
gen_uc_tracecode(tcg_ctx, 0xf8f8f8f8, UC_HOOK_BLOCK_IDX, env->uc, pc_start);
|
||||
}
|
||||
|
||||
gen_tb_start(tcg_ctx);
|
||||
|
@ -59,7 +59,6 @@ void x86_reg_reset(struct uc_struct *uc)
|
||||
env->features[FEAT_8000_0001_ECX] = CPUID_EXT3_LAHF_LM | CPUID_EXT3_ABM | CPUID_EXT3_SKINIT | CPUID_EXT3_CR8LEG;
|
||||
env->features[FEAT_7_0_EBX] = CPUID_7_0_EBX_BMI1 | CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ADX | CPUID_7_0_EBX_SMAP;
|
||||
|
||||
env->invalid_error = UC_ERR_OK; // no error
|
||||
memset(env->regs, 0, sizeof(env->regs));
|
||||
memset(env->segs, 0, sizeof(env->segs));
|
||||
memset(env->cr, 0, sizeof(env->cr));
|
||||
@ -658,9 +657,15 @@ int x86_reg_write(struct uc_struct *uc, unsigned int regid, const void *value)
|
||||
break;
|
||||
case UC_X86_REG_EIP:
|
||||
X86_CPU(uc, mycpu)->env.eip = *(uint32_t *)value;
|
||||
// force to quit execution and flush TB
|
||||
uc->quit_request = true;
|
||||
uc_emu_stop(uc);
|
||||
break;
|
||||
case UC_X86_REG_IP:
|
||||
WRITE_WORD(X86_CPU(uc, mycpu)->env.eip, *(uint16_t *)value);
|
||||
// force to quit execution and flush TB
|
||||
uc->quit_request = true;
|
||||
uc_emu_stop(uc);
|
||||
break;
|
||||
case UC_X86_REG_CS:
|
||||
X86_CPU(uc, mycpu)->env.segs[R_CS].base = *(uint32_t *)value;
|
||||
@ -808,12 +813,21 @@ int x86_reg_write(struct uc_struct *uc, unsigned int regid, const void *value)
|
||||
break;
|
||||
case UC_X86_REG_RIP:
|
||||
X86_CPU(uc, mycpu)->env.eip = *(uint64_t *)value;
|
||||
// force to quit execution and flush TB
|
||||
uc->quit_request = true;
|
||||
uc_emu_stop(uc);
|
||||
break;
|
||||
case UC_X86_REG_EIP:
|
||||
WRITE_DWORD(X86_CPU(uc, mycpu)->env.eip, *(uint32_t *)value);
|
||||
// force to quit execution and flush TB
|
||||
uc->quit_request = true;
|
||||
uc_emu_stop(uc);
|
||||
break;
|
||||
case UC_X86_REG_IP:
|
||||
WRITE_WORD(X86_CPU(uc, mycpu)->env.eip, *(uint16_t *)value);
|
||||
// force to quit execution and flush TB
|
||||
uc->quit_request = true;
|
||||
uc_emu_stop(uc);
|
||||
break;
|
||||
case UC_X86_REG_CS:
|
||||
X86_CPU(uc, mycpu)->env.segs[R_CS].base = *(uint64_t *)value;
|
||||
|
Reference in New Issue
Block a user