Skip to content

Commit

Permalink
s390/kasan: add bitops instrumentation
Browse files Browse the repository at this point in the history
Add KASAN instrumentation of architecture-specific asm implementation
of bitops. It also covers s390 specific *_inv functions.

Signed-off-by: Vasily Gorbik <[email protected]>
Signed-off-by: Heiko Carstens <[email protected]>
  • Loading branch information
Vasily Gorbik authored and heicarst committed Jul 23, 2019
1 parent 0a5c3c2 commit 9779048
Showing 1 changed file with 35 additions and 30 deletions.
65 changes: 35 additions & 30 deletions arch/s390/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ __bitops_byte(unsigned long nr, volatile unsigned long *ptr)
return ((unsigned char *)ptr) + ((nr ^ (BITS_PER_LONG - 8)) >> 3);
}

static inline void set_bit(unsigned long nr, volatile unsigned long *ptr)
static inline void arch_set_bit(unsigned long nr, volatile unsigned long *ptr)
{
unsigned long *addr = __bitops_word(nr, ptr);
unsigned long mask;
Expand All @@ -77,7 +77,7 @@ static inline void set_bit(unsigned long nr, volatile unsigned long *ptr)
__atomic64_or(mask, (long *)addr);
}

static inline void clear_bit(unsigned long nr, volatile unsigned long *ptr)
static inline void arch_clear_bit(unsigned long nr, volatile unsigned long *ptr)
{
unsigned long *addr = __bitops_word(nr, ptr);
unsigned long mask;
Expand All @@ -98,7 +98,8 @@ static inline void clear_bit(unsigned long nr, volatile unsigned long *ptr)
__atomic64_and(mask, (long *)addr);
}

static inline void change_bit(unsigned long nr, volatile unsigned long *ptr)
static inline void arch_change_bit(unsigned long nr,
volatile unsigned long *ptr)
{
unsigned long *addr = __bitops_word(nr, ptr);
unsigned long mask;
Expand All @@ -119,8 +120,8 @@ static inline void change_bit(unsigned long nr, volatile unsigned long *ptr)
__atomic64_xor(mask, (long *)addr);
}

static inline bool
test_and_set_bit(unsigned long nr, volatile unsigned long *ptr)
static inline bool arch_test_and_set_bit(unsigned long nr,
volatile unsigned long *ptr)
{
unsigned long *addr = __bitops_word(nr, ptr);
unsigned long old, mask;
Expand All @@ -130,8 +131,8 @@ test_and_set_bit(unsigned long nr, volatile unsigned long *ptr)
return (old & mask) != 0;
}

static inline bool
test_and_clear_bit(unsigned long nr, volatile unsigned long *ptr)
static inline bool arch_test_and_clear_bit(unsigned long nr,
volatile unsigned long *ptr)
{
unsigned long *addr = __bitops_word(nr, ptr);
unsigned long old, mask;
Expand All @@ -141,8 +142,8 @@ test_and_clear_bit(unsigned long nr, volatile unsigned long *ptr)
return (old & ~mask) != 0;
}

static inline bool
test_and_change_bit(unsigned long nr, volatile unsigned long *ptr)
static inline bool arch_test_and_change_bit(unsigned long nr,
volatile unsigned long *ptr)
{
unsigned long *addr = __bitops_word(nr, ptr);
unsigned long old, mask;
Expand All @@ -152,30 +153,31 @@ test_and_change_bit(unsigned long nr, volatile unsigned long *ptr)
return (old & mask) != 0;
}

static inline void __set_bit(unsigned long nr, volatile unsigned long *ptr)
static inline void arch___set_bit(unsigned long nr, volatile unsigned long *ptr)
{
unsigned char *addr = __bitops_byte(nr, ptr);

*addr |= 1 << (nr & 7);
}

static inline void
__clear_bit(unsigned long nr, volatile unsigned long *ptr)
static inline void arch___clear_bit(unsigned long nr,
volatile unsigned long *ptr)
{
unsigned char *addr = __bitops_byte(nr, ptr);

*addr &= ~(1 << (nr & 7));
}

static inline void __change_bit(unsigned long nr, volatile unsigned long *ptr)
static inline void arch___change_bit(unsigned long nr,
volatile unsigned long *ptr)
{
unsigned char *addr = __bitops_byte(nr, ptr);

*addr ^= 1 << (nr & 7);
}

static inline bool
__test_and_set_bit(unsigned long nr, volatile unsigned long *ptr)
static inline bool arch___test_and_set_bit(unsigned long nr,
volatile unsigned long *ptr)
{
unsigned char *addr = __bitops_byte(nr, ptr);
unsigned char ch;
Expand All @@ -185,8 +187,8 @@ __test_and_set_bit(unsigned long nr, volatile unsigned long *ptr)
return (ch >> (nr & 7)) & 1;
}

static inline bool
__test_and_clear_bit(unsigned long nr, volatile unsigned long *ptr)
static inline bool arch___test_and_clear_bit(unsigned long nr,
volatile unsigned long *ptr)
{
unsigned char *addr = __bitops_byte(nr, ptr);
unsigned char ch;
Expand All @@ -196,8 +198,8 @@ __test_and_clear_bit(unsigned long nr, volatile unsigned long *ptr)
return (ch >> (nr & 7)) & 1;
}

static inline bool
__test_and_change_bit(unsigned long nr, volatile unsigned long *ptr)
static inline bool arch___test_and_change_bit(unsigned long nr,
volatile unsigned long *ptr)
{
unsigned char *addr = __bitops_byte(nr, ptr);
unsigned char ch;
Expand All @@ -207,7 +209,8 @@ __test_and_change_bit(unsigned long nr, volatile unsigned long *ptr)
return (ch >> (nr & 7)) & 1;
}

static inline bool test_bit(unsigned long nr, const volatile unsigned long *ptr)
static inline bool arch_test_bit(unsigned long nr,
const volatile unsigned long *ptr)
{
const volatile unsigned char *addr;

Expand All @@ -216,28 +219,30 @@ static inline bool test_bit(unsigned long nr, const volatile unsigned long *ptr)
return (*addr >> (nr & 7)) & 1;
}

static inline bool test_and_set_bit_lock(unsigned long nr,
volatile unsigned long *ptr)
static inline bool arch_test_and_set_bit_lock(unsigned long nr,
volatile unsigned long *ptr)
{
if (test_bit(nr, ptr))
if (arch_test_bit(nr, ptr))
return 1;
return test_and_set_bit(nr, ptr);
return arch_test_and_set_bit(nr, ptr);
}

static inline void clear_bit_unlock(unsigned long nr,
volatile unsigned long *ptr)
static inline void arch_clear_bit_unlock(unsigned long nr,
volatile unsigned long *ptr)
{
smp_mb__before_atomic();
clear_bit(nr, ptr);
arch_clear_bit(nr, ptr);
}

static inline void __clear_bit_unlock(unsigned long nr,
volatile unsigned long *ptr)
static inline void arch___clear_bit_unlock(unsigned long nr,
volatile unsigned long *ptr)
{
smp_mb();
__clear_bit(nr, ptr);
arch___clear_bit(nr, ptr);
}

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

/*
* Functions which use MSB0 bit numbering.
* The bits are numbered:
Expand Down

0 comments on commit 9779048

Please sign in to comment.