Skip to content
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

Support nested interrupts on AArch32 (non-Cortex-M) #23636

Merged
merged 4 commits into from
Apr 2, 2020

Conversation

stephanosio
Copy link
Member

@stephanosio stephanosio commented Mar 20, 2020

arch: arm: aarch32: Rework non-Cortex-M context preservation 

The current context preservation implementation saves the spsr and
lr_irq registers, which contain the cpsr and pc register values of the
interrupted context, in the thread callee-saved block and this prevents
nesting of interrupts because these values are required to be part of
the exception stack frame to preserve the nested interrupt context.

This commit reworks the AArch32 non-Cortex-M context preservation
implementation to save the spsr and lr_irq registers in the exception
stack frame to allow preservation of the nested interrupt context as
well as the interrupted thread context.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>

Includes the commits from #23518 and #23614.

Closes #22670.

@stephanosio stephanosio force-pushed the cortex_r_nested_irq branch from fa81128 to b7c5188 Compare March 20, 2020 13:45
@zephyrbot zephyrbot added area: Devicetree area: Timer Timer area: Boards area: ARM ARM (32-bit) Architecture area: API Changes to public APIs area: Tests Issues related to a particular existing or missing test area: Kernel labels Mar 20, 2020
@zephyrbot
Copy link
Collaborator

zephyrbot commented Mar 20, 2020

All checks passed.

Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages.

@stephanosio
Copy link
Member Author

tests/kernel/interrupt:test_nested_isr Test Output

starting test - test_nested_isr
Triggering irq : 14
isr0: Enter
Triggering irq : 15
isr1: Enter
isr1: Leave
isr0: Leave
PASS - test_nested_isr

@stephanosio stephanosio added this to the v2.3.0 milestone Mar 20, 2020
@stephanosio stephanosio added the DNM This PR should not be merged (Do Not Merge) label Mar 20, 2020
@stephanosio
Copy link
Member Author

I just realised I have a more recent (and advanced) version of this in one of my private branches ... (it's been a while since I worked on this and my memory is failing ...). I will push that version tomorrow.

@stephanosio stephanosio force-pushed the cortex_r_nested_irq branch from b7c5188 to 5d561cd Compare March 21, 2020 15:11
@stephanosio stephanosio removed the DNM This PR should not be merged (Do Not Merge) label Mar 21, 2020
@stephanosio
Copy link
Member Author

stephanosio commented Mar 22, 2020

Shippable fails because tests/arch/arm/arm_irq_vector_table/arch.interrupt.arm.irq_vector_table is failing, but this test is not supposed to be run for qemu_cortex_r5 because its testcase.yaml has filter: CONFIG_ARMV6_M_ARMV8_M_BASELINE or CONFIG_ARMV7_M_ARMV8_M_MAINLINE.

It looks like we have a bug in sanitycheck?

cc @nashif @SebastianBoe @ulfalizer

p.s. It seems only the tests that have Kconfig of their own are affected by this (tests/arch/arm/arm_irq_vector_table does). Even without its own Kconfig, CMake fails.
p.s. 2. probably a CMake-related thing, not sanitycheck since it's the CMake run that is failing
p.s. 3. The direct cause is $<TARGET_FILE:zephyr_final> in

"-device;loader,file=$<TARGET_FILE:zephyr_final>,cpu-num=4"

p.s. 4. CONFIG_GEN_ISR_TABLES=n in prj.conf seems to be causing this.

For now, I have just changed CONFIG_GEN_ISR_TABLES=n to CONFIG_GEN_IRQ_VECTOR_TABLE=n since that achieves the same thing and does not cause a build failure. Nope, that causes gen_isr_tables.py to fail on other platforms ... It seems we will need a proper fix for this.

@stephanosio stephanosio force-pushed the cortex_r_nested_irq branch 2 times, most recently from 10da529 to 6690691 Compare March 22, 2020 10:29
@stephanosio
Copy link
Member Author

Rebased

@stephanosio
Copy link
Member Author

Rebased

@stephanosio stephanosio added the Release Notes To be mentioned in the release notes label Mar 30, 2020
The current context preservation implementation saves the spsr and
lr_irq registers, which contain the cpsr and pc register values of the
interrupted context, in the thread callee-saved block and this prevents
nesting of interrupts because these values are required to be part of
the exception stack frame to preserve the nested interrupt context.

This commit reworks the AArch32 non-Cortex-M context preservation
implementation to save the spsr and lr_irq registers in the exception
stack frame to allow preservation of the nested interrupt context as
well as the interrupted thread context.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit enables nested interrupt test for the Cortex-R platforms
that use the ARM Generic Interrupt Controller (GIC).

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit removes the ignore tags for the tests that work after the
changes in the PR zephyrproject-rtos#23636.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
@stephanosio stephanosio force-pushed the cortex_r_nested_irq branch from dfe0c1c to 2166e0e Compare April 1, 2020 02:16
@stephanosio stephanosio requested a review from tejlmand as a code owner April 1, 2020 02:16
@stephanosio
Copy link
Member Author

Rebased

@stephanosio stephanosio closed this Apr 1, 2020
@stephanosio stephanosio reopened this Apr 1, 2020
This commit allows the `QEMU_KERNEL_OPTION` variable, which can be
overridden by the `board.cmake`, to contain references to the variables
that are not available at the time of `board.cmake` inclusion, by
expanding its escpaed variable references in `cmake/emu/qemu.cmake`
which is included nearby the end of the root `CMakeLists.txt`.

With this change, the `board.cmake` can escape variable references as
follows and allow them to be expanded later:

set(QEMU_KERNEL_OPTION "-device;loader,file=\$<TARGET_FILE:$\{...}>")

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
@stephanosio stephanosio force-pushed the cortex_r_nested_irq branch from 2166e0e to e77b825 Compare April 1, 2020 02:18
@ioannisg ioannisg requested a review from carlocaione April 1, 2020 07:50
Copy link
Member

@ioannisg ioannisg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - just a small questions around a scratch register

@ioannisg
Copy link
Member

ioannisg commented Apr 1, 2020

cc @bbolen

@ioannisg
Copy link
Member

ioannisg commented Apr 1, 2020

@carlocaione pls, review

@ioannisg ioannisg requested a review from SebastianBoe April 1, 2020 16:05
@ioannisg ioannisg self-assigned this Apr 1, 2020
@ioannisg ioannisg merged commit 19965f8 into zephyrproject-rtos:master Apr 2, 2020
ioannisg pushed a commit that referenced this pull request Apr 2, 2020
This commit removes the ignore tags for the tests that work after the
changes in the PR #23636.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
@stephanosio stephanosio deleted the cortex_r_nested_irq branch April 23, 2020 06:22
hakehuang pushed a commit to hakehuang/zephyr that referenced this pull request Apr 30, 2020
This commit removes the ignore tags for the tests that work after the
changes in the PR zephyrproject-rtos#23636.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API Changes to public APIs area: Architectures area: ARM ARM (32-bit) Architecture area: Boards area: Build System area: Devicetree area: Kernel area: Tests Issues related to a particular existing or missing test area: Timer Timer Release Notes To be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement GIC-based ARM interrupt tests
5 participants