mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 04:52:59 +01:00
06e27d5aba
19619: cpu/arm7: Fix undefined behavior based on invalid assembly r=aabadie a=Teufelchen1 ### Contribution description Hellooo! 🦤 In this PR a single `NOP` is added after an `ldm` in ARM7 common code in the scheduling management. The change is necessary because this particular `ldm` affects certain banked registers, including `R14 / lr`. The next instruction then immediately accesses `lr`. This is invalid and the exact effect depends on the underlying hardware implementation. An intermediate `NOP` ensures correct behaviour in such cases. The ARM docs can be found [here](https://documentation-service.arm.com/static/5f8dacc8f86e16515cdb865a), in section `A4.1.21 LDM (2)`. It states: > In ARM architecture versions earlier than ARMv6, this form of LDM must not be followed by an instruction that accesses banked registers. A following NOP is a good way to ensure this. ### Testing procedure Without this change, on the Game Boy Advance, RIOT behaves irregularly. With the `NOP`, it works fine! If possible, this change should be tested on other ARM7 hardware as well but I do not have access to any. ---- Special thanks `@pyropeter` for spotting the extremely tiny note on this issue within the ARM docs. You saved me hours of tears! 👾 Co-authored-by: Teufelchen1 <bennet.blischke@outlook.com> |
||
---|---|---|
.. | ||
arm7_common | ||
atmega32u4 | ||
atmega128rfa1 | ||
atmega256rfr2 | ||
atmega328p | ||
atmega1281 | ||
atmega1284p | ||
atmega2560 | ||
atmega_common | ||
atxmega | ||
avr8_common | ||
cc26x0_cc13x0 | ||
cc26x2_cc13x2 | ||
cc26xx_cc13xx | ||
cc2538 | ||
cortexm_common | ||
efm32 | ||
esp32 | ||
esp8266 | ||
esp_common | ||
fe310 | ||
gd32v | ||
kinetis | ||
lm4f120 | ||
lpc23xx | ||
lpc1768 | ||
msp430_common | ||
msp430fxyz | ||
native | ||
nrf5x_common | ||
nrf51 | ||
nrf52 | ||
nrf9160 | ||
qn908x | ||
riscv_common | ||
rpx0xx | ||
sam0_common | ||
sam3 | ||
sam_common | ||
samd5x | ||
samd21 | ||
saml1x | ||
saml21 | ||
stellaris_common | ||
stm32 | ||
doc.txt | ||
Kconfig |