From b39f5d2a91228a832b543abe0c6631a7276d3a32 Mon Sep 17 00:00:00 2001 From: Chris Eagle Date: Wed, 26 Aug 2015 08:55:19 -0700 Subject: [PATCH] When checking for invalid memory always do the faster check of whether we are hooking env->uc->hook_mem_idx before doing the expensive check of scanning the memory map --- qemu/softmmu_template.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qemu/softmmu_template.h b/qemu/softmmu_template.h index 2bc357d8..a48ee8d5 100755 --- a/qemu/softmmu_template.h +++ b/qemu/softmmu_template.h @@ -188,7 +188,7 @@ WORD_TYPE helper_le_ld_name(CPUArchState *env, target_ulong addr, int mmu_idx, } // Unicorn: callback on invalid memory - if (!memory_mapping(env->uc, addr) && env->uc->hook_mem_idx) { + if (env->uc->hook_mem_idx && !memory_mapping(env->uc, addr)) { if (!((uc_cb_eventmem_t)env->uc->hook_callbacks[env->uc->hook_mem_idx].callback)( (uch)env->uc, UC_MEM_READ, addr, DATA_SIZE, 0, env->uc->hook_callbacks[env->uc->hook_mem_idx].user_data)) { @@ -310,7 +310,7 @@ WORD_TYPE helper_be_ld_name(CPUArchState *env, target_ulong addr, int mmu_idx, } // Unicorn: callback on invalid memory - if (!memory_mapping(env->uc, addr) && env->uc->hook_mem_idx) { + if (env->uc->hook_mem_idx && !memory_mapping(env->uc, addr)) { if (!((uc_cb_eventmem_t)env->uc->hook_callbacks[env->uc->hook_mem_idx].callback)( (uch)env->uc, UC_MEM_READ, addr, DATA_SIZE, 0, env->uc->hook_callbacks[env->uc->hook_mem_idx].user_data)) { @@ -470,7 +470,7 @@ void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, } // Unicorn: callback on invalid memory - if (!memory_mapping(env->uc, addr) && env->uc->hook_mem_idx) { + if (env->uc->hook_mem_idx && !memory_mapping(env->uc, addr)) { if (!((uc_cb_eventmem_t)env->uc->hook_callbacks[env->uc->hook_mem_idx].callback)( (uch)env->uc, UC_MEM_WRITE, addr, DATA_SIZE, (int64_t)val, env->uc->hook_callbacks[env->uc->hook_mem_idx].user_data)) { @@ -584,7 +584,7 @@ void helper_be_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, } // Unicorn: callback on invalid memory - if (!memory_mapping(env->uc, addr) && env->uc->hook_mem_idx) { + if (env->uc->hook_mem_idx && !memory_mapping(env->uc, addr)) { if (!((uc_cb_eventmem_t)env->uc->hook_callbacks[env->uc->hook_mem_idx].callback)( (uch)env->uc, UC_MEM_WRITE, addr, DATA_SIZE, (int64_t)val, env->uc->hook_callbacks[env->uc->hook_mem_idx].user_data)) {