mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 11:56:10 +08:00
sched/task: move kernel stack allocation to task initialization
Move kernel stack allocation from exec_module() (binary format execution) to nxtask_init() (task initialization) with proper type checking. Add conditional check to allocate kernel stack only for non-kernel tasks (ttype != TCB_FLAG_TTYPE_KERNEL). Enables kernel stack allocation for both exec'd tasks and regular task_create() calls in protected builds, allowing userspace to create tasks with proper kernel stack isolation. Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
@@ -240,17 +240,6 @@ int exec_module(FAR struct binary_s *binp,
|
||||
umm_initialize(vheap, up_addrenv_heapsize(addrenv));
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_ARCH_KERNEL_STACK)
|
||||
/* Allocate the kernel stack */
|
||||
|
||||
ret = up_addrenv_kstackalloc(tcb);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: up_addrenv_kstackalloc() failed: %d\n", ret);
|
||||
goto errout_with_addrenv;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Note that tcb->flags are not modified. 0=normal task */
|
||||
|
||||
/* tcb->flags |= TCB_FLAG_TTYPE_TASK; */
|
||||
|
||||
Reference in New Issue
Block a user