Format
This commit is contained in:
parent
3dd2e0f95d
commit
0a3e46bf4f
@ -980,32 +980,9 @@ static void tb_htable_init(struct uc_struct *uc)
|
|||||||
qht_init(&uc->tcg_ctx->tb_ctx.htable, tb_cmp, CODE_GEN_HTABLE_SIZE, mode);
|
qht_init(&uc->tcg_ctx->tb_ctx.htable, tb_cmp, CODE_GEN_HTABLE_SIZE, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GVA to GPA (GPA -> HVA via page_find, HVA->HPA via host mmu)
|
|
||||||
// Unicorn: Why addr - 1?
|
|
||||||
// 0: INC ecx
|
|
||||||
// 1: DEC edx <--- We put exit here, then the range of TB is [0, 1)
|
|
||||||
//
|
|
||||||
// While tb_invalidate_phys_range invalides [start, end)
|
|
||||||
//
|
|
||||||
// This function is designed to used with g_tree_foreach
|
|
||||||
static inline gboolean uc_exit_invalidate_iter(gpointer key, gpointer val, gpointer data) {
|
|
||||||
uint64_t exit = *((uint64_t*)key);
|
|
||||||
uc_engine* uc = (uc_engine*)data;
|
|
||||||
tb_page_addr_t start, end;
|
|
||||||
|
|
||||||
if (exit != 0) {
|
static void uc_invalidate_tb(struct uc_struct *uc, uint64_t start_addr, size_t len)
|
||||||
end = get_page_addr_code(uc->cpu->env_ptr, exit);
|
{
|
||||||
|
|
||||||
start = (end-1) ;
|
|
||||||
end = end & (target_ulong)(-1);
|
|
||||||
|
|
||||||
tb_invalidate_phys_range(uc, start, end);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void uc_invalidate_tb(struct uc_struct *uc, uint64_t start_addr, size_t len) {
|
|
||||||
tb_page_addr_t start, end;
|
tb_page_addr_t start, end;
|
||||||
|
|
||||||
// GVA to GPA (GPA -> HVA via page_find, HVA->HPA via host mmu)
|
// GVA to GPA (GPA -> HVA via page_find, HVA->HPA via host mmu)
|
||||||
@ -1022,7 +999,8 @@ static void uc_invalidate_tb(struct uc_struct *uc, uint64_t start_addr, size_t l
|
|||||||
tb_invalidate_phys_range(uc, start, end);
|
tb_invalidate_phys_range(uc, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TranslationBlock* uc_gen_tb(struct uc_struct *uc, uint64_t addr) {
|
static TranslationBlock* uc_gen_tb(struct uc_struct *uc, uint64_t addr)
|
||||||
|
{
|
||||||
TranslationBlock *tb;
|
TranslationBlock *tb;
|
||||||
target_ulong cs_base, pc;
|
target_ulong cs_base, pc;
|
||||||
CPUState *cpu = uc->cpu;
|
CPUState *cpu = uc->cpu;
|
||||||
|
@ -172,18 +172,21 @@ void cpu_stop_current(struct uc_struct *uc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static inline gboolean uc_exit_invalidate_iter(gpointer key, gpointer val, gpointer data)
|
||||||
|
{
|
||||||
|
uint64_t exit = *((uint64_t*)key);
|
||||||
|
uc_engine *uc = (uc_engine*)data;
|
||||||
|
|
||||||
|
if (exit != 0) {
|
||||||
// Unicorn: Why addr - 1?
|
// Unicorn: Why addr - 1?
|
||||||
|
//
|
||||||
// 0: INC ecx
|
// 0: INC ecx
|
||||||
// 1: DEC edx <--- We put exit here, then the range of TB is [0, 1)
|
// 1: DEC edx <--- We put exit here, then the range of TB is [0, 1)
|
||||||
//
|
//
|
||||||
// While tb_invalidate_phys_range invalides [start, end)
|
// While tb_invalidate_phys_range invalides [start, end)
|
||||||
//
|
//
|
||||||
// This function is designed to used with g_tree_foreach
|
// This function is designed to used with g_tree_foreach
|
||||||
static inline gboolean uc_exit_invalidate_iter(gpointer key, gpointer val, gpointer data) {
|
|
||||||
uint64_t exit = *((uint64_t*)key);
|
|
||||||
uc_engine* uc = (uc_engine*)data;
|
|
||||||
|
|
||||||
if (exit != 0) {
|
|
||||||
uc->uc_invalidate_tb(uc, exit - 1, 1);
|
uc->uc_invalidate_tb(uc, exit - 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
#include <unicorn/unicorn.h>
|
#include <unicorn/unicorn.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
// code to be emulated
|
|
||||||
// code to be emulated
|
// code to be emulated
|
||||||
#define X86_CODE32 "\x41\x4a" // INC ecx; DEC edx; PXOR xmm0, xmm1
|
#define X86_CODE32 "\x41\x4a" // INC ecx; DEC edx; PXOR xmm0, xmm1
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user