Merge pull request #568 from riscv/zero

Don't write to zero.
This commit is contained in:
Tim Newsome 2021-01-15 16:41:36 -08:00 committed by GitHub
commit ed37337b0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -4165,6 +4165,11 @@ static int register_set(struct reg *reg, uint8_t *buf)
riscv_current_hartid(target), str, reg->name, reg->valid);
free(str);
/* Exit early for writing x0, which on the hardware would be ignored, and we
* don't want to update our cache. */
if (reg->number == GDB_REGNO_ZERO)
return ERROR_OK;
memcpy(reg->value, buf, DIV_ROUND_UP(reg->size, 8));
reg->valid = gdb_regno_cacheable(reg->number, true);