zephyr/kernel
Andy Ross 762ff2f428 kernel/swap: Simply/robustify return value handling
The call to _arch_switch is a giant screaming sign inviting optimizer
bugs.  The code that appears before is what happened long ago when we
were switched out, but the version that EXECUTED just now is actually
in a different thread.  So the assignment to _current before the
switch actually assigned OUR thread (the "new_thread" of the old
context!) to _current.

But obviously the optimizer looks at that code and assumes that the
_current which got assigned to the thread we were switching to long
ago is still correct, and used it when retrieving the swap return
value.

Obviously the real bug here is that the _arch_switch() in question
lacked a memory clobber (and it's getting one).

But we can remove two lines, remove code from inside the interrupt
lock and make the implementation more robust by moving the read to
after the irq_unlock() (which generally also has a memory clobber).

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-01-11 15:18:52 -05:00
..
include kernel/swap: Simply/robustify return value handling 2019-01-11 15:18:52 -05:00
CMakeLists.txt
Kconfig kconfig: Minor comments and 'help' text fixes 2018-12-30 16:24:50 -05:00
Kconfig.power_mgmt kernel: ensure System Power Managment enables Tickless Idle. 2018-11-21 23:16:35 -05:00
alert.c kernel: alert: Declare tracing variables only when needed. 2018-10-31 08:44:47 -04:00
atomic_c.c
compiler_stack_protect.c
device.c kernel: check retval of driver init 2018-12-07 19:33:23 -05:00
errno.c
idle.c power: rename api sys_soc -> sys_ 2018-12-28 16:16:28 -05:00
init.c kernel: init: Add nop instruction in main 2018-12-14 13:17:36 +01:00
int_latency_bench.c kernel: Make statements evaluate boolean expressions 2019-01-07 08:52:07 -05:00
mailbox.c kernel: Make statements evaluate boolean expressions 2019-01-07 08:52:07 -05:00
mem_domain.c kernel: Make statements evaluate boolean expressions 2019-01-07 08:52:07 -05:00
mem_slab.c kernel: Add 'U' to unsigned variable assignments 2018-12-04 22:51:56 -05:00
mempool.c
msg_q.c kernel: Add missing include 2019-01-11 15:18:52 -05:00
mutex.c kernel: mutex: delay setting lock_count = 0. 2018-12-05 11:00:10 +01:00
pipes.c kernel: Add missing include 2019-01-11 15:18:52 -05:00
poll.c kernel: Fix asynchronous event polling interface 2019-01-09 17:06:08 -05:00
queue.c kernel: Add missing include 2019-01-11 15:18:52 -05:00
sched.c kernel/sched: Remove stale comment 2019-01-03 12:29:02 -05:00
sem.c
smp.c
stack.c kernel: Add missing include 2019-01-11 15:18:52 -05:00
system_work_q.c kernel: system_work_q: Set dedicated "sysworkq" name. 2018-10-19 07:58:45 -04:00
thread.c kernel: Change k_is_in_isr to return bool 2019-01-07 08:52:07 -05:00
thread_abort.c
timeout.c kernel/timeout: Don't reset imminent timeouts 2019-01-03 12:29:02 -05:00
timer.c kernel: Make statements evaluate boolean expressions 2019-01-07 08:52:07 -05:00
userspace.c kernel: Make statements evaluate boolean expressions 2019-01-07 08:52:07 -05:00
userspace_handler.c kernel: Make statements evaluate boolean expressions 2019-01-07 08:52:07 -05:00
version.c doc: add kernel version API to doxygen 2018-12-08 17:24:53 -05:00
work_q.c kernel: Use NULL instead of 0 2018-12-11 14:37:10 -08:00