patacongo commented on a change in pull request #3626:
URL: https://github.com/apache/incubator-nuttx/pull/3626#discussion_r623914937



##########
File path: arch/arm/src/armv7-a/arm_syscall.c
##########
@@ -290,19 +290,21 @@ uint32_t *arm_syscall(uint32_t *regs)
        *   R2 = arg
        */
 
-#if defined(CONFIG_BUILD_KERNEL) && !defined(CONFIG_DISABLE_PTHREAD)
+#if !defined(CONFIG_BUILD_FLAT) && !defined(CONFIG_DISABLE_PTHREAD)
       case SYS_pthread_start:
         {
           /* Set up to return to the user-space pthread start-up function in
            * unprivileged mode. We need:
            *
-           *   R0   = arg
-           *   PC   = entrypt
+           *   R0   = entrypt
+           *   R1   = arg
+           *   PC   = startup
            *   CSPR = user mode
            */
 

Review comment:
       In order to start a pthread in the the KERNEL mode, we will need to make 
sure that the proper application address space is selected.  this should be 
doable by calling `group_addrenv(tcb)`.  Otherwise, we might start the pthread 
in the address environment of some other process.
   
   I don't see that being done.  Hmm... maybe I am wrong.  
sched/pthread/pthread_create.c does do:
   
       #ifdef CONFIG_ARCH_ADDRENV
         /* Share the address environment of the parent task group. */
       
         ret = up_addrenv_attach(ptcb->cmn.group, this_task());
         if (ret < 0)
           {
             errcode = -ret;
             goto errout_with_tcb;
           }
       #endif
   
   Does that do the job?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to