boards/arm/stm32*/: Align ARM STM32 idle stack#18569
Open
pbarada wants to merge 1 commit intoapache:masterfrom
Open
boards/arm/stm32*/: Align ARM STM32 idle stack#18569pbarada wants to merge 1 commit intoapache:masterfrom
pbarada wants to merge 1 commit intoapache:masterfrom
Conversation
This patch fixes [BUG apache#18558] for stm32 by aligning _ebss symbol(used as base of idle stack) in linker files to 8-byte boundary to conform to AAPCS-32. Signed-off-by: Peter Barada <peter.barada@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch fixes [BUG #18558] for STM32 variants by aligning _ebss symbol(used as base of idle stack) in linker files to 8-byte boundary to conform to AAPCS-32. This PR does not address all possible ARM cases where idles tack does not align to AAPCS-32.
Summary
Currently STM32 builds use _ebss symbol (located at end of .bss linker section) as the base address of the idle stack, but _ebss is not aligned to AAPCS-32 required 8-byte boundary. Normally this isn't an issue but vararg processing by GCC forcibly aligns accesses of long long on 8-byte boundaries causing remaining varargs to be misaligned. Depending on stack content this bug can cause an exception.
While adding code to remove the "Missing logic" warning in stm32_irq.c:152 I ran into a bus fault exception while calling syslog() from stm32_dumpnvic during startup(which uses the idle stack) on a nucleo-stm32h743zi2 board(based on stm32h7). This was also observed on nucleo-f446re(stm32) and nuclio-f767zi(stm32f7) when configured to have an unaligned idle stack.
The fix is to force _ebss alignment to an 8-byte boundary in the linker files.
Impact
If _ebss is not aligned on an 8-byte boundary then any varag processing in the idle task (e.g. syslog message with timestamps) can cause an exception. This issue I believe potentially affects a vast majority of 32-bit ARM ports(arm64 looks to use a separate properly aligned section for the idle stack).
Testing
Build Host:
Target:
in 'make menuconfig' enable ARCH_IRQPRIO, DEBUG_FEATURES, DEBUG_IRQ, DEBUG_IRQ_INFO, then built/booted(log for nucleo-h743zi2 shown) to have syslog messages called from idle task:
Repeated on nucleo-f767zi and nucleo-f446re.