qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Bin Meng
Subject: [PATCH 2/2] monitor/misc: Set current_cpu for memory dump
Date: Tue, 22 Mar 2022 23:42:13 +0800

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 --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)
-- 
2.25.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]