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:
hujun5
2025-05-06 18:45:05 +08:00
committed by GUIDINGLI
parent a9d9dd2120
commit 6f4cb9f457
2 changed files with 13 additions and 11 deletions
-11
View File
@@ -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; */