hax: fix "hflags" synchronization problem
authorSeokYeon Hwang <syeon.hwang@samsung.com>
Thu, 3 Nov 2016 13:07:55 +0000 (22:07 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Wed, 9 Nov 2016 04:56:39 +0000 (13:56 +0900)
CPUState synchronization should be done after MSR_EFER is updated.

Change-Id: I904564896d64ec9c31137cd5f2c47738ef2b79fd
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
hw/yagl/yagl_process.c
hw/yagl/yagl_process.h
hw/yagl/yagl_thread.c
target-i386/hax-all.c

index 16bff17..1e6844f 100644 (file)
@@ -62,7 +62,6 @@ struct yagl_process_state
                 &((CPUX86State *)current_cpu->env_ptr)->cr[0],
                 sizeof(ps->cr));
         ps->hflags = env->hflags;
-        ps->efer = env->efer;
     }
 #endif
 
index 0768f07..bbf4568 100644 (file)
@@ -58,7 +58,6 @@ struct yagl_process_state
 #if defined (CONFIG_KVM) || defined (CONFIG_HAX)
     target_ulong cr[5];
     uint32_t hflags;
-    uint64_t efer;
 #endif
 };
 
index 9481f48..b965e32 100644 (file)
@@ -62,13 +62,6 @@ static __inline void yagl_cpu_synchronize_state(struct yagl_process_state *ps)
                 &ps->cr[0],
                 sizeof(ps->cr));
         env->hflags = ps->hflags;
-
-        // FIXME: Somtimes "hflags" is not synced propery on HAX.
-        // It can be bug on synchronizing CPU state
-        env->efer = ps->efer;
-        if (env->efer & MSR_EFER_LMA) {
-            env->hflags |= HF_LMA_MASK;
-        }
     }
 }
 #else
index dfff527..10fec18 100644 (file)
@@ -1234,8 +1234,14 @@ static int hax_sync_vcpu_register(CPUArchState *env, int set)
         if (ret < 0)
             return -1;
     }
+
+    // it should be done after get_msrs, since it needs
+    // EFER synchonization
+#if 0
     if (!set)
         hax_setup_qemu_emulator(env);
+#endif
+
     return 0;
 }
 
@@ -1406,6 +1412,8 @@ static int hax_arch_get_registers(CPUArchState *env)
     if (ret < 0)
         return ret;
 
+    hax_setup_qemu_emulator(env);
+
     return 0;
 }