1. 25 Jul, 2018 4 commits
    • Mark Rutland's avatar
      locking/atomics: Instrument cmpxchg_double*() · 4d2b25f6
      Mark Rutland authored
      We currently don't instrument cmpxchg_double() and
      cmpxchg_double_local() due to compilation issues reported in the past,
      which are supposedly related to GCC bug 72873 [1], reported when GCC 7
      was not yet released. This bug only applies to x86-64, and does not
      apply to other architectures.
      
      While the test case for GCC bug 72873 triggers issues with released
      versions of GCC, the instrumented kernel code compiles fine for all
      configurations I have tried, and it is unclear how the two cases
      are/were related.
      
      As we can't reproduce the kernel build failures, let's instrument
      cmpxchg_double*() again. We can revisit the issue if build failures
      reappear.
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarWill Deacon <will.deacon@arm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: andy.shevchenko@gmail.com
      Cc: aryabinin@virtuozzo.com
      Cc: catalin.marinas@arm.com
      Cc: glider@google.com
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: parri.andrea@gmail.com
      Cc: peter@hurleysoftware.com
      Link: http://lkml.kernel.org/r/20180716113017.3909-6-mark.rutland@arm.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      4d2b25f6
    • Mark Rutland's avatar
      locking/atomics: Instrument xchg() · f9881cc4
      Mark Rutland authored
      While we instrument all of the (non-relaxed) atomic_*() functions and
      cmpxchg(), we missed xchg().
      
      Let's add instrumentation for xchg(), fixing up x86 to implement
      arch_xchg().
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarWill Deacon <will.deacon@arm.com>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: andy.shevchenko@gmail.com
      Cc: arnd@arndb.de
      Cc: aryabinin@virtuozzo.com
      Cc: catalin.marinas@arm.com
      Cc: glider@google.com
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: parri.andrea@gmail.com
      Cc: peter@hurleysoftware.com
      Link: http://lkml.kernel.org/r/20180716113017.3909-5-mark.rutland@arm.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      f9881cc4
    • Mark Rutland's avatar
      locking/atomics: Simplify cmpxchg() instrumentation · df79ed2c
      Mark Rutland authored
      Currently we define some fairly verbose wrappers for the cmpxchg()
      family so that we can pass a pointer and size into kasan_check_write().
      
      The wrappers duplicate the size-switching logic necessary in arch code,
      and only work for scalar types. On some architectures, (cmp)xchg are
      used on non-scalar types, and thus the instrumented wrappers need to be
      able to handle this.
      
      We could take the type-punning logic from {READ,WRITE}_ONCE(), but this
      makes the wrappers even more verbose, and requires several local
      variables in the macros.
      
      Instead, let's simplify the wrappers into simple macros which:
      
      * snapshot the pointer into a single local variable, called __ai_ptr to
        avoid conflicts with variables in the scope of the caller.
      
      * call kasan_check_write() on __ai_ptr.
      
      * invoke the relevant arch_*() function, passing the original arguments,
        bar __ai_ptr being substituted for ptr.
      
      There should be no functional change as a result of this patch.
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarWill Deacon <will.deacon@arm.com>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: andy.shevchenko@gmail.com
      Cc: arnd@arndb.de
      Cc: aryabinin@virtuozzo.com
      Cc: catalin.marinas@arm.com
      Cc: glider@google.com
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: parri.andrea@gmail.com
      Cc: peter@hurleysoftware.com
      Link: http://lkml.kernel.org/r/20180716113017.3909-4-mark.rutland@arm.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      df79ed2c
    • Mark Rutland's avatar
      locking/atomics/x86: Reduce arch_cmpxchg64*() instrumentation · 00d5551c
      Mark Rutland authored
      Currently x86's arch_cmpxchg64() and arch_cmpxchg64_local() are
      instrumented twice, as they call into instrumented atomics rather than
      their arch_ equivalents.
      
      A call to cmpxchg64() results in:
      
        cmpxchg64()
          kasan_check_write()
          arch_cmpxchg64()
            cmpxchg()
              kasan_check_write()
              arch_cmpxchg()
      
      Let's fix this up and call the arch_ equivalents, resulting in:
      
        cmpxchg64()
          kasan_check_write()
          arch_cmpxchg64()
            arch_cmpxchg()
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Acked-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarWill Deacon <will.deacon@arm.com>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: andy.shevchenko@gmail.com
      Cc: arnd@arndb.de
      Cc: aryabinin@virtuozzo.com
      Cc: catalin.marinas@arm.com
      Cc: glider@google.com
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: parri.andrea@gmail.com
      Cc: peter@hurleysoftware.com
      Link: http://lkml.kernel.org/r/20180716113017.3909-3-mark.rutland@arm.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      00d5551c
  2. 17 Jul, 2018 15 commits
  3. 15 Jul, 2018 2 commits
  4. 14 Jul, 2018 19 commits