aboutsummaryrefslogtreecommitdiff
path: root/sys/i386/linux/linux_sysvec.c
Commit message (Collapse)AuthorAgeFilesLines
* linux: Check for copyout errors in linux_fixup()Mark Johnston2024-01-021-3/+6
| | | | | | | | | | | This is in preparation for annotating copyin() and related functions with __result_use_check. Reviewed by: olce, dchagin MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D43104 (cherry picked from commit 3fde275167ce1f1455a03586d29840546d06d97a)
* syscalls: fix missing SIGSYS for several ENOSYS errorsKonstantin Belousov2023-10-091-1/+1
| | | | (cherry picked from commit 39024a89146902ca9aba250130b828ad9aced99d)
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-231-2/+0
| | | | | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/ Similar commit in current: (cherry picked from commit 685dc743dc3b)
* linux(4): Add elf_hwcap2 to x86Dmitry Chagin2023-08-111-0/+1
| | | | | | | | | | | On x86 Linux via AT_HWCAP2 the user controlled (by tunables) processor capabilities are exposed. Reviewed by: Differential Revision: https://reviews.freebsd.org/D41165 MFC after: 2 weeks (cherry picked from commit 4281dab8bc11b3b2f3b58be5e0f67806329bddae)
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-07-251-1/+1
| | | | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix (cherry picked from commit 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
* linux(4): Deduplicate linux_copyout_auxargs()Dmitry Chagin2023-06-291-53/+11
| | | | | | | | | | Export default MINSIGSTKSZ value for the x86 until we do not preserve AVX registers in the signal context. Differential Revision: https://reviews.freebsd.org/D39644 MFC after: 1 month (cherry picked from commit 7d8c98398302b939b97310d31883ebdab8c0b938)
* linux(4): Cleanup includes under i386/linuxDmitry Chagin2023-03-011-7/+3
| | | | | | | | | Cleanup unneeded includes, sort the rest according to style(9). No functional changes. MFC after: 2 weeks (cherry picked from commit f4a512a5f187d9139c04111784fe811572bc0ed6)
* linux(4): Attach netlink on i386.Dmitry Chagin2023-02-091-0/+3
| | | | | | | Discussed with: melifaro MFC after: 3 days (cherry picked from commit 07db1f36848c008efb7ab6b37e199212560833ae)
* linux(4): Deduplicate linux_trans_osrel().Dmitry Chagin2023-02-091-27/+0
| | | | | | MFC after: 1 week (cherry picked from commit 95b8603427d5759c5d6090ffaacfaf7f3b8fb926)
* linux(4): Deduplicate linux_copyout_strings().Dmitry Chagin2023-02-091-121/+1
| | | | | | | | It is still present in the 32-bit Linuxulator on amd64. MFC after: 1 week (cherry picked from commit 6039e966ff276ff6bcb57f2f70e7d8ff376b24fd)
* linux(4): Deduplicate linux_fixup_elf().Dmitry Chagin2023-02-091-16/+1
| | | | | | | | | Use native routines to fixup initial process stack. On Arm64 linux_elf_fixup() is noop, as it do the stack fixup (room for argc) in the linux_copyout_strings(). MFC after: 1 week (cherry picked from commit 9e550625f867a23ea3d87a77aa3c216b79ecd790)
* linux(4): Add coredump support to i386.Dmitry Chagin2023-02-091-3/+6
| | | | | | MFC after: 1 week (cherry picked from commit cc1b0f7d9626bbd116429014444cbf61edf708a2)
* linux: populate sv_syscallnames in each sysentvecMitchell Horne2022-11-061-1/+2
| | | | | | | | | | | | | | This allows the syscallname() function to give a usable result for Linux ABIs. Reported by: jrtc27 Reviewed by: jrtc27, markj, jhb MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D37199 (cherry picked from commit 1da65dcb1c57fae7be75ddf1bd300ddf19ced850) (cherry picked from commit f396f9b6c96f6d68d4e3606ddb090287230fc565)
* linux(4): Properly restore the thread signal mask after signal delivery on i386Dmitry Chagin2022-06-171-8/+2
| | | | | | | | | | | Replace sigframe sf_extramask by native sigset_t and use it to store/restore the thread signal mask without conversion to/from Linux signal mask. Pointy hat to: dchagin MFC after: 2 weeks (cherry picked from commit 4a6c2d075da0c5105269e6edcbe57bf6aaa0a0ae)
* linux(4): Deduplicate bsd_to_linux_trapcode()Dmitry Chagin2022-06-171-39/+0
| | | | | | | | | As bsd_to_linux_trapcode() is common for x86 Linuxulators, move it under x86/linux. MFC after: 2 weeks (cherry picked from commit 9016ec056ae3896522798ead39bb2f3ff4f68809)
* linux(4): Deduplicate translate_traps()Dmitry Chagin2022-06-171-22/+0
| | | | | | | | | As translate_traps() is common for x86 Linuxulators, move it under x86/linux. MFC after: 2 weeks (cherry picked from commit 2434137f690dabc35586ab45fc4c4ecc5b71184f)
* Retire sv_transtrapDmitry Chagin2022-06-171-4/+2
| | | | | | | | Call translate_traps directly from sendsig(). MFC after: 2 weeks (cherry picked from commit eca368ecb6e00e9db7e1c090e98a29439d255895)
* linux(4): Retire handmade DWARF annotations from signal trampolinesDmitry Chagin2022-06-171-4/+4
| | | | | | | | | | | | | | | | | The Linux exports __kernel_sigreturn and __kernel_rt_sigreturn from the vdso. Modern glibc's sigaction sets the sa_restorer field of sigaction to the corresponding vdso __sigreturn, and sets the SA_RESTORER. Our signal trampolines uses the FreeBSD-way to call a signal handler, so does not use the sigaction's sa_restorer. However, as glibc's runtime linker depends on the existment of the vdso __sigreturn symbols, for all Linuxulators was added separate trampolines named __sigcode with DWARF anotations and left separate __sigreturn methods, which are exported. MFC after: 2 weeks (cherry picked from commit 8f9635dc99f571a0ae4e613b9a0439e68da7b160)
* linux(4): Better naming for ucontext field of struct rt_sigframeDmitry Chagin2022-06-171-26/+26
| | | | | | | | | To reduce sendsig code difference and to avoid confusing me, rename sf_sc to sf_uc to match the content. MFC after: 2 weeks (cherry picked from commit 6e826d27c340fa29e166d06e5d8553f6c63c409e)
* linux(4): Move sigframe definitions to separate headersDmitry Chagin2022-06-171-6/+8
| | | | | | | | | | The signal trampoine-related definitions are used only in the MD part of code, wherefore moved from everywhere used linux.h to separate MD headers. MFC after: 2 weeks (cherry picked from commit 21f246174184742ba8952aeb1dadbf58d48d54b4)
* linux(4): Cleanup signal trampolinesDmitry Chagin2022-06-171-2/+2
| | | | | | | | | | | | | | | | | | | | This is the first stage of a signal trampolines refactoring. From trampolines retired emulation of the 'call' instruction, which is replaced by direct call of a signal handler. The signal handler address is in the register. The previous trampoline implemenatation used semi-Linux-way to call a signal handler via the 'jmp' instruction. Wherefore the trampoline emulated a 'call' instruction to into the stack the return address for signal handler's 'ret' instruction. Wherefore handmade DWARD annotations was used. While here rephrased and removed excessive comments. MFC after: 2 weeks (cherry picked from commit ba279bcd6d75aa236bcb9ccf11aeb6f51a2f8514)
* linux(4): Retire unneeded initializationDmitry Chagin2022-06-171-3/+0
| | | | | | | | | | Both uc_flags and uc_link are zeroed above. On amd64 and i386 the uc_link field is not used at all. The UC_FP_XSTATE bit should be set in the uc_flags if OS xsave knob is turned on (and xsave is implemented). MFC after: 2 weeks (cherry picked from commit 0b5d5dc3767fcf2f0198f0f9549cb23983e0ee3e)
* linux(4): Implement vdso getcpu for x86.Dmitry Chagin2022-06-171-0/+7
| | | | | | | | This is modeled after f2395455 (by kib@). MFC after: 2 weeks (cherry picked from commit 5a6a4fb284b1a9c4b4105fd6ab8143356f3ef3f7)
* i386 linux: Remove unused variables.John Baldwin2022-06-171-6/+1
| | | | (cherry picked from commit 9e70163017ff929a36926ddbc5bd6e8b6b19cfeb)
* linux(4): Add struct clone_args for future clone3 system call.Dmitry Chagin2022-06-171-0/+1
| | | | | | | | | | | In preparation for clone3 system call add struct clone_args and use it in clone implementation. Move all of clone related bits to the newly created linux_fork.h header. Differential revision: https://reviews.freebsd.org/D31474 MFC after: 2 weeks (cherry picked from commit 0a4b664ae8582b7596858317b53d84eb4f8bbf9a)
* fork: Allow ABI to specify fork return values for child.Dmitry Chagin2022-06-171-0/+11
| | | | | | | | | | | | | | At least Linux x86 ABI's does not use carry bit and expects that the dx register is preserved. For this add a new sv_set_fork_retval hook and call it from cpu_fork(). Add a short comment about touching dx in x86_set_fork_retval(), for more details see phab comments from kib@ and imp@. Reviewed by: kib Differential revision: https://reviews.freebsd.org/D31472 MFC after: 2 weeks (cherry picked from commit de8374df28cc23ce0d893fd96d1ad0a861414154)
* linux(4): Eliminating an accidental comment.Dmitry Chagin2022-06-171-5/+0
| | | | | | MFC after: 2 weeks (cherry picked from commit 741f80df531cb58a38a8ec98203c7e315b6f9bca)
* linux(4): Reimplement futexes using umtx.Dmitry Chagin2022-06-171-5/+0
| | | | | | | Differential Revision: https://reviews.freebsd.org/D31236 MFC after: 2 weeks (cherry picked from commit 0dc38e33031b353468888fe25a6f8ba1f910dd26)
* linux(4): Allow musl brand to use FUTEX_REQUEUE op.Dmitry Chagin2022-06-171-1/+2
| | | | | | | | | | | Initial patch from submitter was adapted by me to prevent unconditional FUTEX_REQUEUE use. PR: 255947 Submitted by: Philippe Michaud-Boudreault Differential Revision: https://reviews.freebsd.org/D30332 (cherry picked from commit cf8d74e3fe63da7359d6ca7e0b4b57c5684c2845)
* linux: implement sigaltstack(2) on arm64Edward Tomasz Napierala2022-06-171-2/+2
| | | | | | | | | | ... by making it machine-independent. Reviewed By: dchagin Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D31286 (cherry picked from commit 30c6d982190482857883fc96eefafcc6fd769fa0)
* linux(4): Fixup the vDSO initialization order.Dmitry Chagin2022-06-171-2/+11
| | | | | | | | | | | | | | | | | | The vDSO initialisation order should be as follows: - native abi init via exec_sysvec_init(); - vDSO symbols queued to the linux_vdso_syms list; - linux_vdso_install(); - linux_exec_sysvec_init(); As the exec_sysvec_init() called with SI_ORDER_ANY (last) at SI_SUB_EXEC order, move linux_vdso_install() and linux_exec_sysvec_init() to the SI_SUB_EXEC+1 order. Reviewed by: trasz Differential Revision: https://reviews.freebsd.org/D30902 MFC after 2 weeks (cherry picked from commit 09cffde975b87b293457c9a228cb980ec729384a)
* linux(4): Constify vdso install/deinstall.Dmitry Chagin2022-06-171-4/+4
| | | | | | | | | | | In order to reduce diff between arches constify vdso install/deinstall functions like arm64. Reviewed by: emaste Differential revision: https://reviews.freebsd.org/D30901 MFC after: 2 weeks (cherry picked from commit a543556c8128c52fb044250b8f52f9702c81788d)
* linux(4); Almost complete the vDSO.Dmitry Chagin2022-06-171-32/+129
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The vDSO (virtual dynamic shared object) is a small shared library that the kernel maps R/O into the address space of all Linux processes on image activation. The vDSO is a fully formed ELF image, shared by all processes with the same ABI, has no process private data. The primary purpose of the vDSO: - non-executable stack, signal trampolines not copied to the stack; - signal trampolines unwind, mandatory for the NPTL; - to avoid contex-switch overhead frequently used system calls can be implemented in the vDSO: for now gettimeofday, clock_gettime. The first two have been implemented, so add the implementation of system calls. System calls implemenation based on a native timekeeping code with some limitations: - ifunc can't be used, as vDSO r/o mapped to the process VA and rtld can't relocate symbols; - reading HPET memory is not implemented for now (TODO). In case on any error vDSO system calls fallback to the kernel system calls. For unimplemented vDSO system calls added prototypes which call corresponding kernel system call. Relnotes: yes Tested by: trasz (arm64) Differential revision: https://reviews.freebsd.org/D30900 MFC after: 2 weeks (cherry picked from commit 9931033bbfbe56a037723638cf3712366c6d943f)
* linux(4): Modify sv_onexec hook to return an error.Dmitry Chagin2022-06-171-2/+12
| | | | | | | | | | Temporary add stubs to the Linux emulation layer which calls the existing hook. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D30911 MFC after: 2 weeks (cherry picked from commit 5fd9cd53d256e08c601548c425bfcb3472f2d09b)
* linux(4): Do not specify shared page for aout binaries.Dmitry Chagin2022-06-171-2/+0
| | | | | | | | | In Linux vDSO is a small shared ELF library, so it is not intended for aout binaries. This was added on 64-bit Linuxulator import by mistake. MFC after: 2 weeks (cherry picked from commit bfe29037983913f27eae9c5a6d31545ed89f4040)
* linux(4): Retire linux_kplatform.Dmitry Chagin2022-06-171-35/+2
| | | | | | | | | | | | | | | | | Assuming we can't run on i486, i586 class cpu, retire linux_kplatform var and use hardcoded 'machine' value in linux_newuname(). I have added linux_kplatform for consistency with linux_platform which is placed in to vdso to avoid excess copyout it on stack for AT_PLATFORM at exec time. This is the first stage of Linuxulator's vdso revision. Reviewed by: trasz, imp Differential Revision: https://reviews.freebsd.org/D30774 MFC after: 2 weeks (cherry picked from commit c1da89fec254f9d079fc17a186e2665a32cc718d)
* linux(4): optimize ksiginfo to siginfo conversion.Dmitry Chagin2022-06-171-1/+1
| | | | | | | | | Retire ksiginfo_to_lsiginfo function, use siginfo_to_lsiginfo instead. Convert rt_sigtimedwait siginfo variables to well known names. MFC after: 2 weeks (cherry picked from commit f4e801085b055fd33f680dd7cb9f8562d236f39a)
* Add infrastructure required for Linux coredump supportEdward Tomasz Napierala2022-05-121-0/+3
| | | | | | | | | | | | | | | | | | This adds `sv_elf_core_osabi`, `sv_elf_core_abi_vendor`, and `sv_elf_core_prepare_notes` fields to `struct sysentvec`, and modifies imgact_elf.c to make use of them instead of hardcoding FreeBSD-specific values. It also updates all of the ABI definitions to preserve current behaviour. This makes it possible to implement non-native ELF coredump support without unnecessary code duplication. It will be used for Linux coredumps. Reviewed By: kib Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D30921 (cherry picked from commit 435754a59ee203c3369f47ff9103f269c81581b7)
* sysent: Add a sv_psstringssz field to struct sysentvecMark Johnston2022-01-311-0/+2
| | | | | | | | | | | The size of the ps_strings structure varies between ABIs, so this is useful for computing the address of the ps_strings structure relative to the top of the stack when stack address randomization is enabled. Reviewed by: kib Sponsored by: The FreeBSD Foundation (cherry picked from commit 3fc21fdd5f8a4eeb71f43cc6841f59ef1debaf9a)
* exec: Introduce the PROC_PS_STRINGS() macroMark Johnston2022-01-311-2/+2
| | | | | | | | | | | Rather than fetching the ps_strings address directly from a process' sysentvec, use this macro. With stack address randomization the ps_strings address is no longer fixed. Reviewed by: kib Sponsored by: The FreeBSD Foundation (cherry picked from commit 706f4a81a81250a326ea25914e7effe1768f1a37)
* exec: Simplify sv_copyout_strings implementations a bitMark Johnston2022-01-141-6/+2
| | | | | | | | | | | | Simplify control flow around handling of the execpath length and signal trampoline. Cache the sysentvec pointer in a local variable. No functional change intended. Reviewed by: kib Sponsored by: The FreeBSD Foundation (cherry picked from commit f04a096049382637178b54ffb45089f5f9fb3db9)
* Add quirks for Linux ABI signals handlingKonstantin Belousov2021-06-221-2/+4
| | | | (cherry picked from commit 870e197d52c1cb8c3ed6d04ddae34dcae57cb657)
* linuxolator: Add compat.linux.setid_allowed knobKonstantin Belousov2021-06-131-0/+2
| | | | | | PR: 21463 (cherry picked from commit 598f6fb49c9ca688029b79de0a44227ab79c608c)
* linux: Update the i386/linux vdso deinitialization routineMark Johnston2021-02-231-1/+2
| | | | | | | | | | This was missed in commit 0fc8a796722 ("linux: Unmap the VDSO page when unloading"). Reported by: Mark Millard MFC with: 0fc8a796722 (cherry picked from commit aa5fef60bf663d31cddf53d7a8c6856d5e4672c0)
* Rename i386's Linux ELF to Linux ELF32Jessica Clarke2021-01-211-1/+1
| | | | | | | | | This is what amd64 calls the i386 Linux ABI in order to distinguish it from the amd64 Linux ABI, and matches the nomenclature used for the FreeBSD ABIs where they always have the size suffix in the name. Reviewed by: trasz Differential Revision: https://reviews.freebsd.org/D27647
* Linuxolator: Replace use of eventhandlers by sysent hooks.Konstantin Belousov2020-11-231-14/+6
| | | | | | | | | Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D27309 Notes: svn path=/head/; revision=367960
* Fix misnomer - linux_to_bsd_errno() does the exact opposite.Edward Tomasz Napierala2020-10-271-1/+1
| | | | | | | | | | Reported by: arichardson MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D26965 Notes: svn path=/head/; revision=367079
* Get rid of sa->narg. It serves no purpose; use sa->callp->sy_narg instead.Edward Tomasz Napierala2020-09-271-1/+0
| | | | | | | | | Reviewed by: kib Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D26458 Notes: svn path=/head/; revision=366205
* Get rid of sv_errtbl and SV_ABI_ERRNO().Edward Tomasz Napierala2020-09-171-5/+1
| | | | | | | | | Reviewed by: kib Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D26388 Notes: svn path=/head/; revision=365832
* Move SV_ABI_ERRNO translation into linux-specific code, to simplifyEdward Tomasz Napierala2020-09-151-2/+15
| | | | | | | | | | | | the syscall path and declutter it a bit. No functional changes intended. Reviewed by: kib (earlier version) MFC after: 2 weeks Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D26378 Notes: svn path=/head/; revision=365755