Lines Matching full:stack

15  * Stack testing
28 K_KERNEL_STACK_MEMBER(stack, STEST_STACKSIZE);
67 k_thread_stack_t *stack; member
78 /* Stack size stored in kernel object metadata if a user stack */
81 /* Return value of sizeof(stack) */
84 /* Return value of K_{THREAD|KERNEL}_STACK_SIZEOF(stack) */
90 /* Whether this stack is part of an array of thread stacks */
111 stack_obj = scenario_data.stack; in stack_buffer_scenarios()
146 /* Assert that the created stack object, with the reserved data in stack_buffer_scenarios()
150 "bad stack size in object"); in stack_buffer_scenarios()
152 /* Check that the stack info in the thread marks a region in stack_buffer_scenarios()
153 * completely contained within the stack object in stack_buffer_scenarios()
156 "stack size in thread struct out of bounds (overflow)"); in stack_buffer_scenarios()
158 "stack size in thread struct out of bounds (underflow)"); in stack_buffer_scenarios()
160 /* Check that the base of the stack is aligned properly. */ in stack_buffer_scenarios()
162 "stack base address %p not aligned to %zu", in stack_buffer_scenarios()
165 /* Check that the entire stack buffer is read/writable */ in stack_buffer_scenarios()
166 printk(" - check read/write to stack buffer\n"); in stack_buffer_scenarios()
168 /* Address of this stack variable is guaranteed to part of in stack_buffer_scenarios()
169 * the active stack, and close to the actual stack pointer. in stack_buffer_scenarios()
170 * Some CPUs have hardware stack overflow detection which in stack_buffer_scenarios()
171 * faults on memory access within the stack buffer but below in stack_buffer_scenarios()
172 * the stack pointer. in stack_buffer_scenarios()
175 * stack pointer up to the highest addresses in the buffer in stack_buffer_scenarios()
176 * Starting from &val which is close enough to stack pointer in stack_buffer_scenarios()
187 /* If we're in user mode, check every byte in the stack buffer in stack_buffer_scenarios()
192 "bad MPU/MMU permission on stack buffer at address %p", in stack_buffer_scenarios()
197 * before or after the stack. Because of memory protection HW in stack_buffer_scenarios()
198 * alignment constraints, we test the end of the stack object in stack_buffer_scenarios()
202 "user mode access to memory %p before start of stack object", in stack_buffer_scenarios()
205 "user mode access to memory %p past end of stack object", in stack_buffer_scenarios()
222 "bad stack size %zu in thread struct", in stack_buffer_scenarios()
232 /* 0 unless this is a stack array */ in stack_buffer_scenarios()
236 /* For all stacks, when k_thread_create() is called with a stack object, in stack_buffer_scenarios()
237 * it is equivalent to pass either the original requested stack size, or in stack_buffer_scenarios()
238 * the return value of K_*_STACK_SIZEOF() for that stack object. in stack_buffer_scenarios()
240 * When the stack is actually instantiated, both expand to fill any space in stack_buffer_scenarios()
245 * For some stack declared with: in stack_buffer_scenarios()
277 * this would require some way for the kernel to know that a stack object in stack_buffer_scenarios()
295 zassert_true(end_space >= 0, "bad stack bounds in stack_info"); in stack_buffer_scenarios()
311 printk("self-reported unused stack space: %zu\n", unused); in stack_buffer_scenarios()
332 k_thread_create(&test_thread, scenario_data.stack, STEST_STACKSIZE, in stest_thread_launch()
340 printk(" - Memory mapped stack object %p\n", scenario_data.stack_mapped); in stest_thread_launch()
350 printk("! cannot report unused stack space due to stack no longer mapped.\n"); in stest_thread_launch()
354 zassert_equal(ret, 0, "failed to calculate unused stack space\n"); in stest_thread_launch()
355 printk("target thread unused stack space: %zu\n", unused); in stest_thread_launch()
376 printk("stack may host user thread, size in metadata is %zu\n", in scenario_entry()
385 scenario_data.stack = stack_obj; in scenario_entry()
393 printk("Stack object %p[%zu]\n", stack_obj, obj_size); in scenario_entry()
408 * @brief Test kernel provides user thread read/write access to its own stack
411 * @details Thread can access its own stack memory buffer and perform
428 printk("irq stack %d: %p size %zu\n", in ZTEST()
433 printk("Provided stack size: %u\n", STEST_STACKSIZE); in ZTEST()
460 scenario_entry(&stest_member_stack.stack, in ZTEST()
461 sizeof(stest_member_stack.stack), in ZTEST()
462 K_KERNEL_STACK_SIZEOF(stest_member_stack.stack), in ZTEST()
483 * @brief Show that the idle thread stack size is correct
486 * Exercise this and show that we didn't overflow, reporting out stack
495 * the idle stack may have been initialized on a in ZTEST()
525 /* Now measure idle thread stack usage */ in ZTEST()
527 zassert_true(ret == 0, "failed to obtain stack space"); in ZTEST()
528 zassert_true(unused_bytes > 0, "idle thread stack size %d too low", in ZTEST()
530 printk("unused idle thread stack size: %zu/%d (%zu used)\n", in ZTEST()