Skip to contentSkip to conversation

hexagon: sys+guest regs in gdbstub

PATCH New Brian Cain 1 participant 3 messages Oct 5

lore
Share & tools
lore

Brian Cain

author
#0 lore raw

v2 cover hexagon: sys+guest regs in gdbstub

Add support for reading/writing system/guest registers in the gdbstub.

In v2:
- updated URLs in hexagon-sys.xml to use a tag.
- updated hexagon_greg_{read,write} to use the full range of guest-regs.

The guest regs above g3 have synthetic values for PMU-like features not-yet- implemented. But they accept writes so we can just treat them more conventionally for now and fill in the PMU behavior later. Guest sw reads from these registers will still generate output for LOG_UNIMP.

v1: https://lore.kernel.org/qemu-devel/[email protected]/

Brian Cain (2):
gdbstub/gdb-xml: Add hexagon sys regs
target/hexagon: gdbstub - Add sys reg support

 configs/targets/hexagon-softmmu.mak |   2 +-
 target/hexagon/cpu.h                |   1 +
 target/hexagon/internal.h           |   4 +
 target/hexagon/cpu.c                |  13 ++-
 target/hexagon/gdbstub.c            |  63 +++++++++++
 gdbstub/gdb-xml/hexagon-sys.xml     | 157 ++++++++++++++++++++++++++++
 6 files changed, 236 insertions(+), 4 deletions(-)
 create mode 100644 gdbstub/gdb-xml/hexagon-sys.xml
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v2 1/2 gdbstub/gdb-xml: Add hexagon sys regs

Add the hexagon-sys.xml gdb feature describing the system and guest registers.

---
 configs/targets/hexagon-softmmu.mak |   2 +-
 gdbstub/gdb-xml/hexagon-sys.xml     | 157 ++++++++++++++++++++++++++++
 2 files changed, 158 insertions(+), 1 deletion(-)
 create mode 100644 gdbstub/gdb-xml/hexagon-sys.xml
configs/targets/hexagon-softmmu.mak +1 -1
index 6cbdc64be56..1ba6420d205 100644
@@ -1,7 +1,7 @@
 # Default configuration for hexagon-softmmu
 
 TARGET_ARCH=hexagon
-TARGET_XML_FILES=hexagon-core.xml hexagon-hvx.xml
+TARGET_XML_FILES=hexagon-core.xml hexagon-hvx.xml hexagon-sys.xml
 TARGET_LONG_BITS=32
 TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
 TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
gdbstub/gdb-xml/hexagon-sys.xml new file +157 -0

157 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#2 lore raw

PATCH v2 2/2 target/hexagon: gdbstub - Add sys reg support

In reply to Brian Cain

Add support for the system and guest registers to the gdbstub.

---
 target/hexagon/cpu.h      |  1 +
 target/hexagon/internal.h |  4 +++
 target/hexagon/cpu.c      | 13 ++++++--
 target/hexagon/gdbstub.c  | 63 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 78 insertions(+), 3 deletions(-)
target/hexagon/cpu.h +1 -0
index df4c0182247..ea54af621d2 100644
@@ -241,6 +241,7 @@ G_NORETURN void hexagon_raise_exception_err(CPUHexagonState *env,
  */
 bool hexagon_thread_is_enabled(const CPUHexagonState *thread_env);
 uint32_t hexagon_greg_read(CPUHexagonState *env, uint32_t reg);
+void hexagon_greg_write(CPUHexagonState *env, uint32_t reg, uint32_t val);
 void hexagon_cpu_soft_reset(CPUHexagonState *env);
 #endif
 
target/hexagon/internal.h +4 -0
index 05d1129916e..3ed83904eb7 100644
@@ -24,6 +24,10 @@ int hexagon_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int hexagon_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 int hexagon_hvx_gdb_read_register(CPUState *env, GByteArray *mem_buf, int n);
 int hexagon_hvx_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n);
+#ifndef CONFIG_USER_ONLY
+int hexagon_sys_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n);
+int hexagon_sys_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n);
+#endif
 
 void hexagon_debug_vreg(CPUHexagonState *env, int regnum);
 void hexagon_debug_qreg(CPUHexagonState *env, int regnum);
target/hexagon/cpu.c +10 -3
index 1f7d8a8df70..ec4ced7e3c3 100644
@@ -494,6 +494,10 @@ static void hexagon_cpu_realize(DeviceState *dev, Error **errp)
                              gdb_find_static_feature("hexagon-hvx.xml"));
 
 #ifndef CONFIG_USER_ONLY
+    gdb_register_coprocessor(cs, hexagon_sys_gdb_read_register,
+                             hexagon_sys_gdb_write_register,
+                             gdb_find_static_feature("hexagon-sys.xml"));
+
     if (!HEXAGON_CPU(dev)->tlb) {
         error_setg(errp, "hexagon cpu requires 'tlb' link property to be set");
         return;
@@ -858,11 +862,14 @@ uint32_t hexagon_greg_read(CPUHexagonState *env, uint32_t reg)
     case HEX_GREG_GPCYCLEHI:
         return ssr_ce ? hexagon_get_sys_pcycle_count_high(env) : 0;
     default:
-        qemu_log_mask(LOG_UNIMP, "reading greg %" PRId32
-                " not yet supported.\n", reg);
-        return 0;
+        return env->greg[reg];
     }
 }
+
+void hexagon_greg_write(CPUHexagonState *env, uint32_t reg, uint32_t val)
+{
+    env->greg[reg] = val;
+}
 #endif
 
 static void hexagon_cpu_class_base_init(ObjectClass *c, const void *data)
target/hexagon/gdbstub.c +63 -0

78 lines not on this page · raw message

Signature · 1 line
2.34.1