MCPcopy Create free account
hub / github.com/F-Stack/f-stack / userret

Function userret

freebsd/kern/subr_trap.c:96–194  ·  view source on GitHub ↗

* Define the code needed before returning to user mode, for trap and * syscall. */

Source from the content-addressed store, hash-verified

94 * syscall.
95 */
96void
97userret(struct thread *td, struct trapframe *frame)
98{
99 struct proc *p = td->td_proc;
100
101 CTR3(KTR_SYSC, "userret: thread %p (pid %d, %s)", td, p->p_pid,
102 td->td_name);
103 KASSERT((p->p_flag & P_WEXIT) == 0,
104 ("Exiting process returns to usermode"));
105#ifdef DIAGNOSTIC
106 /*
107 * Check that we called signotify() enough. For
108 * multi-threaded processes, where signal distribution might
109 * change due to other threads changing sigmask, the check is
110 * racy and cannot be performed reliably.
111 * If current process is vfork child, indicated by P_PPWAIT, then
112 * issignal() ignores stops, so we block the check to avoid
113 * classifying pending signals.
114 */
115 if (p->p_numthreads == 1) {
116 PROC_LOCK(p);
117 thread_lock(td);
118 if ((p->p_flag & P_PPWAIT) == 0 &&
119 (td->td_pflags & TDP_SIGFASTBLOCK) == 0) {
120 if (SIGPENDING(td) && (td->td_flags &
121 (TDF_NEEDSIGCHK | TDF_ASTPENDING)) !=
122 (TDF_NEEDSIGCHK | TDF_ASTPENDING)) {
123 thread_unlock(td);
124 panic(
125 "failed to set signal flags for ast p %p td %p fl %x",
126 p, td, td->td_flags);
127 }
128 }
129 thread_unlock(td);
130 PROC_UNLOCK(p);
131 }
132#endif
133
134 /*
135 * Charge system time if profiling.
136 */
137 if (__predict_false(p->p_flag & P_PROFIL))
138 addupc_task(td, TRAPF_PC(frame), td->td_pticks * psratio);
139
140#ifdef HWPMC_HOOKS
141 if (PMC_THREAD_HAS_SAMPLES(td))
142 PMC_CALL_HOOK(td, PMC_FN_THR_USERRET, NULL);
143#endif
144 /*
145 * Let the scheduler adjust our priority etc.
146 */
147 sched_userret(td);
148
149 /*
150 * Check for misbehavior.
151 *
152 * In case there is a callchain tracing ongoing because of
153 * hwpmc(4), skip the scheduler pinning check.

Callers 14

trapFunction · 0.85
trapFunction · 0.85
trapFunction · 0.85
svc_handlerFunction · 0.85
align_abortFunction · 0.85
data_abortFunction · 0.85
do_el0_syncFunction · 0.85
abort_impreciseFunction · 0.85
abort_debugFunction · 0.85
abort_handlerFunction · 0.85
undefinedinstructionFunction · 0.85
syscallretFunction · 0.85

Calls 4

addupc_taskFunction · 0.85
sched_userretFunction · 0.85
epoch_trace_listFunction · 0.85
panicFunction · 0.70

Tested by

no test coverage detected