Skip to contentSkip to conversation

riscv, gdbstub.c: fix reg_width in ricsv_gen_dynamic_vector_feature()

PATCH Superseded Daniel Henrique Barboza 3 participants 4 messages May 16, 2024 – May 17, 2024 RISC-V

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover riscv, gdbstub.c: fix reg_width in ricsv_gen_dynamic_vector_feature()

Hi,

Commit 33a24910ae ("target/riscv: Use GDBFeature for dynamic XML") changed 'reg_width' for vector regs, a change that I believe to be unintended, and we're unable to print vector regs in GDB ATM.

The following is a gdb output of a simple program running with qemu-riscv64 when trying to print the value of 'v1' after a 'vle' insns:

(gdb) p $v1
$1 = {q = 0x0, l = 0x0, w = 0x0, s = {57920}, b = {64, 226}} (gdb)

After this patch:

(gdb) p $v1
$1 = {q = {9781192033638379298842687819604544}, l = {530239482618432, 530239482618432}, w = {123456, 123456,

    123456, 123456}, s = {57920, 1, 57920, 1, 57920, 1, 57920, 1}, b = {64, 226, 1, 0, 64, 226, 1, 0, 64, 226, 1, 
    0, 64, 226, 1, 0}}

(gdb)

Michael, this is a good pick for qemu-stable.

Daniel Henrique Barboza (1):
riscv, gdbstub.c: fix reg_width in ricsv_gen_dynamic_vector_feature()

 target/riscv/gdbstub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
2.44.0
#1 lore raw

PATCH 1/1 riscv, gdbstub.c: fix reg_width in ricsv_gen_dynamic_vector_feature()

Commit 33a24910ae changed 'reg_width' to use 'vlenb', i.e. vector length in bytes, when in this context we want 'reg_width' as the length in bits.

Fix 'reg_width' back to the value in bits like 7cb59921c05a ("target/riscv/gdbstub.c: use 'vlenb' instead of shifting 'vlen'") set beforehand.

Cc Akihiko Odaki <[email protected]>
Cc Alex Bennée <[email protected]>
Fixes 33a24910ae ("target/riscv: Use GDBFeature for dynamic XML")
---
 target/riscv/gdbstub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/gdbstub.c +1 -1
index d0cc5762c2..358158c42a 100644
@@ -288,7 +288,7 @@ static GDBFeature *riscv_gen_dynamic_csr_feature(CPUState *cs, int base_reg)
 static GDBFeature *ricsv_gen_dynamic_vector_feature(CPUState *cs, int base_reg)
 {
     RISCVCPU *cpu = RISCV_CPU(cs);
-    int reg_width = cpu->cfg.vlenb;
+    int reg_width = cpu->cfg.vlenb << 3;
     GDBFeatureBuilder builder;
     int i;
 
Signature · 1 line
2.44.0
Reviewed-by on v1 1/1
#2 lore raw
Quoted 8 lines · Daniel Henrique Barboza

Commit 33a24910ae changed 'reg_width' to use 'vlenb', i.e. vector length in bytes, when in this context we want 'reg_width' as the length in bits.

Fix 'reg_width' back to the value in bits like 7cb59921c05a ("target/riscv/gdbstub.c: use 'vlenb' instead of shifting 'vlen'") set beforehand.

Quoted 5 lines
Cc Akihiko Odaki <[email protected]>
Cc Alex Bennée <[email protected]>
Fixes 33a24910ae ("target/riscv: Use GDBFeature for dynamic XML")

Zhiwei

Quoted 17 lines
---
  target/riscv/gdbstub.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/gdbstub.c +1 -1
index d0cc5762c2..358158c42a 100644
@@ -288,7 +288,7 @@ static GDBFeature *riscv_gen_dynamic_csr_feature(CPUState *cs, int base_reg)
  static GDBFeature *ricsv_gen_dynamic_vector_feature(CPUState *cs, int base_reg)
  {
      RISCVCPU *cpu = RISCV_CPU(cs);
-    int reg_width = cpu->cfg.vlenb;
+    int reg_width = cpu->cfg.vlenb << 3;
      GDBFeatureBuilder builder;
      int i;
 
Acked-by on v1 1/1
#3 lore raw
In reply to Daniel Henrique Barboza
Quoted 22 lines · Daniel Henrique Barboza

Commit 33a24910ae changed 'reg_width' to use 'vlenb', i.e. vector length in bytes, when in this context we want 'reg_width' as the length in bits.

Fix 'reg_width' back to the value in bits like 7cb59921c05a ("target/riscv/gdbstub.c: use 'vlenb' instead of shifting 'vlen'") set beforehand.

Cc Akihiko Odaki <[email protected]>
Cc Alex Bennée <[email protected]>
Fixes 33a24910ae ("target/riscv: Use GDBFeature for dynamic XML")
---
 target/riscv/gdbstub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/gdbstub.c +0 -0
index d0cc5762c2..358158c42a 100644

target/riscv/gdbstub.c static GDBFeature *riscv_gen_dynamic_csr_feature(CPUState *cs, int base_reg) · line 291

Quoted 5 lines
target/riscv/gdbstub.c +1 -1
@@ -288,7 +288,7 @@ static GDBFeature *riscv_gen_dynamic_csr_feature(CPUState *cs, int base_reg)
 static GDBFeature *ricsv_gen_dynamic_vector_feature(CPUState *cs, int base_reg)
 {
     RISCVCPU *cpu = RISCV_CPU(cs);
-    int reg_width = cpu->cfg.vlenb;
+    int reg_width = cpu->cfg.vlenb << 3;

You could consider renaming the var to reg_bits for clarity but otherwise:

Quoted 2 lines
target/riscv/gdbstub.c +0 -0
     GDBFeatureBuilder builder;
     int i;
Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro