zephyr/kernel/include
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
..
gen_offset.h
kernel_internal.h kernel: expose k_busy_wait() to user mode 2018-11-15 16:20:36 -05:00
kernel_offsets.h kernel: Remove duplicated identifier 2018-11-04 11:37:24 -05:00
kernel_structs.h kernel: Remove duplicated identifier 2018-11-04 11:37:24 -05:00
ksched.h kernel: Use distinct macro names 2018-10-31 19:43:47 -04:00
kswap.h kernel/swap: Simply/robustify return value handling 2019-01-11 15:18:52 -05:00
offsets_short.h
syscall_handler.h kernel: Make statements evaluate boolean expressions 2019-01-07 08:52:07 -05:00
timeout_q.h kernel: Always set clock expiry with sync with timeout module 2018-11-26 12:24:59 +01:00
wait_q.h kernel/include: Move stubs for timeout functions to their declarations 2018-10-16 15:03:10 -04:00