|
From: openocd-gerrit <ope...@us...> - 2026-07-01 09:58:37
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via ef5ac7aef3d11dfe806b9bdd88a2770febdaefa3 (commit)
from 0b3e390506d1dd0e3d8a0db2e3163fce71f6f131 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit ef5ac7aef3d11dfe806b9bdd88a2770febdaefa3
Author: Anatoly Parshintsev <kup...@gm...>
Date: Tue Jan 27 00:19:55 2026 +0300
target/riscv: vstart should be preserved when manipulating vector state
read access should not ruin the current execution context
Change-Id: I76a932986958c5715a7b5dd0012c868303a6c83b
Signed-off-by: Anatoly Parshintsev <kup...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/9415
Reviewed-by: Mark Zhuang <mar...@sp...>
Reviewed-by: Jan Matyas <jan...@co...>
Reviewed-by: Evgeniy Naydanov <eu...@gm...>
Tested-by: jenkins
Reviewed-by: Tomas Vanek <va...@fb...>
diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c
index d588331a9..a87e3f97b 100644
--- a/src/target/riscv/riscv-013.c
+++ b/src/target/riscv/riscv-013.c
@@ -2339,7 +2339,7 @@ static int try_set_vsew(struct target *target, unsigned int *debug_vsew)
static int prep_for_vector_access(struct target *target,
riscv_reg_t *orig_mstatus, riscv_reg_t *orig_vtype, riscv_reg_t *orig_vl,
- unsigned int *debug_vl, unsigned int *debug_vsew)
+ riscv_reg_t *orig_vstart, unsigned int *debug_vl, unsigned int *debug_vsew)
{
assert(orig_mstatus);
assert(orig_vtype);
@@ -2356,12 +2356,15 @@ static int prep_for_vector_access(struct target *target,
if (prep_for_register_access(target, orig_mstatus, GDB_REGNO_VL) != ERROR_OK)
return ERROR_FAIL;
- /* Save vtype and vl. */
+ /* Save original vstart, vtype and vl values for later restoration */
+ if (riscv_reg_get(target, orig_vstart, GDB_REGNO_VSTART) != ERROR_OK)
+ return ERROR_FAIL;
if (riscv_reg_get(target, orig_vtype, GDB_REGNO_VTYPE) != ERROR_OK)
return ERROR_FAIL;
if (riscv_reg_get(target, orig_vl, GDB_REGNO_VL) != ERROR_OK)
return ERROR_FAIL;
-
+ /* Note: vstart may be non-zero at this point. Updating vsew (via VTYPE)
+ * reset vstart to 0. */
if (try_set_vsew(target, debug_vsew) != ERROR_OK)
return ERROR_FAIL;
/* Set the number of elements to be updated with results from a vector
@@ -2372,13 +2375,15 @@ static int prep_for_vector_access(struct target *target,
}
static int cleanup_after_vector_access(struct target *target,
- riscv_reg_t mstatus, riscv_reg_t vtype, riscv_reg_t vl)
+ riscv_reg_t mstatus, riscv_reg_t vtype, riscv_reg_t vl, riscv_reg_t vstart)
{
- /* Restore vtype and vl. */
+ /* Restore vtype, vl and vstart. */
if (riscv_reg_write(target, GDB_REGNO_VTYPE, vtype) != ERROR_OK)
return ERROR_FAIL;
if (riscv_reg_write(target, GDB_REGNO_VL, vl) != ERROR_OK)
return ERROR_FAIL;
+ if (riscv_reg_write(target, GDB_REGNO_VSTART, vstart) != ERROR_OK)
+ return ERROR_FAIL;
return cleanup_after_register_access(target, mstatus, GDB_REGNO_VL);
}
@@ -2390,10 +2395,10 @@ int riscv013_get_register_buf(struct target *target, uint8_t *value,
if (dm013_select_target(target) != ERROR_OK)
return ERROR_FAIL;
- riscv_reg_t mstatus, vtype, vl;
+ riscv_reg_t mstatus, vtype, vl, vstart;
unsigned int debug_vl, debug_vsew;
- if (prep_for_vector_access(target, &mstatus, &vtype, &vl,
+ if (prep_for_vector_access(target, &mstatus, &vtype, &vl, &vstart,
&debug_vl, &debug_vsew) != ERROR_OK)
return ERROR_FAIL;
@@ -2431,7 +2436,7 @@ int riscv013_get_register_buf(struct target *target, uint8_t *value,
}
}
- if (cleanup_after_vector_access(target, mstatus, vtype, vl) != ERROR_OK)
+ if (cleanup_after_vector_access(target, mstatus, vtype, vl, vstart) != ERROR_OK)
return ERROR_FAIL;
return result;
@@ -2445,10 +2450,10 @@ int riscv013_set_register_buf(struct target *target, enum gdb_regno regno,
if (dm013_select_target(target) != ERROR_OK)
return ERROR_FAIL;
- riscv_reg_t mstatus, vtype, vl;
+ riscv_reg_t mstatus, vtype, vl, vstart;
unsigned int debug_vl, debug_vsew;
- if (prep_for_vector_access(target, &mstatus, &vtype, &vl,
+ if (prep_for_vector_access(target, &mstatus, &vtype, &vl, &vstart,
&debug_vl, &debug_vsew) != ERROR_OK)
return ERROR_FAIL;
@@ -2470,7 +2475,7 @@ int riscv013_set_register_buf(struct target *target, enum gdb_regno regno,
break;
}
- if (cleanup_after_vector_access(target, mstatus, vtype, vl) != ERROR_OK)
+ if (cleanup_after_vector_access(target, mstatus, vtype, vl, vstart) != ERROR_OK)
return ERROR_FAIL;
return result;
-----------------------------------------------------------------------
Summary of changes:
src/target/riscv/riscv-013.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|