target/riscv: Print privilege level and ELP in riscv_cpu_dump_state
PATCH 1/2 target/riscv: Print privilege level and ELP in riscv_cpu_dump_state
The privilege level and ELP are implicit state (like virt), so print them out.
--- target/riscv/cpu.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
target/riscv/cpu.c +22 -0
@@ -580,6 +580,22 @@ static void riscv_dump_csr(CPURISCVState *env, int csrno, FILE *f) } } +#if !defined(CONFIG_USER_ONLY ) +static const char *riscv_priv_str (uint32_t priv) +{ +switch (priv) { +case PRV_M : +return "M" ; +case PRV_S : +return "S" ; +case PRV_U : +return "U" ; + } + +return "?" ; +} +#endif +static void riscv_cpu_dump_state (CPUState *cs,FILE *f,int flags) {RISCVCPU *cpu =RISCV_CPU (cs);
@@ -588,9 +604,15 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags)uint8_t *p;#if !defined(CONFIG_USER_ONLY ) +qemu_fprintf (f," %s %s\n" ,"priv = " ,riscv_priv_str (env->priv)); +if (riscv_has_ext (env,RVH )) {qemu_fprintf (f," %s %d\n" ,"V = " , env->virt_enabled); } + +if (cpu->cfg.ext_zicfilp) { +qemu_fprintf (f," %s %d\n" ,"elp = " , env->elp); + }#endif qemu_fprintf (f," %s %" PRIx64"\n" ,"pc " , env->pc);#ifndef CONFIG_USER_ONLY
Signature · 1 line
2.34.1
PATCH 2/2 target/riscv: Improve alignment in riscv_cpu_dump_state
Align all the CSR values. mcountinhibit is the longest CSR name at 13 characters, so use that width for PC, implicit state, and CSR names. Also remove the redundant '=' from the implicit state lines.t
--- target/riscv/cpu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
This makes it easier to read the output in my eyes, but I wasn't sure if the format is set in stone. Feel free to drop it if so.
target/riscv/cpu.c +5 -5
@@ -575,7 +575,7 @@ static void riscv_dump_csr(CPURISCVState *env, int csrno, FILE *f)* to do the filtering of the registers that are present. */ if (res ==RISCV_EXCP_NONE ) { -qemu_fprintf (f," %-8s " TARGET_FMT_lx"\n" , +qemu_fprintf (f," %-13s " TARGET_FMT_lx"\n" , csr_ops[csrno].name, val); } }
@@ -604,17 +604,17 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags)uint8_t *p;#if !defined(CONFIG_USER_ONLY ) -qemu_fprintf (f," %s %s\n" ,"priv = " ,riscv_priv_str (env->priv)); +qemu_fprintf (f," %-13s %s\n" ,"priv" ,riscv_priv_str (env->priv));if (riscv_has_ext (env,RVH )) { -qemu_fprintf (f," %s %d\n" ,"V = " , env->virt_enabled); +qemu_fprintf (f," %-13s %d\n" ,"V" , env->virt_enabled); }if (cpu->cfg.ext_zicfilp) { -qemu_fprintf (f," %s %d\n" ,"elp = " , env->elp); +qemu_fprintf (f," %-13s %d\n" ,"elp" , env->elp); }#endif -qemu_fprintf (f," %s %" PRIx64"\n" ,"pc " , env->pc); +qemu_fprintf (f," %-13s %" PRIx64"\n" ,"pc" , env->pc);#ifndef CONFIG_USER_ONLY for (i =0 ; i <ARRAY_SIZE (csr_ops); i++) {int csrno = i;
Signature · 1 line
2.34.1
Re: [PATCH 2/2] target/riscv: Improve alignment in riscv_cpu_dump_state
Quoted 6 lines · Anton Blanchard
Align all the CSR values. mcountinhibit is the longest CSR name at 13 characters, so use that width for PC, implicit state, and CSR names. Also remove the redundant '=' from the implicit state lines.t
Signed-off-by Anton Blanchard <[email protected]>---
Quoted 41 lines
target/riscv/cpu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)This makes it easier to read the output in my eyes, but I wasn't sure if the format is set in stone. Feel free to drop it if so.
target/riscv/cpu.c +5
-5@@ -575,7 +575,7 @@ static void riscv_dump_csr(CPURISCVState *env, int csrno, FILE *f)* to do the filtering of the registers that are present. */ if (res ==RISCV_EXCP_NONE ) { -qemu_fprintf (f," %-8s " TARGET_FMT_lx"\n" , +qemu_fprintf (f," %-13s " TARGET_FMT_lx"\n" , csr_ops[csrno].name, val); } }@@ -604,17 +604,17 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags)uint8_t *p;#if !defined(CONFIG_USER_ONLY ) -qemu_fprintf (f," %s %s\n" ,"priv = " ,riscv_priv_str (env->priv)); +qemu_fprintf (f," %-13s %s\n" ,"priv" ,riscv_priv_str (env->priv));if (riscv_has_ext (env,RVH )) { -qemu_fprintf (f," %s %d\n" ,"V = " , env->virt_enabled); +qemu_fprintf (f," %-13s %d\n" ,"V" , env->virt_enabled); }if (cpu->cfg.ext_zicfilp) { -qemu_fprintf (f," %s %d\n" ,"elp = " , env->elp); +qemu_fprintf (f," %-13s %d\n" ,"elp" , env->elp); }#endif -qemu_fprintf (f," %s %" PRIx64"\n" ,"pc " , env->pc); +qemu_fprintf (f," %-13s %" PRIx64"\n" ,"pc" , env->pc);#ifndef CONFIG_USER_ONLY for (i =0 ; i <ARRAY_SIZE (csr_ops); i++) {int csrno = i;
Re: [PATCH 2/2] target/riscv: Improve alignment in riscv_cpu_dump_state
In reply to Anton BlanchardQuoted 6 lines · Anton Blanchard
Align all the CSR values. mcountinhibit is the longest CSR name at 13 characters, so use that width for PC, implicit state, and CSR names. Also remove the redundant '=' from the implicit state lines.t
Signed-off-by Anton Blanchard <[email protected]>
Alistair
Quoted 46 lines
--- target/riscv/cpu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)This makes it easier to read the output in my eyes, but I wasn't sure if the format is set in stone. Feel free to drop it if so.
target/riscv/cpu.c +5
-6@@ -575,7 +575,7 @@ static void riscv_dump_csr(CPURISCVState *env, int csrno, FILE *f)* to do the filtering of the registers that are present. */ if (res ==RISCV_EXCP_NONE ) { -qemu_fprintf (f," %-8s " TARGET_FMT_lx"\n" , +qemu_fprintf (f," %-13s " TARGET_FMT_lx"\n" , csr_ops[csrno].name, val); } }@@ -604,17 +604,17 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags)uint8_t *p;#if !defined(CONFIG_USER_ONLY ) -qemu_fprintf (f," %s %s\n" ,"priv = " ,riscv_priv_str (env->priv)); +qemu_fprintf (f," %-13s %s\n" ,"priv" ,riscv_priv_str (env->priv));if (riscv_has_ext (env,RVH )) { -qemu_fprintf (f," %s %d\n" ,"V = " , env->virt_enabled); +qemu_fprintf (f," %-13s %d\n" ,"V" , env->virt_enabled); }if (cpu->cfg.ext_zicfilp) { -qemu_fprintf (f," %s %d\n" ,"elp = " , env->elp); +qemu_fprintf (f," %-13s %d\n" ,"elp" , env->elp); }#endif -qemu_fprintf (f," %s %" PRIx64"\n" ,"pc " , env->pc); +qemu_fprintf (f," %-13s %" PRIx64"\n" ,"pc" , env->pc);#ifndef CONFIG_USER_ONLY for (i =0 ; i <ARRAY_SIZE (csr_ops); i++) {int csrno = i; --2.34.1
Alistair Francis
AppliedRe: [PATCH 2/2] target/riscv: Improve alignment in riscv_cpu_dump_state
In reply to Anton BlanchardQuoted 6 lines · Anton Blanchard
Align all the CSR values. mcountinhibit is the longest CSR name at 13 characters, so use that width for PC, implicit state, and CSR names. Also remove the redundant '=' from the implicit state lines.t
Signed-off-by Anton Blanchard <[email protected]>
Thanks!
Applied to riscv-to-apply.next
In future please make sure a multi-patch series includes a cover letter. It makes it easier for the tools to apply the patches
Alistair
Quoted 46 lines
--- target/riscv/cpu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)This makes it easier to read the output in my eyes, but I wasn't sure if the format is set in stone. Feel free to drop it if so.
target/riscv/cpu.c +5
-6@@ -575,7 +575,7 @@ static void riscv_dump_csr(CPURISCVState *env, int csrno, FILE *f)* to do the filtering of the registers that are present. */ if (res ==RISCV_EXCP_NONE ) { -qemu_fprintf (f," %-8s " TARGET_FMT_lx"\n" , +qemu_fprintf (f," %-13s " TARGET_FMT_lx"\n" , csr_ops[csrno].name, val); } }@@ -604,17 +604,17 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags)uint8_t *p;#if !defined(CONFIG_USER_ONLY ) -qemu_fprintf (f," %s %s\n" ,"priv = " ,riscv_priv_str (env->priv)); +qemu_fprintf (f," %-13s %s\n" ,"priv" ,riscv_priv_str (env->priv));if (riscv_has_ext (env,RVH )) { -qemu_fprintf (f," %s %d\n" ,"V = " , env->virt_enabled); +qemu_fprintf (f," %-13s %d\n" ,"V" , env->virt_enabled); }if (cpu->cfg.ext_zicfilp) { -qemu_fprintf (f," %s %d\n" ,"elp = " , env->elp); +qemu_fprintf (f," %-13s %d\n" ,"elp" , env->elp); }#endif -qemu_fprintf (f," %s %" PRIx64"\n" ,"pc " , env->pc); +qemu_fprintf (f," %-13s %" PRIx64"\n" ,"pc" , env->pc);#ifndef CONFIG_USER_ONLY for (i =0 ; i <ARRAY_SIZE (csr_ops); i++) {int csrno = i; --2.34.1
Quoted 5 lines · Anton Blanchard
The privilege level and ELP are implicit state (like virt), so print them out.
Signed-off-by Anton Blanchard <[email protected]>---
Quoted 46 lines
target/riscv/cpu.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)target/riscv/cpu.c +22
-0@@ -580,6 +580,22 @@ static void riscv_dump_csr(CPURISCVState *env, int csrno, FILE *f) } } +#if !defined(CONFIG_USER_ONLY ) +static const char *riscv_priv_str (uint32_t priv) +{ +switch (priv) { +case PRV_M : +return "M" ; +case PRV_S : +return "S" ; +case PRV_U : +return "U" ; + } + +return "?" ; +} +#endif +static void riscv_cpu_dump_state (CPUState *cs,FILE *f,int flags) {RISCVCPU *cpu =RISCV_CPU (cs);@@ -588,9 +604,15 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags)uint8_t *p;#if !defined(CONFIG_USER_ONLY ) +qemu_fprintf (f," %s %s\n" ,"priv = " ,riscv_priv_str (env->priv)); +if (riscv_has_ext (env,RVH )) {qemu_fprintf (f," %s %d\n" ,"V = " , env->virt_enabled); } + +if (cpu->cfg.ext_zicfilp) { +qemu_fprintf (f," %s %d\n" ,"elp = " , env->elp); + }#endif qemu_fprintf (f," %s %" PRIx64"\n" ,"pc " , env->pc);#ifndef CONFIG_USER_ONLY
Quoted 5 lines · Anton Blanchard
The privilege level and ELP are implicit state (like virt), so print them out.
Signed-off-by Anton Blanchard <[email protected]>
Alistair
Quoted 51 lines
--- target/riscv/cpu.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)target/riscv/cpu.c +22
-1@@ -580,6 +580,22 @@ static void riscv_dump_csr(CPURISCVState *env, int csrno, FILE *f) } } +#if !defined(CONFIG_USER_ONLY ) +static const char *riscv_priv_str (uint32_t priv) +{ +switch (priv) { +case PRV_M : +return "M" ; +case PRV_S : +return "S" ; +case PRV_U : +return "U" ; + } + +return "?" ; +} +#endif +static void riscv_cpu_dump_state (CPUState *cs,FILE *f,int flags) {RISCVCPU *cpu =RISCV_CPU (cs);@@ -588,9 +604,15 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags)uint8_t *p;#if !defined(CONFIG_USER_ONLY ) +qemu_fprintf (f," %s %s\n" ,"priv = " ,riscv_priv_str (env->priv)); +if (riscv_has_ext (env,RVH )) {qemu_fprintf (f," %s %d\n" ,"V = " , env->virt_enabled); } + +if (cpu->cfg.ext_zicfilp) { +qemu_fprintf (f," %s %d\n" ,"elp = " , env->elp); + }#endif qemu_fprintf (f," %s %" PRIx64"\n" ,"pc " , env->pc);#ifndef CONFIG_USER_ONLY --2.34.1