Skip to contentSkip to conversation

hw/intc/arm_gic: Fix crash on register access from monitor

RFC PATCH New Jayachandran C 1 participant 1 message Nov 22, 2016

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 hw/intc/arm_gic: Fix crash on register access from monitor

'current_cpu' is NULL when the GIC registers are accessed from the monitor command line, and this causes qemu to crash in call to gic_get_current_cpu().

Fix this by using the cpu returned by monitor_get_cpu_index() for current cpu if current_cpu is NULL.

---

This is marked RFC because I am not completely sure this is the right fix. The issue is: qemu aarch64 with gicv2 crashes when reading the GIC registers from monitor command line with 'xp'.

 hw/intc/arm_gic.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/intc/arm_gic.c +4 -0
index 521aac3..17ef4fd 100644
@@ -19,6 +19,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "monitor/monitor.h"
 #include "hw/sysbus.h"
 #include "gic_internal.h"
 #include "qapi/error.h"
@@ -49,6 +50,9 @@ static const uint8_t gic_id_gicv2[] = {
 
 static inline int gic_get_current_cpu(GICState *s)
 {
+    if (!current_cpu) {
+        return monitor_get_cpu_index();
+    }
     if (s->num_cpu > 1) {
         return current_cpu->cpu_index;
     }
Signature · 1 line
2.7.4