Skip to contentSkip to conversation

hmp: synchronize cpu state for lapic info

PATCH Superseded Dongli Zhang 1 participant 2 messages Jul 1, 2021

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hmp: synchronize cpu state for lapic info

While the default "info lapic" always synchronizes cpu state ...

mon_get_cpu()
-> mon_get_cpu_sync(mon, true)
-> cpu_synchronize_state(cpu)

      -> ioctl KVM_GET_LAPIC (taking KVM as example)

... the cpu state is not synchronized when the apic-id is available as argument.

The cpu state should be synchronized when apic-id is available. Otherwise the "info lapic <apic-id>" always returns stale data.

---
 target/i386/monitor.c | 3 +++
 1 file changed, 3 insertions(+)
target/i386/monitor.c +3 -0
index 119211f0b0..09b3b73955 100644
@@ -28,6 +28,7 @@
 #include "monitor/hmp-target.h"
 #include "monitor/hmp.h"
 #include "qapi/qmp/qdict.h"
+#include "sysemu/hw_accel.h"
 #include "sysemu/kvm.h"
 #include "sysemu/sev.h"
 #include "qapi/error.h"
@@ -656,7 +657,9 @@ void hmp_info_local_apic(Monitor *mon, const QDict *qdict)
 
     if (qdict_haskey(qdict, "apic-id")) {
         int id = qdict_get_try_int(qdict, "apic-id", 0);
+
         cs = cpu_by_arch_id(id);
+        cpu_synchronize_state(cs);
     } else {
         cs = mon_get_cpu(mon);
     }
Signature · 1 line
2.17.1
#1 lore raw

Please ignore this patch. I sent out the wrong version without memory check.

I will re-send again.

Thank you very much!

Dongli Zhang

Quoted 42 lines · Dongli Zhang

While the default "info lapic" always synchronizes cpu state ...

mon_get_cpu()
-> mon_get_cpu_sync(mon, true)
-> cpu_synchronize_state(cpu)

      -> ioctl KVM_GET_LAPIC (taking KVM as example)

... the cpu state is not synchronized when the apic-id is available as argument.

The cpu state should be synchronized when apic-id is available. Otherwise the "info lapic <apic-id>" always returns stale data.

---
 target/i386/monitor.c | 3 +++
 1 file changed, 3 insertions(+)
target/i386/monitor.c +3 -0
index 119211f0b0..09b3b73955 100644
@@ -28,6 +28,7 @@
 #include "monitor/hmp-target.h"
 #include "monitor/hmp.h"
 #include "qapi/qmp/qdict.h"
+#include "sysemu/hw_accel.h"
 #include "sysemu/kvm.h"
 #include "sysemu/sev.h"
 #include "qapi/error.h"
@@ -656,7 +657,9 @@ void hmp_info_local_apic(Monitor *mon, const QDict *qdict)
 
     if (qdict_haskey(qdict, "apic-id")) {
         int id = qdict_get_try_int(qdict, "apic-id", 0);
+
         cs = cpu_by_arch_id(id);
+        cpu_synchronize_state(cs);
     } else {
         cs = mon_get_cpu(mon);
     }