From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: "Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [PULL for-2.0-rc0 29/58] cpu: Move can_do_io field from CPU_COMMON to CPUState
Date: Thu, 13 Mar 2014 15:54:32 +0100 [thread overview]
Message-ID: <1394722501-32326-30-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1394722501-32326-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 eda6d02..05016dc 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 bdcfefb3..068b6c1 100644
--- a/include/exec/cpu-defs.h
+++ b/include/exec/cpu-defs.h
@@ -157,7 +157,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 4d60c03..e7d5999 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -241,6 +241,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-13 14:55 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-13 14:54 [Qemu-devel] [PULL for-2.0-rc0 00/58] QOM CPUState patch queue 2014-03-13 Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 01/58] cpu: Don't clear cpu->exit_request on reset Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 02/58] target-alpha: Clean up ENV_GET_CPU() usage Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 03/58] target-arm: " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 04/58] target-i386: " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 05/58] target-ppc: " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 06/58] target-s390x: " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 07/58] target-sparc: " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 08/58] target-unicore32: " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 09/58] target-xtensa: " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 10/58] cpu: Turn cpu_has_work() into a CPUClass hook Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 11/58] target-i386: Rename cpu_x86_register() to x86_cpu_load_def() Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 12/58] target-i386: Call x86_cpu_load_def() earlier Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 13/58] target-i386: Rename x86_def_t to X86CPUDefinition Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 14/58] target-i386: Don't declare variables in the middle of blocks Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 15/58] target-i386: Make kvm_default_features an array Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 16/58] target-i386: Introduce x86_cpu_compat_disable_kvm_features() Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 17/58] target-i386: Enable x2apic by default on KVM Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 18/58] target-i386: Prepare CPUClass::class_by_name for X86CPU Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 19/58] target-i386: X86CPU model subclasses Andreas Färber
2014-03-13 18:19 ` Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 20/58] cpu: Introduce CPUClass::parse_features() hook Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 21/58] target-sparc: Use error_report() for CPU error reporting Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 22/58] target-sparc: Implement CPUClass::parse_features() for SPARCCPU Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 23/58] target-sparc: Defer SPARCCPU feature inference to QOM realize Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 24/58] cpu: Implement CPUClass::parse_features() for the rest of CPUs Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 25/58] cpu: Factor out cpu_generic_init() Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 26/58] target-m68k: Remove custom qemu_assert() function Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 27/58] cpu: Turn cpu_handle_mmu_fault() into a CPUClass hook Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 28/58] cpu: Move mem_io_{pc, vaddr} fields from CPU_COMMON to CPUState Andreas Färber
2014-03-13 14:54 ` Andreas Färber [this message]
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 30/58] cpu: Move icount_extra field " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 31/58] cpu: Move icount_decr " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 32/58] cpu: Move tb_jmp_cache " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 33/58] cpu: Move jmp_env " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 34/58] cpu: Move exception_index " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 35/58] cpu: Move opaque " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 36/58] cpu: Move watchpoint fields " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 37/58] cpu: Move breakpoints field " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 38/58] exec: Change tlb_fill() argument " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 39/58] cpu-exec: Change cpu_loop_exit() " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 40/58] translate-all: Change cpu_restore_state() " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 41/58] translate-all: Change cpu_restore_state_from_tb() " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 42/58] translate-all: Change tb_check_watchpoint() " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 43/58] translate-all: Change cpu_io_recompile() " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 44/58] translate-all: Change tb_gen_code() " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 45/58] translate-all: Change tb_flush_jmp_cache() " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 46/58] target-ppc: Use PowerPCCPU in PowerPCCPUClass::handle_mmu_fault hook Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 47/58] exec: Change cpu_watchpoint_{insert, remove{, _by_ref, _all}} argument Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 48/58] exec: Change cpu_breakpoint_{insert, " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 49/58] cpu-exec: Change cpu_resume_from_signal() argument to CPUState Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 50/58] cputlb: Change tlb_unprotect_code_phys() " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 51/58] exec: Change memory_region_section_get_iotlb() " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 52/58] exec: Change cpu_abort() " Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 53/58] target-cris: Replace DisasContext::env field with CRISCPU Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 54/58] target-microblaze: Replace DisasContext::env field with MicroBlazeCPU Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 55/58] cputlb: Change tlb_flush_page() argument to CPUState Andreas Färber
2014-03-13 14:54 ` [Qemu-devel] [PULL for-2.0-rc0 56/58] cputlb: Change tlb_flush() " Andreas Färber
2014-03-17 16:13 ` [Qemu-devel] [PATCH]: exec: fix cpu rework fallout (was cputlb: Change tlb_flush() argument to CPUState) Christian Borntraeger
2014-03-17 19:37 ` Andreas Färber
2014-03-13 14:55 ` [Qemu-devel] [PULL for-2.0-rc0 57/58] cputlb: Change tlb_set_page() argument to CPUState Andreas Färber
2014-03-13 14:55 ` [Qemu-devel] [PULL for-2.0-rc0 58/58] user-exec: Change exception_action() " Andreas Färber
2014-03-13 15:29 ` [Qemu-devel] [PULL for-2.0-rc0 00/58] QOM CPUState patch queue 2014-03-13 Christian Borntraeger
2014-03-13 17:10 ` Peter Maydell
2014-03-13 18:44 ` 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=1394722501-32326-30-git-send-email-afaerber@suse.de \
--to=afaerber@suse.de \
--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).