On Thu, 2024-10-24 at 21:09 +0900, Hajime Tazaki wrote:
> Since ptrace facility isn't used under !MMU of UML, there is different
> code path to invoke proceeses/threads; on an entry to the syscall

typo: processes

>  /* Called magically, see new_thread_handler above */
>  static void fork_handler(void)
>  {
> -     schedule_tail(current->thread.prev_sched);
> +     if (current->thread.prev_sched != NULL)

nit: no need for "!= NULL"

> @@ -134,6 +138,21 @@ static void fork_handler(void)
>  
>       current->thread.prev_sched = NULL;
>  
> +#ifndef CONFIG_MMU
> +     /*
> +      * This fork can only come from libc's vfork, which
> +      * does this:
> +      *      popq %%rdx;
> +      *      call *%0; // vsyscall
> +      *      pushq %%rdx;
> +      * %rdx stores the return address which is stored
> +      * at pt_regs[HOST_IP] at the moment. We still
> +      * need to pop the pushed address by "call" though,
> +      * so this is what this next line does.
> +      */
> +     if (current->thread.regs.regs.gp[HOST_ORIG_AX] == __NR_vfork)
> +             current->thread.regs.regs.gp[REGS_SP_INDEX] += 8;
> +#endif

Kind of ugly ... but I guess not much choice.

> +#ifndef CONFIG_MMU
> +     current_top_of_stack = task_top_of_stack(to);
> +     current_ptregs = (long)task_pt_regs(to);
> +
> +     if ((to->thread.regs.regs.gp[FS_BASE / sizeof(unsigned long)] == 0)
> +         || (to->mm == NULL))

Put || on the previous line, "!to->mm"

> +             return;
> +
> +     // rkj: this changes the FS on every context switch

Not sure we're allowing C99 comments yet, and there shouldn't be a "rkj"
tag either :)

johannes

Reply via email to