diff mbox series

[2/2] monitor/misc: Set current_cpu for memory dump

Message ID 20220322154213.86475-2-bmeng.cn@gmail.com
State New
Headers show
Series [1/2] gdbstub: Set current_cpu for memory read write | expand

Commit Message

Bin Meng March 22, 2022, 3:42 p.m. UTC
When accessing the per-CPU register bank of some devices (e.g.: GIC)
from the monitor context, a segfault occurs. This is due to current_cpu
is not set, as the context is not a guest CPU.

Let's set current_cpu before doing the acutal memory dump.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---

 monitor/misc.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/monitor/misc.c b/monitor/misc.c
index b1839cb8ee..228f017b71 100644
--- a/monitor/misc.c
+++ b/monitor/misc.c
@@ -558,6 +558,7 @@  static void memory_dump(Monitor *mon, int count, int format, int wsize,
         break;
     }
 
+    current_cpu = cs;
     while (len > 0) {
         if (is_physical) {
             monitor_printf(mon, TARGET_FMT_plx ":", addr);
@@ -622,6 +623,7 @@  static void memory_dump(Monitor *mon, int count, int format, int wsize,
         addr += l;
         len -= l;
     }
+    current_cpu = NULL;
 }
 
 static void hmp_memory_dump(Monitor *mon, const QDict *qdict)