From f4f3ce7db7a1f5a264a0a957e338e71c9d583ea2 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Thu, 9 Feb 2023 10:07:42 -0800 Subject: [PATCH] Don't reuse a single riscv_program. Because riscv_program_exec() tries to add an instruction every time through. This would cause an error accessing vector registers where VL > 14(?). Change-Id: Ie676ca8c9be786b46aa2a4b4028ac8b27f7a4b40 Signed-off-by: Tim Newsome --- src/target/riscv/riscv-013.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index cfc0f14ff..71cf2876a 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -1992,13 +1992,15 @@ static int riscv013_get_register_buf(struct target *target, unsigned vnum = regno - GDB_REGNO_V0; - struct riscv_program program; - riscv_program_init(&program, target); - riscv_program_insert(&program, vmv_x_s(S0, vnum)); - riscv_program_insert(&program, vslide1down_vx(vnum, vnum, S0, true)); - int result = ERROR_OK; for (unsigned i = 0; i < debug_vl; i++) { + /* Can't reuse the same program because riscv_program_exec() adds + * ebreak to the end every time. */ + struct riscv_program program; + riscv_program_init(&program, target); + riscv_program_insert(&program, vmv_x_s(S0, vnum)); + riscv_program_insert(&program, vslide1down_vx(vnum, vnum, S0, true)); + /* Executing the program might result in an exception if there is some * issue with the vector implementation/instructions we're using. If that * happens, attempt to restore as usual. We may have clobbered the