From 0a3e46bf4f4050acee4531719932ee44f0a97525 Mon Sep 17 00:00:00 2001 From: lazymio Date: Mon, 1 Nov 2021 09:41:25 +0100 Subject: [PATCH] Format --- qemu/accel/tcg/translate-all.c | 30 ++++-------------------------- qemu/softmmu/cpus.c | 21 ++++++++++++--------- samples/sample_ctl.c | 1 - 3 files changed, 16 insertions(+), 36 deletions(-) diff --git a/qemu/accel/tcg/translate-all.c b/qemu/accel/tcg/translate-all.c index a7b94d99..5c7f3abe 100644 --- a/qemu/accel/tcg/translate-all.c +++ b/qemu/accel/tcg/translate-all.c @@ -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); } -// 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) { - 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) { +static void uc_invalidate_tb(struct uc_struct *uc, uint64_t start_addr, size_t len) +{ tb_page_addr_t start, end; // 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); } -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; target_ulong cs_base, pc; CPUState *cpu = uc->cpu; diff --git a/qemu/softmmu/cpus.c b/qemu/softmmu/cpus.c index c318b855..25568fac 100644 --- a/qemu/softmmu/cpus.c +++ b/qemu/softmmu/cpus.c @@ -172,18 +172,21 @@ void cpu_stop_current(struct uc_struct *uc) } -// 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) { + +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; + uc_engine *uc = (uc_engine*)data; if (exit != 0) { + // 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 uc->uc_invalidate_tb(uc, exit - 1, 1); } diff --git a/samples/sample_ctl.c b/samples/sample_ctl.c index 543a6e6a..359b1e71 100644 --- a/samples/sample_ctl.c +++ b/samples/sample_ctl.c @@ -6,7 +6,6 @@ #include #include -// code to be emulated // code to be emulated #define X86_CODE32 "\x41\x4a" // INC ecx; DEC edx; PXOR xmm0, xmm1