From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KszE0-0007Jb-Fx for qemu-devel@nongnu.org; Thu, 23 Oct 2008 08:23:36 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KszDx-0007HM-S2 for qemu-devel@nongnu.org; Thu, 23 Oct 2008 08:23:34 -0400 Received: from [199.232.76.173] (port=51715 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KszDx-0007HI-Fi for qemu-devel@nongnu.org; Thu, 23 Oct 2008 08:23:33 -0400 Received: from mx20.gnu.org ([199.232.41.8]:41076) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KszDv-0006IQ-LH for qemu-devel@nongnu.org; Thu, 23 Oct 2008 08:23:33 -0400 Received: from mx2.redhat.com ([66.187.237.31]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KszDh-0006Wq-0D for qemu-devel@nongnu.org; Thu, 23 Oct 2008 08:23:17 -0400 From: Glauber Costa Date: Thu, 23 Oct 2008 12:19:04 -0200 Message-Id: <1224771556-11146-21-git-send-email-glommer@redhat.com> In-Reply-To: <1224771556-11146-1-git-send-email-glommer@redhat.com> References: <1224771556-11146-1-git-send-email-glommer@redhat.com> Subject: [Qemu-devel] [PATCH 20/32] accel_trace_io Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, jan.kiszka@siemens.com, jes@sgi.com, avi@qumranet.com, Glauber Costa , dmitry.baryshkov@siemens.com From: Glauber Costa kqemu keeps trace of the last io done. Do it through an accel_wrapper. Signed-off-by: Glauber Costa --- accel.c | 2 ++ accel.h | 13 ++++++++++++- cpu-exec.c | 9 ++------- kqemu.c | 18 ++++++++++++++++++ softmmu_template.h | 10 ++++------ vl.c | 30 ++++++------------------------ 6 files changed, 44 insertions(+), 38 deletions(-) diff --git a/accel.c b/accel.c index bf1194d..0890039 100644 --- a/accel.c +++ b/accel.c @@ -32,5 +32,7 @@ QEMUAccel noaccel = { .get_real_ticks = cpu_get_ticks, #endif .register_physical_memory = accel_nop, + .trace_io = accel_nop, + .break_loop = accel_nop, }; diff --git a/accel.h b/accel.h index dbb6372..b37175b 100644 --- a/accel.h +++ b/accel.h @@ -19,7 +19,8 @@ typedef struct QEMUAccel { #endif void (*register_physical_memory)(uint64_t start_addr, ram_addr_t size, ram_addr_t phys_offset); - + void (*trace_io)(CPUState *env); + int (*break_loop)(CPUState *env); } QEMUAccel; typedef struct QEMUCont { @@ -142,4 +143,14 @@ static inline void accel_register_phys_mem(uint64_t start_addr, { current_accel->register_physical_memory(start_addr, size, phys_offset); } + +static inline void accel_trace_io(CPUState *env) +{ + current_accel->trace_io(env); +} + +static inline int accel_break_loop(CPUState *env) +{ + return current_accel->break_loop(env); +} #endif diff --git a/cpu-exec.c b/cpu-exec.c index 88b7d6f..18908d5 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -36,6 +36,7 @@ #include #include #endif +#include "accel.h" #if defined(__sparc__) && !defined(HOST_SOLARIS) // Work around ugly bugs in glibc that mangle global register contents @@ -646,13 +647,7 @@ int cpu_exec(CPUState *env1) } /* reset soft MMU for next block (it can currently only be set by a memory fault) */ -#if defined(USE_KQEMU) -#define MIN_CYCLE_BEFORE_SWITCH (100 * 1000) - if (kqemu_is_ok(env) && - (cpu_get_time_fast() - env->last_io_time) >= MIN_CYCLE_BEFORE_SWITCH) { - cpu_loop_exit(); - } -#endif + accel_break_loop(env); } /* for(;;) */ } else { env_to_regs(); diff --git a/kqemu.c b/kqemu.c index f4d905a..d38d0e3 100644 --- a/kqemu.c +++ b/kqemu.c @@ -1107,6 +1107,22 @@ static int kqemu_profile(CPUState *env, char *buf) return len; } +static void kqemu_trace_io(CPUState *env) +{ + if (env) + env->last_io_time = cpu_get_time_fast(); +} + +static int kqemu_break_loop(CPUState *env) +{ +#define MIN_CYCLE_BEFORE_SWITCH (100 * 1000) + if (kqemu_is_ok(env) && + (cpu_get_time_fast() - env->last_io_time) >= MIN_CYCLE_BEFORE_SWITCH) { + return 1; + } + return 0; +} + QEMUAccel kqemu_accel = { .name = "KQEMU", .cpu_interrupt = kqemu_cpu_interrupt, @@ -1125,6 +1141,8 @@ QEMUAccel kqemu_accel = { .get_real_ticks = cpu_get_real_ticks, #endif .register_physical_memory = kqemu_set_phys_mem, + .trace_io = kqemu_trace_io, + .break_loop = kqemu_break_loop, }; #endif diff --git a/softmmu_template.h b/softmmu_template.h index 98dd378..4945352 100644 --- a/softmmu_template.h +++ b/softmmu_template.h @@ -47,6 +47,8 @@ #define ADDR_READ addr_read #endif +#include "accel.h" + static DATA_TYPE glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(target_ulong addr, int mmu_idx, void *retaddr); @@ -75,9 +77,7 @@ static inline DATA_TYPE glue(io_read, SUFFIX)(target_phys_addr_t physaddr, res |= (uint64_t)io_mem_read[index][2](io_mem_opaque[index], physaddr + 4) << 32; #endif #endif /* SHIFT > 2 */ -#ifdef USE_KQEMU - env->last_io_time = cpu_get_time_fast(); -#endif + accel_trace_io(env); return res; } @@ -220,9 +220,7 @@ static inline void glue(io_write, SUFFIX)(target_phys_addr_t physaddr, io_mem_write[index][2](io_mem_opaque[index], physaddr + 4, val >> 32); #endif #endif /* SHIFT > 2 */ -#ifdef USE_KQEMU - env->last_io_time = cpu_get_time_fast(); -#endif + accel_trace_io(env); } void REGPARM glue(glue(__st, SUFFIX), MMUSUFFIX)(target_ulong addr, diff --git a/vl.c b/vl.c index 964205d..e64becb 100644 --- a/vl.c +++ b/vl.c @@ -420,10 +420,7 @@ void cpu_outb(CPUState *env, int addr, int val) fprintf(logfile, "outb: %04x %02x\n", addr, val); #endif ioport_write(0, addr, val); -#ifdef USE_KQEMU - if (env) - env->last_io_time = cpu_get_time_fast(); -#endif + accel_trace_io(env); } void cpu_outw(CPUState *env, int addr, int val) @@ -433,10 +430,7 @@ void cpu_outw(CPUState *env, int addr, int val) fprintf(logfile, "outw: %04x %04x\n", addr, val); #endif ioport_write(1, addr, val); -#ifdef USE_KQEMU - if (env) - env->last_io_time = cpu_get_time_fast(); -#endif + accel_trace_io(env); } void cpu_outl(CPUState *env, int addr, int val) @@ -446,10 +440,7 @@ void cpu_outl(CPUState *env, int addr, int val) fprintf(logfile, "outl: %04x %08x\n", addr, val); #endif ioport_write(2, addr, val); -#ifdef USE_KQEMU - if (env) - env->last_io_time = cpu_get_time_fast(); -#endif + accel_trace_io(env); } int cpu_inb(CPUState *env, int addr) @@ -460,10 +451,7 @@ int cpu_inb(CPUState *env, int addr) if (loglevel & CPU_LOG_IOPORT) fprintf(logfile, "inb : %04x %02x\n", addr, val); #endif -#ifdef USE_KQEMU - if (env) - env->last_io_time = cpu_get_time_fast(); -#endif + accel_trace_io(env); return val; } @@ -475,10 +463,7 @@ int cpu_inw(CPUState *env, int addr) if (loglevel & CPU_LOG_IOPORT) fprintf(logfile, "inw : %04x %04x\n", addr, val); #endif -#ifdef USE_KQEMU - if (env) - env->last_io_time = cpu_get_time_fast(); -#endif + accel_trace_io(env); return val; } @@ -490,10 +475,7 @@ int cpu_inl(CPUState *env, int addr) if (loglevel & CPU_LOG_IOPORT) fprintf(logfile, "inl : %04x %08x\n", addr, val); #endif -#ifdef USE_KQEMU - if (env) - env->last_io_time = cpu_get_time_fast(); -#endif + accel_trace_io(env); return val; } -- 1.5.5.1