From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMnt7-0000n0-Dv for qemu-devel@nongnu.org; Sun, 09 Mar 2014 20:16:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WMnt0-00058T-Jm for qemu-devel@nongnu.org; Sun, 09 Mar 2014 20:16:13 -0400 Received: from cantor2.suse.de ([195.135.220.15]:42218 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMnt0-00058A-AR for qemu-devel@nongnu.org; Sun, 09 Mar 2014 20:16:06 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 10 Mar 2014 01:15:20 +0100 Message-Id: <1394410549-13751-12-git-send-email-afaerber@suse.de> In-Reply-To: <1394410549-13751-1-git-send-email-afaerber@suse.de> References: <1394410549-13751-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH qom-cpu v2 11/40] cpu: Move can_do_io field from CPU_COMMON to CPUState List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, =?UTF-8?q?Andreas=20F=C3=A4rber?= Rename can_do_io() to cpu_can_do_io() and change argument to CPUState. Signed-off-by: Andreas F=C3=A4rber --- cpus.c | 2 +- include/exec/cpu-defs.h | 1 - include/exec/exec-all.h | 21 +++++++++++++-------- include/exec/gen-icount.h | 4 ++-- include/exec/softmmu_template.h | 4 ++-- include/qom/cpu.h | 2 ++ qom/cpu.c | 1 + translate-all.c | 5 +++-- 8 files changed, 24 insertions(+), 16 deletions(-) diff --git a/cpus.c b/cpus.c index 57dc71e..dd5e59f 100644 --- a/cpus.c +++ b/cpus.c @@ -140,7 +140,7 @@ static int64_t cpu_get_icount_locked(void) icount =3D qemu_icount; if (cpu) { CPUArchState *env =3D cpu->env_ptr; - if (!can_do_io(env)) { + if (!cpu_can_do_io(cpu)) { fprintf(stderr, "Bad clock read\n"); } icount -=3D (env->icount_decr.u16.low + env->icount_extra); diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h index f228d8c..4d34457 100644 --- a/include/exec/cpu-defs.h +++ b/include/exec/cpu-defs.h @@ -156,7 +156,6 @@ typedef struct CPUWatchpoint { uint32_t u32; = \ icount_decr_u16 u16; = \ } icount_decr; = \ - uint32_t can_do_io; /* nonzero if memory mapped IO is safe. */ = \ = \ /* from this point: preserved by CPU reset */ = \ /* ice debug support */ = \ diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index a387922..2179329 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -380,20 +380,25 @@ extern int singlestep; /* cpu-exec.c */ extern volatile sig_atomic_t exit_request; =20 -/* Deterministic execution requires that IO only be performed on the las= t - instruction of a TB so that interrupts take effect immediately. */ -static inline int can_do_io(CPUArchState *env) +/** + * cpu_can_do_io: + * @cpu: The CPU for which to check IO. + * + * Deterministic execution requires that IO only be performed on the las= t + * instruction of a TB so that interrupts take effect immediately. + * + * Returns: %true if memory-mapped IO is safe, %false otherwise. + */ +static inline bool cpu_can_do_io(CPUState *cpu) { - CPUState *cpu =3D ENV_GET_CPU(env); - if (!use_icount) { - return 1; + return true; } /* If not executing code then assume we are ok. */ if (cpu->current_tb =3D=3D NULL) { - return 1; + return true; } - return env->can_do_io !=3D 0; + return cpu->can_do_io !=3D 0; } =20 #endif diff --git a/include/exec/gen-icount.h b/include/exec/gen-icount.h index 39a6b61..f0dace3 100644 --- a/include/exec/gen-icount.h +++ b/include/exec/gen-icount.h @@ -51,14 +51,14 @@ static void gen_tb_end(TranslationBlock *tb, int num_= insns) static inline void gen_io_start(void) { TCGv_i32 tmp =3D tcg_const_i32(1); - tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUArchState, can_do_io)); + tcg_gen_st_i32(tmp, cpu_env, -ENV_OFFSET + offsetof(CPUState, can_do= _io)); tcg_temp_free_i32(tmp); } =20 static inline void gen_io_end(void) { TCGv_i32 tmp =3D tcg_const_i32(0); - tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUArchState, can_do_io)); + tcg_gen_st_i32(tmp, cpu_env, -ENV_OFFSET + offsetof(CPUState, can_do= _io)); tcg_temp_free_i32(tmp); } =20 diff --git a/include/exec/softmmu_template.h b/include/exec/softmmu_templ= ate.h index c7cd937..ac825d2 100644 --- a/include/exec/softmmu_template.h +++ b/include/exec/softmmu_template.h @@ -127,7 +127,7 @@ static inline DATA_TYPE glue(io_read, SUFFIX)(CPUArch= State *env, =20 physaddr =3D (physaddr & TARGET_PAGE_MASK) + addr; cpu->mem_io_pc =3D retaddr; - if (mr !=3D &io_mem_rom && mr !=3D &io_mem_notdirty && !can_do_io(en= v)) { + if (mr !=3D &io_mem_rom && mr !=3D &io_mem_notdirty && !cpu_can_do_i= o(cpu)) { cpu_io_recompile(env, retaddr); } =20 @@ -333,7 +333,7 @@ static inline void glue(io_write, SUFFIX)(CPUArchStat= e *env, MemoryRegion *mr =3D iotlb_to_region(cpu->as, physaddr); =20 physaddr =3D (physaddr & TARGET_PAGE_MASK) + addr; - if (mr !=3D &io_mem_rom && mr !=3D &io_mem_notdirty && !can_do_io(en= v)) { + if (mr !=3D &io_mem_rom && mr !=3D &io_mem_notdirty && !cpu_can_do_i= o(cpu)) { cpu_io_recompile(env, retaddr); } =20 diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 9d52cf3..f80036e 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -157,6 +157,7 @@ struct kvm_run; * @tcg_exit_req: Set to force TCG to stop executing linked TBs for this * CPU and return to its top level loop. * @singlestep_enabled: Flags for single-stepping. + * @can_do_io: Nonzero if memory-mapped IO is safe. * @env_ptr: Pointer to subclass-specific CPUArchState field. * @current_tb: Currently executing TB. * @gdb_regs: Additional GDB registers. @@ -220,6 +221,7 @@ struct CPUState { /* TODO Move common fields from CPUArchState here. */ int cpu_index; /* used by alpha TCG */ uint32_t halted; /* used by alpha, cris, ppc TCG */ + uint32_t can_do_io; }; =20 QTAILQ_HEAD(CPUTailQ, CPUState); diff --git a/qom/cpu.c b/qom/cpu.c index c59e8b1..686b6f9 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -242,6 +242,7 @@ static void cpu_common_reset(CPUState *cpu) cpu->halted =3D 0; cpu->mem_io_pc =3D 0; cpu->mem_io_vaddr =3D 0; + cpu->can_do_io =3D 0; } =20 static bool cpu_common_has_work(CPUState *cs) diff --git a/translate-all.c b/translate-all.c index dc35caa..a1af5ef 100644 --- a/translate-all.c +++ b/translate-all.c @@ -200,6 +200,7 @@ int cpu_gen_code(CPUArchState *env, TranslationBlock = *tb, int *gen_code_size_ptr static int cpu_restore_state_from_tb(TranslationBlock *tb, CPUArchState = *env, uintptr_t searched_pc) { + CPUState *cpu =3D ENV_GET_CPU(env); TCGContext *s =3D &tcg_ctx; int j; uintptr_t tc_ptr; @@ -218,7 +219,7 @@ static int cpu_restore_state_from_tb(TranslationBlock= *tb, CPUArchState *env, /* Reset the cycle counter to the start of the block. */ env->icount_decr.u16.low +=3D tb->icount; /* Clear the IO flag. */ - env->can_do_io =3D 0; + cpu->can_do_io =3D 0; } =20 /* find opc index corresponding to search_pc */ @@ -1409,7 +1410,7 @@ static void tcg_handle_interrupt(CPUState *cpu, int= mask) =20 if (use_icount) { env->icount_decr.u16.high =3D 0xffff; - if (!can_do_io(env) + if (!cpu_can_do_io(cpu) && (mask & ~old_mask) !=3D 0) { cpu_abort(env, "Raised interrupt while not in I/O function")= ; } --=20 1.8.4.5