task_fork.c: Fix vfork for BUILD_KERNEL
Two things need to be done when vfork'ing: - Must attach to parent's address environment (the addrenv is shared) - Must allocate a kernel stack (where would the register context go otherwise) Note that this code assumes the address environment is shared, since we don't support fork() which would _clone_ the address environment instead.
This commit is contained in:
parent
3c05da536a
commit
6047a9fe14
@ -145,6 +145,19 @@ FAR struct task_tcb_s *nxtask_setup_fork(start_t retaddr)
|
||||
|
||||
child->cmn.flags |= TCB_FLAG_FREE_TCB;
|
||||
|
||||
#if defined(CONFIG_ARCH_ADDRENV)
|
||||
/* Join the parent address environment (REVISIT: vfork() only) */
|
||||
|
||||
if (ttype != TCB_FLAG_TTYPE_KERNEL)
|
||||
{
|
||||
ret = addrenv_join(parent, &child->cmn);
|
||||
if (ret < 0)
|
||||
{
|
||||
goto errout_with_tcb;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Initialize the task join */
|
||||
|
||||
nxtask_joininit(&child->cmn);
|
||||
@ -184,6 +197,19 @@ FAR struct task_tcb_s *nxtask_setup_fork(start_t retaddr)
|
||||
goto errout_with_tcb;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_ARCH_KERNEL_STACK)
|
||||
/* Allocate the kernel stack */
|
||||
|
||||
if (ttype != TCB_FLAG_TTYPE_KERNEL)
|
||||
{
|
||||
ret = up_addrenv_kstackalloc(&child->cmn);
|
||||
if (ret < 0)
|
||||
{
|
||||
goto errout_with_tcb;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Setup thread local storage */
|
||||
|
||||
ret = tls_dup_info(&child->cmn, parent);
|
||||
|
Loading…
Reference in New Issue
Block a user