kcsan: Simplify value change detection
authorMark Rutland <mark.rutland@arm.com>
Wed, 14 Apr 2021 11:28:17 +0000 (13:28 +0200)
committerPaul E. McKenney <paulmck@kernel.org>
Tue, 18 May 2021 17:58:14 +0000 (10:58 -0700)
commit6f2d98192c3f204592434177ba240564346eed9f
tree1b4187027078ed1a02fca8abf7a2202c72ad3459
parentea0484644e5b8486c8335f677fc1e2a4a5d76d3f
kcsan: Simplify value change detection

In kcsan_setup_watchpoint() we store snapshots of a watched value into a
union of u8/u16/u32/u64 sized fields, modify this in place using a
consistent field, then later check for any changes via the u64 field.

We can achieve the safe effect more simply by always treating the field
as a u64, as smaller values will be zero-extended. As the values are
zero-extended, we don't need to truncate the access_mask when we apply
it, and can always apply the full 64-bit access_mask to the 64-bit
value.

Finally, we can store the two snapshots and calculated difference
separately, which makes the code a little easier to read, and will
permit reporting the old/new values in subsequent patches.

There should be no functional change as a result of this patch.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
kernel/kcsan/core.c