Skip to contentSkip to conversation

Bug 1855617 Save registers to haxm when vcpu_dirty flag is set and clear it. vcpu_dirty flag was set in initialization code and not cleared, so read attempts were skipped and snapshots didn't contain correct register values.

PATCH New Alexey Romko 1 participant 1 message Jun 22, 2020 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 Bug 1855617 Save registers to haxm when vcpu_dirty flag is set and clear it. vcpu_dirty flag was set in initialization code and not cleared, so read attempts were skipped and snapshots didn't contain correct register values.

Bug 1855617 Save registers to haxm when vcpu_dirty flag is
set and clear it. vcpu_dirty flag was set in initialization code and not cleared, so read attempts were skipped and snapshots didn't contain correct register values.

---
 target/i386/hax-all.c | 16 +++++++++++-----

 1 file changed, 11 insertions(+), 5 deletions(-)
target/i386/hax-all.c +0 -0
index f9c83fff25..8aea72db07 100644
@@ -504,16 +504,15 @@ static int hax_vcpu_hax_exec(CPUArchState *env)

     if (cpu->interrupt_request & CPU_INTERRUPT_INIT) { DPRINTF("\nhax_vcpu_hax_exec: handling INIT for %d\n",
                 cpu->cpu_index);
+        hax_cpu_synchronize_state(cpu);
         do_cpu_init(x86_cpu);
-        hax_vcpu_sync_state(env, 1);
     }

     if (cpu->interrupt_request & CPU_INTERRUPT_SIPI) { DPRINTF("hax_vcpu_hax_exec: handling SIPI for %d\n",
                 cpu->cpu_index);
-        hax_vcpu_sync_state(env, 0);
+        hax_cpu_synchronize_state(cpu);
         do_cpu_sipi(x86_cpu);
-        hax_vcpu_sync_state(env, 1);
     }

     if (cpu->halted) {
@@ -534,6 +533,11 @@ static int hax_vcpu_hax_exec(CPUArchState *env)
             break;
         }

+        if (cpu->vcpu_dirty) {
+            hax_vcpu_sync_state(env, 1);
+            cpu->vcpu_dirty = false;
+        }
+
         hax_vcpu_interrupt(env);

         qemu_mutex_unlock_iothread();
@@ -621,8 +625,10 @@ static void do_hax_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg) {
     CPUArchState *env = cpu->env_ptr;

-    hax_arch_get_registers(env);
-    cpu->vcpu_dirty = true;
+    if (!cpu->vcpu_dirty) {
+        hax_arch_get_registers(env);
+        cpu->vcpu_dirty = true;
+    }
 }

 void hax_cpu_synchronize_state(CPUState *cpu)
--
2.15.0.windows.1