2019-11-15 02:02:54 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
|
|
|
|
#ifndef _KERNEL_KCSAN_ATOMIC_H
|
|
|
|
#define _KERNEL_KCSAN_ATOMIC_H
|
|
|
|
|
|
|
|
#include <linux/jiffies.h>
|
|
|
|
|
|
|
|
/*
|
2019-11-20 17:41:43 +08:00
|
|
|
* Helper that returns true if access to @ptr should be considered an atomic
|
2019-11-15 02:02:54 +08:00
|
|
|
* access, even though it is not explicitly atomic.
|
|
|
|
*
|
|
|
|
* List all volatile globals that have been observed in races, to suppress
|
|
|
|
* data race reports between accesses to these variables.
|
|
|
|
*
|
|
|
|
* For now, we assume that volatile accesses of globals are as strong as atomic
|
|
|
|
* accesses (READ_ONCE, WRITE_ONCE cast to volatile). The situation is still not
|
|
|
|
* entirely clear, as on some architectures (Alpha) READ_ONCE/WRITE_ONCE do more
|
|
|
|
* than cast to volatile. Eventually, we hope to be able to remove this
|
|
|
|
* function.
|
|
|
|
*/
|
2020-01-08 00:31:04 +08:00
|
|
|
static __always_inline bool kcsan_is_atomic(const volatile void *ptr)
|
2019-11-15 02:02:54 +08:00
|
|
|
{
|
|
|
|
/* only jiffies for now */
|
|
|
|
return ptr == &jiffies;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* _KERNEL_KCSAN_ATOMIC_H */
|