From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, "Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [PATCH qom-cpu v2 11/40] cpu: Move can_do_io field from CPU_COMMON to CPUState
Date: Mon, 10 Mar 2014 01:15:20 +0100 [thread overview]
Message-ID: <1394410549-13751-12-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1394410549-13751-1-git-send-email-afaerber@suse.de>
Rename can_do_io() to cpu_can_do_io() and change argument to CPUState.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
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 = qemu_icount;
if (cpu) {
CPUArchState *env = cpu->env_ptr;
- if (!can_do_io(env)) {
+ if (!cpu_can_do_io(cpu)) {
fprintf(stderr, "Bad clock read\n");
}
icount -= (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;
-/* Deterministic execution requires that IO only be performed on the last
- 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 last
+ * 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 = ENV_GET_CPU(env);
-
if (!use_icount) {
- return 1;
+ return true;
}
/* If not executing code then assume we are ok. */
if (cpu->current_tb == NULL) {
- return 1;
+ return true;
}
- return env->can_do_io != 0;
+ return cpu->can_do_io != 0;
}
#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 = 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);
}
static inline void gen_io_end(void)
{
TCGv_i32 tmp = 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);
}
diff --git a/include/exec/softmmu_template.h b/include/exec/softmmu_template.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)(CPUArchState *env,
physaddr = (physaddr & TARGET_PAGE_MASK) + addr;
cpu->mem_io_pc = retaddr;
- if (mr != &io_mem_rom && mr != &io_mem_notdirty && !can_do_io(env)) {
+ if (mr != &io_mem_rom && mr != &io_mem_notdirty && !cpu_can_do_io(cpu)) {
cpu_io_recompile(env, retaddr);
}
@@ -333,7 +333,7 @@ static inline void glue(io_write, SUFFIX)(CPUArchState *env,
MemoryRegion *mr = iotlb_to_region(cpu->as, physaddr);
physaddr = (physaddr & TARGET_PAGE_MASK) + addr;
- if (mr != &io_mem_rom && mr != &io_mem_notdirty && !can_do_io(env)) {
+ if (mr != &io_mem_rom && mr != &io_mem_notdirty && !cpu_can_do_io(cpu)) {
cpu_io_recompile(env, retaddr);
}
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;
};
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 = 0;
cpu->mem_io_pc = 0;
cpu->mem_io_vaddr = 0;
+ cpu->can_do_io = 0;
}
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 = ENV_GET_CPU(env);
TCGContext *s = &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 += tb->icount;
/* Clear the IO flag. */
- env->can_do_io = 0;
+ cpu->can_do_io = 0;
}
/* find opc index corresponding to search_pc */
@@ -1409,7 +1410,7 @@ static void tcg_handle_interrupt(CPUState *cpu, int mask)
if (use_icount) {
env->icount_decr.u16.high = 0xffff;
- if (!can_do_io(env)
+ if (!cpu_can_do_io(cpu)
&& (mask & ~old_mask) != 0) {
cpu_abort(env, "Raised interrupt while not in I/O function");
}
--
1.8.4.5
next prev parent reply other threads:[~2014-03-10 0:16 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-10 0:15 [Qemu-devel] [PATCH qom-cpu v2 00/40] QOM CPUState, part 13: Emptying CPU_COMMON Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 01/40] target-alpha: Clean up ENV_GET_CPU() usage Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 02/40] target-arm: " Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 03/40] target-i386: " Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 04/40] target-ppc: " Andreas Färber
2014-03-12 22:56 ` Stuart Brady
2014-03-12 23:53 ` Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 05/40] target-s390x: " Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 06/40] target-sparc: " Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 07/40] target-unicore32: " Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 08/40] target-xtensa: " Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 09/40] cpu: Turn cpu_handle_mmu_fault() into a CPUClass hook Andreas Färber
2014-03-10 7:52 ` Paolo Bonzini
2014-03-11 23:47 ` Andreas Färber
2014-03-12 17:58 ` Paolo Bonzini
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 10/40] cpu: Move mem_io_{pc, vaddr} fields from CPU_COMMON to CPUState Andreas Färber
2014-03-10 0:15 ` Andreas Färber [this message]
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 12/40] cpu: Move icount_extra field " Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 13/40] cpu: Move icount_decr " Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 14/40] cpu: Move tb_jmp_cache " Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 15/40] cpu: Move jmp_env " Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 16/40] cpu: Move exception_index " Andreas Färber
2014-03-11 22:29 ` Andreas Färber
2014-03-13 0:56 ` Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 17/40] cpu: Move opaque " Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 18/40] cpu: Move watchpoint fields " Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 19/40] cpu: Move breakpoints field " Andreas Färber
2014-03-12 23:08 ` Stuart Brady
2014-03-12 23:59 ` Andreas Färber
2014-03-13 0:40 ` Stuart Brady
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 20/40] exec: Change tlb_fill() argument " Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 21/40] cpu-exec: Change cpu_loop_exit() " Andreas Färber
2014-03-11 22:35 ` Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 22/40] translate-all: Change cpu_restore_state() " Andreas Färber
2014-03-11 15:02 ` Max Filippov
2014-03-11 23:23 ` Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 23/40] translate-all: Change cpu_restore_state_from_tb() " Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 24/40] translate-all: Change tb_check_watchpoint() " Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 25/40] translate-all: Change cpu_io_recompile() " Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 26/40] translate-all: Change tb_gen_code() " Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 27/40] translate-all: Change tb_flush_jmp_cache() " Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 28/40] target-ppc: Use PowerPCCPU in PowerPCCPUClass::handle_mmu_fault hook Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 29/40] exec: Change cpu_watchpoint_{insert, remove{, _by_ref, _all}} argument Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 30/40] exec: Change cpu_breakpoint_{insert, " Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 31/40] cpu-exec: Change cpu_resume_from_signal() argument to CPUState Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 32/40] cputlb: Change tlb_unprotect_code_phys() " Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 33/40] exec: Change memory_region_section_get_iotlb() " Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 34/40] exec: Change cpu_abort() " Andreas Färber
2014-03-12 23:28 ` Andreas Färber
2014-03-13 0:59 ` Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 35/40] target-cris: Replace DisasContext::env field with CRISCPU Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 36/40] target-microblaze: Replace DisasContext::env field with MicroBlazeCPU Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 37/40] cputlb: Change tlb_flush_page() argument to CPUState Andreas Färber
2014-03-11 15:05 ` Max Filippov
2014-03-13 0:33 ` Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 38/40] cputlb: Change tlb_flush() " Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 39/40] cputlb: Change tlb_set_page() " Andreas Färber
2014-03-10 0:15 ` [Qemu-devel] [PATCH qom-cpu v2 40/40] user-exec: Change exception_action() " Andreas Färber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1394410549-13751-12-git-send-email-afaerber@suse.de \
--to=afaerber@suse.de \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).