Revert "hax: for testing..."
authorSeokYeon Hwang <syeon.hwang@samsung.com>
Fri, 7 Nov 2014 02:42:34 +0000 (11:42 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Fri, 7 Nov 2014 02:42:34 +0000 (11:42 +0900)
This reverts commit 57a0d655687a503ab76db51942543c9b8812a941.

cpu-exec.c
cpus.c
include/sysemu/hax.h
target-i386/hax-all.c
target-i386/translate.c

index c3d4b7b..64a6150 100644 (file)
@@ -214,17 +214,26 @@ static void cpu_handle_debug_exception(CPUArchState *env)
 
 volatile sig_atomic_t exit_request;
 
+/*
+ * QEMU emulate can happens because of MMIO or emulation mode, i.e. non-PG mode,
+ * when it's because of MMIO, the MMIO, the interrupt should not be emulated,
+ * because MMIO is emulated for only one instruction now and then back to
+ * HAX kernel
+ */
 static int need_handle_intr_request(CPUState *cpu)
 {
+#ifdef CONFIG_HAX
+    if (!hax_enabled() || hax_vcpu_emulation_mode(cpu))
+        return cpu->interrupt_request;
+    return 0;
+#else
     return cpu->interrupt_request;
+#endif
 }
 
 
 int cpu_exec(CPUArchState *env)
 {
-#ifdef CONFIG_HAX
-    assert(0);
-#else
     CPUState *cpu = ENV_GET_CPU(env);
 #if !(defined(CONFIG_USER_ONLY) && \
       (defined(TARGET_M68K) || defined(TARGET_PPC) || defined(TARGET_S390X)))
@@ -322,6 +331,11 @@ int cpu_exec(CPUArchState *env)
                 }
             }
 
+#ifdef CONFIG_HAX
+            if (hax_enabled() && !hax_vcpu_exec(cpu))
+                longjmp(cpu->jmp_env, 1);
+#endif
+
             next_tb = 0; /* force lookup of first TB */
             for(;;) {
                 interrupt_request = need_handle_intr_request(cpu);
@@ -366,6 +380,10 @@ int cpu_exec(CPUArchState *env)
                             cpu_svm_check_intercept_param(env, SVM_EXIT_SMI,
                                                           0);
                             cpu->interrupt_request &= ~CPU_INTERRUPT_SMI;
+#ifdef CONFIG_HAX
+                            if (hax_enabled())
+                                cpu->hax_vcpu->resync = 1;
+#endif
                             do_smm_enter(x86_cpu);
                             next_tb = 0;
                         } else if ((interrupt_request & CPU_INTERRUPT_NMI) &&
@@ -691,6 +709,10 @@ int cpu_exec(CPUArchState *env)
                     }
                 }
                 cpu->current_tb = NULL;
+#ifdef CONFIG_HAX
+                if (hax_enabled() && hax_stop_emulation(cpu))
+                    cpu_loop_exit(cpu);
+#endif
                 /* reset soft MMU for next block (it can currently
                    only be set by a memory fault) */
             } /* for(;;) */
diff --git a/cpus.c b/cpus.c
index 226dbc4..b28a92a 100644 (file)
--- a/cpus.c
+++ b/cpus.c
@@ -1182,6 +1182,10 @@ void resume_all_vcpus(void)
 
 static void qemu_tcg_init_vcpu(CPUState *cpu)
 {
+#ifdef CONFIG_HAX
+    if (hax_enabled())
+        hax_init_vcpu(cpu);
+#endif
     char thread_name[VCPU_THREAD_NAME_SIZE];
 
     tcg_cpu_address_space_init(cpu, cpu->as);
index a2c6da4..3b67838 100644 (file)
@@ -48,10 +48,8 @@ void hax_cpu_synchronize_post_init(CPUState *cpu);
 int hax_populate_ram(uint64_t va, uint32_t size);
 int hax_set_phys_mem(MemoryRegionSection *section);
 int hax_vcpu_emulation_mode(CPUState *cpu);
-/*
 int hax_stop_emulation(CPUState *cpu);
 int hax_stop_translate(CPUState *cpu);
-*/
 int hax_vcpu_destroy(CPUState *cpu);
 void hax_raise_event(CPUState *cpu);
 void hax_reset_vcpu_state(void *opaque);
index d0d4afc..7b4bd46 100644 (file)
@@ -70,15 +70,12 @@ int hax_vcpu_emulation_mode(CPUState *cpu)
 
     if (hax_enabled())
         return 0;
-    else {
-        assert(0);
+    else
         return 1;
-    }
 }
 
 static int hax_prepare_emulation(CPUArchState *env)
 {
-    assert(0);
     /* Flush all emulation states */
     tlb_flush(ENV_GET_CPU(env), 1);
     tb_flush(env);
@@ -91,7 +88,6 @@ static int hax_prepare_emulation(CPUArchState *env)
  * Check whether to break the translation block loop
  * break tbloop after one MMIO emulation, or after finish emulation mode
  */
-#if 0
 static int hax_stop_tbloop(CPUArchState *env)
 {
     CPUState *cpu = ENV_GET_CPU(env);
@@ -147,7 +143,6 @@ int hax_stop_translate(CPUState *cpu)
 
     return 0;
 }
-#endif
 
 int valid_hax_tunnel_size(uint16_t size)
 {
index 5868291..7016639 100644 (file)
@@ -7993,15 +7993,12 @@ static inline void gen_intermediate_code_internal(X86CPU *cpu,
         pc_ptr = disas_insn(env, dc, pc_ptr);
         num_insns++;
 #ifdef CONFIG_HAX
-        assert(1);
-/*
         if (hax_enabled() && hax_stop_translate(cs))
         {
             gen_jmp_im(pc_ptr - dc->cs_base);
             gen_eob(dc);
             break;
         }
-*/
 #endif
         /* stop translation if indicated */
         if (dc->is_jmp)