Skip to content

Commit

Permalink
kasan: support instrumented bitops combined with generic bitops
Browse files Browse the repository at this point in the history
Currently bitops-instrumented.h assumes that the architecture provides
atomic, non-atomic and locking bitops (e.g. both set_bit and __set_bit).
This is true on x86 and s390, but is not always true: there is a
generic bitops/non-atomic.h header that provides generic non-atomic
operations, and also a generic bitops/lock.h for locking operations.

powerpc uses the generic non-atomic version, so it does not have it's
own e.g. __set_bit that could be renamed arch___set_bit.

Split up bitops-instrumented.h to mirror the atomic/non-atomic/lock
split. This allows arches to only include the headers where they
have arch-specific versions to rename. Update x86 and s390.

(The generic operations are automatically instrumented because they're
written in C, not asm.)

Suggested-by: Christophe Leroy <christophe.leroy@c-s.fr>
Reviewed-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Daniel Axtens <dja@axtens.net>
Acked-by: Marco Elver <elver@google.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20190820024941.12640-1-dja@axtens.net
  • Loading branch information
Daniel Axtens authored and Michael Ellerman committed Nov 7, 2019
1 parent da0c9ea commit 81d2c6f
Show file tree
Hide file tree
Showing 7 changed files with 317 additions and 266 deletions.
17 changes: 16 additions & 1 deletion Documentation/core-api/kernel-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,22 @@ The Linux kernel provides more basic utility functions.
Bit Operations
--------------

.. kernel-doc:: include/asm-generic/bitops-instrumented.h
Atomic Operations
~~~~~~~~~~~~~~~~~

.. kernel-doc:: include/asm-generic/bitops/instrumented-atomic.h
:internal:

Non-atomic Operations
~~~~~~~~~~~~~~~~~~~~~

.. kernel-doc:: include/asm-generic/bitops/instrumented-non-atomic.h
:internal:

Locking Operations
~~~~~~~~~~~~~~~~~~

.. kernel-doc:: include/asm-generic/bitops/instrumented-lock.h
:internal:

Bitmap Operations
Expand Down
4 changes: 3 additions & 1 deletion arch/s390/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ static inline void arch___clear_bit_unlock(unsigned long nr,
arch___clear_bit(nr, ptr);
}

#include <asm-generic/bitops-instrumented.h>
#include <asm-generic/bitops/instrumented-atomic.h>
#include <asm-generic/bitops/instrumented-non-atomic.h>
#include <asm-generic/bitops/instrumented-lock.h>

/*
* Functions which use MSB0 bit numbering.
Expand Down
4 changes: 3 additions & 1 deletion arch/x86/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,9 @@ static __always_inline int fls64(__u64 x)

#include <asm-generic/bitops/const_hweight.h>

#include <asm-generic/bitops-instrumented.h>
#include <asm-generic/bitops/instrumented-atomic.h>
#include <asm-generic/bitops/instrumented-non-atomic.h>
#include <asm-generic/bitops/instrumented-lock.h>

#include <asm-generic/bitops/le.h>

Expand Down
263 changes: 0 additions & 263 deletions include/asm-generic/bitops-instrumented.h

This file was deleted.

Loading

0 comments on commit 81d2c6f

Please sign in to comment.