mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +08:00
addrenv/kstack: Allocate the kernel stack before initializing tcb
This is preparation to use kernel stack for everything when the user process enters the kernel. Now the user stack is in use when the user process runs a system call, which might not be the safest option.
This commit is contained in:
+11
-11
@@ -186,6 +186,17 @@ 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->cmn);
|
||||
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; */
|
||||
@@ -229,17 +240,6 @@ int exec_module(FAR struct binary_s *binp,
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_ARCH_KERNEL_STACK)
|
||||
/* Allocate the kernel stack */
|
||||
|
||||
ret = up_addrenv_kstackalloc(&tcb->cmn);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: up_addrenv_kstackalloc() failed: %d\n", ret);
|
||||
goto errout_with_tcbinit;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PIC
|
||||
/* Add the D-Space address as the PIC base address. By convention, this
|
||||
* must be the first allocated address space.
|
||||
|
||||
Reference in New Issue
Block a user