-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
target/riscv: Ensure to handle all triggered a halt events #1171
base: riscv
Are you sure you want to change the base?
Conversation
If all current halted states are due to a halt group, then a new "triggered a halt" event has occurred.
7652128
to
21d836a
Compare
else | ||
break; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This loop seems weird. What is it's purpose? DCSR is writable, so we can occasionally trick debugger into wrong conclusion.
halt groups are an optional feature and I'm quite confused that we don't check for it.
Could you please provide a test scenario to reproduce your issue? Is it possible to use spike to model it? Or do you need a specific HW ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This bug was discovered when I was testing Semihosting on our hardware and smp
is enable. It fails when the following happens:
If all current halted states are due to a halt group, and other harts state was running. In fact, there was a hart halted, which caused the other harts to halt because of the hart group.
riscv-openocd/src/target/riscv/riscv.c
Lines 3792 to 3796 in f51900b
} else if (halted && running) { | |
LOG_TARGET_DEBUG(target, "halt all; halted=%d", | |
halted); | |
riscv_halt(target); | |
} else { |
If there is such a halted hart,but the record status is running,it would not process
riscv_semihosting
.riscv-openocd/src/target/riscv/riscv.c
Lines 3605 to 3623 in f51900b
if (halt_reason == RISCV_HALT_EBREAK) { | |
int retval; | |
/* Detect if this EBREAK is a semihosting request. If so, handle it. */ | |
switch (riscv_semihosting(target, &retval)) { | |
case SEMIHOSTING_NONE: | |
break; | |
case SEMIHOSTING_WAITING: | |
/* This hart should remain halted. */ | |
*next_action = RPH_REMAIN_HALTED; | |
break; | |
case SEMIHOSTING_HANDLED: | |
/* This hart should be resumed, along with any other | |
* harts that halted due to haltgroups. */ | |
*next_action = RPH_RESUME; | |
return ERROR_OK; | |
case SEMIHOSTING_ERROR: | |
return retval; | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aap-sc I think this is a bug, would you provide some suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lz-bro I'm still trying to understand your reasoning and what the issue is exactly (the situation is still not quite obvious to me). It will take a couple of days - I'll ask additional question if necessary.
@lz-bro I am afraid I have not understood what case this merge request addresses; not even after reading the commit description and the discussion so far. Please, could you provide a very clear description in the commit message. Doing so will help:
Thank you. |
Let me try to explain this issue. When openocd calls A. if no hardware state change occurs,sequence is: B. If core0 hit soft breakpoints on hardware, one possible sequence is Let's re-assume that core0/core1 are both running and consider case C C. If core0 hit semihosting ebeak on hardware, one possible sequence is: Let's re-assume that core0/core1 are both running and consider case D D. If core0 hit semihosting ebeak on the hardware, but the timing was earlier than in case C, one possible sequence is: Thank you. |
Things are a bit complicated. |
@JanMatCodasip @aap-sc Does my description of the issue help you understand what the issue is ? |
@zqb-all Thank you for describing the situation in more detail. It will take me some time to get back to it. |
If all current halted states are due to a halt group, then a new "triggered a halt" event has occurred.