Skip to content

Commit

Permalink
Fix missing barrier in TX_DISABLE for Cortex-R5
Browse files Browse the repository at this point in the history
This commit fixes thread safety issue in tx_byte_allocate by correcting
clobber list and adding missing compiler fence. This addresses potential
race conditions when aggressive compiler optimization is enabled.

Patched by Pat Kusbel.
See eclipse-threadx#334
  • Loading branch information
jserv committed Nov 26, 2024
1 parent 0670e81 commit 51ac4f1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ports/cortex_r5/gnu/inc/tx_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ unsigned int _tx_thread_interrupt_restore(UINT old_posture);
#define TX_INTERRUPT_SAVE_AREA UINT interrupt_save;

#ifdef TX_ENABLE_FIQ_SUPPORT
#define TX_DISABLE asm volatile (" MRS %0,CPSR; CPSID if ": "=r" (interrupt_save) );
#define TX_DISABLE asm volatile (" MRS %0,CPSR; CPSID if ": "=r" (interrupt_save) : : "memory", "cc");
#else
#define TX_DISABLE asm volatile (" MRS %0,CPSR; CPSID i ": "=r" (interrupt_save) );
#define TX_DISABLE asm volatile (" MRS %0,CPSR; CPSID i ": "=r" (interrupt_save) : : "memory", "cc");
#endif

#define TX_RESTORE asm volatile (" MSR CPSR_c,%0 "::"r" (interrupt_save) );
Expand Down

0 comments on commit 51ac4f1

Please sign in to comment.