Skip to content

Commit

Permalink
kmsan: suppress false positives in assembly routines
Browse files Browse the repository at this point in the history
TODO(glider): handle the assembly in the compiler properly instead
  • Loading branch information
ramosian-glider committed May 7, 2018
1 parent e20aace commit 9224ff4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
15 changes: 10 additions & 5 deletions arch/x86/include/asm/bitops.h
Expand Up @@ -142,7 +142,7 @@ static __always_inline void __clear_bit(long nr, volatile unsigned long *addr)

static __always_inline bool clear_bit_unlock_is_negative_byte(long nr, volatile unsigned long *addr)
{
bool negative;
bool negative = false; // TODO(glider): false positive
asm volatile(LOCK_PREFIX "andb %2,%1"
CC_SET(s)
: CC_OUT(s) (negative), ADDR
Expand Down Expand Up @@ -245,7 +245,8 @@ test_and_set_bit_lock(long nr, volatile unsigned long *addr)
*/
static __always_inline bool __test_and_set_bit(long nr, volatile unsigned long *addr)
{
bool oldbit;
// TODO(glider): false positive
bool oldbit = false;

asm(__ASM_SIZE(bts) " %2,%1"
CC_SET(c)
Expand Down Expand Up @@ -286,7 +287,8 @@ static __always_inline bool test_and_clear_bit(long nr, volatile unsigned long *
*/
static __always_inline bool __test_and_clear_bit(long nr, volatile unsigned long *addr)
{
bool oldbit;
// TODO(glider): false positive
bool oldbit = false;

asm volatile(__ASM_SIZE(btr) " %2,%1"
CC_SET(c)
Expand All @@ -298,7 +300,8 @@ static __always_inline bool __test_and_clear_bit(long nr, volatile unsigned long
/* WARNING: non atomic and it can be reordered! */
static __always_inline bool __test_and_change_bit(long nr, volatile unsigned long *addr)
{
bool oldbit;
// TODO(glider): false positive
bool oldbit = false;

asm volatile(__ASM_SIZE(btc) " %2,%1"
CC_SET(c)
Expand Down Expand Up @@ -330,7 +333,9 @@ static __always_inline bool constant_test_bit(long nr, const volatile unsigned l

static __always_inline bool variable_test_bit(long nr, volatile const unsigned long *addr)
{
bool oldbit;
/// TODO(glider): instrument the assembly below.
///bool oldbit;
bool oldbit = false;

asm volatile(__ASM_SIZE(bt) " %2,%1"
CC_SET(c)
Expand Down
3 changes: 2 additions & 1 deletion arch/x86/include/asm/cmpxchg.h
Expand Up @@ -157,7 +157,8 @@ extern void __add_wrong_size(void)

#define __raw_try_cmpxchg(_ptr, _pold, _new, size, lock) \
({ \
bool success; \
/* TODO(glider): false positive */ \
bool success = false; \
__typeof__(_ptr) _old = (__typeof__(_ptr))(_pold); \
__typeof__(*(_ptr)) __old = *_old; \
__typeof__(*(_ptr)) __new = (_new); \
Expand Down
3 changes: 2 additions & 1 deletion arch/x86/include/asm/irqflags.h
Expand Up @@ -15,7 +15,8 @@

static inline unsigned long native_save_fl(void)
{
unsigned long flags;
/// TODO(glider): false positive here.
unsigned long flags = 0;

/*
* "=rm" is safe here, because "pop" adjusts the stack before
Expand Down
3 changes: 2 additions & 1 deletion arch/x86/include/asm/rmwcc.h
Expand Up @@ -27,7 +27,8 @@ cc_label: \

#define __GEN_RMWcc(fullop, var, cc, clobbers, ...) \
do { \
bool c; \
/* TODO(glider): false positive */ \
bool c = 0; \
asm volatile (fullop CC_SET(cc) \
: [counter] "+m" (var), CC_OUT(cc) (c) \
: __VA_ARGS__ : clobbers); \
Expand Down

0 comments on commit 9224ff4

Please sign in to comment.