Do not call FreeBSD-ABI specific code for all ABIs
Use sysentvec hooks to only call umtx_thread_exit/umtx_exec, which handle robust mutexes, for native FreeBSD ABI. Similarly, there is no sense in calling sigfastblock_clear() for non-native ABIs. Requested by: dchagin Reviewed by: dchagin, markj (previous version) Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D30987
This commit is contained in:
@@ -85,6 +85,8 @@ struct sysentvec elf64_freebsd_sysvec_la48 = {
|
|||||||
.sv_thread_detach = NULL,
|
.sv_thread_detach = NULL,
|
||||||
.sv_trap = NULL,
|
.sv_trap = NULL,
|
||||||
.sv_stackgap = elf64_stackgap,
|
.sv_stackgap = elf64_stackgap,
|
||||||
|
.sv_onexec_old = exec_onexec_old,
|
||||||
|
.sv_onexit = exit_onexit,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sysentvec elf64_freebsd_sysvec_la57 = {
|
struct sysentvec elf64_freebsd_sysvec_la57 = {
|
||||||
@@ -123,6 +125,8 @@ struct sysentvec elf64_freebsd_sysvec_la57 = {
|
|||||||
.sv_thread_detach = NULL,
|
.sv_thread_detach = NULL,
|
||||||
.sv_trap = NULL,
|
.sv_trap = NULL,
|
||||||
.sv_stackgap = elf64_stackgap,
|
.sv_stackgap = elf64_stackgap,
|
||||||
|
.sv_onexec_old = exec_onexec_old,
|
||||||
|
.sv_onexit = exit_onexit,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@@ -100,6 +100,8 @@ struct sysentvec elf32_freebsd_sysvec = {
|
|||||||
.sv_trap = NULL,
|
.sv_trap = NULL,
|
||||||
.sv_hwcap = &elf_hwcap,
|
.sv_hwcap = &elf_hwcap,
|
||||||
.sv_hwcap2 = &elf_hwcap2,
|
.sv_hwcap2 = &elf_hwcap2,
|
||||||
|
.sv_onexec_old = exec_onexec_old,
|
||||||
|
.sv_onexit = exit_onexit,
|
||||||
};
|
};
|
||||||
INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec);
|
INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec);
|
||||||
|
|
||||||
|
|||||||
@@ -112,6 +112,8 @@ static struct sysentvec elf32_freebsd_sysvec = {
|
|||||||
.sv_schedtail = NULL,
|
.sv_schedtail = NULL,
|
||||||
.sv_thread_detach = NULL,
|
.sv_thread_detach = NULL,
|
||||||
.sv_trap = NULL,
|
.sv_trap = NULL,
|
||||||
|
.sv_onexec_old = exec_onexec_old,
|
||||||
|
.sv_onexit = exit_onexit,
|
||||||
};
|
};
|
||||||
INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec);
|
INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec);
|
||||||
|
|
||||||
|
|||||||
@@ -95,6 +95,8 @@ static struct sysentvec elf64_freebsd_sysvec = {
|
|||||||
.sv_trap = NULL,
|
.sv_trap = NULL,
|
||||||
.sv_hwcap = &elf_hwcap,
|
.sv_hwcap = &elf_hwcap,
|
||||||
.sv_hwcap2 = &elf_hwcap2,
|
.sv_hwcap2 = &elf_hwcap2,
|
||||||
|
.sv_onexec_old = exec_onexec_old,
|
||||||
|
.sv_onexit = exit_onexit,
|
||||||
};
|
};
|
||||||
INIT_SYSENTVEC(elf64_sysvec, &elf64_freebsd_sysvec);
|
INIT_SYSENTVEC(elf64_sysvec, &elf64_freebsd_sysvec);
|
||||||
|
|
||||||
|
|||||||
@@ -131,6 +131,8 @@ struct sysentvec ia32_freebsd_sysvec = {
|
|||||||
.sv_thread_detach = NULL,
|
.sv_thread_detach = NULL,
|
||||||
.sv_trap = NULL,
|
.sv_trap = NULL,
|
||||||
.sv_stackgap = elf32_stackgap,
|
.sv_stackgap = elf32_stackgap,
|
||||||
|
.sv_onexec_old = exec_onexec_old,
|
||||||
|
.sv_onexit = exit_onexit,
|
||||||
};
|
};
|
||||||
INIT_SYSENTVEC(elf_ia32_sysvec, &ia32_freebsd_sysvec);
|
INIT_SYSENTVEC(elf_ia32_sysvec, &ia32_freebsd_sysvec);
|
||||||
|
|
||||||
|
|||||||
@@ -86,6 +86,8 @@ struct sysentvec elf32_freebsd_sysvec = {
|
|||||||
.sv_schedtail = NULL,
|
.sv_schedtail = NULL,
|
||||||
.sv_thread_detach = NULL,
|
.sv_thread_detach = NULL,
|
||||||
.sv_trap = NULL,
|
.sv_trap = NULL,
|
||||||
|
.sv_onexec_old = exec_onexec_old,
|
||||||
|
.sv_onexit = exit_onexit,
|
||||||
};
|
};
|
||||||
INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec);
|
INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec);
|
||||||
|
|
||||||
|
|||||||
@@ -101,6 +101,8 @@ struct sysentvec aout_sysvec = {
|
|||||||
.sv_schedtail = NULL,
|
.sv_schedtail = NULL,
|
||||||
.sv_thread_detach = NULL,
|
.sv_thread_detach = NULL,
|
||||||
.sv_trap = NULL,
|
.sv_trap = NULL,
|
||||||
|
.sv_onexec_old = exec_onexec_old,
|
||||||
|
.sv_onexit = exit_onexit,
|
||||||
};
|
};
|
||||||
|
|
||||||
#elif defined(__amd64__)
|
#elif defined(__amd64__)
|
||||||
@@ -137,6 +139,8 @@ struct sysentvec aout_sysvec = {
|
|||||||
.sv_set_syscall_retval = ia32_set_syscall_retval,
|
.sv_set_syscall_retval = ia32_set_syscall_retval,
|
||||||
.sv_fetch_syscall_args = ia32_fetch_syscall_args,
|
.sv_fetch_syscall_args = ia32_fetch_syscall_args,
|
||||||
.sv_syscallnames = freebsd32_syscallnames,
|
.sv_syscallnames = freebsd32_syscallnames,
|
||||||
|
.sv_onexec_old = exec_onexec_old,
|
||||||
|
.sv_onexit = exit_onexit,
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
#error "Port me"
|
#error "Port me"
|
||||||
|
|||||||
@@ -1040,6 +1040,13 @@ exec_unmap_first_page(struct image_params *imgp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
exec_onexec_old(struct thread *td)
|
||||||
|
{
|
||||||
|
sigfastblock_clear(td);
|
||||||
|
umtx_exec(td->td_proc);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Destroy old address space, and allocate a new stack.
|
* Destroy old address space, and allocate a new stack.
|
||||||
* The new stack is only sgrowsiz large because it is grown
|
* The new stack is only sgrowsiz large because it is grown
|
||||||
@@ -1062,8 +1069,6 @@ exec_new_vmspace(struct image_params *imgp, struct sysentvec *sv)
|
|||||||
imgp->vmspace_destroyed = 1;
|
imgp->vmspace_destroyed = 1;
|
||||||
imgp->sysent = sv;
|
imgp->sysent = sv;
|
||||||
|
|
||||||
sigfastblock_clear(td);
|
|
||||||
umtx_exec(p);
|
|
||||||
if (p->p_sysent->sv_onexec_old != NULL)
|
if (p->p_sysent->sv_onexec_old != NULL)
|
||||||
p->p_sysent->sv_onexec_old(td);
|
p->p_sysent->sv_onexec_old(td);
|
||||||
itimers_exec(p);
|
itimers_exec(p);
|
||||||
|
|||||||
@@ -195,6 +195,13 @@ proc_clear_orphan(struct proc *p)
|
|||||||
p->p_treeflag &= ~P_TREE_ORPHANED;
|
p->p_treeflag &= ~P_TREE_ORPHANED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
exit_onexit(struct proc *p)
|
||||||
|
{
|
||||||
|
MPASS(p->p_numthreads == 1);
|
||||||
|
umtx_thread_exit(FIRST_THREAD_IN_PROC(p));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* exit -- death of process.
|
* exit -- death of process.
|
||||||
*/
|
*/
|
||||||
@@ -370,7 +377,6 @@ exit1(struct thread *td, int rval, int signo)
|
|||||||
|
|
||||||
PROC_UNLOCK(p);
|
PROC_UNLOCK(p);
|
||||||
|
|
||||||
umtx_thread_exit(td);
|
|
||||||
if (p->p_sysent->sv_onexit != NULL)
|
if (p->p_sysent->sv_onexit != NULL)
|
||||||
p->p_sysent->sv_onexit(p);
|
p->p_sysent->sv_onexit(p);
|
||||||
seltdfini(td);
|
seltdfini(td);
|
||||||
|
|||||||
@@ -91,6 +91,8 @@ static struct sysentvec elf_freebsd_sysvec = {
|
|||||||
.sv_schedtail = NULL,
|
.sv_schedtail = NULL,
|
||||||
.sv_thread_detach = NULL,
|
.sv_thread_detach = NULL,
|
||||||
.sv_trap = NULL,
|
.sv_trap = NULL,
|
||||||
|
.sv_onexec_old = exec_onexec_old,
|
||||||
|
.sv_onexit = exit_onexit,
|
||||||
};
|
};
|
||||||
|
|
||||||
static __ElfN(Brandinfo) freebsd_brand_info = {
|
static __ElfN(Brandinfo) freebsd_brand_info = {
|
||||||
|
|||||||
@@ -134,6 +134,8 @@ struct sysentvec elf32_freebsd_sysvec = {
|
|||||||
.sv_trap = NULL,
|
.sv_trap = NULL,
|
||||||
.sv_hwcap = &cpu_features,
|
.sv_hwcap = &cpu_features,
|
||||||
.sv_hwcap2 = &cpu_features2,
|
.sv_hwcap2 = &cpu_features2,
|
||||||
|
.sv_onexec_old = exec_onexec_old,
|
||||||
|
.sv_onexit = exit_onexit,
|
||||||
};
|
};
|
||||||
INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec);
|
INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec);
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,8 @@ struct sysentvec elf64_freebsd_sysvec_v1 = {
|
|||||||
.sv_trap = NULL,
|
.sv_trap = NULL,
|
||||||
.sv_hwcap = &cpu_features,
|
.sv_hwcap = &cpu_features,
|
||||||
.sv_hwcap2 = &cpu_features2,
|
.sv_hwcap2 = &cpu_features2,
|
||||||
|
.sv_onexec_old = exec_onexec_old,
|
||||||
|
.sv_onexit = exit_onexit,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sysentvec elf64_freebsd_sysvec_v2 = {
|
struct sysentvec elf64_freebsd_sysvec_v2 = {
|
||||||
@@ -135,6 +137,8 @@ struct sysentvec elf64_freebsd_sysvec_v2 = {
|
|||||||
.sv_trap = NULL,
|
.sv_trap = NULL,
|
||||||
.sv_hwcap = &cpu_features,
|
.sv_hwcap = &cpu_features,
|
||||||
.sv_hwcap2 = &cpu_features2,
|
.sv_hwcap2 = &cpu_features2,
|
||||||
|
.sv_onexec_old = exec_onexec_old,
|
||||||
|
.sv_onexit = exit_onexit,
|
||||||
};
|
};
|
||||||
|
|
||||||
static boolean_t ppc64_elfv1_header_match(struct image_params *params,
|
static boolean_t ppc64_elfv1_header_match(struct image_params *params,
|
||||||
|
|||||||
@@ -99,6 +99,8 @@ struct sysentvec elf64_freebsd_sysvec = {
|
|||||||
.sv_trap = NULL,
|
.sv_trap = NULL,
|
||||||
.sv_hwcap = &elf_hwcap,
|
.sv_hwcap = &elf_hwcap,
|
||||||
.sv_machine_arch = riscv_machine_arch,
|
.sv_machine_arch = riscv_machine_arch,
|
||||||
|
.sv_onexec_old = exec_onexec_old,
|
||||||
|
.sv_onexit = exit_onexit,
|
||||||
};
|
};
|
||||||
INIT_SYSENTVEC(elf64_sysvec, &elf64_freebsd_sysvec);
|
INIT_SYSENTVEC(elf64_sysvec, &elf64_freebsd_sysvec);
|
||||||
|
|
||||||
|
|||||||
@@ -322,6 +322,9 @@ void exec_sysvec_init(void *param);
|
|||||||
void exec_sysvec_init_secondary(struct sysentvec *sv, struct sysentvec *sv2);
|
void exec_sysvec_init_secondary(struct sysentvec *sv, struct sysentvec *sv2);
|
||||||
void exec_inittk(void);
|
void exec_inittk(void);
|
||||||
|
|
||||||
|
void exit_onexit(struct proc *p);
|
||||||
|
void exec_onexec_old(struct thread *td);
|
||||||
|
|
||||||
#define INIT_SYSENTVEC(name, sv) \
|
#define INIT_SYSENTVEC(name, sv) \
|
||||||
SYSINIT(name, SI_SUB_EXEC, SI_ORDER_ANY, \
|
SYSINIT(name, SI_SUB_EXEC, SI_ORDER_ANY, \
|
||||||
(sysinit_cfunc_t)exec_sysvec_init, sv);
|
(sysinit_cfunc_t)exec_sysvec_init, sv);
|
||||||
|
|||||||
Reference in New Issue
Block a user