1. 17 7月, 2019 2 次提交
    • R
      clean up mips64/n32 syscall asm constraints · ddc7c4f9
      Rich Felker 提交于
      ever since inline syscalls were added for (o32) mips in commit
      328810d3, the asm has nonsensically
      loaded the syscall number, rather than taking $2 as an input
      constraint to let the compiler load it. commit
      cfc09b1e improved on this somewhat by
      allowing a constant syscall number to propagate into an immediate, but
      missed that the whole operation made no sense.
      
      now, only $4, $5, $6, $8, and $9 are potential input-only registers.
      $2 is always input and output, and $7 is both when it's an argument,
      otherwise output-only. previously, $7 was treated as an input (with a
      "1" constraint matching its output position) even when it was not an
      input, which was arguably undefined behavior (asm input from
      indeterminate value). this is corrected.
      ddc7c4f9
    • R
      deduplicate mips64/n32 syscall clobbered register lists · db2a148d
      Rich Felker 提交于
      this patch is not purely non-functional changes, since before, $8 and
      $9 were wrongly in the clobberlist for syscalls with fewer than 5 or 6
      arguments. of course it's impossible for syscalls to have different
      clobbers depending on their number of arguments. the clobberlist for
      the recently-added 5- and 6-argument forms was correct, and for the 0-
      to 4-argument forms was erroneously copied from the mips o32 ABI where
      the additional arguments had to be passed on the stack.
      
      in making this change, I reviewed the kernel sources, and $8 and $9
      are always saved for 64-bit kernels since they're part of the syscall
      argument list for n32 and n64 ABIs.
      db2a148d
  2. 05 5月, 2019 1 次提交
  3. 11 4月, 2019 1 次提交
    • R
      implement inline 5- and 6-argument syscalls for mipsn32 and mips64 · 1bcdaeee
      Rich Felker 提交于
      n32 and n64 ABIs add new argument registers vs o32, so that passing on
      the stack is not necessary, so it's not clear why the 5- and
      6-argument versions were special-cased to begin with; it seems to have
      been pattern-copying from arch/mips (o32).
      
      i've treated the new argument registers like the first 4 in terms of
      clobber status (non-clobbered). hopefully this is correct.
      1bcdaeee
  4. 06 9月, 2018 1 次提交
    • R
      define and use internal macros for hidden visibility, weak refs · 9b95fd09
      Rich Felker 提交于
      this cleans up what had become widespread direct inline use of "GNU C"
      style attributes directly in the source, and lowers the barrier to
      increased use of hidden visibility, which will be useful to recovering
      some of the efficiency lost when the protected visibility hack was
      dropped in commit dc2f368e, especially
      on archs where the PLT ABI is costly.
      9b95fd09
  5. 07 9月, 2017 1 次提交
    • S
      make syscall.h consistent with linux · 822dddfb
      Szabolcs Nagy 提交于
      most of the found naming differences don't matter to musl, because
      internally it unifies the syscall names that vary across targets,
      but for external code the names should match the kernel uapi.
      
      aarch64:
      	__NR_fstatat is called __NR_newfstatat in linux.
      	__NR_or1k_atomic got mistakenly copied from or1k.
      arm:
      	__NR_arm_sync_file_range is an alias for __NR_sync_file_range2
      	__NR_fadvise64_64 is called __NR_arm_fadvise64_64 in linux,
      	the old non-arm name is kept too, it should not cause issues.
      	(powerpc has similar nonstandard fadvise and it uses the
      	normal name.)
      i386:
      	__NR_madvise1 was removed from linux in commit
      	303395ac3bf3e2cb488435537d416bc840438fcb 2011-11-11
      microblaze:
      	__NR_fadvise, __NR_fstatat, __NR_pread, __NR_pwrite
      	had different name in linux.
      mips:
      	__NR_fadvise, __NR_fstatat, __NR_pread, __NR_pwrite, __NR_select
      	had different name in linux.
      mipsn32:
      	__NR_fstatat is called __NR_newfstatat in linux.
      or1k:
      	__NR__llseek is called __NR_llseek in linux.
      	the old name is kept too because that's the name musl uses
      	internally.
      powerpc:
      	__NR_{get,set}res{gid,uid}32 was never present in powerpc linux.
      	__NR_timerfd was briefly defined in linux but then got renamed.
      822dddfb
  6. 01 6月, 2017 1 次提交
  7. 18 4月, 2016 1 次提交
  8. 28 1月, 2016 1 次提交
    • H
      mips: add vdso support · b0bf52f3
      Hauke Mehrtens 提交于
      vdso support is available on mips starting with kernel 4.4, see kernel
      commit a7f4df4e21 "MIPS: VDSO: Add implementations of gettimeofday()
      and clock_gettime()" for details.
      
      In Linux kernel 4.4.0 the mips code returns -ENOSYS in case it can not
      handle the vdso call and assumes the libc will call the original
      syscall in this case. Handle this case in musl. Currently Linux kernel
      4.4.0 handles the following types: CLOCK_REALTIME_COARSE,
      CLOCK_MONOTONIC_COARSE, CLOCK_REALTIME and CLOCK_MONOTONIC.
      b0bf52f3
  9. 16 12月, 2015 1 次提交
  10. 01 5月, 2015 1 次提交
  11. 08 4月, 2015 1 次提交
    • R
      fix possible clobbering of syscall return values on mips · 25748db3
      Rich Felker 提交于
      depending on the compiler's interpretation of __asm__ register names
      for register class objects, it may be possible for the return value in
      r2 to be clobbered by the function call to __stat_fix. I have not
      observed any such breakage in normal builds and suspect it only
      happens with -O0 or other unusual build options, but since there's an
      ambiguity as to the semantics of this feature, it's best to use an
      explicit temporary to avoid the issue.
      
      based on reporting and patch by Eugene.
      25748db3
  12. 21 7月, 2014 1 次提交
    • R
      fix regression that negated some mips syscall error returns · 1312930f
      Rich Felker 提交于
      due to what was essentially a copy and paste error, the changes made
      in commit f61be1f8 caused syscalls
      with 5 or 6 arguments (and syscalls with 2, 3, or 4 arguments when
      compiled with clang compatibility) to negate the returned error code a
      second time, breaking errno reporting.
      1312930f
  13. 20 7月, 2014 1 次提交
    • R
      fix mips struct stat dev_t members for big endian · f61be1f8
      Rich Felker 提交于
      the mips version of this structure on the kernel side wrongly has
      32-bit type rather than 64-bit type. fortunately there is adjacent
      padding to bring it up to 64 bits, and on little-endian, this allows
      us to treat the adjacent kernel st_dev and st_pad0[0] as as single
      64-bit dev_t. however, on big endian, such treatment results in the
      upper and lower 32-bit parts of the dev_t value being swapped. for the
      purpose of just comparing st_dev values this did not break anything,
      but it precluded actually processing the device numbers as major/minor
      values.
      
      since the broken kernel behavior that needs to be worked around is
      isolated to one arch, I put the workarounds in syscall_arch.h rather
      than adding a stat fixup path in the common code. on little endian
      mips, the added code optimizes out completely.
      
      the changes necessary were incompatible with the way the __asm_syscall
      macro was factored so I just removed it and flattened the individual
      __syscallN functions. this arguably makes the code easier to read and
      understand, anyway.
      f61be1f8
  14. 30 5月, 2014 1 次提交
    • S
      fix for broken kernel side RLIM_INFINITY on mips · 8258014f
      Szabolcs Nagy 提交于
      On 32 bit mips the kernel uses -1UL/2 to mark RLIM_INFINITY (and
      this is the definition in the userspace api), but since it is in
      the middle of the valid range of limits and limits are often
      compared with relational operators, various kernel side logic is
      broken if larger than -1UL/2 limits are used. So we truncate the
      limits to -1UL/2 in get/setrlimit and prlimit.
      
      Even if the kernel side logic consistently treated -1UL/2 as greater
      than any other limit value, there wouldn't be any clean workaround
      that allowed using large limits:
      * using -1UL/2 as RLIM_INFINITY in userspace would mean different
      infinity value for get/setrlimt and prlimit (where infinity is always
      -1ULL) and userspace logic could break easily (just like the kernel
      is broken now) and more special case code would be needed for mips.
      * translating -1UL/2 kernel side value to -1ULL in userspace would
      mean that -1UL/2 limit cannot be set (eg. -1UL/2+1 had to be passed
      to the kernel instead).
      8258014f
  15. 25 2月, 2014 1 次提交
    • R
      fixup general __syscall breakage introduced in x32 port · dbed3924
      rofl0r 提交于
      the reordering of headers caused some risc archs to not see
      the __syscall declaration anymore.
      this caused build errors on mips with any compiler,
      and on arm and microblaze with clang.
      
      we now declare it locally just like the powerpc port does.
      dbed3924
  16. 27 3月, 2013 1 次提交
    • R
      remove __SYSCALL_SSLEN arch macro in favor of using public _NSIG · ccc7b4c3
      Rich Felker 提交于
      the issue at hand is that many syscalls require as an argument the
      kernel-ABI size of sigset_t, intended to allow the kernel to switch to
      a larger sigset_t in the future. previously, each arch was defining
      this size in syscall_arch.h, which was redundant with the definition
      of _NSIG in bits/signal.h. as it's used in some not-quite-portable
      application code as well, _NSIG is much more likely to be recognized
      and understood immediately by someone reading the code, and it's also
      shorter and less cluttered.
      
      note that _NSIG is actually 65/129, not 64/128, but the division takes
      care of throwing away the off-by-one part.
      ccc7b4c3
  17. 15 9月, 2012 1 次提交
    • R
      fix buggy constraints in mips inline syscall asm · 4221f154
      Rich Felker 提交于
      if same register is used for input/output, the compiler must be told.
      otherwise is generates random junk code that clobbers the result. in
      pure syscall-wrapper functions, nothing went wrong, but in more
      complex functions where register allocation is non-trivial, things
      broke badly.
      4221f154
  18. 11 9月, 2012 2 次提交
    • R
      improve mips syscall asm constraints to use immediates, if possible · cfc09b1e
      Rich Felker 提交于
      by using the "ir" constraint (immediate or register) and the carefully
      constructed instruction addu $2,$0,%2 which can take either an
      immediate or a register for %2, the new inline asm admits maximal
      optimization with no register spillage to the stack when the compiler
      successfully performs constant propagration, but still works by
      allocating a register when the syscall number cannot be recognized as
      a constant. in the case of syscalls with 0-3 arguments it barely
      matters, but for 4-argument syscalls, using an immediate for the
      syscall number avoids creating a stack frame for the syscall wrapper
      function.
      cfc09b1e
    • R
      eliminate assumption that mips syscall restart preserves r25 · b94067ee
      Rich Felker 提交于
      all past and current kernel versions have done so, but there seems to
      be no reason it's necessary and the sentiment from everyone I've asked
      has been that we should not rely on it. instead, use r7 (an argument
      register) which will necessarily be preserved upon syscall restart.
      however this only works for 0-3 argument syscalls, and we have to
      resort to the function call for 4-argument syscalls.
      b94067ee
  19. 09 9月, 2012 2 次提交
    • R
      inline syscall support for mips · 328810d3
      Rich Felker 提交于
      this drastically reduces the size of some functions which are purely
      syscall wrappers.
      
      disabled for clang due to known bugs satisfying register constraints.
      328810d3
    • R
      syscall organization overhaul · 208eb584
      Rich Felker 提交于
      now public syscall.h only exposes __NR_* and SYS_* constants and the
      variadic syscall function. no macros or inline functions, no
      __syscall_ret or other internal details, no 16-/32-bit legacy syscall
      renaming, etc. this logic has all been moved to src/internal/syscall.h
      with the arch-specific parts in arch/$(ARCH)/syscall_arch.h, and the
      amount of arch-specific stuff has been reduced to a minimum.
      
      changes still need to be reviewed/double-checked. minimal testing on
      i386 and mips has already been performed.
      208eb584