• Marco Elver's avatar
    kcsan: Add support for atomic builtins · 0f8ad5f2
    Marco Elver authored
    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: default avatarMarco Elver <elver@google.com>
    Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
    0f8ad5f2
core.c 34 KB