Loading...
Note: File does not exist in v3.5.6.
1/* SPDX-License-Identifier: GPL-2.0 */
2
3#ifndef _LINUX_KCSAN_H
4#define _LINUX_KCSAN_H
5
6#include <linux/kcsan-checks.h>
7#include <linux/types.h>
8
9#ifdef CONFIG_KCSAN
10
11/*
12 * Context for each thread of execution: for tasks, this is stored in
13 * task_struct, and interrupts access internal per-CPU storage.
14 */
15struct kcsan_ctx {
16 int disable_count; /* disable counter */
17 int atomic_next; /* number of following atomic ops */
18
19 /*
20 * We distinguish between: (a) nestable atomic regions that may contain
21 * other nestable regions; and (b) flat atomic regions that do not keep
22 * track of nesting. Both (a) and (b) are entirely independent of each
23 * other, and a flat region may be started in a nestable region or
24 * vice-versa.
25 *
26 * This is required because, for example, in the annotations for
27 * seqlocks, we declare seqlock writer critical sections as (a) nestable
28 * atomic regions, but reader critical sections as (b) flat atomic
29 * regions, but have encountered cases where seqlock reader critical
30 * sections are contained within writer critical sections (the opposite
31 * may be possible, too).
32 *
33 * To support these cases, we independently track the depth of nesting
34 * for (a), and whether the leaf level is flat for (b).
35 */
36 int atomic_nest_count;
37 bool in_flat_atomic;
38
39 /*
40 * Access mask for all accesses if non-zero.
41 */
42 unsigned long access_mask;
43
44 /* List of scoped accesses. */
45 struct list_head scoped_accesses;
46};
47
48/**
49 * kcsan_init - initialize KCSAN runtime
50 */
51void kcsan_init(void);
52
53#else /* CONFIG_KCSAN */
54
55static inline void kcsan_init(void) { }
56
57#endif /* CONFIG_KCSAN */
58
59#endif /* _LINUX_KCSAN_H */