[RFC PATCH 06/13] x86/um: nommu: process/thread handling

Hajime Tazaki thehajime at gmail.com
Fri Oct 25 05:58:37 PDT 2024


On Fri, 25 Oct 2024 18:22:29 +0900,
Johannes Berg wrote:
> 
> 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

thanks. (I thought checkpatch.pl detects them..)

> >  /* 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"

will fix it.

> > @@ -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.

(indeed)

> > +#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"

will fix it.

> > +		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 :)

this is my mistake; forgot to remove those private tags.
will fix it.

-- Hajime



More information about the linux-um mailing list