riscv, gdbstub.c: fix reg_width in ricsv_gen_dynamic_vector_feature()
v2 cover riscv, gdbstub.c: fix reg_width in ricsv_gen_dynamic_vector_feature()
Hi,
In this v2 'reg_width' was renamed to 'bitsize' to provide a bit more clarity about what's the value type of the variable. It is the same name used by riscv_gen_dynamic_csr_feature() for a variable that has the same purpose. The variable rename was suggested by Alex in v1.
Changes from v1:
- rename 'reg_width' to 'bitsize'
- v1 link: https://lore.kernel.org/qemu-riscv/[email protected]/
Daniel Henrique Barboza (1):
riscv, gdbstub.c: fix reg_width in ricsv_gen_dynamic_vector_feature()
target/riscv/gdbstub.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.44.0
PATCH v2 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.
While we're at it, rename 'reg_width' to 'bitsize' to provide a bit more clarity about what the variable represents. 'bitsize' is also used in riscv_gen_dynamic_csr_feature() with the same purpose, i.e. as an input to gdb_feature_builder_append_reg().
--- target/riscv/gdbstub.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
target/riscv/gdbstub.c +3 -3
@@ -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 bitsize = cpu->cfg.vlenb <<3 ;GDBFeatureBuilder builder;int i;
@@ -298,7 +298,7 @@ static GDBFeature *ricsv_gen_dynamic_vector_feature(CPUState *cs, int base_reg)/* First define types and totals in a whole VL */ for (i =0 ; i <ARRAY_SIZE (vec_lanes); i++) { -int count = reg_width / vec_lanes[i].size; +int count = bitsize / vec_lanes[i].size;gdb_feature_builder_append_tag ( &builder,"<vector id=\"%s\" type=\"%s\" count=\"%d\"/>" , vec_lanes[i].id, vec_lanes[i].gdb_type, count);
@@ -316,7 +316,7 @@ static GDBFeature *ricsv_gen_dynamic_vector_feature(CPUState *cs, int base_reg)/* Define vector registers */ for (i =0 ; i <32 ; i++) {gdb_feature_builder_append_reg (&builder,g_strdup_printf ("v%d" , i), - reg_width, i,"riscv_vector" ,"vector" ); + bitsize, i,"riscv_vector" ,"vector" ); }gdb_feature_builder_end (&builder);
Signature · 1 line
2.44.0
Quoted 13 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.While we're at it, rename '
reg_width' to 'bitsize' to provide a bit more clarity about what the variable represents. 'bitsize' is also used inriscv_gen_dynamic_csr_feature()with the same purpose, i.e. as an input togdb_feature_builder_append_reg().
Quoted 7 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]>Reviewed-by LIU Zhiwei <[email protected]>Acked-by Alex Bennée <[email protected]>
Quoted 14 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.While we're at it, rename '
reg_width' to 'bitsize' to provide a bit more clarity about what the variable represents. 'bitsize' is also used inriscv_gen_dynamic_csr_feature()with the same purpose, i.e. as an input togdb_feature_builder_append_reg().
Quoted 7 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]>Reviewed-by LIU Zhiwei <[email protected]>Acked-by Alex Bennée <[email protected]>
Alistair
Quoted 39 lines
--- target/riscv/gdbstub.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)target/riscv/gdbstub.c +3
-4@@ -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 bitsize = cpu->cfg.vlenb <<3 ;GDBFeatureBuilder builder;int i;@@ -298,7 +298,7 @@ static GDBFeature *ricsv_gen_dynamic_vector_feature(CPUState *cs, int base_reg)/* First define types and totals in a whole VL */ for (i =0 ; i <ARRAY_SIZE (vec_lanes); i++) { -int count = reg_width / vec_lanes[i].size; +int count = bitsize / vec_lanes[i].size;gdb_feature_builder_append_tag ( &builder,"<vector id=\"%s\" type=\"%s\" count=\"%d\"/>" , vec_lanes[i].id, vec_lanes[i].gdb_type, count);@@ -316,7 +316,7 @@ static GDBFeature *ricsv_gen_dynamic_vector_feature(CPUState *cs, int base_reg)/* Define vector registers */ for (i =0 ; i <32 ; i++) {gdb_feature_builder_append_reg (&builder,g_strdup_printf ("v%d" , i), - reg_width, i,"riscv_vector" ,"vector" ); + bitsize, i,"riscv_vector" ,"vector" ); }gdb_feature_builder_end (&builder); --2.44.0
Alistair Francis
AppliedQuoted 8 lines · Daniel Henrique Barboza
Hi,
In this v2 '
reg_width' was renamed to 'bitsize' to provide a bit more clarity about what's the value type of the variable. It is the same name used byriscv_gen_dynamic_csr_feature()for a variable that has the same purpose. The variable rename was suggested by Alex in v1.
Quoted 6 lines
Changes from v1:
- rename 'reg_width' to 'bitsize'
- v1 link: https://lore.kernel.org/qemu-riscv/[email protected]/Daniel Henrique Barboza (1):
riscv,gdbstub.c: fixreg_widthinricsv_gen_dynamic_vector_feature()
Thanks!
Applied to riscv-to-apply.next
Alistair
Quoted 8 lines
target/riscv/gdbstub.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)--
2.44.0