target/riscv: calloc() memory per register.

This replaces a static array with 8 bytes per register. When there are
vector registers larger than 8 bytes, they would end up clobbering each
other's values. I can't believe I didn't catch this earlier.

See https://github.com/riscv/riscv-openocd/pull/658

Change-Id: I9df4eaf05617a2c8df3140fff9fe53f61ab2b261
Signed-off-by: Tim Newsome <tim@sifive.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6775
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
This commit is contained in:
Tim Newsome
2021-11-02 09:55:07 -07:00
committed by Antonio Borneo
parent 9828c0a440
commit 3ba21e5f00
2 changed files with 5 additions and 8 deletions

View File

@@ -96,11 +96,6 @@ typedef struct {
* every function than an actual */
int current_hartid;
/* OpenOCD's register cache points into here. This is not per-hart because
* we just invalidate the entire cache when we change which hart is
* selected. Use an array of 8 uint8_t per register. */
uint8_t reg_cache_values[RISCV_MAX_REGISTERS][8];
/* Single buffer that contains all register names, instead of calling
* malloc for each register. Needs to be freed when reg_list is freed. */
char *reg_names;