}
#if defined(TARGET_I386)
- if (!kvm_enabled()) {
- /* 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);
- }
+ /* 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);
#elif defined(TARGET_SPARC)
#elif defined(TARGET_M68K)
env->cc_op = CC_OP_FLAGS;
if (setjmp(env->jmp_env) == 0) {
#if defined(__sparc__) && !defined(CONFIG_SOLARIS)
#undef env
- env = cpu_single_env;
+ env = cpu_single_env;
#define env cpu_single_env
#endif
/* if an exception is pending, we execute it here */
}
}
- if (kvm_enabled()) {
- kvm_cpu_exec(env);
- longjmp(env->jmp_env, 1);
- }
-
next_tb = 0; /* force lookup of first TB */
for(;;) {
interrupt_request = env->interrupt_request;
qemu_wait_io_event_common(env);
}
-static int qemu_cpu_exec(CPUState *env);
-
static void *qemu_kvm_cpu_thread_fn(void *arg)
{
CPUState *env = arg;
while (1) {
if (cpu_can_run(env)) {
- r = qemu_cpu_exec(env);
+ r = kvm_cpu_exec(env);
if (r == EXCP_DEBUG) {
cpu_handle_debug_exception(env);
}
#endif
-static int qemu_cpu_exec(CPUState *env)
+static int tcg_cpu_exec(CPUState *env)
{
int ret;
#ifdef CONFIG_PROFILER
break;
}
if (cpu_can_run(env)) {
- r = qemu_cpu_exec(env);
if (kvm_enabled()) {
+ r = kvm_cpu_exec(env);
qemu_kvm_eat_signals(env);
+ } else {
+ r = tcg_cpu_exec(env);
}
if (r == EXCP_DEBUG) {
cpu_handle_debug_exception(env);
if (kvm_arch_process_irqchip_events(env)) {
env->exit_request = 0;
- env->exception_index = EXCP_HLT;
- return 0;
+ return EXCP_HLT;
}
+ cpu_single_env = env;
+
do {
if (env->kvm_vcpu_dirty) {
kvm_arch_put_registers(env, KVM_PUT_RUNTIME_STATE);
kvm_flush_coalesced_mmio_buffer();
if (ret == -EINTR || ret == -EAGAIN) {
- cpu_exit(env);
DPRINTF("io window exit\n");
ret = 0;
break;
DPRINTF("kvm_exit_debug\n");
#ifdef KVM_CAP_SET_GUEST_DEBUG
if (kvm_arch_debug(&run->debug.arch)) {
- env->exception_index = EXCP_DEBUG;
- return 0;
+ ret = EXCP_DEBUG;
+ goto out;
}
/* re-enter, this exception was guest-internal */
ret = 1;
if (ret < 0) {
cpu_dump_state(env, stderr, fprintf, CPU_DUMP_CODE);
vm_stop(VMSTOP_PANIC);
- env->exit_request = 1;
- }
- if (env->exit_request) {
- env->exit_request = 0;
- env->exception_index = EXCP_INTERRUPT;
}
+ ret = EXCP_INTERRUPT;
+out:
+ env->exit_request = 0;
+ cpu_single_env = NULL;
return ret;
}
int kvm_arch_process_irqchip_events(CPUState *env)
{
+ if (env->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI)) {
+ env->halted = 0;
+ }
if (env->interrupt_request & CPU_INTERRUPT_INIT) {
kvm_cpu_synchronize_state(env);
do_cpu_init(env);
- env->exception_index = EXCP_HALTED;
}
-
if (env->interrupt_request & CPU_INTERRUPT_SIPI) {
kvm_cpu_synchronize_state(env);
do_cpu_sipi(env);
(env->eflags & IF_MASK)) &&
!(env->interrupt_request & CPU_INTERRUPT_NMI)) {
env->halted = 1;
- env->exception_index = EXCP_HLT;
return 0;
}