Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_thread.c
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
#include <sys/ktr.h> | #include <sys/ktr.h> | ||||
#include <sys/rwlock.h> | #include <sys/rwlock.h> | ||||
#include <sys/umtx.h> | #include <sys/umtx.h> | ||||
#include <sys/vmmeter.h> | #include <sys/vmmeter.h> | ||||
#include <sys/cpuset.h> | #include <sys/cpuset.h> | ||||
#ifdef HWPMC_HOOKS | #ifdef HWPMC_HOOKS | ||||
#include <sys/pmckern.h> | #include <sys/pmckern.h> | ||||
#endif | #endif | ||||
#ifdef VIMAGE | |||||
#include <sys/jail.h> | |||||
#endif | |||||
#include <security/audit/audit.h> | #include <security/audit/audit.h> | ||||
#include <vm/vm.h> | #include <vm/vm.h> | ||||
#include <vm/vm_extern.h> | #include <vm/vm_extern.h> | ||||
#include <vm/uma.h> | #include <vm/uma.h> | ||||
#include <sys/eventhandler.h> | #include <sys/eventhandler.h> | ||||
Show All 9 Lines | |||||
*/ | */ | ||||
#ifdef __amd64__ | #ifdef __amd64__ | ||||
_Static_assert(offsetof(struct thread, td_flags) == 0xfc, | _Static_assert(offsetof(struct thread, td_flags) == 0xfc, | ||||
"struct thread KBI td_flags"); | "struct thread KBI td_flags"); | ||||
_Static_assert(offsetof(struct thread, td_pflags) == 0x104, | _Static_assert(offsetof(struct thread, td_pflags) == 0x104, | ||||
"struct thread KBI td_pflags"); | "struct thread KBI td_pflags"); | ||||
_Static_assert(offsetof(struct thread, td_frame) == 0x470, | _Static_assert(offsetof(struct thread, td_frame) == 0x470, | ||||
"struct thread KBI td_frame"); | "struct thread KBI td_frame"); | ||||
_Static_assert(offsetof(struct thread, td_emuldata) == 0x518, | _Static_assert(offsetof(struct thread, td_emuldata) == 0x528, | ||||
"struct thread KBI td_emuldata"); | "struct thread KBI td_emuldata"); | ||||
_Static_assert(offsetof(struct proc, p_flag) == 0xb0, | _Static_assert(offsetof(struct proc, p_flag) == 0xb0, | ||||
"struct proc KBI p_flag"); | "struct proc KBI p_flag"); | ||||
_Static_assert(offsetof(struct proc, p_pid) == 0xbc, | _Static_assert(offsetof(struct proc, p_pid) == 0xbc, | ||||
"struct proc KBI p_pid"); | "struct proc KBI p_pid"); | ||||
_Static_assert(offsetof(struct proc, p_filemon) == 0x3d0, | _Static_assert(offsetof(struct proc, p_filemon) == 0x3d0, | ||||
"struct proc KBI p_filemon"); | "struct proc KBI p_filemon"); | ||||
_Static_assert(offsetof(struct proc, p_comm) == 0x3e4, | _Static_assert(offsetof(struct proc, p_comm) == 0x3e4, | ||||
"struct proc KBI p_comm"); | "struct proc KBI p_comm"); | ||||
_Static_assert(offsetof(struct proc, p_emuldata) == 0x4b8, | _Static_assert(offsetof(struct proc, p_emuldata) == 0x4b8, | ||||
"struct proc KBI p_emuldata"); | "struct proc KBI p_emuldata"); | ||||
#endif | #endif | ||||
#ifdef __i386__ | #ifdef __i386__ | ||||
_Static_assert(offsetof(struct thread, td_flags) == 0x98, | _Static_assert(offsetof(struct thread, td_flags) == 0x98, | ||||
"struct thread KBI td_flags"); | "struct thread KBI td_flags"); | ||||
_Static_assert(offsetof(struct thread, td_pflags) == 0xa0, | _Static_assert(offsetof(struct thread, td_pflags) == 0xa0, | ||||
"struct thread KBI td_pflags"); | "struct thread KBI td_pflags"); | ||||
_Static_assert(offsetof(struct thread, td_frame) == 0x2e8, | _Static_assert(offsetof(struct thread, td_frame) == 0x2e8, | ||||
"struct thread KBI td_frame"); | "struct thread KBI td_frame"); | ||||
_Static_assert(offsetof(struct thread, td_emuldata) == 0x334, | _Static_assert(offsetof(struct thread, td_emuldata) == 0x33c, | ||||
"struct thread KBI td_emuldata"); | "struct thread KBI td_emuldata"); | ||||
_Static_assert(offsetof(struct proc, p_flag) == 0x68, | _Static_assert(offsetof(struct proc, p_flag) == 0x68, | ||||
"struct proc KBI p_flag"); | "struct proc KBI p_flag"); | ||||
_Static_assert(offsetof(struct proc, p_pid) == 0x74, | _Static_assert(offsetof(struct proc, p_pid) == 0x74, | ||||
"struct proc KBI p_pid"); | "struct proc KBI p_pid"); | ||||
_Static_assert(offsetof(struct proc, p_filemon) == 0x27c, | _Static_assert(offsetof(struct proc, p_filemon) == 0x27c, | ||||
"struct proc KBI p_filemon"); | "struct proc KBI p_filemon"); | ||||
_Static_assert(offsetof(struct proc, p_comm) == 0x28c, | _Static_assert(offsetof(struct proc, p_comm) == 0x28c, | ||||
▲ Show 20 Lines • Show All 331 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
void | void | ||||
thread_cow_get_proc(struct thread *newtd, struct proc *p) | thread_cow_get_proc(struct thread *newtd, struct proc *p) | ||||
{ | { | ||||
PROC_LOCK_ASSERT(p, MA_OWNED); | PROC_LOCK_ASSERT(p, MA_OWNED); | ||||
newtd->td_ucred = crhold(p->p_ucred); | newtd->td_ucred = crhold(p->p_ucred); | ||||
#ifdef VIMAGE | |||||
/* Make sure the cached vps stays correct. */ | |||||
newtd->td_vps = p->p_ucred->cr_prison->pr_vps; | |||||
#endif | |||||
newtd->td_limit = lim_hold(p->p_limit); | newtd->td_limit = lim_hold(p->p_limit); | ||||
newtd->td_cowgen = p->p_cowgen; | newtd->td_cowgen = p->p_cowgen; | ||||
} | } | ||||
void | void | ||||
thread_cow_get(struct thread *newtd, struct thread *td) | thread_cow_get(struct thread *newtd, struct thread *td) | ||||
{ | { | ||||
newtd->td_ucred = crhold(td->td_ucred); | newtd->td_ucred = crhold(td->td_ucred); | ||||
#ifdef VIMAGE | |||||
/* Make sure to inherit the cached vps as well. */ | |||||
newtd->td_vps = td->td_vps; | |||||
#endif | |||||
newtd->td_limit = lim_hold(td->td_limit); | newtd->td_limit = lim_hold(td->td_limit); | ||||
newtd->td_cowgen = td->td_cowgen; | newtd->td_cowgen = td->td_cowgen; | ||||
} | } | ||||
void | void | ||||
thread_cow_free(struct thread *td) | thread_cow_free(struct thread *td) | ||||
{ | { | ||||
Show All 13 Lines | thread_cow_update(struct thread *td) | ||||
p = td->td_proc; | p = td->td_proc; | ||||
oldcred = NULL; | oldcred = NULL; | ||||
oldlimit = NULL; | oldlimit = NULL; | ||||
PROC_LOCK(p); | PROC_LOCK(p); | ||||
if (td->td_ucred != p->p_ucred) { | if (td->td_ucred != p->p_ucred) { | ||||
oldcred = td->td_ucred; | oldcred = td->td_ucred; | ||||
td->td_ucred = crhold(p->p_ucred); | td->td_ucred = crhold(p->p_ucred); | ||||
} | } | ||||
#ifdef VIMAGE | |||||
/* Make sure the cached vps stays correct. */ | |||||
if (td->td_vps != p->p_ucred->cr_prison->pr_vps) | |||||
td->td_vps = p->p_ucred->cr_prison->pr_vps; | |||||
#endif | |||||
if (td->td_limit != p->p_limit) { | if (td->td_limit != p->p_limit) { | ||||
oldlimit = td->td_limit; | oldlimit = td->td_limit; | ||||
td->td_limit = lim_hold(p->p_limit); | td->td_limit = lim_hold(p->p_limit); | ||||
} | } | ||||
td->td_cowgen = p->p_cowgen; | td->td_cowgen = p->p_cowgen; | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
if (oldcred != NULL) | if (oldcred != NULL) | ||||
crfree(oldcred); | crfree(oldcred); | ||||
▲ Show 20 Lines • Show All 768 Lines • Show Last 20 Lines |