riscv, gdbstub.c: fix reg_width in ricsv_gen_dynamic_vector_feature()
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
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.
--- target/riscv/gdbstub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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 ;GDBFeatureBuilder builder;int i;
Signature · 1 line
2.44.0
Quoted 8 lines · Daniel Henrique Barboza
Commit
33a24910aechanged '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 like7cb59921c05a("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]>Reported-by Robin Dapp <[email protected]>Fixes 33a24910ae ("target/riscv: Use GDBFeature for dynamic XML")Signed-off-by Daniel Henrique Barboza <[email protected]>
Zhiwei
Quoted 17 lines
--- target/riscv/gdbstub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)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 ;GDBFeatureBuilder builder;int i;
Quoted 22 lines · Daniel Henrique Barboza
Commit
33a24910aechanged '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 like7cb59921c05a("target/riscv/gdbstub.c: use 'vlenb' instead of shifting 'vlen'") set beforehand.Cc Akihiko Odaki <[email protected]>Cc Alex Bennée <[email protected]>Reported-by Robin Dapp <[email protected]>Fixes 33a24910ae ("target/riscv: Use GDBFeature for dynamic XML")Signed-off-by Daniel Henrique Barboza <[email protected]>--- target/riscv/gdbstub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/riscv/gdbstub.c +0
-0
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
-0GDBFeatureBuilder builder;int i;
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro