Commit 41840f0
committed
Fix Cortex-R5 memory barrier for interrupt control
This adds missing memory barriers to interrupt disable/restore ops to
prevent compiler reordering and ensure proper memory ordering on
ARMv7-R.
- tx_port.h: Add DMB/ISB barriers and "memory"/"cc" clobbers to
TX_DISABLE and TX_RESTORE inline assembly macros
- tx_thread_interrupt_disable.S: Add DMB/ISB after CPSID instruction
- tx_thread_interrupt_restore.S: Add DMB before MSR, ISB after
Implementation:
- TX_DISABLE: MRS → CPSID → DMB → ISB (acquire semantics)
- TX_RESTORE: DMB → MSR → ISB (release semantics)
- Uses DMB (Data Memory Barrier) for optimal lockstep performance
- ISB ensures pipeline synchronization for deterministic interrupt timing
Rationale:
- "memory" clobber prevents compiler from reordering memory operations
- "cc" clobber indicates CPSR condition codes are modified
- DMB ensures memory ordering without waiting for completion (vs DSB)
- ISB flushes pipeline to ensure CPSID/MSR takes effect immediately
- DMB before MSR in restore ensures stores are visible before interrupts
re-enable (release semantics)
Impact:
- Fixes race conditions in queue/mutex operations under -O3 optimization
- Prevents data corruption from out-of-order memory access
- Lockstep-safe: identical execution on both cores in dual-core R5F
Reference: ARMv7-R Architecture Manual (DDI 0406C), Sections B1.8.14, A3.8.3
Fixes: eclipse-threadx#3341 parent c460287 commit 41840f0
3 files changed
Lines changed: 8 additions & 4 deletions
File tree
- ports/cortex_r5/gnu
- inc
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
| 290 | + | |
291 | 291 | | |
292 | | - | |
| 292 | + | |
293 | 293 | | |
294 | 294 | | |
295 | | - | |
| 295 | + | |
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
98 | 100 | | |
99 | 101 | | |
100 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
90 | 91 | | |
| 92 | + | |
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
| |||
0 commit comments