qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH 04/32] move kqemu_cpu_exec to kqemu.c


From: Glauber Costa
Subject: [Qemu-devel] Re: [PATCH 04/32] move kqemu_cpu_exec to kqemu.c
Date: Thu, 23 Oct 2008 12:21:15 -0200
User-agent: Mutt/1.5.18 (2008-05-17)

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 <address@hidden>
>> ---
>>  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 <sys/ioccom.h>
>>  #endif
>> +#include "exec.h"
>>  #include <stdlib.h>
>>  #include <stdio.h>
>>  #include <stdarg.h>
>> @@ -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)
>>   
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]