]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Ensure "init" (PID 1) also executes userret() initially
authorOlivier Certner <olce.freebsd@certner.fr>
Tue, 10 Oct 2023 17:36:20 +0000 (19:36 +0200)
committerMark Johnston <markj@FreeBSD.org>
Thu, 2 Nov 2023 13:30:03 +0000 (09:30 -0400)
commiteac624207ccf3a16225368d226861b06e3631d0d
tree17f7bb7751b816e15b06183637a3ba530a73a580
parent56bb3ce091371ffd95711c65e1eff306a19435e2
Ensure "init" (PID 1) also executes userret() initially

Calling userret() from fork_return() misses the first return to
userspace of the "init" (PID 1) process.  The latter is indeed created
by fork1() followed by a call to cpu_fork_kthread_handler() call that
replaces fork_return() by start_init() as the function to execute after
fork.

A new process' initial return to userspace in the end always happens
through returning from fork_exit(), so move userret() there instead to
fix the omission.

This problem was discovered as part of a revamp of scheduling priorities
that lead to experimenting with asserting and sometimes resetting
priorities in sched_userret(), in the course of which the author
stumbled on panics being triggered only in init() or only in other
processes, depending on the modifications to sched_userret().  This
change currently has no practical effect but will have some in the near
future.

Reviewed by:            markj, kib
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D42257
sys/kern/kern_fork.c