tb: consistently use uint32_t for tb->flags
PATCH 1/1 tb: consistently use uint32_t for tb->flags
We are inconsistent with the type of tb->flags: usage varies loosely between int and uint64_t. Settle to uint32_t everywhere, which is superior to both: at least one target (aarch64) uses the most significant bit in the u32, and uint64_t is wasteful.
Compile-tested for all targets.
--- cpu-exec.c | 6 +++--- exec.c | 2 +- hw/i386/kvmvapic.c | 2 +- include/exec/exec-all.h | 5 +++-- target-alpha/cpu.h | 2 +- target-arm/cpu.h | 2 +- target-cris/cpu.h | 2 +- target-i386/cpu.h | 2 +- target-i386/translate.c | 2 +- target-lm32/cpu.h | 2 +- target-m68k/cpu.h | 2 +- target-microblaze/cpu.h | 2 +- target-mips/cpu.h | 2 +- target-moxie/cpu.h | 2 +- target-openrisc/cpu.h | 2 +- target-ppc/cpu.h | 2 +- target-s390x/cpu.h | 2 +- target-sh4/cpu.h | 2 +- target-sparc/cpu.h | 2 +- target-tilegx/cpu.h | 2 +- target-tricore/cpu.h | 2 +- target-unicore32/cpu.h | 2 +- target-xtensa/cpu.h | 2 +- translate-all.c | 10 +++++----- 24 files changed, 32 insertions(+), 31 deletions(-)
cpu-exec.c +3 -3
@@ -220,7 +220,7 @@ static void cpu_exec_nocache(CPUState *cpu, int max_cycles,static TranslationBlock *tb_find_physical (CPUState *cpu,target_ulong pc,target_ulong cs_base, -uint64_t flags) +uint32_t flags) {CPUArchState *env = (CPUArchState *)cpu->env_ptr;TranslationBlock *tb, **ptb1;
@@ -271,7 +271,7 @@ static TranslationBlock *tb_find_physical(CPUState *cpu,static TranslationBlock *tb_find_slow (CPUState *cpu,target_ulong pc,target_ulong cs_base, -uint64_t flags) +uint32_t flags) {TranslationBlock *tb;
@@ -314,7 +314,7 @@ static inline TranslationBlock *tb_find_fast(CPUState *cpu)CPUArchState *env = (CPUArchState *)cpu->env_ptr;TranslationBlock *tb;target_ulong cs_base, pc; -int flags; +uint32_t flags;/* we record a subset of the CPU state. It will always be the same before a given translated block
exec.c +1 -1
@@ -2083,7 +2083,7 @@ static void check_watchpoint(int offset, int len, MemTxAttrs attrs, int flags)target_ulong pc, cs_base;target_ulong vaddr;CPUWatchpoint *wp; -int cpu_flags; +uint32_t cpu_flags;if (cpu->watchpoint_hit) {/* We re-entered the check after replacing the TB. Now raise
hw/i386/kvmvapic.c +1 -1
@@ -397,7 +397,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)uint32_t imm32;target_ulong current_pc =0 ;target_ulong current_cs_base =0 ; -int current_flags =0 ; +uint32_t current_flags =0 ;if (smp_cpus ==1 ) { handlers = &s->rom_state.up;
include/exec/exec-all.h +3 -2
@@ -76,7 +76,8 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t searched_pc); void QEMU_NORETURN cpu_resume_from_signal(CPUState *cpu, void *puc); void QEMU_NORETURN cpu_io_recompile(CPUState *cpu, uintptr_t retaddr);TranslationBlock *tb_gen_code (CPUState *cpu, -target_ulong pc,target_ulong cs_base,int flags, +target_ulong pc,target_ulong cs_base, +uint32_t flags,int cflags);void cpu_exec_init (CPUState *cpu,Error **errp); void QEMU_NORETURN cpu_loop_exit(CPUState *cpu);
@@ -235,7 +236,7 @@ static inline void tlb_flush_by_mmuidx(CPUState *cpu, ...)struct TranslationBlock {target_ulong pc;/* simulated PC corresponding to this block (EIP + CS base) */ target_ulong cs_base;/* CS base for this block */ -uint64_t flags;/* flags defining in which context the code was generated */ +uint32_t flags;/* flags defining in which context the code was generated */ uint16_t size;/* size of target code for this block (1 <= size <= TARGET_PAGE_SIZE) */ uint16_t icount;
target-alpha/cpu.h +1 -1
@@ -465,7 +465,7 @@ enum { };static inline void cpu_get_tb_cpu_state (CPUAlphaState *env,target_ulong *pc, -target_ulong *cs_base,int *pflags) +target_ulong *cs_base,uint32_t *pflags) {int flags =0 ;
target-arm/cpu.h +1 -1
@@ -2117,7 +2117,7 @@ static inline bool arm_cpu_bswap_data(CPUARMState *env)#endif static inline void cpu_get_tb_cpu_state (CPUARMState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) {if (is_a64 (env)) { *pc = env->pc;
target-cris/cpu.h +1 -1
@@ -249,7 +249,7 @@ int cris_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw,#include "exec/cpu-all.h" static inline void cpu_get_tb_cpu_state (CPUCRISState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->pc; *cs_base =0 ;
target-i386/cpu.h +1 -1
@@ -1269,7 +1269,7 @@ void tcg_x86_init(void);#include "exec/exec-all.h" static inline void cpu_get_tb_cpu_state (CPUX86State *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *cs_base = env->segs[R_CS ].base; *pc = *cs_base + env->eip;
target-i386/translate.c +1 -1
@@ -8178,7 +8178,7 @@ void gen_intermediate_code(CPUX86State *env, TranslationBlock *tb)CPUState *cs =CPU (cpu);DisasContext dc1, *dc = &dc1;target_ulong pc_ptr; -uint64_t flags; +uint32_t flags;target_ulong pc_start;target_ulong cs_base;int num_insns;
target-lm32/cpu.h +1 -1
@@ -226,7 +226,7 @@ int lm32_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw,#include "exec/cpu-all.h" static inline void cpu_get_tb_cpu_state (CPULM32State *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->pc; *cs_base =0 ;
target-m68k/cpu.h +1 -1
@@ -230,7 +230,7 @@ int m68k_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw,#include "exec/cpu-all.h" static inline void cpu_get_tb_cpu_state (CPUM68KState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->pc; *cs_base =0 ;
target-microblaze/cpu.h +1 -1
@@ -322,7 +322,7 @@ int mb_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw,#include "exec/cpu-all.h" static inline void cpu_get_tb_cpu_state (CPUMBState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->sregs[SR_PC ]; *cs_base =0 ;
target-mips/cpu.h +1 -1
@@ -839,7 +839,7 @@ static inline void restore_pamask(CPUMIPSState *env) }static inline void cpu_get_tb_cpu_state (CPUMIPSState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->active_tc.PC; *cs_base =0 ;
target-moxie/cpu.h +1 -1
@@ -132,7 +132,7 @@ static inline int cpu_mmu_index(CPUMoxieState *env, bool ifetch)#include "exec/exec-all.h" static inline void cpu_get_tb_cpu_state (CPUMoxieState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->pc; *cs_base =0 ;
target-openrisc/cpu.h +1 -1
@@ -392,7 +392,7 @@ int cpu_openrisc_get_phys_data(OpenRISCCPU *cpu,static inline void cpu_get_tb_cpu_state (CPUOpenRISCState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->pc; *cs_base =0 ;
target-ppc/cpu.h +1 -1
@@ -2293,7 +2293,7 @@ static inline void cpu_write_xer(CPUPPCState *env, target_ulong xer) }static inline void cpu_get_tb_cpu_state (CPUPPCState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->nip; *cs_base =0 ;
target-s390x/cpu.h +1 -1
@@ -338,7 +338,7 @@ static inline uint64_t cpu_mmu_idx_to_asc(int mmu_idx) }static inline void cpu_get_tb_cpu_state (CPUS390XState * env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->psw.addr; *cs_base =0 ;
target-sh4/cpu.h +1 -1
@@ -347,7 +347,7 @@ static inline void cpu_write_sr(CPUSH4State *env, target_ulong sr) }static inline void cpu_get_tb_cpu_state (CPUSH4State *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->pc; *cs_base =0 ;
target-sparc/cpu.h +1 -1
@@ -688,7 +688,7 @@ trap_state* cpu_tsptr(CPUSPARCState* env);#define TB_FLAG_AM_ENABLED (1 << 5)static inline void cpu_get_tb_cpu_state (CPUSPARCState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->pc; *cs_base = env->npc;
target-tilegx/cpu.h +1 -1
@@ -169,7 +169,7 @@ TileGXCPU *cpu_tilegx_init(const char *cpu_model);#define cpu_signal_handler cpu_tilegx_signal_handlerstatic inline void cpu_get_tb_cpu_state (CPUTLGState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->pc; *cs_base =0 ;
target-tricore/cpu.h +1 -1
@@ -377,7 +377,7 @@ void tricore_tcg_init(void);int cpu_tricore_signal_handler (int host_signum,void *pinfo,void *puc);static inline void cpu_get_tb_cpu_state (CPUTriCoreState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->PC; *cs_base =0 ;
target-unicore32/cpu.h +1 -1
@@ -144,7 +144,7 @@ UniCore32CPU *uc32_cpu_init(const char *cpu_model);#define cpu_init (cpu_model) CPU(uc32_cpu_init(cpu_model))static inline void cpu_get_tb_cpu_state (CPUUniCore32State *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->regs[31 ]; *cs_base =0 ;
target-xtensa/cpu.h +1 -1
@@ -507,7 +507,7 @@ static inline int cpu_mmu_index(CPUXtensaState *env, bool ifetch)#define XTENSA_TBFLAG_WINDOW_SHIFT 15static inline void cpu_get_tb_cpu_state (CPUXtensaState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) {CPUState *cs =CPU (xtensa_env_get_cpu (env));
translate-all.c +5 -5
@@ -1050,7 +1050,7 @@ static void build_page_bitmap(PageDesc *p)/* Called with mmap_lock held for user mode emulation. */ TranslationBlock *tb_gen_code (CPUState *cpu,target_ulong pc,target_ulong cs_base, -int flags,int cflags) +uint32_t flags,int cflags) {CPUArchState *env = cpu->env_ptr;TranslationBlock *tb;
@@ -1204,7 +1204,7 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end,int current_tb_modified =0 ;target_ulong current_pc =0 ;target_ulong current_cs_base =0 ; -int current_flags =0 ; +uint32_t current_flags =0 ;#endif /* TARGET_HAS_PRECISE_SMC */ p =page_find (start >>TARGET_PAGE_BITS );
@@ -1349,7 +1349,7 @@ static void tb_invalidate_phys_page(tb_page_addr_t addr,int current_tb_modified =0 ;target_ulong current_pc =0 ;target_ulong current_cs_base =0 ; -int current_flags =0 ; +uint32_t current_flags =0 ;#endif addr &=TARGET_PAGE_MASK ;
@@ -1573,7 +1573,7 @@ void tb_check_watchpoint(CPUState *cpu)CPUArchState *env = cpu->env_ptr;target_ulong pc, cs_base;tb_page_addr_t addr; -int flags; +uint32_t flags;cpu_get_tb_cpu_state (env, &pc, &cs_base, &flags); addr =get_page_addr_code (env, pc);
@@ -1592,7 +1592,7 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr)TranslationBlock *tb;uint32_t n, cflags;target_ulong pc, cs_base; -uint64_t flags; +uint32_t flags; tb =tb_find_pc (retaddr);if (!tb) {
Signature · 1 line
2.5.0
Quoted 10 lines · Emilio G. Cota
We are inconsistent with the type of
tb->flags: usage varies loosely between int anduint64_t. Settle touint32_teverywhere, which is superior to both: at least one target (aarch64) uses the most significant bit in the u32, anduint64_tis wasteful.Compile-tested for all targets.
Suggested-by Laurent Desnogues <[email protected]>Suggested-by Richard Henderson <[email protected]>Signed-off-by Emilio G. Cota <[email protected]>
Context:
https://lists.gnu.org/archive/html/qemu-devel/2016-04/msg01110.html
Thanks,
Emilio
Hello,
Quoted 11 lines · Emilio G. Cota
We are inconsistent with the type of
tb->flags: usage varies loosely between int anduint64_t. Settle touint32_teverywhere, which is superior to both: at least one target (aarch64) uses the most significant bit in the u32, anduint64_tis wasteful.Compile-tested for all targets.
Suggested-by Laurent Desnogues <[email protected]>Suggested-by Richard Henderson <[email protected]>Signed-off-by Emilio G. Cota <[email protected]>
Thanks for taking care of this.
Laurent
Quoted 406 lines
--- cpu-exec.c | 6 +++--- exec.c | 2 +- hw/i386/kvmvapic.c | 2 +- include/exec/exec-all.h | 5 +++-- target-alpha/cpu.h | 2 +- target-arm/cpu.h | 2 +- target-cris/cpu.h | 2 +- target-i386/cpu.h | 2 +- target-i386/translate.c | 2 +- target-lm32/cpu.h | 2 +- target-m68k/cpu.h | 2 +- target-microblaze/cpu.h | 2 +- target-mips/cpu.h | 2 +- target-moxie/cpu.h | 2 +- target-openrisc/cpu.h | 2 +- target-ppc/cpu.h | 2 +- target-s390x/cpu.h | 2 +- target-sh4/cpu.h | 2 +- target-sparc/cpu.h | 2 +- target-tilegx/cpu.h | 2 +- target-tricore/cpu.h | 2 +- target-unicore32/cpu.h | 2 +- target-xtensa/cpu.h | 2 +- translate-all.c | 10 +++++----- 24 files changed, 32 insertions(+), 31 deletions(-)cpu-exec.c +3
-3@@ -220,7 +220,7 @@ static void cpu_exec_nocache(CPUState *cpu, int max_cycles,static TranslationBlock *tb_find_physical (CPUState *cpu,target_ulong pc,target_ulong cs_base, -uint64_t flags) +uint32_t flags) {CPUArchState *env = (CPUArchState *)cpu->env_ptr;TranslationBlock *tb, **ptb1;@@ -271,7 +271,7 @@ static TranslationBlock *tb_find_physical(CPUState *cpu,static TranslationBlock *tb_find_slow (CPUState *cpu,target_ulong pc,target_ulong cs_base, -uint64_t flags) +uint32_t flags) {TranslationBlock *tb;@@ -314,7 +314,7 @@ static inline TranslationBlock *tb_find_fast(CPUState *cpu)CPUArchState *env = (CPUArchState *)cpu->env_ptr;TranslationBlock *tb;target_ulong cs_base, pc; -int flags; +uint32_t flags;/* we record a subset of the CPU state. It will always be the same before a given translated block exec.c +1
-1@@ -2083,7 +2083,7 @@ static void check_watchpoint(int offset, int len, MemTxAttrs attrs, int flags)target_ulong pc, cs_base;target_ulong vaddr;CPUWatchpoint *wp; -int cpu_flags; +uint32_t cpu_flags;if (cpu->watchpoint_hit) {/* We re-entered the check after replacing the TB. Now raise hw/i386/kvmvapic.c +1
-1@@ -397,7 +397,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)uint32_t imm32;target_ulong current_pc =0 ;target_ulong current_cs_base =0 ; -int current_flags =0 ; +uint32_t current_flags =0 ;if (smp_cpus ==1 ) { handlers = &s->rom_state.up;include/exec/exec-all.h +3
-2@@ -76,7 +76,8 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t searched_pc); void QEMU_NORETURN cpu_resume_from_signal(CPUState *cpu, void *puc); void QEMU_NORETURN cpu_io_recompile(CPUState *cpu, uintptr_t retaddr);TranslationBlock *tb_gen_code (CPUState *cpu, -target_ulong pc,target_ulong cs_base,int flags, +target_ulong pc,target_ulong cs_base, +uint32_t flags,int cflags);void cpu_exec_init (CPUState *cpu,Error **errp); void QEMU_NORETURN cpu_loop_exit(CPUState *cpu);@@ -235,7 +236,7 @@ static inline void tlb_flush_by_mmuidx(CPUState *cpu, ...)struct TranslationBlock {target_ulong pc;/* simulated PC corresponding to this block (EIP + CS base) */ target_ulong cs_base;/* CS base for this block */ -uint64_t flags;/* flags defining in which context the code was generated */ +uint32_t flags;/* flags defining in which context the code was generated */ uint16_t size;/* size of target code for this block (1 <= size <= TARGET_PAGE_SIZE) */ uint16_t icount;target-alpha/cpu.h +1
-1@@ -465,7 +465,7 @@ enum { };static inline void cpu_get_tb_cpu_state (CPUAlphaState *env,target_ulong *pc, -target_ulong *cs_base,int *pflags) +target_ulong *cs_base,uint32_t *pflags) {int flags =0 ;target-arm/cpu.h +1
-1@@ -2117,7 +2117,7 @@ static inline bool arm_cpu_bswap_data(CPUARMState *env)#endif static inline void cpu_get_tb_cpu_state (CPUARMState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) {if (is_a64 (env)) { *pc = env->pc;target-cris/cpu.h +1
-1@@ -249,7 +249,7 @@ int cris_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw,#include "exec/cpu-all.h" static inline void cpu_get_tb_cpu_state (CPUCRISState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->pc; *cs_base =0 ;target-i386/cpu.h +1
-1@@ -1269,7 +1269,7 @@ void tcg_x86_init(void);#include "exec/exec-all.h" static inline void cpu_get_tb_cpu_state (CPUX86State *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *cs_base = env->segs[R_CS ].base; *pc = *cs_base + env->eip;target-i386/translate.c +1
-1@@ -8178,7 +8178,7 @@ void gen_intermediate_code(CPUX86State *env, TranslationBlock *tb)CPUState *cs =CPU (cpu);DisasContext dc1, *dc = &dc1;target_ulong pc_ptr; -uint64_t flags; +uint32_t flags;target_ulong pc_start;target_ulong cs_base;int num_insns;target-lm32/cpu.h +1
-1@@ -226,7 +226,7 @@ int lm32_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw,#include "exec/cpu-all.h" static inline void cpu_get_tb_cpu_state (CPULM32State *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->pc; *cs_base =0 ;target-m68k/cpu.h +1
-1@@ -230,7 +230,7 @@ int m68k_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw,#include "exec/cpu-all.h" static inline void cpu_get_tb_cpu_state (CPUM68KState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->pc; *cs_base =0 ;target-microblaze/cpu.h +1
-1@@ -322,7 +322,7 @@ int mb_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw,#include "exec/cpu-all.h" static inline void cpu_get_tb_cpu_state (CPUMBState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->sregs[SR_PC ]; *cs_base =0 ;target-mips/cpu.h +1
-1@@ -839,7 +839,7 @@ static inline void restore_pamask(CPUMIPSState *env) }static inline void cpu_get_tb_cpu_state (CPUMIPSState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->active_tc.PC; *cs_base =0 ;target-moxie/cpu.h +1
-1@@ -132,7 +132,7 @@ static inline int cpu_mmu_index(CPUMoxieState *env, bool ifetch)#include "exec/exec-all.h" static inline void cpu_get_tb_cpu_state (CPUMoxieState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->pc; *cs_base =0 ;target-openrisc/cpu.h +1
-1@@ -392,7 +392,7 @@ int cpu_openrisc_get_phys_data(OpenRISCCPU *cpu,static inline void cpu_get_tb_cpu_state (CPUOpenRISCState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->pc; *cs_base =0 ;target-ppc/cpu.h +1
-1@@ -2293,7 +2293,7 @@ static inline void cpu_write_xer(CPUPPCState *env, target_ulong xer) }static inline void cpu_get_tb_cpu_state (CPUPPCState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->nip; *cs_base =0 ;target-s390x/cpu.h +1
-1@@ -338,7 +338,7 @@ static inline uint64_t cpu_mmu_idx_to_asc(int mmu_idx) }static inline void cpu_get_tb_cpu_state (CPUS390XState * env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->psw.addr; *cs_base =0 ;target-sh4/cpu.h +1
-1@@ -347,7 +347,7 @@ static inline void cpu_write_sr(CPUSH4State *env, target_ulong sr) }static inline void cpu_get_tb_cpu_state (CPUSH4State *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->pc; *cs_base =0 ;target-sparc/cpu.h +1
-1@@ -688,7 +688,7 @@ trap_state* cpu_tsptr(CPUSPARCState* env);#define TB_FLAG_AM_ENABLED (1 << 5)static inline void cpu_get_tb_cpu_state (CPUSPARCState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->pc; *cs_base = env->npc;target-tilegx/cpu.h +1
-1@@ -169,7 +169,7 @@ TileGXCPU *cpu_tilegx_init(const char *cpu_model);#define cpu_signal_handler cpu_tilegx_signal_handlerstatic inline void cpu_get_tb_cpu_state (CPUTLGState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->pc; *cs_base =0 ;target-tricore/cpu.h +1
-1@@ -377,7 +377,7 @@ void tricore_tcg_init(void);int cpu_tricore_signal_handler (int host_signum,void *pinfo,void *puc);static inline void cpu_get_tb_cpu_state (CPUTriCoreState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->PC; *cs_base =0 ;target-unicore32/cpu.h +1
-1@@ -144,7 +144,7 @@ UniCore32CPU *uc32_cpu_init(const char *cpu_model);#define cpu_init (cpu_model) CPU(uc32_cpu_init(cpu_model))static inline void cpu_get_tb_cpu_state (CPUUniCore32State *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->regs[31 ]; *cs_base =0 ;target-xtensa/cpu.h +1
-1@@ -507,7 +507,7 @@ static inline int cpu_mmu_index(CPUXtensaState *env, bool ifetch)#define XTENSA_TBFLAG_WINDOW_SHIFT 15static inline void cpu_get_tb_cpu_state (CPUXtensaState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) {CPUState *cs =CPU (xtensa_env_get_cpu (env));translate-all.c +5
-6@@ -1050,7 +1050,7 @@ static void build_page_bitmap(PageDesc *p)/* Called with mmap_lock held for user mode emulation. */ TranslationBlock *tb_gen_code (CPUState *cpu,target_ulong pc,target_ulong cs_base, -int flags,int cflags) +uint32_t flags,int cflags) {CPUArchState *env = cpu->env_ptr;TranslationBlock *tb;@@ -1204,7 +1204,7 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end,int current_tb_modified =0 ;target_ulong current_pc =0 ;target_ulong current_cs_base =0 ; -int current_flags =0 ; +uint32_t current_flags =0 ;#endif /* TARGET_HAS_PRECISE_SMC */ p =page_find (start >>TARGET_PAGE_BITS );@@ -1349,7 +1349,7 @@ static void tb_invalidate_phys_page(tb_page_addr_t addr,int current_tb_modified =0 ;target_ulong current_pc =0 ;target_ulong current_cs_base =0 ; -int current_flags =0 ; +uint32_t current_flags =0 ;#endif addr &=TARGET_PAGE_MASK ;@@ -1573,7 +1573,7 @@ void tb_check_watchpoint(CPUState *cpu)CPUArchState *env = cpu->env_ptr;target_ulong pc, cs_base;tb_page_addr_t addr; -int flags; +uint32_t flags;cpu_get_tb_cpu_state (env, &pc, &cs_base, &flags); addr =get_page_addr_code (env, pc);@@ -1592,7 +1592,7 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr)TranslationBlock *tb;uint32_t n, cflags;target_ulong pc, cs_base; -uint64_t flags; +uint32_t flags; tb =tb_find_pc (retaddr);if (!tb) { --2.5.0
Quoted 28 lines · Emilio G. Cota
We are inconsistent with the type of
tb->flags: usage varies loosely between int anduint64_t. Settle touint32_teverywhere, which is superior to both: at least one target (aarch64) uses the most significant bit in the u32, anduint64_tis wasteful.Compile-tested for all targets.
Suggested-by Laurent Desnogues<[email protected]>Suggested-by Richard Henderson<[email protected]>Signed-off-by Emilio G. Cota<[email protected]>--- cpu-exec.c | 6 +++--- exec.c | 2 +- hw/i386/kvmvapic.c | 2 +- include/exec/exec-all.h | 5 +++-- target-alpha/cpu.h | 2 +- target-arm/cpu.h | 2 +- target-cris/cpu.h | 2 +- target-i386/cpu.h | 2 +- target-i386/translate.c | 2 +- target-lm32/cpu.h | 2 +- target-m68k/cpu.h | 2 +- target-microblaze/cpu.h | 2 +- target-mips/cpu.h | 2 +- target-moxie/cpu.h | 2 +- target-openrisc/cpu.h | 2 +- target-ppc/cpu.h | 2 +- target-s390x/cpu.h | 2 +-
Quoted 8 lines
target-sh4/cpu.h | 2 +- target-sparc/cpu.h | 2 +- target-tilegx/cpu.h | 2 +- target-tricore/cpu.h | 2 +- target-unicore32/cpu.h | 2 +- target-xtensa/cpu.h | 2 +- translate-all.c | 10 +++++----- 24 files changed, 32 insertions(+), 31 deletions(-)
r~
Quoted 6 lines · Emilio G. Cota
We are inconsistent with the type of
tb->flags: usage varies loosely between int anduint64_t. Settle touint32_teverywhere, which is superior to both: at least one target (aarch64) uses the most significant bit in the u32, anduint64_tis wasteful.Compile-tested for all targets.
Looks good. I ran tests on CRIS, MicroBlaze and a few mixed ARM and PPC images I've got.
Quoted 410 lines
Suggested-by Laurent Desnogues <[email protected]>Suggested-by Richard Henderson <[email protected]>Signed-off-by Emilio G. Cota <[email protected]>--- cpu-exec.c | 6 +++--- exec.c | 2 +- hw/i386/kvmvapic.c | 2 +- include/exec/exec-all.h | 5 +++-- target-alpha/cpu.h | 2 +- target-arm/cpu.h | 2 +- target-cris/cpu.h | 2 +- target-i386/cpu.h | 2 +- target-i386/translate.c | 2 +- target-lm32/cpu.h | 2 +- target-m68k/cpu.h | 2 +- target-microblaze/cpu.h | 2 +- target-mips/cpu.h | 2 +- target-moxie/cpu.h | 2 +- target-openrisc/cpu.h | 2 +- target-ppc/cpu.h | 2 +- target-s390x/cpu.h | 2 +- target-sh4/cpu.h | 2 +- target-sparc/cpu.h | 2 +- target-tilegx/cpu.h | 2 +- target-tricore/cpu.h | 2 +- target-unicore32/cpu.h | 2 +- target-xtensa/cpu.h | 2 +- translate-all.c | 10 +++++----- 24 files changed, 32 insertions(+), 31 deletions(-)cpu-exec.c +3
-3@@ -220,7 +220,7 @@ static void cpu_exec_nocache(CPUState *cpu, int max_cycles,static TranslationBlock *tb_find_physical (CPUState *cpu,target_ulong pc,target_ulong cs_base, -uint64_t flags) +uint32_t flags) {CPUArchState *env = (CPUArchState *)cpu->env_ptr;TranslationBlock *tb, **ptb1;@@ -271,7 +271,7 @@ static TranslationBlock *tb_find_physical(CPUState *cpu,static TranslationBlock *tb_find_slow (CPUState *cpu,target_ulong pc,target_ulong cs_base, -uint64_t flags) +uint32_t flags) {TranslationBlock *tb;@@ -314,7 +314,7 @@ static inline TranslationBlock *tb_find_fast(CPUState *cpu)CPUArchState *env = (CPUArchState *)cpu->env_ptr;TranslationBlock *tb;target_ulong cs_base, pc; -int flags; +uint32_t flags;/* we record a subset of the CPU state. It will always be the same before a given translated block exec.c +1
-1@@ -2083,7 +2083,7 @@ static void check_watchpoint(int offset, int len, MemTxAttrs attrs, int flags)target_ulong pc, cs_base;target_ulong vaddr;CPUWatchpoint *wp; -int cpu_flags; +uint32_t cpu_flags;if (cpu->watchpoint_hit) {/* We re-entered the check after replacing the TB. Now raise hw/i386/kvmvapic.c +1
-1@@ -397,7 +397,7 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)uint32_t imm32;target_ulong current_pc =0 ;target_ulong current_cs_base =0 ; -int current_flags =0 ; +uint32_t current_flags =0 ;if (smp_cpus ==1 ) { handlers = &s->rom_state.up;include/exec/exec-all.h +3
-2@@ -76,7 +76,8 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t searched_pc); void QEMU_NORETURN cpu_resume_from_signal(CPUState *cpu, void *puc); void QEMU_NORETURN cpu_io_recompile(CPUState *cpu, uintptr_t retaddr);TranslationBlock *tb_gen_code (CPUState *cpu, -target_ulong pc,target_ulong cs_base,int flags, +target_ulong pc,target_ulong cs_base, +uint32_t flags,int cflags);void cpu_exec_init (CPUState *cpu,Error **errp); void QEMU_NORETURN cpu_loop_exit(CPUState *cpu);@@ -235,7 +236,7 @@ static inline void tlb_flush_by_mmuidx(CPUState *cpu, ...)struct TranslationBlock {target_ulong pc;/* simulated PC corresponding to this block (EIP + CS base) */ target_ulong cs_base;/* CS base for this block */ -uint64_t flags;/* flags defining in which context the code was generated */ +uint32_t flags;/* flags defining in which context the code was generated */ uint16_t size;/* size of target code for this block (1 <= size <= TARGET_PAGE_SIZE) */ uint16_t icount;target-alpha/cpu.h +1
-1@@ -465,7 +465,7 @@ enum { };static inline void cpu_get_tb_cpu_state (CPUAlphaState *env,target_ulong *pc, -target_ulong *cs_base,int *pflags) +target_ulong *cs_base,uint32_t *pflags) {int flags =0 ;target-arm/cpu.h +1
-1@@ -2117,7 +2117,7 @@ static inline bool arm_cpu_bswap_data(CPUARMState *env)#endif static inline void cpu_get_tb_cpu_state (CPUARMState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) {if (is_a64 (env)) { *pc = env->pc;target-cris/cpu.h +1
-1@@ -249,7 +249,7 @@ int cris_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw,#include "exec/cpu-all.h" static inline void cpu_get_tb_cpu_state (CPUCRISState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->pc; *cs_base =0 ;target-i386/cpu.h +1
-1@@ -1269,7 +1269,7 @@ void tcg_x86_init(void);#include "exec/exec-all.h" static inline void cpu_get_tb_cpu_state (CPUX86State *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *cs_base = env->segs[R_CS ].base; *pc = *cs_base + env->eip;target-i386/translate.c +1
-1@@ -8178,7 +8178,7 @@ void gen_intermediate_code(CPUX86State *env, TranslationBlock *tb)CPUState *cs =CPU (cpu);DisasContext dc1, *dc = &dc1;target_ulong pc_ptr; -uint64_t flags; +uint32_t flags;target_ulong pc_start;target_ulong cs_base;int num_insns;target-lm32/cpu.h +1
-1@@ -226,7 +226,7 @@ int lm32_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw,#include "exec/cpu-all.h" static inline void cpu_get_tb_cpu_state (CPULM32State *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->pc; *cs_base =0 ;target-m68k/cpu.h +1
-1@@ -230,7 +230,7 @@ int m68k_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw,#include "exec/cpu-all.h" static inline void cpu_get_tb_cpu_state (CPUM68KState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->pc; *cs_base =0 ;target-microblaze/cpu.h +1
-1@@ -322,7 +322,7 @@ int mb_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw,#include "exec/cpu-all.h" static inline void cpu_get_tb_cpu_state (CPUMBState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->sregs[SR_PC ]; *cs_base =0 ;target-mips/cpu.h +1
-1@@ -839,7 +839,7 @@ static inline void restore_pamask(CPUMIPSState *env) }static inline void cpu_get_tb_cpu_state (CPUMIPSState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->active_tc.PC; *cs_base =0 ;target-moxie/cpu.h +1
-1@@ -132,7 +132,7 @@ static inline int cpu_mmu_index(CPUMoxieState *env, bool ifetch)#include "exec/exec-all.h" static inline void cpu_get_tb_cpu_state (CPUMoxieState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->pc; *cs_base =0 ;target-openrisc/cpu.h +1
-1@@ -392,7 +392,7 @@ int cpu_openrisc_get_phys_data(OpenRISCCPU *cpu,static inline void cpu_get_tb_cpu_state (CPUOpenRISCState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->pc; *cs_base =0 ;target-ppc/cpu.h +1
-1@@ -2293,7 +2293,7 @@ static inline void cpu_write_xer(CPUPPCState *env, target_ulong xer) }static inline void cpu_get_tb_cpu_state (CPUPPCState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->nip; *cs_base =0 ;target-s390x/cpu.h +1
-1@@ -338,7 +338,7 @@ static inline uint64_t cpu_mmu_idx_to_asc(int mmu_idx) }static inline void cpu_get_tb_cpu_state (CPUS390XState * env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->psw.addr; *cs_base =0 ;target-sh4/cpu.h +1
-1@@ -347,7 +347,7 @@ static inline void cpu_write_sr(CPUSH4State *env, target_ulong sr) }static inline void cpu_get_tb_cpu_state (CPUSH4State *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->pc; *cs_base =0 ;target-sparc/cpu.h +1
-1@@ -688,7 +688,7 @@ trap_state* cpu_tsptr(CPUSPARCState* env);#define TB_FLAG_AM_ENABLED (1 << 5)static inline void cpu_get_tb_cpu_state (CPUSPARCState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->pc; *cs_base = env->npc;target-tilegx/cpu.h +1
-1@@ -169,7 +169,7 @@ TileGXCPU *cpu_tilegx_init(const char *cpu_model);#define cpu_signal_handler cpu_tilegx_signal_handlerstatic inline void cpu_get_tb_cpu_state (CPUTLGState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->pc; *cs_base =0 ;target-tricore/cpu.h +1
-1@@ -377,7 +377,7 @@ void tricore_tcg_init(void);int cpu_tricore_signal_handler (int host_signum,void *pinfo,void *puc);static inline void cpu_get_tb_cpu_state (CPUTriCoreState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->PC; *cs_base =0 ;target-unicore32/cpu.h +1
-1@@ -144,7 +144,7 @@ UniCore32CPU *uc32_cpu_init(const char *cpu_model);#define cpu_init (cpu_model) CPU(uc32_cpu_init(cpu_model))static inline void cpu_get_tb_cpu_state (CPUUniCore32State *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) { *pc = env->regs[31 ]; *cs_base =0 ;target-xtensa/cpu.h +1
-1@@ -507,7 +507,7 @@ static inline int cpu_mmu_index(CPUXtensaState *env, bool ifetch)#define XTENSA_TBFLAG_WINDOW_SHIFT 15static inline void cpu_get_tb_cpu_state (CPUXtensaState *env,target_ulong *pc, -target_ulong *cs_base,int *flags) +target_ulong *cs_base,uint32_t *flags) {CPUState *cs =CPU (xtensa_env_get_cpu (env));translate-all.c +5
-5@@ -1050,7 +1050,7 @@ static void build_page_bitmap(PageDesc *p)/* Called with mmap_lock held for user mode emulation. */ TranslationBlock *tb_gen_code (CPUState *cpu,target_ulong pc,target_ulong cs_base, -int flags,int cflags) +uint32_t flags,int cflags) {CPUArchState *env = cpu->env_ptr;TranslationBlock *tb;@@ -1204,7 +1204,7 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end,int current_tb_modified =0 ;target_ulong current_pc =0 ;target_ulong current_cs_base =0 ; -int current_flags =0 ; +uint32_t current_flags =0 ;#endif /* TARGET_HAS_PRECISE_SMC */ p =page_find (start >>TARGET_PAGE_BITS );@@ -1349,7 +1349,7 @@ static void tb_invalidate_phys_page(tb_page_addr_t addr,int current_tb_modified =0 ;target_ulong current_pc =0 ;target_ulong current_cs_base =0 ; -int current_flags =0 ; +uint32_t current_flags =0 ;#endif addr &=TARGET_PAGE_MASK ;@@ -1573,7 +1573,7 @@ void tb_check_watchpoint(CPUState *cpu)CPUArchState *env = cpu->env_ptr;target_ulong pc, cs_base;tb_page_addr_t addr; -int flags; +uint32_t flags;cpu_get_tb_cpu_state (env, &pc, &cs_base, &flags); addr =get_page_addr_code (env, pc);@@ -1592,7 +1592,7 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr)TranslationBlock *tb;uint32_t n, cflags;target_ulong pc, cs_base; -uint64_t flags; +uint32_t flags; tb =tb_find_pc (retaddr);if (!tb) {Signature · 1 line
2.5.0
Quoted 10 lines · Emilio G. Cota
We are inconsistent with the type of
tb->flags: usage varies loosely between int anduint64_t. Settle touint32_teverywhere, which is superior to both: at least one target (aarch64) uses the most significant bit in the u32, anduint64_tis wasteful.Compile-tested for all targets.
Suggested-by Laurent Desnogues <[email protected]>Suggested-by Richard Henderson <[email protected]>Signed-off-by Emilio G. Cota <[email protected]>
Has this patch been queued by anyone? If not, should I resend after 2.6 is released?
Thanks,
Emilio
Quoted 6 lines · Emilio G. Cota
Quoted 5 lines · Emilio G. Cota
We are inconsistent with the type of
tb->flags: usage varies loosely between int anduint64_t. Settle touint32_teverywhere, which is superior to both: at least one target (aarch64) uses the most significant bit in the u32, anduint64_tis wasteful.
Quoted 8 lines
Quoted 5 lines
Compile-tested for all targets.
Suggested-by Laurent Desnogues <[email protected]>Suggested-by Richard Henderson <[email protected]>Signed-off-by Emilio G. Cota <[email protected]>Has this patch been queued by anyone? If not, should I resend after 2.6 is released?
Sorry for the delay. Queued for 2.7.
r~