aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/powerpc64
Commit message (Collapse)AuthorAgeFilesLines
* libc/powerpc64: Fix swapcontext(3)Timothy Pearson2025-07-132-1/+16
| | | | | | | | | | | | | | | | | | | | | On PowerPC platforms a valid link to the Table of Contents (TOC) is required for PLT lookups to function. This TOC pointer is stored in a dedicated register, and is used along with the stack pointer by both C prologue and PLT lookup code. When calling swapcontext() with uc_link != NULL, a PLT lookup to setcontext(3) is attempted from within the _ctx_done context. The exiting process has usually trashed both r1 and r2 at this point, leading to a crash within the PLT lookup before setcontext(2) is reached to restore the linked context. Save and restore r2 as in a regular function. This ensures the subsequent PLT lookup to setcontext(3) succeeds. Signed-off-by: Timothy Pearson <tpearson@raptorengineering.com> MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/1759
* libc, libthr: Ditch MD __pthread_distribute_static_tls helpersJessica Clarke2025-05-291-44/+0
| | | | | | | | | | | | | | | | | | _libc_get_static_tls_base() is just _tcb_get() followed by adding (for Variant I) or subtracting (for Variant II) the offset, so just inline that as the implementation (like we do in rtld-elf) rather than having another copy (or equivalent) of _tcb_get()'s assembly. _get_static_tls_base() doesn't even have any MD assembly as it's reading thr->tcb, the only difference is whether to add or subtract, so again just inline that. Whilst here add some missing blank lines to comply with style(9) for elf_utils.c's includes, and use a pointer type rather than uintptr_t to reduce the need to cast, as is done in rtld-elf. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D50592
* Remove residual blank line at start of MakefileWarner Losh2024-07-153-3/+0
| | | | | | | This is a residual of the $FreeBSD$ removal. MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
* libc/softfloat: we don't export _fp[gs]et* symbolsBrooks Davis2024-03-131-4/+0
| | | | | | | | | | Remove attempts to use NetBSD __weak_alias macros to export _-prefixed versions of various fp[sg]et* symbols under softfloat. __weak_alias isn't defined so we didn't export them and thus the Symbol.map entries were wrong. Reviewed by: jhibbits Differential Revision: https://reviews.freebsd.org/D44327
* lib{c,sys}: return wrapped syscall APIs to libcBrooks Davis2024-03-131-0/+2
| | | | | | | | | | | | | These provide standard APIs, but are implemented using another system call (e.g., pipe implemented in terms of pipe2) or are interposed by the threading library to support cancelation. After discussion with kib (see D44111), I've concluded that it is better to keep most public interfaces in libc with as little as possible in libsys. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D44241
* lib{c,sys}: expose _getlogin consistentlyBrooks Davis2024-02-291-4/+0
| | | | | | | | | | Historically we exposed _getlogin as a private symbol on a per-arch basis (except on aarch64 and riscv) for no obvious reason. We now need to expose it for libc's use so remove the special case from makesyscalls.lua and expose it in the generated syscalls.map. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D44116
* libc: move MD sys related symbols to libsysBrooks Davis2024-02-051-9/+0
| | | | | | | This is a mix genuine MD interfaces and compat symbols like _getlogin. Reviewed by: kib, emaste, imp Pull Request: https://github.com/freebsd/freebsd-src/pull/908
* libc: Move per-arch sys/Makefile.inc to libsysBrooks Davis2024-02-051-4/+0
| | | | | | | | | | | | | | | libc/<arch>/sys/Makefile.inc -> libsys/<arch>/Makefile.sys. Require that libsys/<arch>/Makefile.sys exist. At least for current archtiectures, it's not possible for an architecture to not have and MD syscall bits. powerpcspe/Makefile.sys's structure means it had to be modified when moved so rename detection won't work, but it has trivial contents so the history is unimportant. Reviewed by: kib, emaste, imp Pull Request: https://github.com/freebsd/freebsd-src/pull/908
* libc: libc/<arch>/sys/__vdso_gettc -> libsys/<arch>/Brooks Davis2024-02-051-62/+0
| | | | | Reviewed by: kib, emaste, imp Pull Request: https://github.com/freebsd/freebsd-src/pull/908
* libsys: relocate implementations and manpagesBrooks Davis2024-02-052-130/+0
| | | | | | | | | Remove core system call implementations and documentation to lib/libsys and lib/libsys/<arch> from lib/libc/sys and lib/libc/<arch>/<sys>. Update paths to allow libc to find them in their new home. Reviewed by: kib, emaste, imp Pull Request: https://github.com/freebsd/freebsd-src/pull/908
* powerpc64/SYS.h: implement _SYSCALL_BODY() macroBrooks Davis2024-01-091-18/+10
| | | | | | | | | Add _SYSCALL_BODY() macro which invokes the syscall via _SYCALL() and calls cerror as required. Use to implement PSEUDO() and RSYSCALL(). Reviewed by: jhibbits Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D43322
* Revert "power*/SYS.h: implement _SYSCALL_BODY() macro"Brooks Davis2023-12-211-10/+18
| | | | | | | bapt reports build errors on powerpc/powerpc so this is the most likely culprit. This reverts commit e88e1272792e41cbf0a5af1f5f0a858afece0475.
* power*/SYS.h: implement _SYSCALL_BODY() macroBrooks Davis2023-12-211-18/+10
| | | | | | | | | Add _SYSCALL_BODY() macro which invokes the syscall via _SYCALL() and calls cerror as required. Use to implement PSEUDO() and RSYSCALL(). Reviewed by: jhibbits Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D43056
* libc/*/SYS.h: remove SYCALL macroBrooks Davis2023-12-121-18/+0
| | | | | | | | | | | This has not been a univerally available interface since it was removed from amd64 by commit efbef97de9805dec95db09953426f0b21bb2964f in 2004. I removed the last consumers in 2016 when I replaced pipe(2) with pipe2(2) in commit b60998c6331e2be21f1fc29fa6c82d94a1f72ef0. Reviewed by: imp, jhibbits Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D42996
* libc: centralize a few numeric symbolsBrooks Davis2023-11-151-3/+0
| | | | | | | | | | | | fabs, __infinity, and __nan are universally implemented so declare them in gen/Symbol.map. We would also include __flt_rounds, but it's under FBSD_1.3 on arm so until that's gone we're stuck with it. Likewise, everyone but i386 implements fp[gs]etmask. Reviewed by: imp, kib, emaste Differential Revision: https://reviews.freebsd.org/D42618
* libc: centralize makecontext symbolsBrooks Davis2023-11-151-2/+0
| | | | | | | | Declare makecontext() and __makecontext() symbols centrally as they are always implemented. Reviewed by: imp, kib Differential Revision: https://reviews.freebsd.org/D42617
* libc: centralize {_,sig,}{set,long}jmp symbolsBrooks Davis2023-11-151-6/+0
| | | | | | | | | These symbols are universally exposed and documented so declare them centrally. Double- and triple-underscore versions exist on some platforms, but leave those alone for now. Reviewed by: imp, kib Differential Revision: https://reviews.freebsd.org/D42616
* libc: centralize ntoh symbolsBrooks Davis2023-11-151-4/+0
| | | | | | | | These are implemented by net/ntoh.c via headers and compiler intrinsics so declare them in net/Symbol.map. Reviewed by: imp, kib, emaste Differential Revision: https://reviews.freebsd.org/D42615
* libc: further centralize syscall symbolsBrooks Davis2023-11-151-4/+0
| | | | | | | | All architectures necessarily implement _exit(2) and vfork(2) so declare them in sys/Symbol.map. Reviewed by: imp, kib, emaste Differential Revision: https://reviews.freebsd.org/D42614
* libc: Remove empty comments in Symbol.mapBrooks Davis2023-11-151-3/+0
| | | | | | | These were left over from $FreeBSD$ removal. Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D42612
* libc/<arch>/sys/Makefile.inc: remove cruftBrooks Davis2023-11-151-1/+0
| | | | | | | | Remove stray blank lines left over from $FreeBSD$ removal as well as some CVS-era (perhaps pre-repocopy) version comments. Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D42611
* libc: Purge unneeded cdefs.hWarner Losh2023-11-0114-14/+0
| | | | | | | | | These sys/cdefs.h are not needed. Purge them. They are mostly left-over from the $FreeBSD$ removal. A few in libc are still required for macros that cdefs.h defines. Keep those. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D42385
* Purge more stray embedded $FreeBSD$ stringsJohn Baldwin2023-09-251-5/+0
| | | | | | | These do not use __FBSDID but instead use bare char arrays. Reviewed by: imp, emaste Differential Revision: https://reviews.freebsd.org/D41957
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-164-4/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-1624-49/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* Remove $FreeBSD$: one-line .c comment patternWarner Losh2023-08-167-7/+0
| | | | Remove /^/[*/]\s*\$FreeBSD\$.*\n/
* Remove $FreeBSD$: one-line .h patternWarner Losh2023-08-162-2/+0
| | | | Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-167-14/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* gdtoa: fix endianness issue on powerpc64lePiotr Kubaj2023-06-281-0/+14
| | | | | | | | The current code assumes running on big-endian, which causes issues with e.g. strtod() as reported on https://github.com/ocaml/ocaml/pull/10837#issuecomment-1605346422 This is probably a leftover from when powerpc64le was introduced. Approved by: jhibbits (on IRC)
* spdx: The BSD-2-Clause-NetBSD identifier is obsolete, drop -NetBSDWarner Losh2023-05-125-5/+5
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-NetBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-126-6/+6
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* libc: Remove _get_tp() and _set_tp().John Baldwin2021-12-094-89/+1
| | | | | | | | | Their uses have been replaced by _tcb_get() and _tcb_set() from <machine/tls.h>. Reviewed by: kib, jrtc27 Sponsored by: The University of Cambridge, Google Inc. Differential Revision: https://reviews.freebsd.org/D33354
* Add sched_getcpu()Konstantin Belousov2021-11-101-1/+3
| | | | | | | | | for compatibility with Linux. Reviewed by: jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32901
* libc: add _get_tp() private functionKonstantin Belousov2021-04-092-1/+49
| | | | | | | | which returns pointer to tcb Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D29623
* libc/<arch>/sys/cerror.S: fix typoKonstantin Belousov2021-04-031-1/+1
| | | | | Sponsored by: The FreeBSD Foundation MFC after: 3 days
* [PowerPC64] Port optimized strcpy to PPC64LELeandro Lupori2021-03-252-9/+64
| | | | | | | | Submitted by: Bruno Larsen <bruno.larsen@eldorado.org.br> Reviewed by: luporl, bdragon (IRC) MFC after: 1 week Sponsored by: Eldorado Research Institute (eldorado.org.br) Differential Revision: https://reviews.freebsd.org/D29067
* [PowerPC64] Enforce natural alignment in bcopyLeandro Lupori2021-03-251-0/+34
| | | | | | | | | | | | | | POWER architecture CPUs (Book-S) require natural alignment for cache-inhibited storage accesses. Since we can't know the caching model for a page ahead of time, always enforce natural alignment in bcopy. This fixes a SIGBUS when calling the function with misaligned pointers on POWER7. Submitted by: Bruno Larsen <bruno.larsen@eldorado.org.br> Reviewed by: luporl, bdragon (IRC) MFC after: 1 week Sponsored by: Eldorado Research Institute (eldorado.org.br) Differential Revision: https://reviews.freebsd.org/D28776
* [PowerPC64] Fix multiple issues in fpsetmask().Brandon Bergren2021-03-011-3/+3
| | | | | | | | | | | | | | | | | Building R exposed a problem in fpsetmask() whereby we were not properly clamping the provided mask to the valid range. R initilizes the mask by calling fpsetmask(~0) on FreeBSD. Since we recently enabled precise exceptions, this was causing an immediate SIGFPE because we were attempting to set invalid bits in the fpscr. Properly limit the range of bits that can be set via fpsetmask(). While here, use the correct fp_except_t type instead of fp_rnd_t. Reported by: pkubaj (in IRC) MFC after: 1 week Sponsored by: Tag1 Consulting, Inc.
* Add CFI start/end proc directives to arm64, i386, and ppcConrad Meyer2020-12-052-2/+5
| | | | | | | | | | | | | | Follow-up to r353959 and r368070: do the same for other architectures. arm32 already seems to use its own .fnstart/.fnend directives, which appear to be ARM-specific variants of the same thing. Likewise, MIPS uses .frame directives. Reviewed by: arichardson Differential Revision: https://reviews.freebsd.org/D27387 Notes: svn path=/head/; revision=368354
* [PowerPC64LE] Fix gdtoa configurations on LE.Brandon Bergren2020-09-231-0/+5
| | | | | | | | | | | | | | | | gdtoa wins the award for "most outdated endianness naming convention" with its IEEE_8087 vs IEEE_MC68k defines. I had a good chuckle. Update softfloat and arith.h to adjust to BE or LE automatically based on the low level preprocessor defines. Fixes printf/scanf on PowerPC64LE, although there is still a problem lurking regarding Signalling NaNs... Sponsored by: Tag1 Consulting, Inc. Notes: svn path=/head/; revision=366054
* [PowerPC64LE] Use a shared LIBC_ARCH for powerpc64le.Brandon Bergren2020-09-231-3/+8
| | | | | | | | | | | | | | | Given that we have converted to ELFv2 for BE already, endianness is the only difference between the two ARCHs. As such, there is no need to differentiate LIBC_ARCH between the two. Combining them like this lets us avoid needing to have two copies of several bits for no good reason. Sponsored by: Tag1 Consulting, Inc. Notes: svn path=/head/; revision=366039
* [PowerPC] Implement VDSO timebase access on powerpc*Brandon Bergren2020-09-083-2/+66
| | | | | | | | | | | | | | | | | Implement the remaining pieces needed to allow userland timestamp reading. Rewritten based on an intial essay into the problem by Justin Hibbits. (Copyright changed to my own on his request.) Tested on ppc64 (POWER9 Talos II), powerpcspe (e500v2 RB800), and powerpc (g4 PowerBook). Reviewed by: jhibbits (in irc) Sponsored by: Tag1 Consulting, Inc. Differential Revision: https://reviews.freebsd.org/D26347 Notes: svn path=/head/; revision=365442
* [POWERPC] Fix ppc64 makecontext() parameter overflow handling.Brandon Bergren2020-08-061-0/+4
| | | | | | | | | | | | | | | | | | On ELFv2, the overflow parameters in the stack frame are at a different offset from sp than ELFv1. Adjust code to use the correct offset in all cases. This had resulted in argv[8] and up being copied to the incorrect address in the new context's initial stack frame. This is not necessarily the only bug in this function, I need to do a full review still and ensure the rest of the math is sane for ELFv2 stack frames. Reported by: pherde (Probably. My notes are a bit unclear.) Reviewed by: jhibbits (in irc) Sponsored by: Tag1 Consulting, Inc. Notes: svn path=/head/; revision=363972
* Fix r358688 -- Remember to actually save r3 before processing.Brandon Bergren2020-03-111-1/+1
| | | | | | | | | | | | Crash was noticed by pkubaj building gcc9. Apparently non dword-aligned char pointers are somewhat rare in the wild. Reported by: pkubaj Sponsored by: Tag1 Consulting, Inc. Notes: svn path=/head/; revision=358902
* powerpc/memcpy: Don't predict the src and dst will be misalignedJustin Hibbits2020-03-061-1/+1
| | | | | | | | Predicting misalignment will pessimize the expected common case. Don't predict true or false in thise case. Notes: svn path=/head/; revision=358691
* Finish revert of r358672, missed in r358688.Justin Hibbits2020-03-061-1/+1
| | | | | | | | | Manual reverts never succeed correctly. Reported by: luporl Notes: svn path=/head/; revision=358690
* powerpc/powerpc64: Enforce natural alignment in memcpyJustin Hibbits2020-03-063-1/+13
| | | | | | | | | | | | | | | | | | Summary: POWER architecture CPUs (Book-S) require natural alignment for cache-inhibited storage accesses. Since we can't know the caching model for a page ahead of time, always enforce natural alignment in memcpy. This fixes a SIGBUS in X with acceleration enabled on POWER9. As part of this, revert r358672, it's no longer necessary with this fix. Regression tested by alfredo. Reviewed by: alfredo Differential Revision: https://reviews.freebsd.org/D23969 Notes: svn path=/head/; revision=358688
* [PowerPC64] restrict memcpy/bcopy optimization to POWER ISA >=V2.07Alfredo Dal'Ava Junior2020-03-051-1/+6
| | | | | | | | | | | | | | | | | | | | VSX instructions were added in POWER ISA V2.06 (POWER7), but it requires data to be word-aligned. Such requirement was removed in ISA V2.07B (POWER8). Since current memcpy/bcopy optimization relies on VSX instructions handling misalignment transparently, and kernel doesn't currently implement an alignment error handler, this optimzation should be restrict to ISA V2.07 onwards. SIGBUS on stxvd2x instruction was reproduced in POWER7+ CPU. Reviewed by: luporl, jhibbits, bdragon Approved by: jhibbits (mentor) Differential Revision: https://reviews.freebsd.org/D23958 Notes: svn path=/head/; revision=358672
* [PPC64] memcpy/memmove/bcopy optimizationLeandro Lupori2020-01-1510-0/+648
| | | | | | | | | | | | | | | | | | | | For copies shorter than 512 bytes, the data is copied using plain ld/std instructions. For 512 bytes or more, the copy is done in 3 phases: Phase 1: copy from the src buffer until it's aligned at a 16-byte boundary Phase 2: copy as many aligned 64-byte blocks from the src buffer as possible Phase 3: copy the remaining data, if any In phase 2, this code uses VSX instructions when available. Otherwise, it uses ldx/stdx. Submitted by: Luis Pires <lffpires_ruabrasil.org> (original version) Reviewed by: jhibbits Differential Revision: https://reviews.freebsd.org/D15118 Notes: svn path=/head/; revision=356767
* [PPC64] strncpy optimizationLeandro Lupori2020-01-154-1/+216
| | | | | | | | | | | | Assembly optimization of strncpy for PowerPC64, using double words instead of bytes to copy strings. Submitted by: Leonardo Bianconi <leonardo.bianconi_eldorado.org.br> (original version) Reviewed by: jhibbits Differential Revision: https://reviews.freebsd.org/D15369 Notes: svn path=/head/; revision=356766