-
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 arm cortex m vector table rework #24012
Arch arm cortex m vector table rework #24012
Conversation
8e1d73f
to
6bd0b08
Compare
I wonder if we are going to make a change like this, if we should also move it out of asm code like arc has. Look at |
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.
Is z_arm_reserved used anymore after this change?
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.
In general, I think setting the reserved vectors to 0 is okay; after all, we do not care about the reserved stuff and that is how reserved things are often handled (and expected to be, in case of #23972).
Yes, it is used to trigger a CPU fault, see fault.S |
No objections to that, but I would prefer to do this once for all cortex- variants together, maybe a task for @stephanosio (?) :) |
I believe that would be feasible for Cortex-M, though not for the rest (i.e. Cortex-A and Cortex-R). There is one major difference between the vector tables for Cortex-M and the rest -- that the former consists of the pointers to the handlers, whereas the latter (usually) consists of the jump instructions to the handlers. Moreover, in AArch64, the space allocated for each vector has increased so that you can actually put small handler implementations in the vector table itself. |
541a889
to
27988ce
Compare
In this case I am less eager to do this for Cortex-M now - I am not 100% happy with having the cortex-m in .c while cortex-r, a in .S format... |
I didn't go down this path before because it's a more intrusive change, but if you're ok with it then so am I. :) I agree with @stephanosio that |
27988ce
to
fcf600e
Compare
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.
Looks ok to me.
z_arm_reserved
can be completely removed for Cortex-R too since it is currently not used by anything and the future Cortex-A support will use z_arm_exc_spurious
as well for the hypervisor vector.
Would you mind doing this in your clean up work for cortex-r? |
Sure, that would work too. |
fcf600e
to
49f28ca
Compare
All checks are passing now. Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
49f28ca
to
697342f
Compare
@MaureenHelm so, i think this is a good cleanup and will solve the issue with the LPC image boot. I also did the rename of z_arm_reserved in this PR. |
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.
Looks ok to me overall.
Just a minor comment about the #if
s; though, this is really not that important since I am splitting Cortex-M and Cortex-A/-R asm exception handling code into separate files in the upcoming PR.
697342f
to
e630b4a
Compare
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.
Minor typo in the test comment, but otherwise this looks great. Thanks @ioannisg
I'll fix the typo, thanks for catching. Have you tested that it works for the LPC SoC, @MaureenHelm ? |
yes |
e630b4a
to
d714131
Compare
@galak this is now even unit-tested :) |
Write 0x0 instead of z_arm_reserved to vector exception entries that are always reserved for future use by the ARM architecture. These vector table entries cannot be fetched to be executed by the Cortex-M exception entry, so having z_arm_reserved gives a false impression, since it is a function that may be invoked in the code. This modification is safe since these vector entries are also not supposed to be read / written by the code. Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
If the Cortex-M core does not implement the SysTick peripheral, we should not be adding z_arm_reserved in the corresponding vector table entry. If we do have SysTick implemented but we are not using it as the system timer, we shall install the reserved interrupt at the vector table entry. Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
If the Cortex-M core does not implement the Security Extension, we should not be adding z_arm_reserved in the corresponding vector table entry. That is because the entry is reserved by the ARM architecture. Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
In the Cortex-M exception table we rename z_arm_reserved() function to z_arm_exc_spurious(), as it is invoked when existing (that is, non-reserved) but un-installed exceptions are triggered, accidentaly, by software, or hardware. This currently applies to SysTick and SecureFault exceptions. Since fault.S is shared between Cortex-M and other AARCH32 architectures, we keep z_arm_reserved as a defined symbol there. This commit does some additional, minor, "no-op" cleanup in #ifdef's for Cortex-M and Cortex-R. Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
We add a simple test case to verify the behavior of z_arm_exc_spurious handler. We use the SysTick interrupt for that so the test is enabled for platforms that have but do not use the SysTick. Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
d714131
to
daa6348
Compare
@galak are you ok with this? |
The selection of the Cortex M systick driver to be used as a system clock driver is controlled by CONFIG_CORTEX_M_SYSTICK. To replace it by another driver CONFIG_CORTEX_M_SYSTICK must be set to 'n'. Unfortunately this also controls the interrupt vector for the systick interrupt. It is now routed to z_arm_exc_spurious. Remove the dependecy on CONFIG_CORTEX_M_SYSTICK and route to z_clock_isr as it was before zephyrproject-rtos#24012. Fixes zephyrproject-rtos#24347 Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
The selection of the Cortex M systick driver to be used as a system clock driver is controlled by CONFIG_CORTEX_M_SYSTICK. To replace it by another driver CONFIG_CORTEX_M_SYSTICK must be set to 'n'. Unfortunately this also controls the interrupt vector for the systick interrupt. It is now routed to z_arm_exc_spurious. Remove the dependecy on CONFIG_CORTEX_M_SYSTICK and route to z_clock_isr as it was before #24012. Fixes #24347 Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
The selection of the Cortex M systick driver to be used as a system clock driver is controlled by CONFIG_CORTEX_M_SYSTICK. To replace it by another driver CONFIG_CORTEX_M_SYSTICK must be set to 'n'. Unfortunately this also controls the interrupt vector for the systick interrupt. It is now routed to z_arm_exc_spurious. Remove the dependecy on CONFIG_CORTEX_M_SYSTICK and route to z_clock_isr as it was before zephyrproject-rtos#24012. Fixes zephyrproject-rtos#24347 Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
The selection of the Cortex M systick driver to be used as a system clock driver is controlled by CONFIG_CORTEX_M_SYSTICK. To replace it by another driver CONFIG_CORTEX_M_SYSTICK must be set to 'n'. Unfortunately this also controls the interrupt vector for the systick interrupt. It is now routed to z_arm_exc_spurious. Remove the dependecy on CONFIG_CORTEX_M_SYSTICK and route to z_clock_isr as it was before zephyrproject-rtos#24012. Fixes zephyrproject-rtos#24347 Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
Ready for review.
This PR does the following changes