-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Interrupt nesting is broken on ARMv7-R / LR_svc corrupted. #30517
Comments
Hi Remy, I'm indeed facing an issue with nested interrupt on Cortex-R, As a temporary workaround, I just disabled nested interrupt, as it's done in Cortex M. |
@stephanosio any chance you could take a look? |
@ioannisg will do. |
With the current implementation, if an ISR is interrupted while executing in a branch, the I will create a PR to fix this in a few days. |
In the current interrupt nesting implementation, if an ISR is interrupted while executing inside a branch, the lr_svc register will be corrupted, and the branch of the interrupted ISR will exit to the return address of the final branch of the interrupting ISR, which may or may not correspond to the intended return address. This commit fixes the aforementioned bug by storing the lr_svc register in the stack at the ISR entry, and restoring its value before exiting the ISR. For more details, refer to the issue zephyrproject-rtos#30517. Signed-off-by: Stephanos Ioannidis <[email protected]>
In the current interrupt nesting implementation, if an ISR is interrupted while executing inside a branch, the lr_svc register will be corrupted, and the branch of the interrupted ISR will exit to the return address of the final branch of the interrupting ISR, which may or may not correspond to the intended return address. This commit fixes the aforementioned bug by storing the lr_svc register in the stack at the ISR entry, and restoring its value before exiting the ISR. For more details, refer to the issue #30517. Signed-off-by: Stephanos Ioannidis <[email protected]>
I have a custom board running a port to ARMv7-A with NEON. This shares much code with the ARMv7-R version and I believe this issue is relevant to your code as well. Please disregard this report should this not be the case.
zephyr/arch/arm/core/aarch32/isr_wrapper.S, edited for clarity, comments starting with // are mine:
At no point is LR_svc preserved. The fix is to simply store LR_svc before it gets clobbered at the first bl instruction and subsequently restore it before exiting the handler. I have chosen to do this onto the IRQ stack, which appeared to be otherwise unused, to preserve my work on getting OpenOCD to behave on the Cortex-A7 that I work with. It is likely that there is a much better solution as to where to put this register, but I currently lack the resources to investigate that and my fix worked well enough for my needs.
The text was updated successfully, but these errors were encountered: