blob: be9e625227f3b543dc94111d856ebf8d7a92c317 [file] [log] [blame]
Marco Elverdfd402a2019-11-14 19:02:54 +01001/* SPDX-License-Identifier: GPL-2.0 */
2
3#ifndef _KERNEL_KCSAN_ATOMIC_H
4#define _KERNEL_KCSAN_ATOMIC_H
5
6#include <linux/jiffies.h>
Marco Elver44656d32020-02-25 15:32:58 +01007#include <linux/sched.h>
Marco Elverdfd402a2019-11-14 19:02:54 +01008
9/*
Marco Elver44656d32020-02-25 15:32:58 +010010 * Special rules for certain memory where concurrent conflicting accesses are
11 * common, however, the current convention is to not mark them; returns true if
12 * access to @ptr should be considered atomic. Called from slow-path.
Marco Elverdfd402a2019-11-14 19:02:54 +010013 */
Marco Elver44656d32020-02-25 15:32:58 +010014static bool kcsan_is_atomic_special(const volatile void *ptr)
Marco Elverdfd402a2019-11-14 19:02:54 +010015{
Marco Elver44656d32020-02-25 15:32:58 +010016 /* volatile globals that have been observed in data races. */
17 return ptr == &jiffies || ptr == &current->state;
Marco Elverdfd402a2019-11-14 19:02:54 +010018}
19
20#endif /* _KERNEL_KCSAN_ATOMIC_H */