#
fa368cc8 |
| 09-Dec-2024 |
Olivier Certner <olce@FreeBSD.org> |
x86 atomics: Remove unused WANT_FUNCTIONS
This macro has not been in use since commit "inline atomics and allow tied modules to inline locks" (r335873, f4b3640475cec929).
Reviewed by: markj, kib
x86 atomics: Remove unused WANT_FUNCTIONS
This macro has not been in use since commit "inline atomics and allow tied modules to inline locks" (r335873, f4b3640475cec929).
Reviewed by: markj, kib, emaste, imp MFC after: 5 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48061
show more ...
|
Revision tags: release/14.2.0, release/13.4.0 |
|
#
5e9a82e8 |
| 19-Jul-2024 |
Olivier Certner <olce@FreeBSD.org> |
atomics: Constify loads
In order to match reality, allow using these functions with pointers on const objects, and bring us closer to C11.
Remove the '+' modifier in the atomic_load_acq_64_i586()'s
atomics: Constify loads
In order to match reality, allow using these functions with pointers on const objects, and bring us closer to C11.
Remove the '+' modifier in the atomic_load_acq_64_i586()'s inline asm statement's constraint for '*p' (the value to load). CMPXCHG8B always writes back some value, even when the value exchange does not happen in which case what was read is written back. atomic_load_acq_64_i586() further takes care of the operation atomically writing back the same value that was read in any case. All in all, this makes the inline asm's write back undetectable by any other code, whether executing on other CPUs or code on the same CPU before and after the call to atomic_load_acq_64_i586(), except for the fact that CMPXCHG8B will trigger a #GP(0) if the memory address is part of a read-only mapping. This unfortunate property is however out of scope of the C abstract machine, and in particular independent of whether the 'uint64_t' pointed to is declared 'const' or not.
Approved by: markj (mentor) MFC after: 5 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D46887
show more ...
|
#
a80b9ee1 |
| 19-Nov-2024 |
John Baldwin <jhb@FreeBSD.org> |
atomic(9): Implement atomic_testand(clear|set)_ptr
For current architectures, these are just aliases for the existing operation on the relevant scalar integer.
Reviewed by: imp, kib Obtained from:
atomic(9): Implement atomic_testand(clear|set)_ptr
For current architectures, these are just aliases for the existing operation on the relevant scalar integer.
Reviewed by: imp, kib Obtained from: CheriBSD Sponsored by: AFRL, DARPA Differential Revision: https://reviews.freebsd.org/D47631
show more ...
|
#
6095f4b0 |
| 24-Jun-2024 |
Ryan Libby <rlibby@FreeBSD.org> |
amd64 kernel __storeload_barrier: quiet gcc -Warray-bounds
Use a constant input operand instead of an output operand to tell the compiler about OFFSETOF_MONITORBUF. If we tell it we are writing to
amd64 kernel __storeload_barrier: quiet gcc -Warray-bounds
Use a constant input operand instead of an output operand to tell the compiler about OFFSETOF_MONITORBUF. If we tell it we are writing to *(u_int *)OFFSETOF_MONITORBUF, it rightly complains, but we aren't. The memory clobber already covers the necessary semantics for the compiler.
Reviewed by: kib Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D45694
show more ...
|
Revision tags: release/14.1.0 |
|
#
73bb5aea |
| 11-Apr-2024 |
Elyes Haouas <ehaouas@noos.fr> |
atomic: Fix typo
Signed-off-by: Elyes Haouas <ehaouas@noos.fr> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/885
|
Revision tags: release/13.3.0, release/14.0.0 |
|
#
95ee2897 |
| 16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
sys: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
|
#
4d846d26 |
| 10-May-2023 |
Warner Losh <imp@FreeBSD.org> |
spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of
spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
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
show more ...
|
Revision tags: release/13.2.0, release/12.4.0 |
|
#
08f16287 |
| 13-Jun-2022 |
Brooks Davis <brooks@FreeBSD.org> |
amd64: -m32 support for machine/atomic.h
Install the i386 atomic.h under /usr/include/i386 on amd64 and include when targeting i386.
Reviewed by: jhb, imp
|
Revision tags: release/13.1.0 |
|
#
3d6f4411 |
| 12-Apr-2022 |
John Baldwin <jhb@FreeBSD.org> |
Remove checks for <sys/cdefs.h> being included.
These files no longer depend on the macros required when these checks were added.
PR: 263102 (exp-run) Reviewed by: brooks, imp, emaste Differential
Remove checks for <sys/cdefs.h> being included.
These files no longer depend on the macros required when these checks were added.
PR: 263102 (exp-run) Reviewed by: brooks, imp, emaste Differential Revision: https://reviews.freebsd.org/D34804
show more ...
|
#
56f5947a |
| 12-Apr-2022 |
John Baldwin <jhb@FreeBSD.org> |
Remove checks for __GNUCLIKE_ASM assuming it is always true.
All supported compilers (modern versions of GCC and clang) support this.
Many places didn't have an #else so would just silently do the
Remove checks for __GNUCLIKE_ASM assuming it is always true.
All supported compilers (modern versions of GCC and clang) support this.
Many places didn't have an #else so would just silently do the wrong thing. Ancient versions of icc (the original motivation for this) are no longer a compiler FreeBSD supports.
PR: 263102 (exp-run) Reviewed by: brooks, imp Differential Revision: https://reviews.freebsd.org/D34797
show more ...
|
#
9596b349 |
| 03-Feb-2022 |
Konstantin Belousov <kib@FreeBSD.org> |
x86 atomic.h: remove obsoleted comment
Modules no longer call kernel functions for atomic ops, and since the previous commit, we always use lock prefix.
Submitted by: Elliott Mitchell <ehem+freebsd
x86 atomic.h: remove obsoleted comment
Modules no longer call kernel functions for atomic ops, and since the previous commit, we always use lock prefix.
Submitted by: Elliott Mitchell <ehem+freebsd@m5p.com> Reviewed by: jhb, markj MFC after: 1 week Differential revision: https://reviews.freebsd.org/D34153
show more ...
|
#
9c0b759b |
| 03-Feb-2022 |
Konstantin Belousov <kib@FreeBSD.org> |
x86 atomics: use lock prefix unconditionally
Atomics have significant other use besides providing in-system primitives for safe memory updates. They are used for implementing communication with out
x86 atomics: use lock prefix unconditionally
Atomics have significant other use besides providing in-system primitives for safe memory updates. They are used for implementing communication with out of system software or hardware following some protocols.
For instance, even UP kernel might require a protocol using atomics to communicate with the software-emulated device on SMP hypervisor. Or real hardware might need atomic accesses as part of the proper management protocol.
Another point is that UP configurations on x86 are extinct, so slight performance hit by unconditionally use proper atomics is not important. It is compensated by less code clutter, which in fact improves the UP/i386 lifetime expectations.
Requested by: Elliott Mitchell <ehem+freebsd@m5p.com> Reviewed by: Elliott Mitchell, imp, jhb, markj, royger Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D34153
show more ...
|
#
cbf999e7 |
| 03-Feb-2022 |
Konstantin Belousov <kib@FreeBSD.org> |
x86 atomic.h: cleanup comments for preprocessor directives
Reviewed by: Elliott Mitchell, imp, jhb, markj, royger Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https:
x86 atomic.h: cleanup comments for preprocessor directives
Reviewed by: Elliott Mitchell, imp, jhb, markj, royger Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D34153
show more ...
|
Revision tags: release/12.3.0 |
|
#
a90d053b |
| 19-Jul-2021 |
Mark Johnston <markj@FreeBSD.org> |
Simplify kernel sanitizer interceptors
KASAN and KCSAN implement interceptors for various primitive operations that are not instrumented by the compiler. KMSAN requires them as well. Rather than ad
Simplify kernel sanitizer interceptors
KASAN and KCSAN implement interceptors for various primitive operations that are not instrumented by the compiler. KMSAN requires them as well. Rather than adding new cases for each sanitizer which requires interceptors, implement the following protocol: - When interceptor definitions are required, define SAN_NEEDS_INTERCEPTORS and SANITIZER_INTERCEPTOR_PREFIX. - In headers that declare functions which need to be intercepted by a sanitizer runtime, use SANITIZER_INTERCEPTOR_PREFIX to provide declarations. - When SAN_RUNTIME is defined, do not redefine the names of intercepted functions. This is typically the case in files which implement sanitizer runtimes but is also needed in, for example, files which define ifunc selectors for intercepted operations.
MFC after: 2 weeks Sponsored by: The FreeBSD Foundation
show more ...
|
Revision tags: release/13.0.0 |
|
#
3ead6023 |
| 23-Mar-2021 |
Mark Johnston <markj@FreeBSD.org> |
Generalize bus_space(9) and atomic(9) sanitizer interceptors
Make it easy to define interceptors for new sanitizer runtimes, rather than assuming KCSAN. Lay a bit of groundwork for KASAN and KMSAN.
Generalize bus_space(9) and atomic(9) sanitizer interceptors
Make it easy to define interceptors for new sanitizer runtimes, rather than assuming KCSAN. Lay a bit of groundwork for KASAN and KMSAN.
When a sanitizer is compiled in, atomic(9) and bus_space(9) definitions in atomic_san.h are used by default instead of the inline implementations in the platform's atomic.h. These definitions are implemented in the sanitizer runtime, which includes machine/{atomic,bus}.h with SAN_RUNTIME defined to pull in the actual implementations.
No functional change intended.
MFC after: 1 month Sponsored by: The FreeBSD Foundation
show more ...
|
#
435c7cfb |
| 08-Mar-2021 |
Mark Johnston <markj@FreeBSD.org> |
Rename _cscan_atomic.h and _cscan_bus.h to atomic_san.h and bus_san.h
Other kernel sanitizers (KMSAN, KASAN) require interceptors as well, so put these in a more generic place as a step towards impo
Rename _cscan_atomic.h and _cscan_bus.h to atomic_san.h and bus_san.h
Other kernel sanitizers (KMSAN, KASAN) require interceptors as well, so put these in a more generic place as a step towards importing the other sanitizers.
No functional change intended.
MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29103
show more ...
|
Revision tags: release/12.2.0, release/11.4.0 |
|
#
ca0ec73c |
| 26-Mar-2020 |
Conrad Meyer <cem@FreeBSD.org> |
Expand generic subword atomic primitives
The goal of this change is to make the atomic_load_acq_{8,16}, atomic_testandset{,_acq}_long, and atomic_testandclear_long primitives available in MI-namespa
Expand generic subword atomic primitives
The goal of this change is to make the atomic_load_acq_{8,16}, atomic_testandset{,_acq}_long, and atomic_testandclear_long primitives available in MI-namespace.
The second goal is to get this draft out of my local tree, as anything that requires a full tinderbox is a big burden out of tree. MD specifics can be refined individually afterwards.
The generic implementations may not be ideal for your architecture; feel free to implement better versions. If no subword_atomic definitions are needed, the include can be removed from your arch's machine/atomic.h. Generic definitions are guarded by defined macros of the same name. To avoid picking up conflicting generic definitions, some macro defines are added to various MD machine/atomic.h to register an existing implementation.
Include _atomic_subword.h in arm and arm64 machine/atomic.h.
For some odd reason, KCSAN only generates some versions of primitives. Generate the _acq variants of atomic_load.*_8, atomic_load.*_16, and atomic_testandset.*_long. There are other questionably disabled primitives, but I didn't run into them, so I left them alone. KCSAN is only built for amd64 in tinderbox for now.
Add atomic_subword implementations of atomic_load_acq_{8,16} implemented using masking and atomic_load_acq_32.
Add generic atomic_subword implementations of atomic_testandset_long(), atomic_testandclear_long(), and atomic_testandset_acq_long(), using atomic_fcmpset_long() and atomic_fcmpset_acq_long().
On x86, add atomic_testandset_acq_long as an alias for atomic_testandset_long.
Reviewed by: kevans, rlibby (previous versions both) Differential Revision: https://reviews.freebsd.org/D22963
show more ...
|
#
91019ea7 |
| 29-Feb-2020 |
Dimitry Andric <dim@FreeBSD.org> |
Merge ^/head r358400 through r358465.
|
#
6d1a70dd |
| 28-Feb-2020 |
Ryan Libby <rlibby@FreeBSD.org> |
amd64 atomic.h: minor codegen optimization in flag access
Previously the pattern to extract status flags from inline assembly blocks was to use setcc in the block to write the flag to a register. Th
amd64 atomic.h: minor codegen optimization in flag access
Previously the pattern to extract status flags from inline assembly blocks was to use setcc in the block to write the flag to a register. This was suboptimal in a few ways: - It would lead to code like: sete %cl; test %cl; jne, i.e. a flag would just be loaded into a register and then reloaded to a flag. - The setcc would force the block to use an additional register. - If the client code didn't care for the flag value then the setcc would be entirely pointless but could not be eliminated by the optimizer.
A more modern inline asm construct (since gcc 6 and clang 9) allows for "flag output operands", where a C variable can be written directly from a flag. The optimizer can then use this to produce direct code where the flag does not take a trip through a register.
In practice this makes each affected operation sequence shorter by five bytes of instructions. It's unlikely this has a measurable performance impact.
Reviewed by: kib, markj, mjg Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D23869
show more ...
|
#
849aef49 |
| 21-Nov-2019 |
Andrew Turner <andrew@FreeBSD.org> |
Port the NetBSD KCSAN runtime to FreeBSD.
Update the NetBSD Kernel Concurrency Sanitizer (KCSAN) runtime to work in the FreeBSD kernel. It is a useful tool for finding data races between threads exe
Port the NetBSD KCSAN runtime to FreeBSD.
Update the NetBSD Kernel Concurrency Sanitizer (KCSAN) runtime to work in the FreeBSD kernel. It is a useful tool for finding data races between threads executing on different CPUs.
This can be enabled by enabling KCSAN in the kernel config, or by using the GENERIC-KCSAN amd64 kernel. It works on amd64 and arm64, however the later needs a compiler change to allow -fsanitize=thread that KCSAN uses.
Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D22315
show more ...
|
Revision tags: release/12.1.0, release/11.3.0, release/12.0.0 |
|
#
a7a7f5b4 |
| 06-Jul-2018 |
Hans Petter Selasky <hselasky@FreeBSD.org> |
Make sure kernel modules built by default are portable between UP and SMP systems by extending defined(SMP) to include defined(KLD_MODULE).
This is a regression issue after r335873 .
Discussed with
Make sure kernel modules built by default are portable between UP and SMP systems by extending defined(SMP) to include defined(KLD_MODULE).
This is a regression issue after r335873 .
Discussed with: mmacy@ Sponsored by: Mellanox Technologies
show more ...
|
#
79ba9195 |
| 04-Jul-2018 |
John Baldwin <jhb@FreeBSD.org> |
Use 'e' instead of 'i' constraints with 64-bit atomic operations on amd64.
The ADD, AND, OR, and SUB instructions take at most a 32-bit sign-extended immediate operand. 64-bit constants that do not
Use 'e' instead of 'i' constraints with 64-bit atomic operations on amd64.
The ADD, AND, OR, and SUB instructions take at most a 32-bit sign-extended immediate operand. 64-bit constants that do not fit into that constraint need to be loaded into a register. The 'i' constraint tells the compiler it can pass any integer constant to the assembler, whereas the 'e' constrain only permits constants that fit into a 32-bit sign-extended value. This fixes using atomic_add/clear/set/subtract_long/64 with constants that do not fit into a 32-bit sign-extended immediate.
Reported by: several folks Tested by: Pete Wright <pete@nomadlogic.org> MFC after: 2 weeks
show more ...
|
#
f4b36404 |
| 02-Jul-2018 |
Matt Macy <mmacy@FreeBSD.org> |
inline atomics and allow tied modules to inline locks
- inline atomics in modules on i386 and amd64 (they were always inline on other arches) - allow modules to opt in to inlining locks by specify
inline atomics and allow tied modules to inline locks
- inline atomics in modules on i386 and amd64 (they were always inline on other arches) - allow modules to opt in to inlining locks by specifying MODULE_TIED=1 in the makefile
Reviewed by: kib Sponsored by: Limelight Networks Differential Revision: https://reviews.freebsd.org/D16079
show more ...
|
Revision tags: release/11.2.0 |
|
#
54b4b13c |
| 24-Dec-2017 |
Dimitry Andric <dim@FreeBSD.org> |
Merge ^/head r326936 through r327149.
|
#
30d4f9e8 |
| 19-Dec-2017 |
Konstantin Belousov <kib@FreeBSD.org> |
Add atomic_load(9) and atomic_store(9) operations.
They provide relaxed-ordered atomic access semantic. Due to the FreeBSD memory model, the operations are syntaxical wrappers around the volatile a
Add atomic_load(9) and atomic_store(9) operations.
They provide relaxed-ordered atomic access semantic. Due to the FreeBSD memory model, the operations are syntaxical wrappers around the volatile accesses. The volatile qualifier is used to ensure that the access not optimized out and in turn depends on the volatile semantic as implemented by supported compilers.
The motivation for adding the operation is to help people coming from other systems or knowing the C11/C++ standards where atomics have special type and require use of the special access operations. It is still the case that FreeBSD requires plain load and stores of aligned integer types to be atomic.
Suggested by: jhb Reviewed by: alc, jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D13534
show more ...
|