mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
sched/addrenv, binfmt: Always allocate address environment from heap
Instead of using a volatile storage for the address environment in the binfmt / loadinfo structures, always allocate the address environment from kheap. This serves two purposes: - If the task creation fails, any kernel thread that depends on the address environment created during task creation will not lose their mappings (because they hold a reference to it) - The current address environment variable (g_addrenv) will NEVER contain a stale / incorrect value - Releasing the address environment is simplified as any pointer given to addrenv_drop() can be assumed to be heap memory - Makes the kludge function addrenv_clear_current irrelevant, as the system will NEVER have invalid mappings any more
This commit is contained in:
@@ -117,7 +117,7 @@ int exec_module(FAR struct binary_s *binp,
|
||||
{
|
||||
FAR struct task_tcb_s *tcb;
|
||||
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
|
||||
FAR struct arch_addrenv_s *addrenv = &binp->addrenv.addrenv;
|
||||
FAR struct arch_addrenv_s *addrenv = &binp->addrenv->addrenv;
|
||||
FAR void *vheap;
|
||||
#endif
|
||||
FAR void *stackaddr = NULL;
|
||||
@@ -165,7 +165,7 @@ int exec_module(FAR struct binary_s *binp,
|
||||
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
|
||||
/* Instantiate the address environment containing the user heap */
|
||||
|
||||
ret = addrenv_select(&binp->addrenv);
|
||||
ret = addrenv_select(binp->addrenv);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: addrenv_select() failed: %d\n", ret);
|
||||
@@ -242,7 +242,7 @@ int exec_module(FAR struct binary_s *binp,
|
||||
#ifdef CONFIG_ARCH_ADDRENV
|
||||
/* Attach the address environment to the new task */
|
||||
|
||||
ret = addrenv_attach((FAR struct tcb_s *)tcb, &binp->addrenv);
|
||||
ret = addrenv_attach((FAR struct tcb_s *)tcb, binp->addrenv);
|
||||
if (ret < 0)
|
||||
{
|
||||
berr("ERROR: addrenv_attach() failed: %d\n", ret);
|
||||
|
||||
Reference in New Issue
Block a user