target/riscv: Don't resume unavailable harts.

Change-Id: I30a2e9ec6c1b99fb92ab1a160ddb63682167c6d8
Signed-off-by: Tim Newsome <tim@sifive.com>
This commit is contained in:
Tim Newsome 2022-10-13 13:29:15 -07:00
parent d3bffe3d86
commit b1f3a75819
2 changed files with 19 additions and 7 deletions

View File

@ -85,7 +85,7 @@ static int breakpoint_add_internal(struct target *target,
reason = "resource not available";
goto fail;
case ERROR_TARGET_NOT_HALTED:
reason = "target running";
reason = "target not halted";
goto fail;
default:
reason = "unknown reason";
@ -222,6 +222,8 @@ int breakpoint_add(struct target *target,
struct target_list *list_node;
foreach_smp_target(list_node, target->smp_targets) {
struct target *curr = list_node->target;
if (curr->state == TARGET_UNAVAILABLE)
continue;
int retval = breakpoint_add_internal(curr, address, length, type);
if (retval != ERROR_OK)
return retval;
@ -243,6 +245,8 @@ int context_breakpoint_add(struct target *target,
foreach_smp_target(head, target->smp_targets) {
struct target *curr = head->target;
if (curr->state == TARGET_UNAVAILABLE)
continue;
int retval = context_breakpoint_add_internal(curr, asid, length, type);
if (retval != ERROR_OK)
return retval;
@ -265,6 +269,8 @@ int hybrid_breakpoint_add(struct target *target,
foreach_smp_target(head, target->smp_targets) {
struct target *curr = head->target;
if (curr->state == TARGET_UNAVAILABLE)
continue;
int retval = hybrid_breakpoint_add_internal(curr, address, asid, length, type);
if (retval != ERROR_OK)
return retval;
@ -441,7 +447,7 @@ int watchpoint_add_internal(struct target *target, target_addr_t address,
reason = "resource not available";
goto bye;
case ERROR_TARGET_NOT_HALTED:
reason = "target running";
reason = "target not halted";
goto bye;
default:
reason = "unrecognized error";
@ -473,6 +479,8 @@ int watchpoint_add(struct target *target, target_addr_t address,
foreach_smp_target(head, target->smp_targets) {
struct target *curr = head->target;
if (curr->state == TARGET_UNAVAILABLE)
continue;
int retval = watchpoint_add_internal(curr, address, length, rw, value, mask);
if (retval != ERROR_OK)
return retval;

View File

@ -1625,9 +1625,11 @@ int riscv_resume(
struct target_list *tlist;
foreach_smp_target_direction(resume_order == RO_NORMAL, tlist, targets) {
struct target *t = tlist->target;
if (resume_prep(t, current, address, handle_breakpoints,
debug_execution) != ERROR_OK)
result = ERROR_FAIL;
if (t->state != TARGET_UNAVAILABLE) {
if (resume_prep(t, current, address, handle_breakpoints,
debug_execution) != ERROR_OK)
result = ERROR_FAIL;
}
}
foreach_smp_target_direction(resume_order == RO_NORMAL, tlist, targets) {
@ -1642,8 +1644,10 @@ int riscv_resume(
foreach_smp_target_direction(resume_order == RO_NORMAL, tlist, targets) {
struct target *t = tlist->target;
if (resume_finish(t, debug_execution) != ERROR_OK)
result = ERROR_FAIL;
if (t->state != TARGET_UNAVAILABLE) {
if (resume_finish(t, debug_execution) != ERROR_OK)
result = ERROR_FAIL;
}
}
return result;