From d70c1416759a9c06292d1886f92a995e84def418 Mon Sep 17 00:00:00 2001 From: Yang Zhong Date: Sat, 3 Mar 2018 21:26:06 -0500 Subject: [PATCH] tcg: move page_size_init() function translate-all.c will be disabled if tcg is disabled in the build, so page_size_init() function and related variables will be moved to exec.c file. Backports commit a0be0c585f5dcc4d50a37f6a20d3d625c5ef3a2c from qemu --- qemu/exec.c | 15 +++++++++++++++ qemu/include/exec/exec-all.h | 3 +++ qemu/translate-all.c | 18 ------------------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/qemu/exec.c b/qemu/exec.c index c6992dd1..f340b667 100644 --- a/qemu/exec.c +++ b/qemu/exec.c @@ -2642,3 +2642,18 @@ int qemu_ram_foreach_block(struct uc_struct *uc, RAMBlockIterFunc func, void *op return ret; } #endif + +void page_size_init(struct uc_struct *uc) +{ + /* NOTE: we can always suppose that qemu_host_page_size >= + TARGET_PAGE_SIZE */ + uc->qemu_real_host_page_size = getpagesize(); + uc->qemu_real_host_page_mask = -(intptr_t)uc->qemu_real_host_page_size; + if (uc->qemu_host_page_size == 0) { + uc->qemu_host_page_size = uc->qemu_real_host_page_size; + } + if (uc->qemu_host_page_size < TARGET_PAGE_SIZE) { + uc->qemu_host_page_size = TARGET_PAGE_SIZE; + } + uc->qemu_host_page_mask = -(intptr_t)uc->qemu_host_page_size; +} diff --git a/qemu/include/exec/exec-all.h b/qemu/include/exec/exec-all.h index 3a81c0ea..aa31e14f 100644 --- a/qemu/include/exec/exec-all.h +++ b/qemu/include/exec/exec-all.h @@ -443,4 +443,7 @@ static inline bool cpu_can_do_io(CPUState *cpu) // Unicorn: Used for freeing void phys_mem_clean(AddressSpace *as); +// Unicorn: Prototype place here +void page_size_init(struct uc_struct *uc); + #endif diff --git a/qemu/translate-all.c b/qemu/translate-all.c index 88884686..8372de12 100644 --- a/qemu/translate-all.c +++ b/qemu/translate-all.c @@ -345,21 +345,6 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t retaddr) return false; } -static void page_size_init(struct uc_struct *uc) -{ - /* NOTE: we can always suppose that qemu_host_page_size >= - TARGET_PAGE_SIZE */ - uc->qemu_real_host_page_size = getpagesize(); - uc->qemu_real_host_page_mask = -(intptr_t)uc->qemu_real_host_page_size; - if (uc->qemu_host_page_size == 0) { - uc->qemu_host_page_size = uc->qemu_real_host_page_size; - } - if (uc->qemu_host_page_size < TARGET_PAGE_SIZE) { - uc->qemu_host_page_size = TARGET_PAGE_SIZE; - } - uc->qemu_host_page_mask = -(intptr_t)uc->qemu_host_page_size; -} - static void page_init(struct uc_struct *uc) { page_size_init(uc); @@ -949,7 +934,6 @@ void tb_flush(CPUState *cpu) { struct uc_struct* uc = cpu->uc; TCGContext *tcg_ctx = uc->tcg_ctx; - int i; #if defined(DEBUG_TB_FLUSH) printf("qemu: flush code_size=%ld nb_tbs=%d avg_tb_size=%ld\n", @@ -1870,8 +1854,6 @@ static void tb_jmp_cache_clear_page(CPUState *cpu, target_ulong page_addr) void tb_flush_jmp_cache(CPUState *cpu, target_ulong addr) { - unsigned int i; - /* Discard jump cache entries for any tb which might potentially overlap the flushed page. */ tb_jmp_cache_clear_page(cpu, addr - TARGET_PAGE_SIZE);