YaGL: Modified the process state for the 64bit guest
authorSeokYeon Hwang <syeon.hwang@samsung.com>
Tue, 3 Nov 2015 07:04:10 +0000 (16:04 +0900)
committerjinhyung.jo <jinhyung.jo@samsung.com>
Wed, 4 Nov 2015 09:11:38 +0000 (18:11 +0900)
If the guest image is 64bit, 'yagl_mem_get' function fails.
So the host yagl can not access the guest memory.
The failure occurs in the 'cpu_get_phys_page_debug'.
(<qemu>/target-i386.helper.c:820 if (env->hflags & HF_LMA_MASK))
Becuase the yagl process state does not have the flag like above,
it does not proceed as a normal routine in Ubuntu 64bit.
Therefore add the 'hflags' to the yagl process state.

Change-Id: Ia1dfa8d7ca51211893149612f400365199fe16b5
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
Signed-off-by: Jinhyung Jo <jinhyung.jo@samsung.com>
hw/yagl/yagl_mem.c
hw/yagl/yagl_process.c
hw/yagl/yagl_process.h
hw/yagl/yagl_thread.c

index d6a4c737813e4d5d34d9e234ca6edb814549c17f..6ca796630510896cbb04852f65c99727e3087cc2 100644 (file)
@@ -37,12 +37,12 @@ bool yagl_mem_put(target_ulong va, const void* data, uint32_t len)
 {
     int ret;
 
-    YAGL_LOG_FUNC_ENTER(yagl_mem_put, "va = 0x%X, len = %u", (uint32_t)va, len);
+    YAGL_LOG_FUNC_ENTER(yagl_mem_put, "va = 0x" TARGET_FMT_lx ", len = %u", va, len);
 
     ret = cpu_memory_rw_debug(current_cpu, va, (void*)data, len, 1);
 
     if (ret == -1) {
-        YAGL_LOG_WARN("page fault at 0x%X", (uint32_t)va, len);
+        YAGL_LOG_WARN("page fault at 0x"TARGET_FMT_lx", len= %u", va, len);
     }
 
     YAGL_LOG_FUNC_EXIT(NULL);
@@ -54,12 +54,12 @@ bool yagl_mem_get(target_ulong va, uint32_t len, void* data)
 {
     int ret;
 
-    YAGL_LOG_FUNC_ENTER(yagl_mem_get, "va = 0x%X, len = %u", (uint32_t)va, len);
+    YAGL_LOG_FUNC_ENTER(yagl_mem_get, "va = 0x" TARGET_FMT_lx ", len = %u", va, len);
 
     ret = cpu_memory_rw_debug(current_cpu, va, data, len, 0);
 
     if (ret == -1) {
-        YAGL_LOG_WARN("page fault at 0x%X", (uint32_t)va, len);
+        YAGL_LOG_WARN("page fault at 0x" TARGET_FMT_lx ", len= %u", va, len);
     }
 
     YAGL_LOG_FUNC_EXIT(NULL);
index 9ff1f4b2e4fb33538fa4af26f5a1c1241ef90865..eb740315c2f8b0e2e9d46f5d2de5292e0a2c9af1 100644 (file)
@@ -48,8 +48,13 @@ struct yagl_process_state
     QLIST_INIT(&ps->threads);
 
 #ifdef CONFIG_KVM
-    cpu_synchronize_state(current_cpu);
-    memcpy(&ps->cr[0], &((CPUX86State*)current_cpu->env_ptr)->cr[0], sizeof(ps->cr));
+    if (kvm_enabled()) {
+        cpu_synchronize_state(current_cpu);
+        memcpy(&ps->cr[0],
+               &((CPUX86State *)current_cpu->env_ptr)->cr[0],
+               sizeof(ps->cr));
+        ps->hflags = ((CPUX86State *)current_cpu->env_ptr)->hflags;
+    }
 #endif
 
     return ps;
index 6dc996a4f5cf9afeb945a8347a8d0145829366fd..4cbae5212cdad5593e95ef04da1d392dfac05bc8 100644 (file)
@@ -57,6 +57,7 @@ struct yagl_process_state
 
 #ifdef CONFIG_KVM
     target_ulong cr[5];
+    uint32_t hflags;
 #endif
 };
 
index 82a7b81f00483249c6431379c2f53cdac731d4ff..82a8d808ddcd49953d60f46527ecd4c2c2aa0ce2 100644 (file)
@@ -57,7 +57,10 @@ struct yagl_thread_work_item
 static __inline void yagl_cpu_synchronize_state(struct yagl_process_state *ps)
 {
     if (kvm_enabled()) {
-        memcpy(&((CPUX86State*)current_cpu->env_ptr)->cr[0], &ps->cr[0], sizeof(ps->cr));
+        memcpy(&((CPUX86State *)current_cpu->env_ptr)->cr[0],
+               &ps->cr[0],
+               sizeof(ps->cr));
+        ((CPUX86State *)current_cpu->env_ptr)->hflags = ps->hflags;
     }
 }
 #else