Skip to content

Commit 00047c2

Browse files
melverpaulmckrcu
authored andcommitted
instrumented.h: Introduce read-write instrumentation hooks
Introduce read-write instrumentation hooks, to more precisely denote an operation's behaviour. KCSAN is able to distinguish compound instrumentation, and with the new instrumentation we then benefit from improved reporting. More importantly, read-write compound operations should not implicitly be treated as atomic, if they aren't actually atomic. Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Marco Elver <elver@google.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
1 parent bec4a24 commit 00047c2

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

include/linux/instrumented.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,21 @@ static __always_inline void instrument_write(const volatile void *v, size_t size
4242
kcsan_check_write(v, size);
4343
}
4444

45+
/**
46+
* instrument_read_write - instrument regular read-write access
47+
*
48+
* Instrument a regular write access. The instrumentation should be inserted
49+
* before the actual write happens.
50+
*
51+
* @ptr address of access
52+
* @size size of access
53+
*/
54+
static __always_inline void instrument_read_write(const volatile void *v, size_t size)
55+
{
56+
kasan_check_write(v, size);
57+
kcsan_check_read_write(v, size);
58+
}
59+
4560
/**
4661
* instrument_atomic_read - instrument atomic read access
4762
*
@@ -72,6 +87,21 @@ static __always_inline void instrument_atomic_write(const volatile void *v, size
7287
kcsan_check_atomic_write(v, size);
7388
}
7489

90+
/**
91+
* instrument_atomic_read_write - instrument atomic read-write access
92+
*
93+
* Instrument an atomic read-write access. The instrumentation should be
94+
* inserted before the actual write happens.
95+
*
96+
* @ptr address of access
97+
* @size size of access
98+
*/
99+
static __always_inline void instrument_atomic_read_write(const volatile void *v, size_t size)
100+
{
101+
kasan_check_write(v, size);
102+
kcsan_check_atomic_read_write(v, size);
103+
}
104+
75105
/**
76106
* instrument_copy_to_user - instrument reads of copy_to_user
77107
*

0 commit comments

Comments
 (0)