-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix regresion from https://github.com/apache/nuttx/pull/14881 #15073
Conversation
[Experimental Bot, please feedback here] No, this PR does not fully meet the NuttX requirements. While it provides a link to the related PR and identifies affected architectures, it lacks crucial details. Here's a breakdown:
The PR needs substantial improvement in all three sections (Summary, Impact, and Testing) before it can be considered complete. |
also influence this issue #14514 |
I confirm that this PR fixes this issue on nrf52 #14514 |
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.
What are the consequences of this change? Does it have any disadvantages compared to PRIMASK? This is not a trivial change, so it's worth discuss it more as we basically force users to use BASEPRI here.
syscall doesn't go through hardfault, which make the syscall process is simple and fast, also avoid confusing the developer with JTAG debugging.
I don't see any bad side effect.
PRIMASK is a bad design in armv6-m, that's why arm introduce BASEPRI from armv7-m. It's wrong to provide this option for armv7-m/armv8-m arch. |
@hujun260 what about armv6-m ? this arch doesn't support BASEPRI, so this architecture is still broken. |
I think the timeline is different. armv7-m was introduced before armv6-m. The second one is a cut version of the first one and if ARM decided to get rid of BASEPRI they must have had a reason for this (but of course they could have made a design mistake here)
I don't see any flaws in this solution either and it can simplify a lot of things. But people use NuttX in different ways. A change like this should be more widely communicated in the community, maybe someone sees drawbacks. |
It has been restored to the old implementation. |
103c9ea
to
a36b0bd
Compare
@hujun260 Please include a complete explanation in the commit log message. I saw @xiaoxiang781216 try to explain a little bit about it, but it is important to explain what was modified initially that caused the issue (and why it was modified) and then how the new modification fixes the issue. It could help us understand it better and help other people in the future when looking this commit. |
done |
@hujun260 please extend the explanation from @xiaoxiang781216 and include it in the commit log message |
reason: svc call may trigger hardfalt Signed-off-by: hujun5 <[email protected]>
aleady add to the second commit |
@hujun260 @xiaoxiang781216 Could we remove the word "bad" from the commit message? I don't think this is a bad design, right? These are two interrupt masking mechanisms provided by the CPU. Similar to cortex-a/r, the CPU also provides cpsr and gic mechanisms, but the application scenarios are different. |
reason: svc call may trigger hardfault Background The origin of this issue is our desire to eliminate the function of storing "regs" in g_current_regs and instead utilize (*running_task)->xcp.regs for storage. The benefits of this approach include faster storage speed and avoiding multiple accesses to g_current_regs during context switching, thus ensuring that whether returning from an interrupt or an exception, we consistently use this_task()->xcp.regs Issue Encountered However, when storing registers, we must ensure that (running_task)->xcp.regs is invalid so that it can be safely overwritten. According to the existing logic, the only scenario where (running_task)->xcp.regs is valid is during restore_context. We must accurately identify this scenario. Initially, we used the condition (running_task)==NULL for this purpose, but we deemed this approach unsatisfactory as it did not align well with the actual logic. (running_task) should not be NULL. Consequently, we adopted other arch-specific methods for judgment, but due to special logic in some arch, the judgment was not accurate, leading to this issue. Solution: For armv6-m, we haven't found a more suitable solution, so we are sticking with (*running_task)==NULL. For armv7-m/armv8-m, by removing support for primask, we can achieve accurate judgment. PRIMASK is a design in armv6-m, that's why arm introduce BASEPRI from armv7-m. It's wrong to provide this option for armv7-m/armv8-m arch. Signed-off-by: hujun5 <[email protected]>
ok |
EDIT: The following comment, which I made earlier, is incorrect. This PR removes support for PRIMASK, not BASEPRI. PRIMASK is not needed because BASEPRI is a superset of the functionality. This PR does not break High Priority, Zero Latency Interrupts! (Leaving the earlier text in place below...) Sorry, I missed this PR before it was merged, but this PR breaks High Priority, Zero Latency Interrupts! See the help text for ARMV7M_USEBASEPRI, which was removed in this PR:
Also see https://nuttx.apache.org/docs/latest/guides/zerolatencyinterrupts.html Important note: If this feature is removed from NuttX, then NuttX is completely useless to me and my employer! We depend on the Zero Latency Interrupts for critical parts of our firmware! |
Please see Issue #15100 |
@raiden00pl the consequences of removing CONFIG_ARMV7M_USEBASEPRI is that high priority zero latency interrupts cannot work anymore. Unfortunately I think several PRs will need to be reverted. It seems the issue starts with PR-14881 which attempts to optimize storing |
We haven't removed this feature; we've just set it to be enabled by default. |
Thank you for clarifying. I misunderstood the changes earlier. |
Summary
fix regresion from #14881
reason:
svc call may trigger hardfalt
Background
The origin of this issue is our desire to eliminate the function of storing
"regs" in g_current_regs and instead utilize (*running_task)->xcp.regs for storage.
The benefits of this approach include faster storage speed and
avoiding multiple accesses to g_current_regs during context switching,
thus ensuring that whether returning from an interrupt or an exception,
we consistently use this_task()->xcp.regs
Issue Encountered
However, when storing registers, we must ensure that (running_task)->xcp.regs is invalid
so that it can be safely overwritten.
According to the existing logic, the only scenario where (running_task)->xcp.regs
is valid is during restore_context. We must accurately identify this scenario.
Initially, we used the condition (running_task)==NULL for this purpose, but we deemed
this approach unsatisfactory as it did not align well with the actual logic.
(running_task) should not be NULL. Consequently, we adopted other arch-specific methods for judgment,
but due to special logic in some arch, the judgment was not accurate, leading to this issue.
Solution:
For armv6-m, we haven't found a more suitable solution, so we are sticking with (*running_task)==NULL.
For armv7-m/armv8-m, by removing support for primask, we can achieve accurate judgment.
PRIMASK is a design in armv6-m, that's why arm introduce BASEPRI from armv7-m. It's wrong to provide this option for armv7-m/armv8-m arch.
Impact
armv6-m
armv7-m
armv8-m
Testing
ci