From 0ae47ae4723431e78c2164d069e530b049fdbbbb Mon Sep 17 00:00:00 2001 From: Parshintsev Anatoly Date: Tue, 15 Aug 2023 23:01:12 +0300 Subject: [PATCH] fix crash when we try to read vector register on a running target Change-Id: I0e140d69faa67f8817310cf18a4db3c581013de2 Signed-off-by: Parshintsev Anatoly --- src/target/riscv/riscv-013.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index 59bd8690c..79da7d51f 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -2369,9 +2369,6 @@ static int riscv013_get_register_buf(struct target *target, if (dm013_select_target(target) != ERROR_OK) return ERROR_FAIL; - if (riscv_save_register(target, GDB_REGNO_S0) != ERROR_OK) - return ERROR_FAIL; - riscv_reg_t mstatus, vtype, vl; unsigned int debug_vl, debug_vsew; @@ -2379,6 +2376,9 @@ static int riscv013_get_register_buf(struct target *target, &debug_vl, &debug_vsew) != ERROR_OK) return ERROR_FAIL; + if (riscv_save_register(target, GDB_REGNO_S0) != ERROR_OK) + return ERROR_FAIL; + unsigned int vnum = regno - GDB_REGNO_V0; int result = ERROR_OK; @@ -2424,9 +2424,6 @@ static int riscv013_set_register_buf(struct target *target, if (dm013_select_target(target) != ERROR_OK) return ERROR_FAIL; - if (riscv_save_register(target, GDB_REGNO_S0) != ERROR_OK) - return ERROR_FAIL; - riscv_reg_t mstatus, vtype, vl; unsigned int debug_vl, debug_vsew; @@ -2434,6 +2431,9 @@ static int riscv013_set_register_buf(struct target *target, &debug_vl, &debug_vsew) != ERROR_OK) return ERROR_FAIL; + if (riscv_save_register(target, GDB_REGNO_S0) != ERROR_OK) + return ERROR_FAIL; + unsigned int vnum = regno - GDB_REGNO_V0; struct riscv_program program;