From aabfcd0c3330830356a55782e2bdc99e3979165a Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 12 Jun 2013 15:11:57 +0200 Subject: smp: Fix _Thread_Dispatch_decrement_disable_level We must obtain the processor ID after interrupts are disabled since a non-optimizing compiler may store the value on the stack and read it back. --- cpukit/score/src/threaddispatchdisablelevel.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'cpukit/score/src') diff --git a/cpukit/score/src/threaddispatchdisablelevel.c b/cpukit/score/src/threaddispatchdisablelevel.c index 4686795bbb..154a6af637 100644 --- a/cpukit/score/src/threaddispatchdisablelevel.c +++ b/cpukit/score/src/threaddispatchdisablelevel.c @@ -56,12 +56,18 @@ uint32_t _Thread_Dispatch_increment_disable_level( void ) { Thread_Dispatch_disable_level_lock_control *level_lock = &_Thread_Dispatch_disable_level_lock; - int self_cpu = bsp_smp_processor_id(); + int self_cpu; ISR_Level isr_level; uint32_t disable_level; _ISR_Disable_on_this_core( isr_level ); + /* + * We must obtain the processor ID after interrupts are disabled since a + * non-optimizing compiler may store the value on the stack and read it back. + */ + self_cpu = bsp_smp_processor_id(); + if ( level_lock->owner_cpu != self_cpu ) { _SMP_lock_Acquire( &level_lock->lock ); level_lock->owner_cpu = self_cpu; -- cgit v1.2.3