From cf5d583ef0221b1e414c3df7bf3f5816bbd143c9 Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Sat, 3 Mar 2018 21:22:27 -0500 Subject: [PATCH] cpu: Introduce a wrapper for tlb_flush() that can be used in common code Commit 1f5c00cfdb8114c ("qom/cpu: move tlb_flush to cpu_common_reset") moved the call to tlb_flush() from the target-specific reset handlers into the common code qom/cpu.c file, and protected the call with "#ifdef CONFIG_SOFTMMU" to avoid that it is called for linux-user only targets. But since qom/cpu.c is common code, CONFIG_SOFTMMU is *never* defined here, so the tlb_flush() was simply never executed anymore. Fix it by introducing a wrapper for tlb_flush() in a file that is re-compiled for each target, i.e. in translate-all.c. Backports commit 2cd53943115be5118b5b2d4b80ee0a39c94c4f73 from qemu --- qemu/aarch64.h | 1 + qemu/aarch64eb.h | 1 + qemu/arm.h | 1 + qemu/armeb.h | 1 + qemu/header_gen.py | 1 + qemu/include/exec/cpu-common.h | 2 ++ qemu/m68k.h | 1 + qemu/mips.h | 1 + qemu/mips64.h | 1 + qemu/mips64el.h | 1 + qemu/mipsel.h | 1 + qemu/powerpc.h | 1 + qemu/qom/cpu.c | 5 ++--- qemu/sparc.h | 1 + qemu/sparc64.h | 1 + qemu/translate-all.c | 8 ++++++++ qemu/x86_64.h | 1 + 17 files changed, 26 insertions(+), 3 deletions(-) diff --git a/qemu/aarch64.h b/qemu/aarch64.h index 546f80c5..05d03c4f 100644 --- a/qemu/aarch64.h +++ b/qemu/aarch64.h @@ -2978,6 +2978,7 @@ #define tcg_exec_all tcg_exec_all_aarch64 #define tcg_exec_init tcg_exec_init_aarch64 #define tcg_find_helper tcg_find_helper_aarch64 +#define tcg_flush_softmmu_tlb tcg_flush_softmmu_tlb_aarch64 #define tcg_func_start tcg_func_start_aarch64 #define tcg_gen_abs_i32 tcg_gen_abs_i32_aarch64 #define tcg_gen_add2_i32 tcg_gen_add2_i32_aarch64 diff --git a/qemu/aarch64eb.h b/qemu/aarch64eb.h index 80912227..27f5a0a7 100644 --- a/qemu/aarch64eb.h +++ b/qemu/aarch64eb.h @@ -2978,6 +2978,7 @@ #define tcg_exec_all tcg_exec_all_aarch64eb #define tcg_exec_init tcg_exec_init_aarch64eb #define tcg_find_helper tcg_find_helper_aarch64eb +#define tcg_flush_softmmu_tlb tcg_flush_softmmu_tlb_aarch64eb #define tcg_func_start tcg_func_start_aarch64eb #define tcg_gen_abs_i32 tcg_gen_abs_i32_aarch64eb #define tcg_gen_add2_i32 tcg_gen_add2_i32_aarch64eb diff --git a/qemu/arm.h b/qemu/arm.h index 01f6fba6..1b6430d2 100644 --- a/qemu/arm.h +++ b/qemu/arm.h @@ -2978,6 +2978,7 @@ #define tcg_exec_all tcg_exec_all_arm #define tcg_exec_init tcg_exec_init_arm #define tcg_find_helper tcg_find_helper_arm +#define tcg_flush_softmmu_tlb tcg_flush_softmmu_tlb_arm #define tcg_func_start tcg_func_start_arm #define tcg_gen_abs_i32 tcg_gen_abs_i32_arm #define tcg_gen_add2_i32 tcg_gen_add2_i32_arm diff --git a/qemu/armeb.h b/qemu/armeb.h index 10611c99..4498a7e3 100644 --- a/qemu/armeb.h +++ b/qemu/armeb.h @@ -2978,6 +2978,7 @@ #define tcg_exec_all tcg_exec_all_armeb #define tcg_exec_init tcg_exec_init_armeb #define tcg_find_helper tcg_find_helper_armeb +#define tcg_flush_softmmu_tlb tcg_flush_softmmu_tlb_armeb #define tcg_func_start tcg_func_start_armeb #define tcg_gen_abs_i32 tcg_gen_abs_i32_armeb #define tcg_gen_add2_i32 tcg_gen_add2_i32_armeb diff --git a/qemu/header_gen.py b/qemu/header_gen.py index 6d7eb093..dc9ad018 100644 --- a/qemu/header_gen.py +++ b/qemu/header_gen.py @@ -2984,6 +2984,7 @@ symbols = ( 'tcg_exec_all', 'tcg_exec_init', 'tcg_find_helper', + 'tcg_flush_softmmu_tlb', 'tcg_func_start', 'tcg_gen_abs_i32', 'tcg_gen_add2_i32', diff --git a/qemu/include/exec/cpu-common.h b/qemu/include/exec/cpu-common.h index d92e8dd6..bb11f175 100644 --- a/qemu/include/exec/cpu-common.h +++ b/qemu/include/exec/cpu-common.h @@ -14,6 +14,8 @@ struct uc_struct; #include "qemu/fprintf-fn.h" #include "qemu/typedefs.h" +void tcg_flush_softmmu_tlb(CPUState *cs); + #if !defined(CONFIG_USER_ONLY) enum device_endian { diff --git a/qemu/m68k.h b/qemu/m68k.h index 504b9742..7facbfaa 100644 --- a/qemu/m68k.h +++ b/qemu/m68k.h @@ -2978,6 +2978,7 @@ #define tcg_exec_all tcg_exec_all_m68k #define tcg_exec_init tcg_exec_init_m68k #define tcg_find_helper tcg_find_helper_m68k +#define tcg_flush_softmmu_tlb tcg_flush_softmmu_tlb_m68k #define tcg_func_start tcg_func_start_m68k #define tcg_gen_abs_i32 tcg_gen_abs_i32_m68k #define tcg_gen_add2_i32 tcg_gen_add2_i32_m68k diff --git a/qemu/mips.h b/qemu/mips.h index 4978f7c9..64d8e16d 100644 --- a/qemu/mips.h +++ b/qemu/mips.h @@ -2978,6 +2978,7 @@ #define tcg_exec_all tcg_exec_all_mips #define tcg_exec_init tcg_exec_init_mips #define tcg_find_helper tcg_find_helper_mips +#define tcg_flush_softmmu_tlb tcg_flush_softmmu_tlb_mips #define tcg_func_start tcg_func_start_mips #define tcg_gen_abs_i32 tcg_gen_abs_i32_mips #define tcg_gen_add2_i32 tcg_gen_add2_i32_mips diff --git a/qemu/mips64.h b/qemu/mips64.h index 1d2e50aa..060fff66 100644 --- a/qemu/mips64.h +++ b/qemu/mips64.h @@ -2978,6 +2978,7 @@ #define tcg_exec_all tcg_exec_all_mips64 #define tcg_exec_init tcg_exec_init_mips64 #define tcg_find_helper tcg_find_helper_mips64 +#define tcg_flush_softmmu_tlb tcg_flush_softmmu_tlb_mips64 #define tcg_func_start tcg_func_start_mips64 #define tcg_gen_abs_i32 tcg_gen_abs_i32_mips64 #define tcg_gen_add2_i32 tcg_gen_add2_i32_mips64 diff --git a/qemu/mips64el.h b/qemu/mips64el.h index d89e3799..eabee7d7 100644 --- a/qemu/mips64el.h +++ b/qemu/mips64el.h @@ -2978,6 +2978,7 @@ #define tcg_exec_all tcg_exec_all_mips64el #define tcg_exec_init tcg_exec_init_mips64el #define tcg_find_helper tcg_find_helper_mips64el +#define tcg_flush_softmmu_tlb tcg_flush_softmmu_tlb_mips64el #define tcg_func_start tcg_func_start_mips64el #define tcg_gen_abs_i32 tcg_gen_abs_i32_mips64el #define tcg_gen_add2_i32 tcg_gen_add2_i32_mips64el diff --git a/qemu/mipsel.h b/qemu/mipsel.h index c5baceeb..e6a7ff30 100644 --- a/qemu/mipsel.h +++ b/qemu/mipsel.h @@ -2978,6 +2978,7 @@ #define tcg_exec_all tcg_exec_all_mipsel #define tcg_exec_init tcg_exec_init_mipsel #define tcg_find_helper tcg_find_helper_mipsel +#define tcg_flush_softmmu_tlb tcg_flush_softmmu_tlb_mipsel #define tcg_func_start tcg_func_start_mipsel #define tcg_gen_abs_i32 tcg_gen_abs_i32_mipsel #define tcg_gen_add2_i32 tcg_gen_add2_i32_mipsel diff --git a/qemu/powerpc.h b/qemu/powerpc.h index d9b0b5db..4b25a0fa 100644 --- a/qemu/powerpc.h +++ b/qemu/powerpc.h @@ -2978,6 +2978,7 @@ #define tcg_exec_all tcg_exec_all_powerpc #define tcg_exec_init tcg_exec_init_powerpc #define tcg_find_helper tcg_find_helper_powerpc +#define tcg_flush_softmmu_tlb tcg_flush_softmmu_tlb_powerpc #define tcg_func_start tcg_func_start_powerpc #define tcg_gen_abs_i32 tcg_gen_abs_i32_powerpc #define tcg_gen_add2_i32 tcg_gen_add2_i32_powerpc diff --git a/qemu/qom/cpu.c b/qemu/qom/cpu.c index 5e38c7c4..e2afc183 100644 --- a/qemu/qom/cpu.c +++ b/qemu/qom/cpu.c @@ -178,9 +178,8 @@ static void cpu_common_reset(CPUState *cpu) //if (tcg_enabled(cpu->uc)) { cpu_tb_jmp_cache_clear(cpu); -#ifdef CONFIG_SOFTMMU - tlb_flush(cpu); -#endif + // Ditto: should also be uncommented + //tcg_flush_softmmu_tlb(cpu); //} } diff --git a/qemu/sparc.h b/qemu/sparc.h index 97e2140b..15a71832 100644 --- a/qemu/sparc.h +++ b/qemu/sparc.h @@ -2978,6 +2978,7 @@ #define tcg_exec_all tcg_exec_all_sparc #define tcg_exec_init tcg_exec_init_sparc #define tcg_find_helper tcg_find_helper_sparc +#define tcg_flush_softmmu_tlb tcg_flush_softmmu_tlb_sparc #define tcg_func_start tcg_func_start_sparc #define tcg_gen_abs_i32 tcg_gen_abs_i32_sparc #define tcg_gen_add2_i32 tcg_gen_add2_i32_sparc diff --git a/qemu/sparc64.h b/qemu/sparc64.h index 4ec141e4..370f1c51 100644 --- a/qemu/sparc64.h +++ b/qemu/sparc64.h @@ -2978,6 +2978,7 @@ #define tcg_exec_all tcg_exec_all_sparc64 #define tcg_exec_init tcg_exec_init_sparc64 #define tcg_find_helper tcg_find_helper_sparc64 +#define tcg_flush_softmmu_tlb tcg_flush_softmmu_tlb_sparc64 #define tcg_func_start tcg_func_start_sparc64 #define tcg_gen_abs_i32 tcg_gen_abs_i32_sparc64 #define tcg_gen_add2_i32 tcg_gen_add2_i32_sparc64 diff --git a/qemu/translate-all.c b/qemu/translate-all.c index 3ae0fa96..88884686 100644 --- a/qemu/translate-all.c +++ b/qemu/translate-all.c @@ -2227,3 +2227,11 @@ int page_unprotect(struct uc_struct *uc, target_ulong address, uintptr_t pc) return 0; } #endif /* CONFIG_USER_ONLY */ + +/* This is a wrapper for common code that can not use CONFIG_SOFTMMU */ +void tcg_flush_softmmu_tlb(CPUState *cs) +{ +#ifdef CONFIG_SOFTMMU + tlb_flush(cs); +#endif +} diff --git a/qemu/x86_64.h b/qemu/x86_64.h index bfd9961a..d86b0ab2 100644 --- a/qemu/x86_64.h +++ b/qemu/x86_64.h @@ -2978,6 +2978,7 @@ #define tcg_exec_all tcg_exec_all_x86_64 #define tcg_exec_init tcg_exec_init_x86_64 #define tcg_find_helper tcg_find_helper_x86_64 +#define tcg_flush_softmmu_tlb tcg_flush_softmmu_tlb_x86_64 #define tcg_func_start tcg_func_start_x86_64 #define tcg_gen_abs_i32 tcg_gen_abs_i32_x86_64 #define tcg_gen_add2_i32 tcg_gen_add2_i32_x86_64