]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
kcsan: Add support for atomic builtins
authorMarco Elver <elver@google.com>
Fri, 3 Jul 2020 13:40:29 +0000 (15:40 +0200)
committerPaul E. McKenney <paulmck@kernel.org>
Mon, 24 Aug 2020 22:09:05 +0000 (15:09 -0700)
commit0f8ad5f2e93425812c393c91ceb5af3d95e79b10
treefcd29f371507fec0bbd0b5b83f93c37fd61ed241
parent9123e3a74ec7b934a4a099e98af6a61c2f80bbf5
kcsan: Add support for atomic builtins

Some architectures (currently e.g. s390 partially) implement atomics
using the compiler's atomic builtins (__atomic_*, __sync_*). To support
enabling KCSAN on such architectures in future, or support experimental
use of these builtins, implement support for them.

We should also avoid breaking KCSAN kernels due to use (accidental or
otherwise) of atomic builtins in drivers, as has happened in the past:
https://lkml.kernel.org/r/5231d2c0-41d9-6721-e15f-a7eedf3ce69e@infradead.org

The instrumentation is subtly different from regular reads/writes: TSAN
instrumentation replaces the use of atomic builtins with a call into the
runtime, and the runtime's job is to also execute the desired atomic
operation. We rely on the __atomic_* compiler builtins, available with
all KCSAN-supported compilers, to implement each TSAN atomic
instrumentation function.

Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
kernel/kcsan/core.c