Linux Audio

Check our new training course

Loading...
v5.9
 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 */
v6.9.4
 1/* SPDX-License-Identifier: GPL-2.0 */
 2/*
 3 * The Kernel Concurrency Sanitizer (KCSAN) infrastructure. Public interface and
 4 * data structures to set up runtime. See kcsan-checks.h for explicit checks and
 5 * modifiers. For more info please see Documentation/dev-tools/kcsan.rst.
 6 *
 7 * Copyright (C) 2019, Google LLC.
 8 */
 9
10#ifndef _LINUX_KCSAN_H
11#define _LINUX_KCSAN_H
12
13#include <linux/kcsan-checks.h>
14#include <linux/types.h>
15
16#ifdef CONFIG_KCSAN
17
18/*
19 * Context for each thread of execution: for tasks, this is stored in
20 * task_struct, and interrupts access internal per-CPU storage.
21 */
22struct kcsan_ctx {
23	int disable_count; /* disable counter */
24	int disable_scoped; /* disable scoped access counter */
25	int atomic_next; /* number of following atomic ops */
26
27	/*
28	 * We distinguish between: (a) nestable atomic regions that may contain
29	 * other nestable regions; and (b) flat atomic regions that do not keep
30	 * track of nesting. Both (a) and (b) are entirely independent of each
31	 * other, and a flat region may be started in a nestable region or
32	 * vice-versa.
33	 *
34	 * This is required because, for example, in the annotations for
35	 * seqlocks, we declare seqlock writer critical sections as (a) nestable
36	 * atomic regions, but reader critical sections as (b) flat atomic
37	 * regions, but have encountered cases where seqlock reader critical
38	 * sections are contained within writer critical sections (the opposite
39	 * may be possible, too).
40	 *
41	 * To support these cases, we independently track the depth of nesting
42	 * for (a), and whether the leaf level is flat for (b).
43	 */
44	int atomic_nest_count;
45	bool in_flat_atomic;
46
47	/*
48	 * Access mask for all accesses if non-zero.
49	 */
50	unsigned long access_mask;
51
52	/* List of scoped accesses; likely to be empty. */
53	struct list_head scoped_accesses;
54
55#ifdef CONFIG_KCSAN_WEAK_MEMORY
56	/*
57	 * Scoped access for modeling access reordering to detect missing memory
58	 * barriers; only keep 1 to keep fast-path complexity manageable.
59	 */
60	struct kcsan_scoped_access reorder_access;
61#endif
62};
63
64/**
65 * kcsan_init - initialize KCSAN runtime
66 */
67void kcsan_init(void);
68
69#else /* CONFIG_KCSAN */
70
71static inline void kcsan_init(void)			{ }
72
73#endif /* CONFIG_KCSAN */
74
75#endif /* _LINUX_KCSAN_H */