From 0ab2ebd1915f9e6c1036e93b0436d50c02c574b4 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Thu, 1 Jun 2023 15:02:32 -0700 Subject: [PATCH] target/riscv: Select hart in update_dcsr() Otherwise we may end up modifying DCSR of a different hart than intended. Change-Id: I39bde21a1444623ed150f2b3d504b9318b9d6191 Signed-off-by: Tim Newsome --- src/target/riscv/riscv-013.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index 6edf57ca7..5f929efab 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -1558,6 +1558,9 @@ static int wait_for_authbusy(struct target *target, uint32_t *dmstatus) static int update_dcsr(struct target *target, bool step) { + if (dm013_select_target(target) != ERROR_OK) + return ERROR_FAIL; + riscv_reg_t dcsr; /* We want to twiddle some bits in the debug CSR so debugging works. */ int result = register_read_direct(target, &dcsr, GDB_REGNO_DCSR);