aboutsummaryrefslogtreecommitdiff
path: root/sys/amd64/linux32/linux32_sysvec.c
Commit message (Collapse)AuthorAgeFilesLines
* Do not export AT_CLKTCK when emulating Linux kernel priorDmitry Chagin2009-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) Notes: svn path=/head/; revision=191973
* Rework r189362, r191883.Dmitry Chagin2009-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) Notes: svn path=/head/; revision=191966
* Move the per-prison Linux MIB from a private one-off pointer to the newJamie Gritton2009-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) Notes: svn path=/head/; revision=191896
* Move extern variable definitions to the header file.Dmitry Chagin2009-05-021-3/+1
| | | | | | | | Approved by: kib (mentor) MFC after: 1 month Notes: svn path=/head/; revision=191741
* Reimplement futexes.Dmitry Chagin2009-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 Notes: svn path=/head/; revision=191719
* Fix KBI breakage by r190520 which affects older linux.ko binaries:Dmitry Chagin2009-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 Notes: svn path=/head/; revision=190708
* Save and restore segment registers on amd64 when entering and leavingKonstantin Belousov2009-04-011-32/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the kernel on amd64. Fill and read segment registers for mcontext and signals. Handle traps caused by restoration of the invalidated selectors. Implement user-mode creation and manipulation of the process-specific LDT descriptors for amd64, see sysarch(2). Implement support for TSS i/o port access permission bitmap for amd64. Context-switch LDT and TSS. Do not save and restore segment registers on the context switch, that is handled by kernel enter/leave trampolines now. Remove segment restore code from the signal trampolines for freebsd/amd64, freebsd/ia32 and linux/i386 for the same reason. Implement amd64-specific compat shims for sysarch. Linuxolator (temporary ?) switched to use gsbase for thread_area pointer. TODO: Currently, gdb is not adapted to show segment registers from struct reg. Also, no machine-depended ptrace command is added to set segment registers for debugged process. In collaboration with: pho Discussed with: peter Reviewed by: jhb Linuxolator tested by: dchagin Notes: svn path=/head/; revision=190620
* Implement new way of branding ELF binaries by looking to aDmitry Chagin2009-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) Notes: svn path=/head/; revision=189771
* A better fix for handling different FPU initial control words for differentJohn Baldwin2009-03-051-0/+1
| | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=189423
* Add AT_PLATFORM, AT_HWCAP and AT_CLKTCK auxiliary vector entries whichDmitry Chagin2009-03-041-15/+33
| | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=189362
* Fix the inconsistent tabbing.David E. O'Brien2009-01-311-50/+53
| | | | | | | Noticed by: bde Notes: svn path=/head/; revision=187964
* Change some movl's to mov's. Newer GAS no longer accept 'movl' instructionsDavid E. O'Brien2009-01-311-4/+4
| | | | | | | | | for moving between a segment register and a 32-bit memory location. Looked at by: jhb Notes: svn path=/head/; revision=187948
* Remove obsolete AT_DEBUG stuff. It never should have been committedWarner Losh2008-12-171-2/+0
| | | | | | | | | in the first place, let alone migrated to linux emulation. Reviewed by: peter, rdivacky Notes: svn path=/head/; revision=186211
* Add sv_flags field to struct sysentvec with intention to provide descriptionKonstantin Belousov2008-11-221-0/+1
| | | | | | | | | | | 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 Notes: svn path=/head/; revision=185169
* Correctly fill siginfo for the signals delivered by linux tkill/tgkill.Konstantin Belousov2008-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 Notes: svn path=/head/; revision=184058
* Set PCB_32BIT and clear PCB_GS32BIT for linux32 binaries.Konstantin Belousov2008-10-181-1/+2
| | | | | | | | Tested by: dchagin MFC after: 3 days Notes: svn path=/head/; revision=184026
* Change the static struct sysentvec and struct Elf_Brandinfo initializersKonstantin Belousov2008-09-241-49/+49
| | | | | | | | | | | | | | to the C99 style. At least, it is easier to read sysent definitions that way, and search for the actual instances of sigcode etc. Explicitely initialize sysentvec.sv_maxssiz that was missed in most sysvecs. No objection from: jhb MFC after: 1 month Notes: svn path=/head/; revision=183322
* Implement the linux syscallsKonstantin Belousov2008-04-081-1/+2
| | | | | | | | | | | | openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat, renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat. Submitted by: rdivacky Sponsored by: Google Summer of Code 2007 Tested by: pho Notes: svn path=/head/; revision=177997
* Since version 4.3, gcc changed its behaviour concerning the i386/amd64Konstantin Belousov2008-03-131-2/+2
| | | | | | | | | | | | | | | | | | | | | ABI and the direction flag, that is it now assumes that the direction flag is cleared at the entry of a function and it doesn't clear once more if needed. This new behaviour conforms to the i386/amd64 ABI. Modify the signal handler frame setup code to clear the DF {e,r}flags bit on the amd64/i386 for the signal handlers. jhb@ noted that it might break old apps if they assumed DF == 1 would be preserved in the signal handlers, but that such apps should be rare and that older versions of gcc would not generate such apps. Submitted by: Aurelien Jarno <aurelien aurel32 net> PR: 121422 Reviewed by: jhb MFC after: 2 weeks Notes: svn path=/head/; revision=177145
* Remove kernel support for M:N threading.Jeff Roberson2008-03-121-2/+1
| | | | | | | | | | | While the KSE project was quite successful in bringing threading to FreeBSD, the M:N approach taken by the kse library was never developed to its full potential. Backwards compatibility will be provided via libmap.conf for dynamically linked binaries and static binaries will be broken. Notes: svn path=/head/; revision=177091
* Fill in cr2 in the signal context from ksi->ksi_addr.Konstantin Belousov2007-09-201-0/+2
| | | | | | | | | | | | | Together with the sys/i386/i386/trap.c rev. 1.306 it fixes the PR. Submitted by: rdivacky Suggested by: jhb Sponsored by: Google Summer of Code 2007 PR: kern/77710 Approved by: re (kensmith) Notes: svn path=/head/; revision=172255
* Fix a couple of issues with the stack limit for 32-bit processes on 64-bitJohn Baldwin2007-07-121-1/+2
| | | | | | | | | | | | | | | | kernels exposed by the recent fixes to resource limits for 32-bit processes on 64-bit kernels: - Let ABIs expose their maximum stack size via a new pointer in sysentvec and use that in preference to maxssiz during exec() rather than always using maxssiz for all processses. - Apply the ABI's limit fixup to the previous stack size when adjusting RLIMIT_STACK to determine if the existing mapping for the stack needs to be grown or shrunk (as well as how much it should be grown or shrunk). Approved by: re (kensmith) Notes: svn path=/head/; revision=171410
* Rework the support for ABIs to override resource limits (used by 32-bitJohn Baldwin2007-05-141-34/+28
| | | | | | | | | | | | | | | | | | | | | | processes under 64-bit kernels). Previously, each 32-bit process overwrote its resource limits at exec() time. The problem with this approach is that the new limits affect all child processes of the 32-bit process, including if the child process forks and execs a 64-bit process. To fix this, don't ovewrite the resource limits during exec(). Instead, sv_fixlimits() is now replaced with a different function sv_fixlimit() which asks the ABI to sanitize a single resource limit. We then use this when querying and setting resource limits. Thus, if a 32-bit process sets a limit, then that new limit will be inherited by future children. However, if the 32-bit process doesn't change a limit, then a future 64-bit child will see the "full" 64-bit limit rather than the 32-bit limit. MFC is tentative since it will break the ABI of old linux.ko modules (no other modules are affected). MFC after: 1 week Notes: svn path=/head/; revision=169565
* MFP4: Turn emul_lock into a mutex.Jung-uk Kim2007-04-021-2/+2
| | | | | | | Submitted by: rdivacky Notes: svn path=/head/; revision=168275
* MFP4: Linux set_thread_area syscall (aka TLS) support for amd64.Jung-uk Kim2007-03-301-2/+6
| | | | | | | | | Initial version was submitted by Divacky Roman and mostly rewritten by me. Tested by: emulation Notes: svn path=/head/; revision=168035
* MFP4 (110939):Alexander Leidinger2006-12-031-1/+1
| | | | | | | | | MFi386: return EOPNOTSUPP for unknown module events. Submitted by: rdivacky Notes: svn path=/head/; revision=164860
* Fix a typo resulting in truncated linux32 signal trampoline code copiedKonstantin Belousov2006-10-311-1/+1
| | | | | | | | | | to the usermode. Usually, signal handler segfaulted on return. Reviewed by: jhb MFC after: 3 days Notes: svn path=/head/; revision=163829
* Change futex lock from mutex to sx. Make futex_get atomic (protected by theAlexander Leidinger2006-09-091-3/+3
| | | | | | | | | | | futex lock). Sponsored by: Google SoC 2006 Submitted by: rdivacky Suggested by: jhb Notes: svn path=/head/; revision=162182
* Move some stuff into headers where they belong.Alexander Leidinger2006-08-171-2/+0
| | | | | | | | | Sponsored by: Google SoC 2006 Submitted by: rdivacky Noticed by: jhb, ssouhlal Notes: svn path=/head/; revision=161419
* Initialize the emul sx-lock.Alexander Leidinger2006-08-171-0/+1
| | | | | | | | Sponsored by: Google SoC 2006 Submitted by: rdivacky Notes: svn path=/head/; revision=161400
* Initialize the eventhandlers, mutexes and sx locks.Alexander Leidinger2006-08-151-0/+26
| | | | | | | | Sponsored by: Google SoC 2006 Submitted by: rdivacky Notes: svn path=/head/; revision=161315
* Add the linux 2.6.x stuff (not used by default!):Alexander Leidinger2006-08-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - TLS - complete - pid/tid mangling - complete - thread area - complete - futexes - complete with issues - clone() extension - complete with some possible minor issues - mq*/timer*/clock* stuff - complete but untested and the mq* stuff is disabled when not build as part of the kernel with native FreeBSD mq* support (module support for this will come later) Tested with: - linux-firefox - works, tested - linux-opera - works, tested - linux-realplay - doesnt work, issue with futexes - linux-skype - doesnt work, issue with futexes - linux-rt2-demo - works, tested - linux-acroread - doesnt work, unknown reason (coredump) and sometimes issue with futexes - various unix utilities in linux-base-gentoo3 and linux-base-fc4: everything tried worked On amd64 not everything is supported like on i386, the catchup is planned for later when the remaining bugs in the new functions are fixed. To test this new stuff, you have to run sysctl compat.linux.osrelease=2.6.16 to switch back use sysctl compat.linux.osrelease=2.4.2 Don't switch while running a linux program, strange things may or may not happen. Sponsored by: Google SoC 2006 Submitted by: rdivacky Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild Notes: svn path=/head/; revision=161310
* Add some more errno mappings (bsd -> linux) and a comment about the status..Alexander Leidinger2006-08-101-1/+6
| | | | | | | Submitted by: "Intron" <mag@intron.ac> Notes: svn path=/head/; revision=161204
* Forgot the amd/linux32 part since sys/*/linux didn't match :-(Doug Ambrisko2006-05-061-0/+6
| | | | | | | Pointed out by: Alexander (thanks) Notes: svn path=/head/; revision=158334
* Unbreak COMPAT_LINUX32 option support on amd64.Ruslan Ermilov2006-03-191-0/+1
| | | | | | | Broken by: netchild Notes: svn path=/head/; revision=156874
* regenAlexander Leidinger2006-03-181-3/+0
| | | | Notes: svn path=/head/; revision=156851
* regen after COMPAT_43 removalAlexander Leidinger2006-03-181-3/+0
| | | | Notes: svn path=/head/; revision=156843
* Remove kern.elf32.can_exec_dyn sysctl. Instead extend Brandinfo structureMaxim Sobolev2005-12-261-0/+2
| | | | | | | | | | | | | with flags bitfield and set BI_CAN_EXEC_DYN flag for all brands that usually allow executing elf dynamic binaries (aka shared libraries). When it is requested to execute ET_DYN elf image check if this flag is on after we know the elf brand allowing execution if so. PR: kern/87615 Submitted by: Marcin Koziej <creep@desk.pl> Notes: svn path=/head/; revision=153741
* Remove linux_mib_destroy() (which I actually added in between 5.0 and 5.1)John Baldwin2005-12-151-1/+0
| | | | | | | | | | | | which existed to cleanup the linux_osname mutex. Now that MTX_SYSINIT() has grown a SYSUNINIT to destroy mutexes on unload, the extra destroy here was redundant and resulted in panics in debug kernels. MFC after: 1 week Reported by: Goran Gajic ggajic at afrodita dot rcub dot bg dot ac dot yu Notes: svn path=/head/; revision=153448
* Calling setrlimit from 32bit apps could potentially increase certainPaul Saab2005-11-021-3/+2
| | | | | | | | | | limits beyond what should be capiable in a 32bit process, so we must fixup the limits. Reviewed by: jhb Notes: svn path=/head/; revision=151980
* The signal code is now an int rather than a long, so update debug printfs.John Baldwin2005-10-141-2/+2
| | | | Notes: svn path=/head/; revision=151343
* 1. Change prototype of trapsignal and sendsig to use ksiginfo_t *, mostDavid Xu2005-10-141-9/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | changes in MD code are trivial, before this change, trapsignal and sendsig use discrete parameters, now they uses member fields of ksiginfo_t structure. For sendsig, this change allows us to pass POSIX realtime signal value to user code. 2. Remove cpu_thread_siginfo, it is no longer needed because we now always generate ksiginfo_t data and feed it to libpthread. 3. Add p_sigqueue to proc structure to hold shared signals which were blocked by all threads in the proc. 4. Add td_sigqueue to thread structure to hold all signals delivered to thread. 5. i386 and amd64 now return POSIX standard si_code, other arches will be fixed. 6. In this sigqueue implementation, pending signal set is kept as before, an extra siginfo list holds additional siginfo_t data for signals. kernel code uses psignal() still behavior as before, it won't be failed even under memory pressure, only exception is when deleting a signal, we should call sigqueue_delete to remove signal from sigqueue but not SIGDELSET. Current there is no kernel code will deliver a signal with additional data, so kernel should be as stable as before, a ksiginfo can carry more information, for example, allow signal to be delivered but throw away siginfo data if memory is not enough. SIGKILL and SIGSTOP have fast path in sigqueue_add, because they can not be caught or masked. The sigqueue() syscall allows user code to queue a signal to target process, if resource is unavailable, EAGAIN will be returned as specification said. Just before thread exits, signal queue memory will be freed by sigqueue_flush. Current, all signals are allowed to be queued, not only realtime signals. Earlier patch reviewed by: jhb, deischen Tested on: i386, amd64 Notes: svn path=/head/; revision=151316
* Fix the "fpudna: fpcurthread == curthread XXX times" problem.Stephan Uphoff2005-09-221-0/+1
| | | | | | | | | Tested by: kris@ Reviewed by: peter@ MFC after: 3 days Notes: svn path=/head/; revision=150473
* Move MODULE_DEPEND() statements for SYSVIPC dependencies to linux_ipc.cJohn Baldwin2005-07-291-3/+0
| | | | | | | | so that they aren't duplicated 3 times and are also in the same file as the code that depends on the SYSVIPC modules. Notes: svn path=/head/; revision=148540
* Make ps_nargvstr and ps_nenvstr unsigned. This fixes an inputDavid Schultz2005-03-231-2/+2
| | | | | | | | | | | | | | validation error in procfs/linprocfs that can be exploited by local users to cause a kernel panic. All versions of FreeBSD with the patch referenced in SA-04:17.procfs have this bug, but versions without that patch have a more serious bug instead. This problem only affects systems on which procfs or linprocfs is mounted. Found by: Coverity Prevent analysis tool Security: Local DOS Notes: svn path=/head/; revision=144011
* - Add a custom version of exec_copyin_args() to deal with the 32-bitJohn Baldwin2005-02-181-7/+6
| | | | | | | | | | | | | | | pointers in argv and envv in userland and use that together with kern_execve() and exec_free_args() to implement linux_execve() for the amd64/linux32 ABI without using the stackgap. - Implement linux_nanosleep() using the recently added kern_nanosleep(). - Use linux_emul_convpath() instead of linux_emul_find() in exec_linux_imgact_try(). Tested by: cokane Silence on: amd64 Notes: svn path=/head/; revision=142057
* o Split out kernel part of execve(2) syscall into two parts: one thatMaxim Sobolev2005-01-291-9/+9
| | | | | | | | | | | | | | copies arguments into the kernel space and one that operates completely in the kernel space; o use kernel-only version of execve(2) to kill another stackgap in linuxlator/i386. Obtained from: DragonFlyBSD (partially) MFC after: 2 weeks Notes: svn path=/head/; revision=140992
* Don't include sys/user.h merely for its side-effect of recursivelyDavid Schultz2004-11-271-1/+2
| | | | | | | including other headers. Notes: svn path=/head/; revision=138129
* I missed an 'IA32' in the documentation.David E. O'Brien2004-08-161-1/+1
| | | | Notes: svn path=/head/; revision=133846
* I'm not sure what tjr envisioned for turning on FreeBSD/i386 rt support,David E. O'Brien2004-08-161-4/+3
| | | | | | | | but make it COMPAT_IA32 for now. Fix the 'DEBUG' argument code to unbreak the amd64 LINT build. Notes: svn path=/head/; revision=133844