From d2cd725dd35d7be7218786cbf8fc08254432a285 Mon Sep 17 00:00:00 2001 From: Palmer Dabbelt Date: Wed, 30 May 2018 17:36:22 -0700 Subject: [PATCH] Invalidate the register cache when touching another hart The 0.13 code now caches registers interally, so when reading registers on a diferent hart we need to invalidate the cache. --- src/target/riscv/riscv.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c index 1d83badf0..123d8de03 100644 --- a/src/target/riscv/riscv.c +++ b/src/target/riscv/riscv.c @@ -1840,7 +1840,15 @@ int riscv_get_register_on_hart(struct target *target, riscv_reg_t *value, int hartid, enum gdb_regno regid) { RISCV_INFO(r); + + if (hartid != riscv_current_hartid(target)) + riscv_invalidate_register_cache(target); + int result = r->get_register(target, value, hartid, regid); + + if (hartid != riscv_current_hartid(target)) + riscv_invalidate_register_cache(target); + LOG_DEBUG("[%d] %s: %" PRIx64, hartid, gdb_regno_name(regid), *value); return result; }