/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2006 Roman Divacky4* All rights reserved.5* Copyright (c) 2013 Dmitry Chagin <[email protected]>6*7* Redistribution and use in source and binary forms, with or without8* modification, are permitted provided that the following conditions9* are met:10* 1. Redistributions of source code must retain the above copyright11* notice, this list of conditions and the following disclaimer.12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15*16* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND17* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE18* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE19* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE20* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL21* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS22* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)23* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT24* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26* SUCH DAMAGE.27*/2829#ifndef _LINUX_EMUL_H_30#define _LINUX_EMUL_H_3132struct image_params;3334/*35* modeled after similar structure in NetBSD36* this will be extended as we need more functionality37*/38struct linux_emuldata {39int *child_set_tid; /* in clone(): Child's TID to set on clone */40int *child_clear_tid;/* in clone(): Child's TID to clear on exit */4142int flags; /* thread emuldata flags */43int em_tid; /* thread id */4445struct linux_robust_list_head *robust_futexes;46};4748struct linux_emuldata *em_find(struct thread *);4950void linux_proc_init(struct thread *, struct thread *, bool);51void linux_on_exit(struct proc *);52void linux_schedtail(struct thread *);53int linux_on_exec(struct proc *, struct image_params *);54void linux_thread_dtor(struct thread *);55int linux_common_execve(struct thread *, struct image_args *);5657/* process emuldata flags */58#define LINUX_XDEPR_REQUEUEOP 0x00000001 /* uses deprecated59futex REQUEUE op*/60#define LINUX_XUNSUP_EPOLL 0x00000002 /* unsupported epoll events */61#define LINUX_XUNSUP_FUTEXPIOP 0x00000004 /* uses unsupported pi futex */6263struct linux_pemuldata {64uint32_t flags; /* process emuldata flags */65struct sx pem_sx; /* lock for this struct */66uint32_t persona; /* process execution domain */67uint32_t ptrace_flags; /* used by ptrace(2) */68uint32_t oom_score_adj; /* /proc/self/oom_score_adj */69uint32_t so_timestamp; /* requested timeval */70uint32_t so_timestampns; /* requested timespec */71};7273#define LINUX_PEM_XLOCK(p) sx_xlock(&(p)->pem_sx)74#define LINUX_PEM_XUNLOCK(p) sx_xunlock(&(p)->pem_sx)75#define LINUX_PEM_SLOCK(p) sx_slock(&(p)->pem_sx)76#define LINUX_PEM_SUNLOCK(p) sx_sunlock(&(p)->pem_sx)7778struct linux_pemuldata *pem_find(struct proc *);7980#endif /* !_LINUX_EMUL_H_ */818283