mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-08-29 16:25:29 +00:00
We need to track permission on stack memory regions like we do with other kernel objects. We want stacks to live in a memory area that is outside the scope of memory domain permission management. We need to be able track what stacks are in use, and what stacks may be used by user threads trying to call k_thread_create(). Some special handling is needed because thread stacks appear as variously-sized arrays of struct _k_thread_stack_element which is just a char. We need the entire array to be considered an object, but also properly handle arrays of stacks. Validation of stacks also requires that the bounds of the stack are not exceeded. Various approaches were considered. Storing the size in some header region of the stack itself would not allow the stack to live in 'noinit'. Having a stack object be a data structure that points to the stack buffer would confound our current APIs for declaring stacks as arrays or struct members. In the end, the struct _k_object was extended to store this size. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
27 lines
790 B
Plaintext
27 lines
790 B
Plaintext
#ifndef KOBJECT_TEXT_AREA
|
|
#if defined(CONFIG_DEBUG) || defined(CONFIG_STACK_CANARIES)
|
|
#define KOBJECT_TEXT_AREA 256
|
|
#else
|
|
#define KOBJECT_TEXT_AREA 128
|
|
#endif
|
|
#endif
|
|
|
|
#ifdef CONFIG_USERSPACE
|
|
/* We need to reserve room for the gperf generated hash functions.
|
|
* Fortunately, unlike the data tables, the size of the code is
|
|
* reasonably predictable.
|
|
*
|
|
* The linker will error out complaining that the location pointer
|
|
* is moving backwards if the reserved room isn't large enough.
|
|
*/
|
|
_kobject_text_area_start = .;
|
|
*(".kobject_data.text*")
|
|
_kobject_text_area_end = .;
|
|
#ifndef LINKER_PASS2
|
|
PROVIDE(_k_object_find = .);
|
|
PROVIDE(_k_object_wordlist_foreach = .);
|
|
#endif
|
|
. += KOBJECT_TEXT_AREA - (_kobject_text_area_end - _kobject_text_area_start);
|
|
#endif /* CONFIG_USERSPACE */
|
|
|