about summary refs log tree commit diff
path: root/arch/i386
Commit message (Collapse)AuthorAgeFilesLines
* fix missing synchronization in atomic store on i386 and x86_64Rich Felker2015-07-281-1/+1
| | | | | | | | | | | | | | | | | despite being strongly ordered, the x86 memory model does not preclude reordering of loads across earlier stores. while a plain store suffices as a release barrier, we actually need a full barrier, since users of a_store subsequently load a waiter count to determine whether to issue a futex wait, and using a stale count will result in soft (fail-to-wake) deadlocks. these deadlocks were observed in malloc and possible with stdio locks and other libc-internal locking. on i386, an atomic operation on the caller's stack is used as the barrier rather than performing the store itself using xchg; this avoids the need to read the cache line on which the store is being performed. mfence is used on x86_64 where it's always available, and could be used on i386 with the appropriate cpu model checks if it's shown to perform better.
* fix inconsistency in a_and and a_or argument types on x86[_64]Rich Felker2015-05-201-4/+4
| | | | | | conceptually, and on other archs, these functions take a pointer to int, but in the i386, x86_64, and x32 versions of atomic.h, they took a pointer to void instead.
* use hidden visibility for i386 asm-internal __vsyscall symbolRich Felker2015-04-141-7/+7
| | | | | otherwise the call instruction in the inline syscall asm results in textrels without ld-time binding.
* dynamic linker bootstrap overhaulRich Felker2015-04-132-44/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | this overhaul further reduces the amount of arch-specific code needed by the dynamic linker and removes a number of assumptions, including: - that symbolic function references inside libc are bound at link time via the linker option -Bsymbolic-functions. - that libc functions used by the dynamic linker do not require access to data symbols. - that static/internal function calls and data accesses can be made without performing any relocations, or that arch-specific startup code handled any such relocations needed. removing these assumptions paves the way for allowing libc.so itself to be built with stack protector (among other things), and is achieved by a three-stage bootstrap process: 1. relative relocations are processed with a flat function. 2. symbolic relocations are processed with no external calls/data. 3. main program and dependency libs are processed with a fully-functional libc/ldso. reduction in arch-specific code is achived through the following: - crt_arch.h, used for generating crt1.o, now provides the entry point for the dynamic linker too. - asm is no longer responsible for skipping the beginning of argv[] when ldso is invoked as a command. - the functionality previously provided by __reloc_self for heavily GOT-dependent RISC archs is now the arch-agnostic stage-1. - arch-specific relocation type codes are mapped directly as macros rather than via an inline translation function/switch statement.
* move O_PATH definition back to arch bitsRich Felker2015-04-011-0/+1
| | | | | | | while it's the same for all presently supported archs, it differs at least on sparc, and conceptually it's no less arch-specific than the other O_* macros. O_SEARCH and O_EXEC are still defined in terms of O_PATH in the main fcntl.h.
* fix MINSIGSTKSZ values for archs with large signal contextsRich Felker2015-03-181-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | the previous values (2k min and 8k default) were too small for some archs. aarch64 reserves 4k in the signal context for future extensions and requires about 4.5k total, and powerpc reportedly uses over 2k. the new minimums are chosen to fit the saved context and also allow a minimal signal handler to run. since the default (SIGSTKSZ) has always been 6k larger than the minimum, it is also increased to maintain the 6k usable by the signal handler. this happens to be able to store one pathname buffer and should be sufficient for calling any function in libc that doesn't involve conversion between floating point and decimal representations. x86 (both 32-bit and 64-bit variants) may also need a larger minimum (around 2.5k) in the future to support avx-512, but the values on these archs are left alone for now pending further analysis. the value for PTHREAD_STACK_MIN is not increased to match MINSIGSTKSZ at this time. this is so as not to preclude applications from using extremely small thread stacks when they know they will not be handling signals. unfortunately cancellation and multi-threaded set*id() use signals as an implementation detail and therefore require a stack large enough for a signal context, so applications which use extremely small thread stacks may still need to avoid using these features.
* fix FLT_ROUNDS to reflect the current rounding modeSzabolcs Nagy2015-03-071-1/+0
| | | | | Implemented as a wrapper around fegetround introducing a new function to the ABI: __flt_rounds. (fegetround cannot be used directly from float.h)
* fix POLLWRNORM and POLLWRBAND on mipsTrutz Behn2015-03-041-0/+0
| | | | | | these macros have the same distinct definition on blackfin, frv, m68k, mips, sparc and xtensa kernels. POLLMSG and POLLRDHUP additionally differ on sparc.
* make all objects used with atomic operations volatileRich Felker2015-03-031-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the memory model we use internally for atomics permits plain loads of values which may be subject to concurrent modification without requiring that a special load function be used. since a compiler is free to make transformations that alter the number of loads or the way in which loads are performed, the compiler is theoretically free to break this usage. the most obvious concern is with atomic cas constructs: something of the form tmp=*p;a_cas(p,tmp,f(tmp)); could be transformed to a_cas(p,*p,f(*p)); where the latter is intended to show multiple loads of *p whose resulting values might fail to be equal; this would break the atomicity of the whole operation. but even more fundamental breakage is possible. with the changes being made now, objects that may be modified by atomics are modeled as volatile, and the atomic operations performed on them by other threads are modeled as asynchronous stores by hardware which happens to be acting on the request of another thread. such modeling of course does not itself address memory synchronization between cores/cpus, but that aspect was already handled. this all seems less than ideal, but it's the best we can do without mandating a C11 compiler and using the C11 model for atomics. in the case of pthread_once_t, the ABI type of the underlying object is not volatile-qualified. so we are assuming that accessing the object through a volatile-qualified lvalue via casts yields volatile access semantics. the language of the C standard is somewhat unclear on this matter, but this is an assumption the linux kernel also makes, and seems to be the correct interpretation of the standard.
* add syscall numbers for the new execveat syscallSzabolcs Nagy2015-02-091-0/+2
| | | | | | | | | this syscall allows fexecve to be implemented without /proc, it is new in linux v3.19, added in commit 51f39a1f0cea1cacf8c787f652f26dfee9611874 (sh and microblaze do not have allocated syscall numbers yet) added a x32 fix as well: the io_setup and io_submit syscalls are no longer common with x86_64, so use the x32 specific numbers.
* move MREMAP_MAYMOVE and MREMAP_FIXED out of bitsTrutz Behn2015-01-301-3/+0
| | | | | | the definitions are generic for all kernel archs. exposure of these macros now only occurs on the same feature test as for the function accepting them, which is believed to be more correct.
* add new syscall numbers for bpf and kexec_file_loadSzabolcs Nagy2014-12-231-0/+2
| | | | | | | | | | | these syscalls are new in linux v3.18, bpf is present on all supported archs except sh, kexec_file_load is only allocted for x86_64 and x32 yet. bpf was added in linux commit 99c55f7d47c0dc6fc64729f37bf435abf43f4c60 kexec_file_load syscall number was allocated in commit f0895685c7fd8c938c91a9d8a6f7c11f22df58d2
* move wint_t definition to the shared part of alltypes.h.inRich Felker2014-12-211-1/+0
|
* add explicit barrier operation to internal atomic.h APIRich Felker2014-10-101-0/+5
|
* add new syscall numbers for seccomp, getrandom, memfd_createSzabolcs Nagy2014-10-081-0/+6
| | | | | | | | | | | | | | | | | | these syscalls are new in linux v3.17 and present on all supported archs except sh. seccomp was added in commit 48dc92b9fc3926844257316e75ba11eb5c742b2c it has operation, flags and pointer arguments (if flags==0 then it is the same as prctl(PR_SET_SECCOMP,...)), the uapi header for flag definitions is linux/seccomp.h getrandom was added in commit c6e9d6f38894798696f23c8084ca7edbf16ee895 it provides an entropy source when open("/dev/urandom",..) would fail, the uapi header for flags is linux/random.h memfd_create was added in commit 9183df25fe7b194563db3fec6dc3202a5855839c it allows anon mmap to have an fd, that can be shared, sealed and needs no mount point, the uapi header for flags is linux/memfd.h
* fix C++ incompatibility in i386 definition of max_align_tRich Felker2014-09-111-0/+4
| | | | | | the C11 _Alignas keyword is not present in C++, and despite it being in the reserved namespace and thus reasonable to support even in non-C11 modes, compilers seem to fail to support it.
* add threads.h and needed per-arch types for mtx_t and cnd_tRich Felker2014-09-061-0/+2
| | | | | | | | | | | | | | | | based on patch by Jens Gustedt. mtx_t and cnd_t are defined in such a way that they are formally "compatible types" with pthread_mutex_t and pthread_cond_t, respectively, when accessed from a different translation unit. this makes it possible to implement the C11 functions using the pthread functions (which will dereference them with the pthread types) without having to use the same types, which would necessitate either namespace violations (exposing pthread type names in threads.h) or incompatible changes to the C++ name mangling ABI for the pthread types. for the rest of the types, things are much simpler; using identical types is possible without any namespace considerations.
* add max_align_t definition for C11 and C++11Rich Felker2014-08-201-0/+2
| | | | | | | | | | | | | | | | | unfortunately this needs to be able to vary by arch, because of a huge mess GCC made: the GCC definition, which became the ABI, depends on quirks in GCC's definition of __alignof__, which does not match the formal alignment of the type. GCC's __alignof__ unexpectedly exposes the an implementation detail, its "preferred alignment" for the type, rather than the formal/ABI alignment of the type, which it only actually uses in structures. on most archs the two values are the same, but on some (at least i386) the preferred alignment is greater than the ABI alignment. I considered using _Alignas(8) unconditionally, but on at least one arch (or1k), the alignment of max_align_t with GCC's definition is only 4 (even the "preferred alignment" for these types is only 4).
* make pointers used in robust list volatileRich Felker2014-08-171-1/+1
| | | | | | | | | | | | | | | | | | | | when manipulating the robust list, the order of stores matters, because the code may be asynchronously interrupted by a fatal signal and the kernel will then access the robust list in what is essentially an async-signal context. previously, aliasing considerations made it seem unlikely that a compiler could reorder the stores, but proving that they could not be reordered incorrectly would have been extremely difficult. instead I've opted to make all the pointers used as part of the robust list, including those in the robust list head and in the individual mutexes, volatile. in addition, the format of the robust list has been changed to point back to the head at the end, rather than ending with a null pointer. this is to match the documented kernel robust list ABI. the null pointer, which was previously used, only worked because faults during access terminate the robust list processing.
* clean up unused and inconsistent atomics in arch dirsRich Felker2014-07-271-23/+0
| | | | | | | | | | | the a_cas_l, a_swap_l, a_swap_p, and a_store_l operations were probably used a long time ago when only i386 and x86_64 were supported. as other archs were added, support for them was inconsistent, and they are obviously not in use at present. having them around potentially confuses readers working on new ports, and the type-punning hacks and inconsistent use of types in their definitions is not a style I wish to perpetuate in the source tree, so removing them seems appropriate.
* add syscall numbers for the new renameat2 syscallSzabolcs Nagy2014-07-201-0/+2
| | | | | it's like rename but with flags eg. to allow atomic exchange of two files, introduced in linux 3.15 commit 520c8b16505236fc82daa352e6c5e73cd9870cff
* add tlsdesc support for i386Rich Felker2014-06-191-0/+2
|
* refactor to remove arch-specific relocation code from dynamic linkerRich Felker2014-06-181-30/+11
| | | | | | | | | | | this was one of the main instances of ugly code duplication: all archs use basically the same types of relocations, but roughly equivalent logic was duplicated for each arch to account for the different naming and numbering of relocation types and variation in whether REL or RELA records are used. as an added bonus, both REL and RELA are now supported on all archs, regardless of which is used by the standard toolchain.
* dynamic linker: permit error returns from arch-specific reloc functionRich Felker2014-06-161-1/+2
| | | | | | | | the immediate motivation is supporting TLSDESC relocations which require allocation and thus may fail (unless we pre-allocate), but this mechanism should also be used for throwing an error on unsupported or invalid relocation types, and perhaps in certain cases, for reporting when a relocation is not satisfiable.
* add vdso clock_gettime acceleration support to i386Rich Felker2014-06-061-0/+4
|
* add sched_{get,set}attr syscall numbers and SCHED_DEADLINE macroSzabolcs Nagy2014-05-301-0/+4
| | | | | | | | | | | | linux 3.14 introduced sched_getattr and sched_setattr syscalls in commit d50dde5a10f305253cbc3855307f608f8a3c5f73 and the related SCHED_DEADLINE scheduling policy in commit aab03e05e8f7e26f51dee792beddcb5cca9215a5 but struct sched_attr "extended scheduling parameters data structure" is not yet exported to userspace (necessary for using the syscalls) so related uapi definitions are not added yet.
* make socketcall types common as they are same for all architecturesTimo Teräs2014-04-171-22/+0
|
* fix RLIMIT_ constants for mipsSzabolcs Nagy2014-04-151-0/+0
| | | | | | | The mips arch is special in that it uses different RLIMIT_ numbers than other archs, so allow bits/resource.h to override the default RLIMIT_ numbers (empty on all archs except mips). Reported by orc.
* fix signal.h breakage from moving stack_t to arch-specific bitsRich Felker2014-03-181-6/+6
| | | | | | in the previous changes, I missed the fact that both the prototype of the sigaltstack function and the definition of ucontext_t depend on stack_t.
* move signal.h definition of stack_t to arch-specific bitsRich Felker2014-03-181-0/+6
| | | | | it's different at least on mips. mips version will be fixed in a separate commit to show the change.
* move struct semid_ds to from shared sys/sem.h to bitsRich Felker2014-03-111-0/+16
| | | | | | | | | | | | the definition was found to be incorrect at least for powerpc, and fixing this cleanly requires making the definition arch-specific. this will allow cleaning up the definition for other archs to make it more specific, and reversing some of the ugliness (time_t hacks) introduced with the x32 port. this first commit simply copies the existing definition to each arch without any changes. this is intentional, to make it easier to review changes made on a per-arch basis.
* sys/shm.h: move arch specific structs to bits/rofl0r2014-02-231-0/+11
|
* add IUTF8 to termios.h on archs that were missing itRich Felker2014-01-081-0/+1
|
* fix namespace violations in termios.h, at least mostlyRich Felker2014-01-081-8/+7
| | | | | | the fix should be complete on archs that use the generic definitions (i386, arm, x86_64, microblaze), but mips and powerpc have not been checked thoroughly and may need more fixes.
* add O_TMPFILE flag, new in linux 3.11Szabolcs Nagy2013-11-231-0/+1
| | | | | | definition in linux: #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY) where __O_TMPFILE and O_DIRECTORY are arch specific
* add missing i386 syscall numbersRich Felker2013-09-261-0/+10
| | | | somehow the range 335-339 was missed when updating the file.
* remove the __mxcsr member from fenv_t on i386 to follow the glibc abiSzabolcs Nagy2013-08-181-1/+0
| | | | | | in the previous commit sse fenv support was added, but there is no need to save mxcsr (sse fenv register) so fix the abi incompatibility with glibc.
* new mostly-C crt1 implementationRich Felker2013-07-261-0/+13
| | | | | | | | | | | | | | | the only immediate effect of this commit is enabling PIE support on some archs that did not previously have any Scrt1.s, since the existing asm files for crt1 override this C code. so some of the crt_arch.h files committed are only there for the sake of documenting what their archs "would do" if they used the new C-based crt1. the expectation is that new archs should use this new system rather than using heavy asm for crt1. aside from being easier and less error-prone, it also ensures that PIE support is available immediately (since Scrt1.o is generated from the same C source, using -fPIC) rather than having to be added as an afterthought in the porting process.
* change jmp_buf to share an underlying type and struct tag with sigjmp_bufRich Felker2013-07-241-1/+1
| | | | | | | | | | this is necessary to meet the C++ ABI target. alternatives were considered to avoid the size increase for non-sig jmp_buf objects, but they seemed to have worse properties. moreover, the relative size increase is only extreme on x86[_64]; one way of interpreting this is that, if the size increase from this patch makes jmp_buf use too much memory, then the program was already using too much memory when built for non-x86 archs.
* fix regression in size of nlink_t (broken stat struct) on x86_64Rich Felker2013-07-221-0/+1
| | | | | | | | rather than moving nlink_t back to the arch-specific file, I've added a macro _Reg defined to the canonical type for register-size values on the arch. this is not the same as _Addr for (not-yet-supported) 32-on-64 pseudo-archs like x32 and mips n32, so a new macro was needed.
* change wint_t to unsignedRich Felker2013-07-221-1/+1
| | | | | | | | | | | | aside from the obvious C++ ABI purpose for this change, it also brings musl into alignment with the compiler's idea of the definition of wint_t (use in -Wformat), and makes the situation less awkward on ARM, where wchar_t is unsigned. internal code using wint_t and WEOF was checked against this change, and while a few cases of storing WEOF into wchar_t were found, they all seem to operate properly with the natural conversion from unsigned to signed.
* refactor headers, especially alltypes.h, and improve C++ ABI compatRich Felker2013-07-223-149/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the arch-specific bits/alltypes.h.sh has been replaced with a generic alltypes.h.in and minimal arch-specific bits/alltypes.h.in. this commit is intended to have no functional changes except: - exposing additional symbols that POSIX allows but does not require - changing the C++ name mangling for some types - fixing the signedness of blksize_t on powerpc (POSIX requires signed) - fixing the limit macros for sig_atomic_t on x86_64 - making dev_t an unsigned type (ABI matching goal, and more logical) in addition, some types that were wrongly defined with long on 32-bit archs were changed to int, and vice versa; this change is non-functional except for the possibility of making pointer types mismatch, and only affects programs that were using them incorrectly, and only at build-time, not runtime. the following changes were made in the interest of moving non-arch-specific types out of the alltypes system and into the headers they're associated with, and also will tend to improve application compatibility: - netdb.h now includes netinet/in.h (for socklen_t and uint32_t) - netinet/in.h now includes sys/socket.h and inttypes.h - sys/resource.h now includes sys/time.h (for struct timeval) - sys/wait.h now includes signal.h (for siginfo_t) - langinfo.h now includes nl_types.h (for nl_item) for the types in stdint.h: - types which are of no interest to other headers were moved out of the alltypes system. - fast types for 8- and 64-bit are hard-coded (at least for now); only the 16- and 32-bit ones have reason to vary by arch. and the following types have been changed for C++ ABI purposes; - mbstate_t now has a struct tag, __mbstate_t - FILE's struct tag has been changed to _IO_FILE - DIR's struct tag has been changed to __dirstream - locale_t's struct tag has been changed to __locale_struct - pthread_t is defined as unsigned long in C++ mode only - fpos_t now has a struct tag, _G_fpos64_t - fsid_t's struct tag has been changed to __fsid_t - idtype_t has been made an enum type (also required by POSIX) - nl_catd has been changed from long to void * - siginfo_t's struct tag has been removed - sigset_t's has been given a struct tag, __sigset_t - stack_t has been given a struct tag, sigaltstack - suseconds_t has been changed to long on 32-bit archs - [u]intptr_t have been changed from long to int rank on 32-bit archs - dev_t has been made unsigned summary of tests that have been performed against these changes: - nsz's libc-test (diff -u before and after) - C++ ABI check symbol dump (diff -u before, after, glibc) - grepped for __NEED, made sure types needed are still in alltypes - built gcc 3.4.6
* change uid_t, gid_t, and id_t to unsigned typesRich Felker2013-07-191-3/+3
| | | | | | | | | this change is both to fix one of the remaining type (and thus C++ ABI) mismatches with glibc/LSB and to allow use of the full range of uid and gid values, if so desired. passwd/group access functions were not prepared to deal with unsigned values, so they too have been fixed with this commit.
* make the dynamic linker find its path file relative to its own locationRich Felker2013-07-181-1/+1
| | | | | | | | | | | | | | | | | | | prior to this change, using a non-default syslibdir was impractical on systems where the ordinary library paths contain musl-incompatible library files. the file containing search paths was always taken from /etc, which would either correspond to a system-wide musl installation, or fail to exist at all, resulting in searching of the default library path. the new search strategy is safe even for suid programs because the pathname used comes from the PT_INTERP header of the program being run, rather than any external input. as part of this change, I have also begun differentiating the names of arch variants that differ by endianness or floating point calling convention. the corresponding changes in the build system and and gcc wrapper script (to use an alternate dynamic linker name) for these configurations have not yet been made.
* respect iso c namespace in stdio.h and wchar.h regarding va_listRich Felker2013-06-251-0/+2
| | | | | | | | | | despite declaring functions that take arguments of type va_list, these headers are not permitted by the c standard to expose the definition of va_list, so an alias for the type must be used. the name __isoc_va_list was chosen to convey that the purpose of this alternate name is for iso c conformance, and to avoid the multitude of names which gcc mangles with its hideous "fixincludes" monstrosity, leading to serious header breakage if these "fixes" are run.
* Merge remote-tracking branch 'nsz/review'Rich Felker2013-05-261-3/+3
|\
| * fix ioctl _IOR, _IOW, etc macros to avoid signed overflow (2<<30)Szabolcs Nagy2013-05-261-3/+3
| |
* | change underlying type of clock_t to be uniform and match ABIRich Felker2013-05-231-1/+1
|/ | | | | | | | | | previously we were using an unsigned type on 32-bit systems so that subtraction would be well-defined when it wrapped, but since wrapping is non-conforming anyway (when clock() overflows, it has to return -1) the only use of unsigned would be to buy a little bit more time before overflow. this does not seem worth having the type vary per-arch (which leads to more arch-specific bugs) or disagree with the ABI musl (mostly) follows.
* add FLT_TRUE_MIN, etc. macros from C11Rich Felker2013-05-171-0/+1
| | | | | | | | there was some question as to how many decimal places to use, since one decimal place is always sufficient to identify the smallest denormal uniquely. for now, I'm following the example in the C standard which is consistent with the other min/max macros we already had in place.
* fix type issues in stdint.h so underlying types of 64-bit types match ABIRich Felker2013-04-041-0/+3
|