aboutsummaryrefslogtreecommitdiff
path: root/sys/amd64/linux32/linux32_sysvec.c
Commit message (Collapse)AuthorAgeFilesLines
* amd64/linux*: mark brandlists as staticKonstantin Belousov2024-02-111-1/+1
| | | | | Sponsored by: The FreeBSD Foundation MFC after: 3 days
* linux(4): Drop the outdated comments about sixth register on i386 int0x80Dmitry Chagin2023-10-101-1/+1
| | | | | | This is well documented in the Linux syscall(2). MFC after: 1 week
* linuxolator: fix nosys() to not send SIGSYSKonstantin Belousov2023-10-021-1/+1
| | | | | | | | Reviewed by: dchagin, markj Discussed with: jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D41976
* linux(4): Cleanup includes under amd64/linux32Dmitry Chagin2023-09-111-6/+1
| | | | | | No functional changes. MFC after: 1 week
* linux(4): Remove sys/cdefs.h inclusion where it's not needed due to 685dc743Dmitry Chagin2023-08-181-1/+0
|
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* linux(4): Add elf_hwcap2 to x86Dmitry Chagin2023-07-281-1/+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
* linux(4): Use pwd_altroot() to tell namei() about ABI root pathDmitry Chagin2023-05-291-5/+1
| | | | | | PR: 72920 Differential Revision: https://reviews.freebsd.org/D40090 MFC after: 2 month
* linux(4): Deduplicate linux_copyout_auxargs()Dmitry Chagin2023-04-221-54/+10
| | | | | | | | 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
* linux(4): Cleanup includes under amd64/linuxDmitry Chagin2023-02-141-10/+1
| | | | | | | Cleanup unneeded includes, sort the rest according to style(9). No functional changes. MFC after: 2 weeks
* linux(4): Get rid of the opt_compat.h include.Dmitry Chagin2023-02-121-2/+0
| | | | | | | Since e013e369 COMPAT_LINUX, COMPAT_LINUX32 build options are removed, so include of opt_compat.h is no more needed. MFC after: 2 weeks
* linux(4): Deduplicate linux_trans_osrel().Dmitry Chagin2023-02-021-28/+1
| | | | MFC after: 1 week
* linux(4): Deduplicate linux_fixup_elf().Dmitry Chagin2023-02-021-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
* linux(4): Microoptimize linux_elf.h for future use.Dmitry Chagin2023-02-021-0/+1
| | | | | | | In order to reduce code duplication move coredump support definitions into the appropriate header and hide private definitions. MFC after: 1 week
* linux: populate sv_syscallnames in each sysentvecMitchell Horne2022-10-281-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
* Rework how shared page related data is storedKornel Dulęba2022-07-181-1/+1
| | | | | | | | | | | | | Store the shared page address in struct vmspace. Also instead of storing absolute addresses of various shared page segments save their offsets with respect to the shared page address. This will be more useful when the shared page address is randomized. Approved by: mw(mentor) Sponsored by: Stormshield Obtained from: Semihalf Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D35393
* linux(4): Properly restore the thread signal mask after signal delivery on i386Dmitry Chagin2022-05-301-9/+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
* linux(4): Deduplicate bsd_to_linux_trapcode()Dmitry Chagin2022-05-231-39/+0
| | | | | | | As bsd_to_linux_trapcode() is common for x86 Linuxulators, move it under x86/linux. MFC after: 2 weeks
* linux(4): Deduplicate translate_traps()Dmitry Chagin2022-05-231-22/+0
| | | | | | | As translate_traps() is common for x86 Linuxulators, move it under x86/linux. MFC after: 2 weeks
* Retire sv_transtrapDmitry Chagin2022-05-201-3/+2
| | | | | | Call translate_traps directly from sendsig(). MFC after: 2 weeks
* linux(4): Retire handmade DWARF annotations from signal trampolinesDmitry Chagin2022-05-151-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
* linux(4): Better naming for ucontext field of struct rt_sigframeDmitry Chagin2022-05-151-27/+27
| | | | | | | To reduce sendsig code difference and to avoid confusing me, rename sf_sc to sf_uc to match the content. MFC after: 2 weeks
* linux(4): Move sigframe definitions to separate headersDmitry Chagin2022-05-151-0/+2
| | | | | | | | 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
* linux(4): Cleanup signal trampolinesDmitry Chagin2022-05-151-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
* linux(4): Retire unneeded initializationDmitry Chagin2022-05-151-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
* linux(4): Implement vdso getcpu for x86.Dmitry Chagin2022-05-081-0/+7
| | | | | | This is modeled after f2395455 (by kib@). MFC after: 2 weeks
* linux(4): Add compat.linux32.emulate_i386 knob.Dmitry Chagin2022-03-311-0/+3
| | | | | | | | | | | | | | Historically 32-bit Linuxulator under amd64 emulated the real i386 behavior. Since 3d8dd983 the old i386 Linux world can't be used under amd64 Linuxulator as it don't know anything about amd64 machine (which is returned now by newuname() syscall). So, add a knob to allow to swith the behavior and use i386 Linux binaries on amd64. Set knob to the new behavior as I think this is common to the modern Linux distros. Reviewed by: Pau Amma (doc), emaste Differential revision: https://reviews.freebsd.org/D34708 MFC after: 2 weeks
* linux_copyout_strings: Use PROC_PS_STRINGS().John Baldwin2022-02-041-1/+1
| | | | | | Reviewed by: markj Obtained from: CheriBSD Differential Revision: https://reviews.freebsd.org/D34173
* sysent: Add a sv_psstringssz field to struct sysentvecMark Johnston2022-01-171-0/+1
| | | | | | | | | | | 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 MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33704
* exec: Simplify sv_copyout_strings implementations a bitMark Johnston2021-12-311-7/+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 MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33703
* amd64: centralize definitions of CS_SECURE and EFL_SECUREKonstantin Belousov2021-09-211-6/+2
| | | | | | | | | Requested by markj Reviewed by: jhb, markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31954
* linux(4): Add struct clone_args for future clone3 system call.Dmitry Chagin2021-08-121-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
* fork: Allow ABI to specify fork return values for child.Dmitry Chagin2021-08-121-0/+10
| | | | | | | | | | | | 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
* linux(4): Allow musl brand to use FUTEX_REQUEUE op.Dmitry Chagin2021-07-201-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
* linux(4): Add arch name to the some printfs.Dmitry Chagin2021-07-201-4/+4
| | | | | | Reviewed by: emaste Differential revision: https://reviews.freebsd.org/D30904 MFC after: 2 weeks
* linux(4): Fixup the vDSO initialization order.Dmitry Chagin2021-07-201-2/+6
| | | | | | | | | | | | | | | | 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
* linux(4): Constify vdso install/deinstall.Dmitry Chagin2021-07-201-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
* linux(4); Almost complete the vDSO.Dmitry Chagin2021-07-201-32/+126
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. Tested by: trasz (arm64) Differential revision: https://reviews.freebsd.org/D30900 MFC after: 2 weeks
* linux(4): Modify sv_onexec hook to return an error.Dmitry Chagin2021-07-201-1/+11
| | | | | | | | 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
* Pass the syscall number to capsicum permission-denied signalsDavid Chisnall2021-07-161-0/+1
| | | | | | | | | | | | | | | | | | The syscall number is stored in the same register as the syscall return on amd64 (and possibly other architectures) and so it is impossible to recover in the signal handler after the call has returned. This small tweak delivers it in the `si_value` field of the signal, which is sufficient to catch capability violations and emulate them with a call to a more-privileged process in the signal handler. This reapplies 3a522ba1bc852c3d4660a4fa32e4a94999d09a47 with a fix for the static assertion failure on i386. Approved by: markj (mentor) Reviewed by: kib, bcr (manpages) Differential Revision: https://reviews.freebsd.org/D29185
* Revert "Pass the syscall number to capsicum permission-denied signals"David Chisnall2021-07-101-1/+0
| | | | | | This broke the i386 build. This reverts commit 3a522ba1bc852c3d4660a4fa32e4a94999d09a47.
* Pass the syscall number to capsicum permission-denied signalsDavid Chisnall2021-07-101-0/+1
| | | | | | | | | | | | | | | The syscall number is stored in the same register as the syscall return on amd64 (and possibly other architectures) and so it is impossible to recover in the signal handler after the call has returned. This small tweak delivers it in the `si_value` field of the signal, which is sufficient to catch capability violations and emulate them with a call to a more-privileged process in the signal handler. Approved by: markj (mentor) Reviewed by: kib, bcr (manpages) Differential Revision: https://reviews.freebsd.org/D29185
* linux(4): implement coredump supportEdward Tomasz Napierala2021-06-301-3/+3
| | | | | | | | | | | Implement dumping core for Linux binaries on amd64, for both 32- and 64-bit executables. Some bits are still missing. This is based on a prototype by chuck@. Reviewed By: kib Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D30019
* Add infrastructure required for Linux coredump supportEdward Tomasz Napierala2021-06-291-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
* linux(4): Make vDSO defines private.Dmitry Chagin2021-06-251-0/+6
| | | | | | | | Hide the vDSO defines to the linux32_sysvec as they are not intended to be used outside of it. Fix LINUX32_PS_STRINGS, use the size of struct linux32_ps_strings instead of a numeric constant. MFC after: 2 weeks
* linux(4): Retire linux_kplatform.Dmitry Chagin2021-06-221-4/+0
| | | | | | | | | | | | | | | 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
* Add quirks for Linux ABI signals handlingKonstantin Belousov2021-06-151-1/+2
| | | | | | | | | | | Require queueing of the signals with default action, and disable dequeueing SIGCHLD on wait for live process. Reported and tested by: dchagin Reviewed by: dchagin, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D30675
* linuxolator: Add compat.linux.setid_allowed knobKonstantin Belousov2021-06-061-0/+1
| | | | | | | | | | PR: 21463 Reported by: kris Reviewed by: dchagin Tested by: trasz Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D28154
* linux(4): optimize ksiginfo to siginfo conversion.Dmitry Chagin2021-06-071-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
* linux: adjust ordering of Linux auxv and add dummy AT_HWCAP2Edward Tomasz Napierala2021-04-131-5/+6
| | | | | | | | | | | | | | This should be a no-op; the purpose of this is to reduce a spurious difference between Linuxulator and Linux, to make debugging core dumps slightly easier. Note that AT_HWCAP2 we pass to Linux binaries is always 0, instead of being equal to 'cpu_feature2'. This matches what I've observed under Ubuntu Focal VM. Reviewed By: chuck, dchagin Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D29609