summaryrefslogtreecommitdiffstats
path: root/sys/i386/linux/linux_sysvec.c
Commit message (Collapse)AuthorAgeFilesLines
* Cleanup redundant parenthesis from existing howmany()/roundup() macro uses.pfg2016-04-221-1/+1
|
* X86: use our nitems() macro when it is avaliable through param.h.pfg2016-04-191-1/+1
| | | | | | No functional change, only trivial cases are done in this sweep, Discussed in: freebsd-current
* Add kern.features flags for linux and linux64 modulesbapt2016-04-051-0/+1
| | | | | | | | | | | | | kern.features.linux: 1 meaning linux 32 bits binaries are supported kern.features.linux64: 1 meaning linux 64 bits binaries are supported The goal here is to help 3rd party applications (including ports) to determine if the host do support linux emulation Reviewed by: dchagin MFC after: 1 week Relnotes: yes Differential Revision: D5830
* Convert ss_sp in stack_t and sigstack to void *.jhb2016-01-271-2/+2
| | | | | | | | | | | | POSIX requires these members to be of type void * rather than the char * inherited from 4BSD. NetBSD and OpenBSD both changed their fields to void * back in 1998. No new build failures were reported via an exp-run. PR: 206503 (exp-run) Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D5092
* Implement AT_SECURE properly.delphij2016-01-271-1/+3
| | | | | | | | | | | AT_SECURE auxv entry has been added to the Linux 2.5 kernel to pass a boolean flag indicating whether secure mode should be enabled. 1 means that the program has changes its credentials during the execution. Being exported AT_SECURE used by glibc issetugid() call. Submitted by: imp, dchagin Security: FreeBSD-SA-16:10.linux Security: CVE-2016-1883
* Implement vsyscall hack. Prior to 2.13 glibc uses vsyscalldchagin2016-01-091-0/+2
| | | | | | | | | instead of vdso. An upcoming linux_base-c6 needs it. Differential Revision: https://reviews.freebsd.org/D1090 Reviewed by: kib, trasz MFC after: 1 week
* Remove sv_prepsyscall, sv_sigsize and sv_sigtbl members of the structkib2015-11-281-6/+0
| | | | | | | | | | | | | | | | sysent. sv_prepsyscall is unused. sv_sigsize and sv_sigtbl translate signal number from the FreeBSD namespace into the ABI domain. It is only utilized on i386 for iBCS2 binaries. The issue with this approach is that signals for iBCS2 were delivered with the FreeBSD signal frame layout, which does not follow iBCS2. The same note is true for any other potential user if sv_sigtbl. In other words, if ABI needs signal number translation, it really needs custom sv_sendsig method instead. Sponsored by: The FreeBSD Foundation
* Fix missing semi-colon from r289055.cem2015-10-081-1/+1
| | | | | Obtained from: mjg Sponsored by: EMC / Isilon Storage Division
* linux: fix handling of out-of-bounds syscall attemptsmjg2015-10-081-1/+1
| | | | | | | Due to an off by one the code would read an entry past the table, as opposed to the last entry which contains the nosys handler. Reported by: Pawel Biernacki <pawel.biernacki gmail.com>
* Rework signal code to allow using it by other modules, like linprocfs:dchagin2015-05-241-37/+12
| | | | | | | | | | | | | | | | | 1. Linux sigset always 64 bit on all platforms. In order to move Linux sigset code to the linux_common module define it as 64 bit int. Move Linux sigset manipulation routines to the MI path. 2. Move Linux signal number definitions to the MI path. In general, they are the same on all platforms except for a few signals. 3. Map Linux RT signals to the FreeBSD RT signals and hide signal conversion tables to avoid conversion errors. 4. Emulate Linux SIGPWR signal via FreeBSD SIGRTMIN signal which is outside of allowed on Linux signal numbers. PR: 197216
* Call nosys in case when the incorrect syscall number is specified.dchagin2015-05-241-1/+2
| | | | Reported by: trinity
* Use the BSD_TO_LINUX_SIGNAL() wherever there is no needdchagin2015-05-241-6/+2
| | | | | | to check the ABI as it is known. Differential Revision: https://reviews.freebsd.org/D1086
* Add AT_RANDOM and AT_EXECFN auxiliary vector entries which are used bydchagin2015-05-241-0/+26
| | | | | | glibc. At list since glibc version 2.16 using AT_RANDOM is mandatory. Differential Revision: https://reviews.freebsd.org/D1080
* Introduce a new module linux_common.ko which is intended for thedchagin2015-05-241-8/+8
| | | | | | | | | | | | | | | | | | | | | | | following primary purposes: 1. Remove the dependency of linsysfs and linprocfs modules from linux.ko, which will be architecture specific on amd64. 2. Incorporate into linux_common.ko general code for platforms on which we'll support two Linuxulator modules (for both instruction set - 32 & 64 bit). 3. Move malloc(9) declaration to linux_common.ko, to enable getting memory usage statistics properly. Currently linux_common.ko incorporates a code from linux_mib.c and linux_util.c and linprocfs, linsysfs and linux kernel modules depend on linux_common.ko. Temporarily remove dtrace garbage from linux_mib.c and linux_util.c Differential Revision: https://reviews.freebsd.org/D1072 In collaboration with: Vassilis Laganakos. Reviewed by: trasz
* Remove stale comment about a signal trampoline whichdchagin2015-05-241-1/+0
| | | | | | | is moved to the shared page at r219609. Differential Revision: https://reviews.freebsd.org/D1063 Reviewed by: trasz
* Put linux_platform into the vdso to avoid copying it onto the stack atdchagin2015-05-241-4/+4
| | | | | | | every exec. Differential Revision: https://reviews.freebsd.org/D1062 Reviewed by: trasz
* Implement vdso - virtual dynamic shared object. Through vdso Linuxdchagin2015-05-241-11/+54
| | | | | | | | | exposes functions from kernel with proper DWARF CFI information so that it becomes easier to unwind through them. Using vdso is a mandatory for a thread cancelation && cleanup on a modern glibc. Differential Revision: https://reviews.freebsd.org/D1060
* Some style(9) && whitespaces fixes. No functional changes.dchagin2015-05-241-9/+9
| | | | | Differential Revision: https://reviews.freebsd.org/D1041 Reviewed by: emaste
* Switch linuxulator to use the native 1:1 threads.dchagin2015-05-241-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The reasons: 1. Get rid of the stubs/quirks with process dethreading, process reparent when the process group leader exits and close to this problems on wait(), waitpid(), etc. 2. Reuse our kernel code instead of writing excessive thread managment routines in Linuxulator. Implementation details: 1. The thread is created via kern_thr_new() in the clone() call with the CLONE_THREAD parameter. Thus, everything else is a process. 2. The test that the process has a threads is done via P_HADTHREADS bit p_flag of struct proc. 3. Per thread emulator state data structure is now located in the struct thread and freed in the thread_dtor() hook. Mandatory holdig of the p_mtx required when referencing emuldata from the other threads. 4. PID mangling has changed. Now Linux pid is the native tid and Linux tgid is the native pid, with the exception of the first thread in the process where tid and pid are one and the same. Ugliness: In case when the Linux thread is the initial thread in the thread group thread id is equal to the process id. Glibc depends on this magic (assert in pthread_getattr_np.c). So for system calls that take thread id as a parameter we should use the special method to reference struct thread. Differential Revision: https://reviews.freebsd.org/D1039
* MFamd64: Move extern declaration of _ucodesel and _udatasel tojhb2014-11-021-1/+0
| | | | <machine/md_var.h>
* Revert r266925 as it can lead to instant panic at fexecve():dchagin2014-06-171-2/+2
| | | | | | To allow to run the interpreter itself add a new ELF branding type. Pointed out by: kib, mjg
* To allow to run the interpreter itself add a new ELF branding type.dchagin2014-05-311-2/+2
| | | | | | Allow Linux ABI to run ELF interpreter. MFC after: 3 days
* x86: Allow users to change PSL_RF via ptrace(PT_SETREGS...)emaste2013-11-141-22/+2
| | | | | | | | | | | | | Debuggers may need to change PSL_RF. Note that tf_eflags is already stored in the signal context during signal handling and PSL_RF previously could be modified via sigreturn, so this change should not provide any new ability to userspace. For background see the thread at: http://lists.freebsd.org/pipermail/freebsd-i386/2007-September/005910.html Reviewed by: jhb, kib Sponsored by: DARPA, AFRL
* Reduce duplication between i386/linux/linux.h and amd64/linux32/linux.hjhb2013-01-291-0/+1
| | | | | | | by moving bits that are MI out into headers in compat/linux. Reviewed by: Chagin Dmitry dmitry | gmail MFC after: 2 weeks
* Revert previous commit...kevlo2012-10-101-1/+1
| | | | Pointyhat to: kevlo (myself)
* Prefer NULL over 0 for pointerskevlo2012-10-091-1/+1
|
* Do not write to the user address directly, use suword().kib2012-02-251-4/+4
| | | | | Reported by: Bengt Ahlgren <bengta sics se> MFC after: 1 week
* Convert files to UTF-8uqs2012-01-151-1/+1
|
* Export the correct AT_PLATFORM value.dchagin2011-03-261-2/+1
| | | | | | | Since signal trampolines are copied to the shared page do not need to leave place on the stack for it. Forgotten in the previous commit. MFC after: 1 Week
* Enable shared page use for amd64/linux32 and i386/linux binaries.dchagin2011-03-131-18/+18
| | | | | | Move signal trampoline code from the top of the stack to the shared page. MFC after: 2 Weeks
* Extend struct sysvec with new method sv_schedtail, which is used for andchagin2011-03-081-4/+2
| | | | | | | | | | | | | | | explicit process at fork trampoline path instead of eventhadler(schedtail) invocation for each child process. Remove eventhandler(schedtail) code and change linux ABI to use newly added sysvec method. While here replace explicit comparing of module sysentvec structure with the newly created process sysentvec to detect the linux ABI. Discussed with: kib MFC after: 2 Week
* Sort include files in the alphabetical order.dchagin2011-02-131-1/+1
|
* Add macro DECLARE_MODULE_TIED to denote a module as requiring thekib2010-10-121-1/+1
| | | | | | | | | | | | | | | kernel of exactly the same __FreeBSD_version as the headers module was compiled against. Mark our in-tree ABI emulators with DECLARE_MODULE_TIED. The modules use kernel interfaces that the Release Engineering Team feel are not stable enough to guarantee they will not change during the life cycle of a STABLE branch. In particular, the layout of struct sysentvec is declared to be not part of the STABLE KBI. Discussed with: bz, rwatson Approved by: re (bz, kensmith) MFC after: 2 weeks
* The interpreter name should no longer be treated as a buffer that can bealc2010-07-281-10/+5
| | | | | | overwritten. (This change should have been included in r210545.) Submitted by: kib
* Reorganize syscall entry and leave handling.kib2010-05-231-18/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extend struct sysvec with three new elements: sv_fetch_syscall_args - the method to fetch syscall arguments from usermode into struct syscall_args. The structure is machine-depended (this might be reconsidered after all architectures are converted). sv_set_syscall_retval - the method to set a return value for usermode from the syscall. It is a generalization of cpu_set_syscall_retval(9) to allow ABIs to override the way to set a return value. sv_syscallnames - the table of syscall names. Use sv_set_syscall_retval in kern_sigsuspend() instead of hardcoding the call to cpu_set_syscall_retval(). The new functions syscallenter(9) and syscallret(9) are provided that use sv_*syscall* pointers and contain the common repeated code from the syscall() implementations for the architecture-specific syscall trap handlers. Syscallenter() fetches arguments, calls syscall implementation from ABI sysent table, and set up return frame. The end of syscall bookkeeping is done by syscallret(). Take advantage of single place for MI syscall handling code and implement ptrace_lwpinfo pl_flags PL_FLAG_SCE, PL_FLAG_SCX and PL_FLAG_EXEC. The SCE and SCX flags notify the debugger that the thread is stopped at syscall entry or return point respectively. The EXEC flag augments SCX and notifies debugger that the process address space was changed by one of exec(2)-family syscalls. The i386, amd64, sparc64, sun4v, powerpc and ia64 syscall()s are changed to use syscallenter()/syscallret(). MIPS and arm are not converted and use the mostly unchanged syscall() implementation. Reviewed by: jhb, marcel, marius, nwhitehorn, stas Tested by: marcel (ia64), marius (sparc64), nwhitehorn (powerpc), stas (mips) MFC after: 1 month
* Change the arguments of exec_setregs() so that it receives a pointernwhitehorn2010-03-251-5/+4
| | | | | | | | to the image_params struct instead of several members of that struct individually. This makes it easier to expand its arguments in the future without touching all platforms. Reviewed by: jhb
* In r197963, a race with thread being selected for signal deliverykib2009-10-271-12/+6
| | | | | | | | | | | | | while in kernel mode, and later changing signal mask to block the signal, was fixed for sigprocmask(2) and ptread_exit(3). The same race exists for sigreturn(2), setcontext(2) and swapcontext(2) syscalls. Use kern_sigprocmask() instead of direct manipulation of td_sigmask to reschedule newly blocked signals, closing the race. Reviewed by: davidxu Tested by: pho MFC after: 1 month
* Fix handling of .note.ABI-tag section for GNU systems [1].bz2009-08-241-5/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Handle GNU/Linux according to LSB Core Specification 4.0, Chapter 11. Object Format, 11.8. ABI note tag. Also check the first word of desc, not only name, according to glibc abi-tags specification to distinguish between Linux and kFreeBSD. Add explicit handling for Debian GNU/kFreeBSD, which runs on our kernels as well [2]. In {amd64,i386}/trap.c, when checking osrel of the current process, also check the ABI to not change the signal behaviour for Linux binary processes, now that we save an osrel version for all three from the lists above in struct proc [2]. These changes make it possible to run FreeBSD, Debian GNU/kFreeBSD and Linux binaries on the same machine again for at least i386 and amd64, and no longer break kFreeBSD which was detected as GNU(/Linux). PR: kern/135468 Submitted by: dchagin [1] (initial patch) Suggested by: kib [2] Tested by: Petr Salinger (Petr.Salinger seznam.cz) for kFreeBSD Reviewed by: kib MFC after: 3 days
* Do not export AT_CLKTCK when emulating Linux kernel priordchagin2009-05-101-1/+11
| | | | | | | | | | | | | | to 2.4.0, as it has appeared in the 2.4.0-rc7 first time. Being exported, AT_CLKTCK is returned by sysconf(_SC_CLK_TCK), glibc falls back to the hard-coded CLK_TCK value when aux entry is not present. Glibc versions prior to 2.2.1 always use hard-coded CLK_TCK value. For older applications/libc's which depends on hard-coded CLK_TCK value user should set compat.linux.osrelease less than 2.4.0. Approved by: kib (mentor)
* Rework r189362, r191883.dchagin2009-05-101-1/+2
| | | | | | | | | The frequency of the statistics clock is given by stathz. Use stathz if it is available, otherwise use hz. Pointed out by: bde Approved by: kib (mentor)
* Move the per-prison Linux MIB from a private one-off pointer to the newjamie2009-05-071-0/+2
| | | | | | | | | OSD-based jail extensions. This allows the Linux MIB to accessed via jail_set and jail_get, and serves as a demonstration of adding jail support to a module. Reviewed by: dchagin, kib Approved by: bz (mentor)
* Move extern variable definitions to the header file.dchagin2009-05-021-3/+1
| | | | | Approved by: kib (mentor) MFC after: 1 month
* Reimplement futexes.dchagin2009-05-011-3/+3
| | | | | | | | | | | | | | | | | | | | Old implemention used Giant to protect the kernel data structures, but at the same time called malloc(M_WAITOK), that could cause the calling thread to sleep and lost Giant protection. User-visible result was the missed wakeup. New implementation uses one sx lock per futex. The sx protects the futex structures and allows to sleep while copyin or copyout are performed. Unlike linux, we return EINVAL when FUTEX_CMP_REQUEUE operation is requested and either caller specified futexes are equial or second futex already exists. This is acceptable since the situation can only occur from the application error, and glibc falls back to old FUTEX_WAKE operation when FUTEX_CMP_REQUEUE returns an error. Approved by: kib (mentor) MFC after: 1 month
* Fix KBI breakage by r190520 which affects older linux.ko binaries:dchagin2009-04-051-2/+2
| | | | | | | | | | | | | | 1) Move the new field (brand_note) to the end of the Brandinfo structure. 2) Add a new flag BI_BRAND_NOTE that indicates that the brand_note pointer is valid. 3) Use the brand_note field if the flag BI_BRAND_NOTE is set and as old modules won't have the flag set, so the new field brand_note would be ignored. Suggested by: jhb Reviewed by: jhb Approved by: kib (mentor) MFC after: 6 days
* Implement new way of branding ELF binaries by looking to adchagin2009-03-131-2/+14
| | | | | | | | | | | | ".note.ABI-tag" section. The search order of a brand is changed, now first of all the ".note.ABI-tag" is looked through. Move code which fetch osreldate for ELF binary to check_note() handler. PR: 118473 Approved by: kib (mentor)
* A better fix for handling different FPU initial control words for differentjhb2009-03-051-7/+3
| | | | | | | | | | | | | | | | ABIs: - Store the FPU initial control word in the pcb for each thread. - When first using the FPU, load the initial control word after restoring the clean state if it is not the standard control word. - Provide a correct control word for Linux/i386 binaries under FreeBSD/amd64. - Adjust the control word returned for fpugetregs()/npxgetregs() when a thread hasn't used the FPU yet to reflect the real initial control word for the current ABI. - The Linux/i386 ABI for FreeBSD/i386 now properly sets the right control word instead of trashing whatever the current state of the FPU is. Reviewed by: bde
* Add AT_PLATFORM, AT_HWCAP and AT_CLKTCK auxiliary vector entries whichdchagin2009-03-041-5/+161
| | | | | | | | | | | | | | are used by glibc. This silents the message "2.4+ kernel w/o ELF notes?" from some programs at start, among them are top and pkill. Do the assignment of the vector entries in elf_linux_fixup() as it is done in glibc. Fix some minor style issues. Submitted by: Marcin Cieslak <saper at SYSTEM PL> Approved by: kib (mentor) MFC after: 1 week
* Remove obsolete AT_DEBUG stuff. It never should have been committedimp2008-12-171-2/+0
| | | | | | in the first place, let alone migrated to linux emulation. Reviewed by: peter, rdivacky
* Add sv_flags field to struct sysentvec with intention to provide descriptionkib2008-11-221-2/+4
| | | | | | | | of the ABI of the currently executing image. Change some places to test the flags instead of explicit comparing with address of known sysentvec structures to determine ABI features. Discussed with: dchagin, imp, jhb, peter
* Correctly fill siginfo for the signals delivered by linux tkill/tgkill.kib2008-10-191-3/+1
| | | | | | | | | | | | | | | | | | | | | It is required for async cancellation to work. Fix PROC_LOCK leak in linux_tgkill when signal delivery attempt is made to not linux process. Do not call em_find(p, ...) with p unlocked. Move common code for linux_tkill() and linux_tgkill() into linux_do_tkill(). Change linux siginfo_t definition to match actual linux one. Extend uid fields to 4 bytes from 2. The extension does not change structure layout and is binary compatible with previous definition, because i386 is little endian, and each uid field has 2 byte padding after it. Reported by: Nicolas Joly <njoly pasteur fr> Submitted by: dchangin MFC after: 1 month
OpenPOWER on IntegriCloud