From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.3 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B41C0FA372A for ; Wed, 16 Oct 2019 11:47:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 848CB21848 for ; Wed, 16 Oct 2019 11:47:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="qxYBTI3s" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389480AbfJPLrp (ORCPT ); Wed, 16 Oct 2019 07:47:45 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:40349 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388069AbfJPLro (ORCPT ); Wed, 16 Oct 2019 07:47:44 -0400 Received: by mail-ot1-f65.google.com with SMTP id y39so19838572ota.7 for ; Wed, 16 Oct 2019 04:47:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4FFfdl/5HhwgogS+uQMVCmerpDy+QFALdziBFwG47Ho=; b=qxYBTI3sDAIe67leQB17PCwhFI+UWqXoCGfOvVZPliY25X9Cp/O2IdRxHSCUnyWG4q Tu5RtHDfeIIAwieu+6Cwh17xFFs59XSifqxoV8fjVPl+qwfuOSDsUNOvDZKGmwUEnROU BQwsxUVu18fnl8vNb9VtrZm7KX1m1ZdfyyiOvKciuypBvupKsxgYYRXrjAxaPFjmyVPk VNdWQtpdWBS3JaivSzlYgGfD1+lzCSW6pxicnllkR4LcOqIQSBVdnETIiV1fJby9fziv gt2ywLf1FY3q+ebS4ed36RPp/4sHlRtB31NCq4sIrHh+8s/E7PBOrKYJ5th3o/KNQRHQ xXGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4FFfdl/5HhwgogS+uQMVCmerpDy+QFALdziBFwG47Ho=; b=WGvv8unxxGhlLsaM2WpLrrrj2KfPPFisGiOPdqbrpTU7XMdIbYMvhJtFOt/JzMf26G 7bIUivcJM/ducoKQqHx2xjWH+JiMYfyGc5jUgDl4+73/XqPWRW1sYGvGUMrcM7yE9qmV RLENt2vd5Tt96bVi8fx/hrvaiukyRYy3wqQL5Y3RWa3NZVV7+MMv59egTW64zjTnsxu7 Jg1yY3qTUir9EJlz/DmBt4JuDv/uNxRezDnPQilyORkg8KPUnbe0NmpESdIHUILyiwPN oPJopAhwGRt9GUQvzPF0A/D+r1Pq+US8O8GBc1HbM6AsCz/loh4BNruyaTB8pKkQPiuV Q7Aw== X-Gm-Message-State: APjAAAUww3h2NLINOQ0/cg4gvyPEyEoO/p6Zbp4Mt+Ra41crm1pOkq3y cH82Uh5mbR27bE6WnXPfxvFUqPtSzRmr4YRjrfRrGA== X-Google-Smtp-Source: APXvYqxLUzdznFDTAtPsUXOQYQINf4AjQMZ44lwwxhy/Q0X7piHQ/pfQCNFVFkyakV+yLYUZARwFLNI44v5WlRcVy2E= X-Received: by 2002:a9d:724e:: with SMTP id a14mr34065885otk.23.1571226461723; Wed, 16 Oct 2019 04:47:41 -0700 (PDT) MIME-Version: 1.0 References: <20191016083959.186860-1-elver@google.com> <20191016083959.186860-8-elver@google.com> <20191016111847.GB44246@lakrids.cambridge.arm.com> In-Reply-To: <20191016111847.GB44246@lakrids.cambridge.arm.com> From: Marco Elver Date: Wed, 16 Oct 2019 13:47:30 +0200 Message-ID: Subject: Re: [PATCH 7/8] locking/atomics, kcsan: Add KCSAN instrumentation To: Mark Rutland Cc: LKMM Maintainers -- Akira Yokosawa , Alan Stern , Alexander Potapenko , Andrea Parri , Andrey Konovalov , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Boqun Feng , Borislav Petkov , Daniel Axtens , Daniel Lustig , dave.hansen@linux.intel.com, dhowells@redhat.com, Dmitry Vyukov , "H. Peter Anvin" , Ingo Molnar , Jade Alglave , Joel Fernandes , Jonathan Corbet , Josh Poimboeuf , Luc Maranget , Nicholas Piggin , "Paul E. McKenney" , Peter Zijlstra , Thomas Gleixner , Will Deacon , kasan-dev , linux-arch , "open list:DOCUMENTATION" , linux-efi@vger.kernel.org, linux-kbuild@vger.kernel.org, LKML , Linux Memory Management List , "the arch/x86 maintainers" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 16 Oct 2019 at 13:18, Mark Rutland wrote: > > Hi Marco, > > On Wed, Oct 16, 2019 at 10:39:58AM +0200, Marco Elver wrote: > > This adds KCSAN instrumentation to atomic-instrumented.h. > > > > Signed-off-by: Marco Elver > > --- > > include/asm-generic/atomic-instrumented.h | 192 +++++++++++++++++++++- > > scripts/atomic/gen-atomic-instrumented.sh | 9 +- > > 2 files changed, 199 insertions(+), 2 deletions(-) > > > > diff --git a/include/asm-generic/atomic-instrumented.h b/include/asm-generic/atomic-instrumented.h > > index e8730c6b9fe2..9e487febc610 100644 > > --- a/include/asm-generic/atomic-instrumented.h > > +++ b/include/asm-generic/atomic-instrumented.h > > @@ -19,11 +19,13 @@ > > > > #include > > #include > > +#include > > > > static inline int > > atomic_read(const atomic_t *v) > > { > > kasan_check_read(v, sizeof(*v)); > > + kcsan_check_atomic(v, sizeof(*v), false); > > For legibility and consistency with kasan, it would be nicer to avoid > the bool argument here and have kcsan_check_atomic_{read,write}() > helpers... > > > diff --git a/scripts/atomic/gen-atomic-instrumented.sh b/scripts/atomic/gen-atomic-instrumented.sh > > index e09812372b17..c0553743a6f4 100755 > > --- a/scripts/atomic/gen-atomic-instrumented.sh > > +++ b/scripts/atomic/gen-atomic-instrumented.sh > > @@ -12,15 +12,20 @@ gen_param_check() > > local type="${arg%%:*}" > > local name="$(gen_param_name "${arg}")" > > local rw="write" > > + local is_write="true" > > > > case "${type#c}" in > > i) return;; > > esac > > > > # We don't write to constant parameters > > - [ ${type#c} != ${type} ] && rw="read" > > + if [ ${type#c} != ${type} ]; then > > + rw="read" > > + is_write="false" > > + fi > > > > printf "\tkasan_check_${rw}(${name}, sizeof(*${name}));\n" > > + printf "\tkcsan_check_atomic(${name}, sizeof(*${name}), ${is_write});\n" > > ... which would also simplify this. > > Though as below, we might want to wrap both in a helper local to > atomic-instrumented.h. > > > } > > > > #gen_param_check(arg...) > > @@ -108,6 +113,7 @@ cat < > ({ \\ > > typeof(ptr) __ai_ptr = (ptr); \\ > > kasan_check_write(__ai_ptr, ${mult}sizeof(*__ai_ptr)); \\ > > + kcsan_check_atomic(__ai_ptr, ${mult}sizeof(*__ai_ptr), true); \\ > > arch_${xchg}(__ai_ptr, __VA_ARGS__); \\ > > }) > > EOF > > @@ -148,6 +154,7 @@ cat << EOF > > > > #include > > #include > > +#include > > We could add the following to this preamble: > > static inline void __atomic_check_read(const volatile void *v, size_t size) > { > kasan_check_read(v, sizeof(*v)); > kcsan_check_atomic(v, sizeof(*v), false); > } > > static inline void __atomic_check_write(const volatile void *v, size_t size) > { > kasan_check_write(v, sizeof(*v)); > kcsan_check_atomic(v, sizeof(*v), true); > } > > ... and only have the one call in each atomic wrapper. > > Otherwise, this looks good to me. Thanks, incorporated suggestions for v2: for readability rename kcsan_check_access -> kcsan_check_{read,write}, and for atomic-instrumented.h, adding the suggested preamble. Thanks, -- Marco From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marco Elver Subject: Re: [PATCH 7/8] locking/atomics, kcsan: Add KCSAN instrumentation Date: Wed, 16 Oct 2019 13:47:30 +0200 Message-ID: References: <20191016083959.186860-1-elver@google.com> <20191016083959.186860-8-elver@google.com> <20191016111847.GB44246@lakrids.cambridge.arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: In-Reply-To: <20191016111847.GB44246@lakrids.cambridge.arm.com> Sender: linux-kernel-owner@vger.kernel.org To: Mark Rutland Cc: LKMM Maintainers -- Akira Yokosawa , Alan Stern , Alexander Potapenko , Andrea Parri , Andrey Konovalov , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Boqun Feng , Borislav Petkov , Daniel Axtens , Daniel Lustig , dave.hansen@linux.intel.com, dhowells@redhat.com, Dmitry Vyukov , "H. Peter Anvin" , Ingo Molnar , Jade Alglave , Joel Fernandes , Jonathan Corbet , Josh Poimboeuf List-Id: linux-arch.vger.kernel.org On Wed, 16 Oct 2019 at 13:18, Mark Rutland wrote: > > Hi Marco, > > On Wed, Oct 16, 2019 at 10:39:58AM +0200, Marco Elver wrote: > > This adds KCSAN instrumentation to atomic-instrumented.h. > > > > Signed-off-by: Marco Elver > > --- > > include/asm-generic/atomic-instrumented.h | 192 +++++++++++++++++++++- > > scripts/atomic/gen-atomic-instrumented.sh | 9 +- > > 2 files changed, 199 insertions(+), 2 deletions(-) > > > > diff --git a/include/asm-generic/atomic-instrumented.h b/include/asm-generic/atomic-instrumented.h > > index e8730c6b9fe2..9e487febc610 100644 > > --- a/include/asm-generic/atomic-instrumented.h > > +++ b/include/asm-generic/atomic-instrumented.h > > @@ -19,11 +19,13 @@ > > > > #include > > #include > > +#include > > > > static inline int > > atomic_read(const atomic_t *v) > > { > > kasan_check_read(v, sizeof(*v)); > > + kcsan_check_atomic(v, sizeof(*v), false); > > For legibility and consistency with kasan, it would be nicer to avoid > the bool argument here and have kcsan_check_atomic_{read,write}() > helpers... > > > diff --git a/scripts/atomic/gen-atomic-instrumented.sh b/scripts/atomic/gen-atomic-instrumented.sh > > index e09812372b17..c0553743a6f4 100755 > > --- a/scripts/atomic/gen-atomic-instrumented.sh > > +++ b/scripts/atomic/gen-atomic-instrumented.sh > > @@ -12,15 +12,20 @@ gen_param_check() > > local type="${arg%%:*}" > > local name="$(gen_param_name "${arg}")" > > local rw="write" > > + local is_write="true" > > > > case "${type#c}" in > > i) return;; > > esac > > > > # We don't write to constant parameters > > - [ ${type#c} != ${type} ] && rw="read" > > + if [ ${type#c} != ${type} ]; then > > + rw="read" > > + is_write="false" > > + fi > > > > printf "\tkasan_check_${rw}(${name}, sizeof(*${name}));\n" > > + printf "\tkcsan_check_atomic(${name}, sizeof(*${name}), ${is_write});\n" > > ... which would also simplify this. > > Though as below, we might want to wrap both in a helper local to > atomic-instrumented.h. > > > } > > > > #gen_param_check(arg...) > > @@ -108,6 +113,7 @@ cat < > ({ \\ > > typeof(ptr) __ai_ptr = (ptr); \\ > > kasan_check_write(__ai_ptr, ${mult}sizeof(*__ai_ptr)); \\ > > + kcsan_check_atomic(__ai_ptr, ${mult}sizeof(*__ai_ptr), true); \\ > > arch_${xchg}(__ai_ptr, __VA_ARGS__); \\ > > }) > > EOF > > @@ -148,6 +154,7 @@ cat << EOF > > > > #include > > #include > > +#include > > We could add the following to this preamble: > > static inline void __atomic_check_read(const volatile void *v, size_t size) > { > kasan_check_read(v, sizeof(*v)); > kcsan_check_atomic(v, sizeof(*v), false); > } > > static inline void __atomic_check_write(const volatile void *v, size_t size) > { > kasan_check_write(v, sizeof(*v)); > kcsan_check_atomic(v, sizeof(*v), true); > } > > ... and only have the one call in each atomic wrapper. > > Otherwise, this looks good to me. Thanks, incorporated suggestions for v2: for readability rename kcsan_check_access -> kcsan_check_{read,write}, and for atomic-instrumented.h, adding the suggested preamble. Thanks, -- Marco From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.3 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 957EBFA372A for ; Wed, 16 Oct 2019 11:47:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4BC7321848 for ; Wed, 16 Oct 2019 11:47:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="qxYBTI3s" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4BC7321848 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E6DDD8E001C; Wed, 16 Oct 2019 07:47:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E429F8E0001; Wed, 16 Oct 2019 07:47:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D81208E001C; Wed, 16 Oct 2019 07:47:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0053.hostedemail.com [216.40.44.53]) by kanga.kvack.org (Postfix) with ESMTP id B886F8E0001 for ; Wed, 16 Oct 2019 07:47:43 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 63820583A for ; Wed, 16 Oct 2019 11:47:43 +0000 (UTC) X-FDA: 76049473206.28.hand93_435b9ddd5d408 X-HE-Tag: hand93_435b9ddd5d408 X-Filterd-Recvd-Size: 7586 Received: from mail-ot1-f67.google.com (mail-ot1-f67.google.com [209.85.210.67]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Wed, 16 Oct 2019 11:47:42 +0000 (UTC) Received: by mail-ot1-f67.google.com with SMTP id 21so19833047otj.11 for ; Wed, 16 Oct 2019 04:47:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4FFfdl/5HhwgogS+uQMVCmerpDy+QFALdziBFwG47Ho=; b=qxYBTI3sDAIe67leQB17PCwhFI+UWqXoCGfOvVZPliY25X9Cp/O2IdRxHSCUnyWG4q Tu5RtHDfeIIAwieu+6Cwh17xFFs59XSifqxoV8fjVPl+qwfuOSDsUNOvDZKGmwUEnROU BQwsxUVu18fnl8vNb9VtrZm7KX1m1ZdfyyiOvKciuypBvupKsxgYYRXrjAxaPFjmyVPk VNdWQtpdWBS3JaivSzlYgGfD1+lzCSW6pxicnllkR4LcOqIQSBVdnETIiV1fJby9fziv gt2ywLf1FY3q+ebS4ed36RPp/4sHlRtB31NCq4sIrHh+8s/E7PBOrKYJ5th3o/KNQRHQ xXGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4FFfdl/5HhwgogS+uQMVCmerpDy+QFALdziBFwG47Ho=; b=qTOubUOye4uPp82mRhNPo9hX8SJqGCrzTkF9vlFeIm6SU69i7fD35/fLFiU0IC/KPV VJNjrDLKe96LoajWnVwdCBqWWiofZxtacORbI+G25nJqgh70igCmSZ+LGatpxazxbz2K eKc/YHwjfjZjqRpO5O3cZ3H3j58Ilio3TyEkLnb+z+PhNKowaBl866w5zS/YQ2GsMK2b 7VTtO4bVmBG6Q7YlBoAtEFMo4LEz83KjTfrq8VWyCu2rggs6jTIMpo2lN3msFKqnSmB4 DPBwSEiR39MOmt8aplh+b6Q2zyvjSat5Sf/87yMTHdYP7QH/4fb5124/9lg6u0pIaE7o 1qAw== X-Gm-Message-State: APjAAAW2LQoap76KjJwesD1S0OQkdkDsaXJT1snzyew+keHRag7Vrd+m HzUYO3b5/WqvheHYOSf6u1eDm/yrEPqUhrZkVs/t6A== X-Google-Smtp-Source: APXvYqxLUzdznFDTAtPsUXOQYQINf4AjQMZ44lwwxhy/Q0X7piHQ/pfQCNFVFkyakV+yLYUZARwFLNI44v5WlRcVy2E= X-Received: by 2002:a9d:724e:: with SMTP id a14mr34065885otk.23.1571226461723; Wed, 16 Oct 2019 04:47:41 -0700 (PDT) MIME-Version: 1.0 References: <20191016083959.186860-1-elver@google.com> <20191016083959.186860-8-elver@google.com> <20191016111847.GB44246@lakrids.cambridge.arm.com> In-Reply-To: <20191016111847.GB44246@lakrids.cambridge.arm.com> From: Marco Elver Date: Wed, 16 Oct 2019 13:47:30 +0200 Message-ID: Subject: Re: [PATCH 7/8] locking/atomics, kcsan: Add KCSAN instrumentation To: Mark Rutland Cc: LKMM Maintainers -- Akira Yokosawa , Alan Stern , Alexander Potapenko , Andrea Parri , Andrey Konovalov , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Boqun Feng , Borislav Petkov , Daniel Axtens , Daniel Lustig , dave.hansen@linux.intel.com, dhowells@redhat.com, Dmitry Vyukov , "H. Peter Anvin" , Ingo Molnar , Jade Alglave , Joel Fernandes , Jonathan Corbet , Josh Poimboeuf , Luc Maranget , Nicholas Piggin , "Paul E. McKenney" , Peter Zijlstra , Thomas Gleixner , Will Deacon , kasan-dev , linux-arch , "open list:DOCUMENTATION" , linux-efi@vger.kernel.org, linux-kbuild@vger.kernel.org, LKML , Linux Memory Management List , "the arch/x86 maintainers" Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, 16 Oct 2019 at 13:18, Mark Rutland wrote: > > Hi Marco, > > On Wed, Oct 16, 2019 at 10:39:58AM +0200, Marco Elver wrote: > > This adds KCSAN instrumentation to atomic-instrumented.h. > > > > Signed-off-by: Marco Elver > > --- > > include/asm-generic/atomic-instrumented.h | 192 +++++++++++++++++++++- > > scripts/atomic/gen-atomic-instrumented.sh | 9 +- > > 2 files changed, 199 insertions(+), 2 deletions(-) > > > > diff --git a/include/asm-generic/atomic-instrumented.h b/include/asm-generic/atomic-instrumented.h > > index e8730c6b9fe2..9e487febc610 100644 > > --- a/include/asm-generic/atomic-instrumented.h > > +++ b/include/asm-generic/atomic-instrumented.h > > @@ -19,11 +19,13 @@ > > > > #include > > #include > > +#include > > > > static inline int > > atomic_read(const atomic_t *v) > > { > > kasan_check_read(v, sizeof(*v)); > > + kcsan_check_atomic(v, sizeof(*v), false); > > For legibility and consistency with kasan, it would be nicer to avoid > the bool argument here and have kcsan_check_atomic_{read,write}() > helpers... > > > diff --git a/scripts/atomic/gen-atomic-instrumented.sh b/scripts/atomic/gen-atomic-instrumented.sh > > index e09812372b17..c0553743a6f4 100755 > > --- a/scripts/atomic/gen-atomic-instrumented.sh > > +++ b/scripts/atomic/gen-atomic-instrumented.sh > > @@ -12,15 +12,20 @@ gen_param_check() > > local type="${arg%%:*}" > > local name="$(gen_param_name "${arg}")" > > local rw="write" > > + local is_write="true" > > > > case "${type#c}" in > > i) return;; > > esac > > > > # We don't write to constant parameters > > - [ ${type#c} != ${type} ] && rw="read" > > + if [ ${type#c} != ${type} ]; then > > + rw="read" > > + is_write="false" > > + fi > > > > printf "\tkasan_check_${rw}(${name}, sizeof(*${name}));\n" > > + printf "\tkcsan_check_atomic(${name}, sizeof(*${name}), ${is_write});\n" > > ... which would also simplify this. > > Though as below, we might want to wrap both in a helper local to > atomic-instrumented.h. > > > } > > > > #gen_param_check(arg...) > > @@ -108,6 +113,7 @@ cat < > ({ \\ > > typeof(ptr) __ai_ptr = (ptr); \\ > > kasan_check_write(__ai_ptr, ${mult}sizeof(*__ai_ptr)); \\ > > + kcsan_check_atomic(__ai_ptr, ${mult}sizeof(*__ai_ptr), true); \\ > > arch_${xchg}(__ai_ptr, __VA_ARGS__); \\ > > }) > > EOF > > @@ -148,6 +154,7 @@ cat << EOF > > > > #include > > #include > > +#include > > We could add the following to this preamble: > > static inline void __atomic_check_read(const volatile void *v, size_t size) > { > kasan_check_read(v, sizeof(*v)); > kcsan_check_atomic(v, sizeof(*v), false); > } > > static inline void __atomic_check_write(const volatile void *v, size_t size) > { > kasan_check_write(v, sizeof(*v)); > kcsan_check_atomic(v, sizeof(*v), true); > } > > ... and only have the one call in each atomic wrapper. > > Otherwise, this looks good to me. Thanks, incorporated suggestions for v2: for readability rename kcsan_check_access -> kcsan_check_{read,write}, and for atomic-instrumented.h, adding the suggested preamble. Thanks, -- Marco