debug: add stack sentinel feature

This places a sentinel value at the lowest 4 bytes of a stack
memory region and checks it at various intervals, including when
servicing interrupts or context switching.

This is implemented on all arches except ARC, which supports stack
bounds checking directly in hardware.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2017-05-11 13:29:15 -07:00 committed by Anas Nashif
commit 5dcb279df8
19 changed files with 162 additions and 19 deletions

View file

@ -59,15 +59,16 @@ SECTION_FUNC(exception.other, __swap)
#if CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH
call _sys_k_event_logger_context_switch
/* Restore caller-saved r10. We could have stuck its value
* onto the stack, but less instructions to just use immediates
*/
movhi r10, %hi(_kernel)
ori r10, r10, %lo(_kernel)
#endif /* CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH */
#endif
#ifdef CONFIG_STACK_SENTINEL
call _check_stack_sentinel
#endif
#if defined(CONFIG_STACK_SENTINEL) || \
defined (CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH)
/* restore caller-saved r10 */
movhi r10, %hi(_kernel)
ori r10, r10, %lo(_kernel)
#endif
/* get cached thread to run */
ldw r2, _kernel_offset_to_ready_q_cache(r10)