target/riscv: Fix bug in getting trap cause name for trace_riscv_trap
PATCH 1/1 target/riscv: Fix bug in getting trap cause name for trace_riscv_trap
When the cause number is equal to or greater than 23, print "(unknown)" in trace_riscv_trap. The max valid number of riscv_excp_names is 23, so the last excpetion "guest_store_page_fault" can not be printed.
In addition, the current check of cause is invalid for riscv_intr_names. So introduce riscv_cpu_get_trap_name to get the trap cause name.
--- target/riscv/cpu.c | 11 +++++++++++ target/riscv/cpu.h | 1 + target/riscv/cpu_helper.c | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-)
target/riscv/cpu.c +11 -0
@@ -96,6 +96,17 @@ const char * const riscv_intr_names[] = { "reserved" }; +const char *riscv_cpu_get_trap_name (target_ulong cause,bool async) +{ +if (async) { +return (cause <ARRAY_SIZE (riscv_intr_names)) ? + riscv_intr_names[cause] :"(unknown)" ; + }else { +return (cause <ARRAY_SIZE (riscv_excp_names)) ? + riscv_excp_names[cause] :"(unknown)" ; + } +} +static void set_misa (CPURISCVState *env,target_ulong misa) { env->misa_mask = env->misa = misa;
target/riscv/cpu.h +1 -0
@@ -312,6 +312,7 @@ extern const char * const riscv_fpr_regnames[];extern const char *const riscv_excp_names[];extern const char *const riscv_intr_names[]; +const char *riscv_cpu_get_trap_name (target_ulong cause,bool async);void riscv_cpu_do_interrupt (CPUState *cpu);int riscv_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int riscv_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);
target/riscv/cpu_helper.c +2 -2
@@ -877,8 +877,8 @@ void riscv_cpu_do_interrupt(CPUState *cs) } } -trace_riscv_trap (env->mhartid, async, cause, env->pc, tval, cause <23 ? - (async ? riscv_intr_names : riscv_excp_names)[cause] :"(unknown)" ); +trace_riscv_trap (env->mhartid, async, cause, env->pc, tval, +riscv_cpu_get_trap_name (cause, async));if (env->priv <=PRV_S && cause <TARGET_LONG_BITS && ((deleg >> cause) &1 )) {
Signature · 1 line
2.19.1
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the docker-quick@centos7 build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END ===
TEST check-unit: tests/test-char
Unexpected error in object_property_try_add() at /tmp/qemu-test/src/qom/object.c:1181:
attempt to add duplicate property 'serial-id' to object (type 'container')
ERROR test-char - too few tests run (expected 38, got 9)
make: *** [check-unit] Error 1
make: *** Waiting for unfinished jobs....
TEST iotest-qcow2: 029
TEST check-qtest-x86_64: tests/qtest/hd-geo-test
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=83e8be982fe84f739b342435f33b62f6', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-brxkol53/src/docker-src.2020-08-14-00.10.36.6152:/var/tmp/qemu:z,ro', 'qemu/centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=83e8be982fe84f739b342435f33b62f6
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-brxkol53/src'
make: *** [docker-run-test-quick@centos7] Error 2
real 13m15.058s
user 0m8.409s
The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Quoted 10 lines · Yifei Jiang
When the cause number is equal to or greater than 23, print "(unknown)" in
trace_riscv_trap. The max valid number ofriscv_excp_namesis 23, so the last excpetion "guest_store_page_fault" can not be printed.In addition, the current check of cause is invalid for
riscv_intr_names. So introduceriscv_cpu_get_trap_nameto get the trap cause name.Signed-off-by Yifei Jiang <[email protected]>Signed-off-by Yipeng Yin <[email protected]>
Applied to riscv-to-apply.next
Alistair
Quoted 60 lines
--- target/riscv/cpu.c | 11 +++++++++++ target/riscv/cpu.h | 1 + target/riscv/cpu_helper.c | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-)target/riscv/cpu.c +11
-0@@ -96,6 +96,17 @@ const char * const riscv_intr_names[] = { "reserved" }; +const char *riscv_cpu_get_trap_name (target_ulong cause,bool async) +{ +if (async) { +return (cause <ARRAY_SIZE (riscv_intr_names)) ? + riscv_intr_names[cause] :"(unknown)" ; + }else { +return (cause <ARRAY_SIZE (riscv_excp_names)) ? + riscv_excp_names[cause] :"(unknown)" ; + } +} +static void set_misa (CPURISCVState *env,target_ulong misa) { env->misa_mask = env->misa = misa;target/riscv/cpu.h +1
-0@@ -312,6 +312,7 @@ extern const char * const riscv_fpr_regnames[];extern const char *const riscv_excp_names[];extern const char *const riscv_intr_names[]; +const char *riscv_cpu_get_trap_name (target_ulong cause,bool async);void riscv_cpu_do_interrupt (CPUState *cpu);int riscv_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int riscv_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);target/riscv/cpu_helper.c +2
-3@@ -877,8 +877,8 @@ void riscv_cpu_do_interrupt(CPUState *cs) } } -trace_riscv_trap (env->mhartid, async, cause, env->pc, tval, cause <23 ? - (async ? riscv_intr_names : riscv_excp_names)[cause] :"(unknown)" ); +trace_riscv_trap (env->mhartid, async, cause, env->pc, tval, +riscv_cpu_get_trap_name (cause, async));if (env->priv <=PRV_S && cause <TARGET_LONG_BITS && ((deleg >> cause) &1 )) { --2.19.1