Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kt12b-0000S4-Vn for qemu-devel@nongnu.org; Thu, 23 Oct 2008 10:19:58 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kt12b-0000RB-0d for qemu-devel@nongnu.org; Thu, 23 Oct 2008 10:19:57 -0400 Received: from [199.232.76.173] (port=40776 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kt12a-0000Qn-MA for qemu-devel@nongnu.org; Thu, 23 Oct 2008 10:19:56 -0400 Received: from mx2.redhat.com ([66.187.237.31]:55924) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Kt12a-0001ON-Eo for qemu-devel@nongnu.org; Thu, 23 Oct 2008 10:19:56 -0400 Date: Thu, 23 Oct 2008 12:21:15 -0200 From: Glauber Costa Message-ID: <20081023142115.GE18872@poweredge.glommer> References: <1224771556-11146-1-git-send-email-glommer@redhat.com> <1224771556-11146-5-git-send-email-glommer@redhat.com> <49008242.4080307@us.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <49008242.4080307@us.ibm.com> Subject: [Qemu-devel] Re: [PATCH 04/32] move kqemu_cpu_exec to kqemu.c Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: jan.kiszka@siemens.com, jes@sgi.com, qemu-devel@nongnu.org, avi@qumranet.com, dmitry.baryshkov@siemens.com On Thu, Oct 23, 2008 at 08:55:14AM -0500, Anthony Liguori wrote: > Glauber Costa wrote: >> Only pieces of code that are frame-safe can be moved. >> compute_all() is an example of a non-frame-safe calling. >> So it has to be done prior to calling kqemu_cpu_exec(). >> >> Signed-off-by: Glauber Costa >> --- >> cpu-exec.c | 33 +++++++++++++-------------------- >> kqemu.c | 18 +++++++++++++++++- >> 2 files changed, 30 insertions(+), 21 deletions(-) >> >> diff --git a/cpu-exec.c b/cpu-exec.c >> index 6d4dcdd..f06df26 100644 >> --- a/cpu-exec.c >> +++ b/cpu-exec.c >> @@ -336,27 +336,20 @@ int cpu_exec(CPUState *env1) >> env->exception_index = -1; >> } >> #ifdef USE_KQEMU >> - if (kqemu_is_ok(env) && env->interrupt_request == 0) { >> - int ret; >> - env->eflags = env->eflags | cc_table[CC_OP].compute_all() | (DF & DF_MASK); >> - ret = kqemu_cpu_exec(env); >> - /* put eflags in CPU temporary format */ >> - CC_SRC = env->eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C); >> - DF = 1 - (2 * ((env->eflags >> 10) & 1)); >> - CC_OP = CC_OP_EFLAGS; >> - env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C); >> - if (ret == 1) { >> - /* exception */ >> - longjmp(env->jmp_env, 1); >> - } else if (ret == 2) { >> - /* softmmu execution needed */ >> + env->eflags = env->eflags | cc_table[CC_OP].compute_all() | (DF & DF_MASK); >> > > Can't do this unconditionally since you're now recomputing all condition > flags even when kqemu is not in use. So unfortunately I'm not sure the > code can be cleaned up much more if compute_all() must stay in cpu_exec. > > Regards, We can add an auxiliary function into the accel structure in which the accelerator indicates whether or not it needs the condition flags to be recomputed. But, in general, I'm fine with not touching it, since kvm io thread's implementation does not rely on this code path. Don't know about xen or any other interested parties, tough. > > Anthony Liguori > >> + ret = kqemu_cpu_exec(env); >> + env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C); >> + if (ret == 1) { >> + /* exception */ >> + longjmp(env->jmp_env, 1); >> + } else if (ret == 2) { >> + /* softmmu execution needed */ >> + } else { >> + if (env->interrupt_request != 0) { >> + /* hardware interrupt will be executed just after */ >> } else { >> - if (env->interrupt_request != 0) { >> - /* hardware interrupt will be executed just after */ >> - } else { >> - /* otherwise, we restart */ >> - longjmp(env->jmp_env, 1); >> - } >> + /* otherwise, we restart */ >> + longjmp(env->jmp_env, 1); >> } >> } >> #endif >> diff --git a/kqemu.c b/kqemu.c >> index 4783aa2..39938e0 100644 >> --- a/kqemu.c >> +++ b/kqemu.c >> @@ -30,6 +30,7 @@ >> #ifdef HOST_SOLARIS >> #include >> #endif >> +#include "exec.h" >> #include >> #include >> #include >> @@ -689,7 +690,7 @@ static inline void kqemu_save_seg(SegmentCache *sc, >> sc->base = ksc->base; >> } >> >> -int kqemu_cpu_exec(CPUState *env) >> +int kqemu_do_cpu_exec(CPUState *env) >> { >> struct kqemu_cpu_state kcpu_state, *kenv = &kcpu_state; >> int ret, cpl, i; >> @@ -939,6 +940,21 @@ int kqemu_cpu_exec(CPUState *env) >> return 0; >> } >> >> +int kqemu_cpu_exec(CPUState *env) >> +{ >> + >> + int ret = 2; >> + if (kqemu_is_ok(env) && env->interrupt_request == 0) { >> + ret = kqemu_do_cpu_exec(env); >> + /* put eflags in CPU temporary format */ >> + CC_SRC = env->eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C); >> + DF = 1 - (2 * ((env->eflags >> 10) & 1)); >> + CC_OP = CC_OP_EFLAGS; >> + } >> + return ret; >> +} >> + >> + >> void kqemu_cpu_interrupt(CPUState *env) >> { >> #if defined(_WIN32) >> >