1. 10 6月, 2016 1 次提交
    • S
      add preadv2 and pwritev2 syscall numbers for linux v4.6 · 78b1f3cb
      Szabolcs Nagy 提交于
      the syscalls take an additional flag argument, they were added in commit
      f17d8b35452cab31a70d224964cd583fb2845449 and a RWF_HIPRI priority hint
      flag was added to linux/fs.h in 97be7ebe53915af504fb491fb99f064c7cf3cb09.
      
      the syscall is not allocated for microblaze and sh yet.
      78b1f3cb
  2. 12 5月, 2016 1 次提交
  3. 30 3月, 2016 1 次提交
  4. 19 3月, 2016 2 次提交
    • S
      add copy_file_range syscall numbers from linux v4.5 · 84d4f5ee
      Szabolcs Nagy 提交于
      it was introduced for offloading copying between regular files
      in linux commit 29732938a6289a15e907da234d6692a2ead71855
      
      (microblaze and sh does not yet have the syscall number.)
      84d4f5ee
    • S
      deduplicate bits/mman.h · e9f1c798
      Szabolcs Nagy 提交于
      currently five targets use the same mman.h constants and the rest
      share most constants too, so move them to sys/mman.h before the
      bits/mman.h include where the differences can be corrected by
      redefinition of the macros.
      
      this fixes two minor bugs: POSIX_MADV_DONTNEED was wrong on most
      targets (it should be the same as MADV_DONTNEED), and sh defined
      the x86-only MAP_32BIT mmap flag.
      e9f1c798
  5. 28 1月, 2016 1 次提交
    • R
      deduplicate the bulk of the arch bits headers · 4dfac115
      Rich Felker 提交于
      all bits headers that were identical for a number of 'clean' archs are
      moved to the new arch/generic tree. in addition, a few headers that
      differed only cosmetically from the new generic version are removed.
      
      additional deduplication may be possible in mman.h and in several
      headers (limits.h, posix.h, stdint.h) that mostly depend on whether
      the arch is 32- or 64-bit, but they are left alone for now because
      greater gains are likely possible with more invasive changes to header
      logic, which is beyond the scope of this commit.
      4dfac115
  6. 27 1月, 2016 5 次提交
    • S
      add MCL_ONFAULT and MLOCK_ONFAULT mlockall and mlock2 flags · 789ff6a9
      Szabolcs Nagy 提交于
      they lock faulted pages into memory (useful when a small part of a
      large mapped file needs efficient access), new in linux v4.4, commit
      b0f205c2a3082dd9081f9a94e50658c5fa906ff1
      
      MLOCK_* is not in the POSIX reserved namespace for sys/mman.h
      789ff6a9
    • S
      add mlock2 syscall number from linux v4.4 · 51d5f139
      Szabolcs Nagy 提交于
      this is mlock with a flags argument, new in linux commit
      a8ca5d0ecbdde5cc3d7accacbd69968b0c98764e
      
      as usual microblaze and sh don't have allocated syscall number yet.
      51d5f139
    • S
      add new membarrier, userfaultfd and switch_endian syscalls · 09001a8f
      Szabolcs Nagy 提交于
      new in linux v4.3 added for aarch64, arm, i386, mips, or1k, powerpc,
      x32 and x86_64.
      
      membarrier is a system wide memory barrier, moves most of the
      synchronization cost to one side, new in kernel commit
      5b25b13ab08f616efd566347d809b4ece54570d1
      
      userfaultfd is useful for qemu and is new in kernel commit
      8d2afd96c20316d112e04d935d9e09150e988397
      
      switch_endian is powerpc only for switching endianness, new in commit
      529d235a0e190ded1d21ccc80a73e625ebcad09b
      09001a8f
    • S
      add new i386 socket syscall numbers · 37bfb68f
      Szabolcs Nagy 提交于
      new in linux v4.3 commit 9dea5dc921b5f4045a18c63eb92e84dc274d17eb
      direct calls instead of socketcall allow better seccomp filtering.
      
      musl continues to use socketcalls internally on i386. (older kernels
      would need a fallback mechanism if the direct calls were used.)
      37bfb68f
    • S
      change the internal socketcall selection logic · a5e133bf
      Szabolcs Nagy 提交于
      only use SYS_socketcall if SYSCALL_USE_SOCKETCALL is defined
      internally, otherwise use direct syscalls.
      
      this commit does not change the current behaviour, it is
      preparation for adding direct syscall numbers for i386.
      a5e133bf
  7. 22 1月, 2016 2 次提交
    • R
      clean up i386 atomics for new atomics framework · e24984ef
      Rich Felker 提交于
      this commit mostly makes consistent things like spacing, function
      ordering in atomic_arch.h, argument names, use of volatile, etc. the
      fake 64-bit and/or atomics are also removed because the shared
      atomic.h does a better job of implementing them; it avoids making two
      atomic memory accesses when only one 32-bit half needs to be touched.
      
      no major overhaul is needed or possible because x86 actually has
      native versions of all the usual atomic operations, rather than using
      ll/sc or needing cas loops.
      e24984ef
    • R
      refactor internal atomic.h · 1315596b
      Rich Felker 提交于
      rather than having each arch provide its own atomic.h, there is a new
      shared atomic.h in src/internal which pulls arch-specific definitions
      from arc/$(ARCH)/atomic_arch.h. the latter can be extremely minimal,
      defining only a_cas or new ll/sc type primitives which the shared
      atomic.h will use to construct everything else.
      
      this commit avoids making heavy changes to the individual archs'
      atomic implementations. definitions which are identical or
      near-identical to what the new shared atomic.h would produce have been
      removed, but otherwise the changes made are just hooking up the
      arch-specific files to the new infrastructure. major changes to take
      advantage of the new system will come in subsequent commits.
      1315596b
  8. 30 12月, 2015 1 次提交
    • R
      adjust i386 max_align_t definition to work around some broken compilers · 71991a80
      Rich Felker 提交于
      at least gcc 4.7 claims c++11 support but does not accept the alignas
      keyword, causing breakage when stddef.h is included in c++11 mode.
      instead, prefer using __attribute__((__aligned__)) on any compiler
      with GNU extensions, and only use the alignas keyword as a fallback
      for other C++ compilers.
      
      C code should not be affected by this patch.
      71991a80
  9. 03 11月, 2015 1 次提交
    • R
      properly access mcontext_t program counter in cancellation handler · cb1bf2f3
      Rich Felker 提交于
      using the actual mcontext_t definition rather than an overlaid pointer
      array both improves correctness/readability and eliminates some ugly
      hacks for archs with 64-bit registers bit 32-bit program counter.
      
      also fix UB due to comparison of pointers not in a common array
      object.
      cb1bf2f3
  10. 17 9月, 2015 1 次提交
    • R
      introduce new symbol-lookup-free rcrt1/dlstart stage chaining · 2907afb8
      Rich Felker 提交于
      previously, the call into stage 2 was made by looking up the symbol
      name "__dls2" (which was chosen short to be easy to look up) from the
      dynamic symbol table. this was no problem for the dynamic linker,
      since it always exports all its symbols. in the case of the static pie
      entry point, however, the dynamic symbol table does not contain the
      necessary symbol unless -rdynamic/-E was used when linking. this
      linking requirement is a major obstacle both to practical use of
      static-pie as a nommu binary format (since it greatly enlarges the
      file) and to upstream toolchain support for static-pie (adding -E to
      default linking specs is not reasonable).
      
      this patch replaces the runtime symbolic lookup with a link-time
      lookup via an inline asm fragment, which reloc.h is responsible for
      providing. in this initial commit, the asm is provided only for i386,
      and the old lookup code is left in place as a fallback for archs that
      have not yet transitioned.
      
      modifying crt_arch.h to pass the stage-2 function pointer as an
      argument was considered as an alternative, but such an approach would
      not be compatible with fdpic, where it's impossible to compute
      function pointers without already having performed relocations. it was
      also deemed desirable to keep crt_arch.h as simple/minimal as
      possible.
      
      in principle, archs with pc-relative or got-relative addressing of
      static variables could instead load the stage-2 function pointer from
      a static volatile object. that does not work for fdpic, and is not
      safe against reordering on mips-like archs that use got slots even for
      static functions, but it's a valid on i386 and many others, and could
      provide a reasonable default implementation in the future.
      2907afb8
  11. 09 9月, 2015 1 次提交
    • R
      fix missing earlyclobber flag in i386 a_ctz_64 asm · 878887c5
      Rich Felker 提交于
      this error was only found by reading the code, but it seems to have
      been causing gcc to produce wrong code in malloc: the same register
      was used for the output and the high word of the input. in principle
      this could have caused an infinite loop searching for an available
      bin, but in practice most x86 models seem to implement the "undefined"
      result of the bsf instruction as "unchanged".
      878887c5
  12. 29 7月, 2015 1 次提交
    • R
      fix missing synchronization in atomic store on i386 and x86_64 · 3c43c076
      Rich Felker 提交于
      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.
      3c43c076
  13. 20 5月, 2015 1 次提交
  14. 14 4月, 2015 1 次提交
  15. 13 4月, 2015 1 次提交
    • R
      dynamic linker bootstrap overhaul · f3ddd173
      Rich Felker 提交于
      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.
      f3ddd173
  16. 02 4月, 2015 1 次提交
    • R
      move O_PATH definition back to arch bits · fd427c4e
      Rich Felker 提交于
      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.
      fd427c4e
  17. 18 3月, 2015 1 次提交
    • R
      fix MINSIGSTKSZ values for archs with large signal contexts · d5a50453
      Rich Felker 提交于
      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.
      d5a50453
  18. 08 3月, 2015 1 次提交
  19. 05 3月, 2015 1 次提交
    • T
      fix POLLWRNORM and POLLWRBAND on mips · f5011c62
      Trutz Behn 提交于
      these macros have the same distinct definition on blackfin, frv, m68k,
      mips, sparc and xtensa kernels. POLLMSG and POLLRDHUP additionally
      differ on sparc.
      f5011c62
  20. 04 3月, 2015 1 次提交
    • R
      make all objects used with atomic operations volatile · 56fbaa3b
      Rich Felker 提交于
      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.
      56fbaa3b
  21. 10 2月, 2015 1 次提交
    • S
      add syscall numbers for the new execveat syscall · f54c28cb
      Szabolcs Nagy 提交于
      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.
      f54c28cb
  22. 31 1月, 2015 1 次提交
    • T
      move MREMAP_MAYMOVE and MREMAP_FIXED out of bits · 2d67ae92
      Trutz Behn 提交于
      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.
      2d67ae92
  23. 23 12月, 2014 1 次提交
    • S
      add new syscall numbers for bpf and kexec_file_load · f90fafea
      Szabolcs Nagy 提交于
      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
      f90fafea
  24. 21 12月, 2014 1 次提交
  25. 11 10月, 2014 1 次提交
  26. 08 10月, 2014 1 次提交
    • S
      add new syscall numbers for seccomp, getrandom, memfd_create · 4ffc39c6
      Szabolcs Nagy 提交于
      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
      4ffc39c6
  27. 11 9月, 2014 1 次提交
  28. 07 9月, 2014 1 次提交
    • R
      add threads.h and needed per-arch types for mtx_t and cnd_t · b7cf71a1
      Rich Felker 提交于
      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.
      b7cf71a1
  29. 21 8月, 2014 1 次提交
    • R
      add max_align_t definition for C11 and C++11 · 321f4fa9
      Rich Felker 提交于
      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).
      321f4fa9
  30. 17 8月, 2014 1 次提交
    • R
      make pointers used in robust list volatile · de7e99c5
      Rich Felker 提交于
      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.
      de7e99c5
  31. 28 7月, 2014 1 次提交
    • R
      clean up unused and inconsistent atomics in arch dirs · 90e51e45
      Rich Felker 提交于
      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.
      90e51e45
  32. 21 7月, 2014 1 次提交
  33. 19 6月, 2014 1 次提交
  34. 18 6月, 2014 1 次提交
    • R
      refactor to remove arch-specific relocation code from dynamic linker · adf94c19
      Rich Felker 提交于
      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.
      adf94c19