Skip to contentSkip to conversation

qemu-system-tricore: segfault when entering "x 0" on the monitor

PATCH In review Eduardo Otubo 2 participants 2 messages Jul 27, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu-system-tricore: segfault when entering "x 0" on the monitor

Starting Qemu with "qemu-system-tricore -nographic -M tricore_testboard -S" and entering "x 0" at the monitor prompt leads to Segmentation fault. This happens because tricore_cpu_get_phys_page_debug() is not implemented yet, this is a temporary workaround to avoid the crash do just abort the execution with exit(1).

---
 target/tricore/cpu.c | 10 ++++++++++
 target/tricore/cpu.h |  3 +++
 2 files changed, 13 insertions(+)
target/tricore/cpu.c +10 -0
index 08f50e2ba7..822c7f4092 100644
@@ -22,6 +22,15 @@
 #include "cpu.h"
 #include "qemu-common.h"
 #include "exec/exec-all.h"
+#include "qemu/error-report.h"
+
+hwaddr tricore_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
+                                         MemTxAttrs *attrs)
+{
+    error_report("function cpu_get_phys_page_attrs_debug not"
+                    "implemented, aborting");
+    exit(1);
+}
 
 static inline void set_feature(CPUTriCoreState *env, int feature)
 {
@@ -176,6 +185,7 @@ static void tricore_cpu_class_init(ObjectClass *c, void *data)
     cc->dump_state = tricore_cpu_dump_state;
     cc->set_pc = tricore_cpu_set_pc;
     cc->synchronize_from_tb = tricore_cpu_synchronize_from_tb;
+    cc->get_phys_page_attrs_debug = tricore_cpu_get_phys_page_attrs_debug;
 }
 
 static void cpu_register(const TriCoreCPUInfo *info)
target/tricore/cpu.h +3 -0
index a3493a123c..c374ed3213 100644
@@ -224,6 +224,9 @@ static inline TriCoreCPU *tricore_env_get_cpu(CPUTriCoreState *env)
 #define ENV_OFFSET offsetof(TriCoreCPU, env)
 
 hwaddr tricore_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
+hwaddr tricore_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
+                                         MemTxAttrs *attrs);
+
 void tricore_cpu_dump_state(CPUState *cpu, FILE *f,
                             fprintf_function cpu_fprintf, int flags);
 
Signature · 1 line
2.13.3
#1 lore raw

Hi Eduardo,

Meta comment: Please always put the maintainer(s) and qemu-devel on CC:

Quoted 18 lines · Eduardo Otubo

Starting Qemu with "qemu-system-tricore -nographic -M tricore_testboard -S" and entering "x 0" at the monitor prompt leads to Segmentation fault. This happens because tricore_cpu_get_phys_page_debug() is not implemented yet, this is a temporary workaround to avoid the crash do just abort the execution with exit(1).

---
 target/tricore/cpu.c | 10 ++++++++++
 target/tricore/cpu.h |  3 +++
 2 files changed, 13 insertions(+)
target/tricore/cpu.c +0 -0
index 08f50e2ba7..822c7f4092 100644
@@ -22,6 +22,15 @@
 #include "cpu.h"

target/tricore/cpu.c line 32

Quoted 10 lines
target/tricore/cpu.c +8 -0
 #include "qemu-common.h"
 #include "exec/exec-all.h"
+#include "qemu/error-report.h"
+
+hwaddr tricore_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
+                                         MemTxAttrs *attrs)
+{
+    error_report("function cpu_get_phys_page_attrs_debug not"
+                    "implemented, aborting");
+    exit(1);

Looking at the description in include/qom/cpu.h and the callers in exec.c, it seems like it is OK if these functions return -1 if the page could not be found. I think you should do that here, too, instead of exiting - it's always a little bit annoying for the users if QEMU exits unexpectedly, so we should try to avoid that if possible.

Quoted 17 lines
target/tricore/cpu.c +2 -0
+}
 
 static inline void set_feature(CPUTriCoreState *env, int feature)
 {
@@ -176,6 +185,7 @@ static void tricore_cpu_class_init(ObjectClass *c, void *data)
     cc->dump_state = tricore_cpu_dump_state;
     cc->set_pc = tricore_cpu_set_pc;
     cc->synchronize_from_tb = tricore_cpu_synchronize_from_tb;
+    cc->get_phys_page_attrs_debug = tricore_cpu_get_phys_page_attrs_debug;
 }
 
 static void cpu_register(const TriCoreCPUInfo *info)
target/tricore/cpu.h +0 -0
index a3493a123c..c374ed3213 100644

target/tricore/cpu.h static inline TriCoreCPU *tricore_env_get_cpu(CPUTriCoreState *env) · line 226

Quoted 3 lines
target/tricore/cpu.h +0 -0
@@ -224,6 +224,9 @@ static inline TriCoreCPU *tricore_env_get_cpu(CPUTriCoreState *env)
 #define ENV_OFFSET offsetof(TriCoreCPU, env)
 
 hwaddr tricore_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);

I think you could also remove that prototype above now - since there is no implementation for this.

target/tricore/cpu.h static inline TriCoreCPU *tricore_env_get_cpu(CPUTriCoreState *env) · line 232

Quoted 7 lines
target/tricore/cpu.h +3 -0
+hwaddr tricore_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
+                                         MemTxAttrs *attrs);
+
 void tricore_cpu_dump_state(CPUState *cpu, FILE *f,
                             fprintf_function cpu_fprintf, int flags);
 

Thomas