-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
arch: xtensa: Fix xtensa error handler #56587
arch: xtensa: Fix xtensa error handler #56587
Conversation
arch/xtensa/core/xtensa-asm2.c
Outdated
@@ -255,6 +255,10 @@ void *xtensa_excint1_c(int *interrupted_stack) | |||
reason = bsa[BSA_A2_OFF/4]; | |||
/* Skip ILL to RETW */ | |||
bsa[BSA_PC_OFF/4] += 3; | |||
/* Prevents xtensa_arch_except from returning in ISR context. */ | |||
if ((arch_curr_cpu()->nested > 1) && (reason == K_ERR_STACK_CHK_FAIL)) { | |||
arch_curr_cpu()->nested = 1U; |
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 needs more explaining on why this is here, how this works, and what kind of issues we need to be aware of. Next time someone else looking at this would be confused.
a6207b7
to
3eb65f2
Compare
I am still hesitant on this. We would have seen the issue on other Xtensa platforms already if the condition has been handled incorrectly. That we haven't seen the problem on other platforms with this common code suggests the issue might be somewhere else. |
The thing is what does |
Agree. Different toolchains are behaving differently to what CODE_UNREACHABLE does. But irrespective the xtensa_arch_except should not return which is what this PR would fix. If that returns, having CODE_UNREACHABLE macro when built using xcc identifies the issue. |
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.
Please do not remove my change request.
I prefer manipulating
|
The problem was just noticed when `CODE_UNREACHABLE`` was added, much likely before that the exception happened and the handler returned to thread passing that instruction and the thread just finished further. |
3eb65f2
to
0a4f12a
Compare
Sorry just re-requested your review. Didnt remove the change request. |
0a4f12a
to
c114a16
Compare
In case of recoverable fatal errors the execution should switch to another thread. This will ensure the current_cpu nested count is reset when there is a context switch. Signed-off-by: Aastha Grover <aastha.grover@intel.com>
c114a16
to
e8c293a
Compare
This commit breaks compilation with
I wish we could upgrade away from this toolchain but it's unfortunately not going to happen:
cc: @kv2019i , @lgirdwood |
Force an early return from exception when a stack check failure is detected at interrupt/exception level. This helps to ensure that ARCH_EXCEPT() does not return.