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=-2.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no 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 1F408FA3728 for ; Thu, 17 Oct 2019 00:26:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 832ED20650 for ; Thu, 17 Oct 2019 00:26:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="csQqSPN/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 832ED20650 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 220E28E0005; Wed, 16 Oct 2019 20:26:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1F8B68E0001; Wed, 16 Oct 2019 20:26:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E8498E0005; Wed, 16 Oct 2019 20:26:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0042.hostedemail.com [216.40.44.42]) by kanga.kvack.org (Postfix) with ESMTP id E07648E0001 for ; Wed, 16 Oct 2019 20:26:03 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 1A175824556B for ; Thu, 17 Oct 2019 00:26:03 +0000 (UTC) X-FDA: 76051384206.17.ship38_8c0e823c30118 X-HE-Tag: ship38_8c0e823c30118 X-Filterd-Recvd-Size: 11752 Received: from mail-qt1-f195.google.com (mail-qt1-f195.google.com [209.85.160.195]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Thu, 17 Oct 2019 00:26:02 +0000 (UTC) Received: by mail-qt1-f195.google.com with SMTP id n17so978701qtr.4 for ; Wed, 16 Oct 2019 17:26:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=c4Hjken7XU2rfPp3dnVy1MaKiaTDJ8xCPdPitHymU3c=; b=csQqSPN/MGMvhU7skkKyvEgZzVQXO9UtV6gWrDu3gonQToGoEuQEgJ9AjvMPvbwgIF +oREHMSAN8YZ3MbVgmYjKeOTN3inuXTVkgzDhuWFONWsJZPVMpqC3T0FmkJCYMOT6owQ KACvVEVlS+FuQvqxRoRF9r6USc4ObR5pLoOlmSRBFhCPeceZvDBGmlWgIXSuOG/pafEp uY4oSoBUSn0SkSBGPgyUqt2KMX7T35aDDjMmjKzLw+WSfserZtwaHXNHUU1cSSsSTmEQ pSk/B8fFRIDl//jlg/wph1G/OYr/lKPNQ9J90dhkq4/zmChmYKpmE5t4/p0dQowfPXFf Ji6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=c4Hjken7XU2rfPp3dnVy1MaKiaTDJ8xCPdPitHymU3c=; b=mKfNxWAAY07DpHODJKYLiHKxerpCyqKCWyDiD6SpRH9sH/ve5X/mMGKLUYkPAW/d2I 8rRVk3YUo6f8Qz6yZPH1PLBLcxu01uBwi+iOO6LHqXFl3KqXK0vTfPrZIjX7/Gh0MGFh opZQE47R6GZXhyAG6aUjpRbty/xSM6BQiO7v2Uii5/EIJyblRGWBJjCTn3d6JmnqDK/b bOZ2KbKSqGZefLGW3zC2j6ClAH0PuL3Zv8eK7Z1CrCXTiUQRRwNfXzNuOZsgJo3BDG42 uUxa/1glFEk3yVmakU9r/ZfWHLs0Fl6hx9q8gRE6FC6m7oONOAWgsrkzFME0LUj6HVfc ur9A== X-Gm-Message-State: APjAAAVbqj9nMWuGeO7en15IRL/PH8OYEcHJ2jKEaz4t3SXV3tlh2+ps tzjBvxzXgrG14qKCtWamclw= X-Google-Smtp-Source: APXvYqwnuvz1GcoONkwCw4W+ofBxGx3iz4s+XHmcMH/nQPqH09WNGtoGGUd1Vbn15devxycq9f20pw== X-Received: by 2002:aed:3847:: with SMTP id j65mr1055138qte.124.1571271961879; Wed, 16 Oct 2019 17:26:01 -0700 (PDT) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id y5sm333254qki.108.2019.10.16.17.25.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Oct 2019 17:26:00 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id A11A621D75; Wed, 16 Oct 2019 20:25:58 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Wed, 16 Oct 2019 20:25:58 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrjeeigdefudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujggfsehgtderredtredvnecuhfhrohhmpeeuohhquhhn ucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecukfhppedutd durdekiedrgedurddvuddvnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsohhquhhnodhm vghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtdeigedqudejjeekhe ehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehfihigmhgvrdhnrghm vgenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from localhost (unknown [101.86.41.212]) by mail.messagingengine.com (Postfix) with ESMTPA id 25DF68005C; Wed, 16 Oct 2019 20:25:55 -0400 (EDT) Date: Thu, 17 Oct 2019 08:25:51 +0800 From: Boqun Feng To: Marco Elver Cc: LKMM Maintainers -- Akira Yokosawa , Alan Stern , Alexander Potapenko , Andrea Parri , Andrey Konovalov , Andy Lutomirski , ard.biesheuvel@linaro.org, Arnd Bergmann , 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 , Mark Rutland , 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 Subject: Re: [PATCH 1/8] kcsan: Add Kernel Concurrency Sanitizer infrastructure Message-ID: <20191017002551.GC2701514@tardis> References: <20191016083959.186860-1-elver@google.com> <20191016083959.186860-2-elver@google.com> <20191016094234.GB2701514@tardis> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="oLBj+sq0vYjzfsbl" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) 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: --oLBj+sq0vYjzfsbl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Oct 16, 2019 at 12:06:51PM +0200, Marco Elver wrote: > On Wed, 16 Oct 2019 at 11:42, Boqun Feng wrote: > > > > Hi Marco, > > > > On Wed, Oct 16, 2019 at 10:39:52AM +0200, Marco Elver wrote: > > [...] > > > --- /dev/null > > > +++ b/kernel/kcsan/kcsan.c > > > @@ -0,0 +1,81 @@ > > > +// SPDX-License-Identifier: GPL-2.0 > > > + > > > +/* > > > + * The Kernel Concurrency Sanitizer (KCSAN) infrastructure. For more= info please > > > + * see Documentation/dev-tools/kcsan.rst. > > > + */ > > > + > > > +#include > > > + > > > +#include "kcsan.h" > > > + > > > +/* > > > + * Concurrency Sanitizer uses the same instrumentation as Thread San= itizer. > > > > Is there any documentation on the instrumentation? Like a complete list > > for all instrumentation functions plus a description of where the > > compiler will use those functions. Yes, the names of the below functions > > are straightforward, but an accurate doc on the instrumentation will > > cerntainly help people review KCSAN. >=20 > As far as I'm aware neither GCC nor Clang have documentation on the > emitted instrumentation that we could reference (other than look into > the compiler passes). >=20 Yeah, I don't find them either, which makes me surprised, because I think the thread sanitizer has been there for a while... > However it is as straightforward as it seems: the compiler emits > instrumentation calls for all loads and stores that the compiler > generates; inline asm is not instrumented. I will add a comment to > that effect for v2. >=20 Or you can push the compiler people to document it, and we can simply reference it in kernel ;-) Regards, Boqun > Thanks, > -- Marco >=20 > > Regards, > > Boqun > > > > > + */ > > > + > > > +#define DEFINE_TSAN_READ_WRITE(size) = \ > > > + void __tsan_read##size(void *ptr) = \ > > > + { = \ > > > + __kcsan_check_access(ptr, size, false); = \ > > > + } = \ > > > + EXPORT_SYMBOL(__tsan_read##size); = \ > > > + void __tsan_write##size(void *ptr) = \ > > > + { = \ > > > + __kcsan_check_access(ptr, size, true); = \ > > > + } = \ > > > + EXPORT_SYMBOL(__tsan_write##size) > > > + > > > +DEFINE_TSAN_READ_WRITE(1); > > > +DEFINE_TSAN_READ_WRITE(2); > > > +DEFINE_TSAN_READ_WRITE(4); > > > +DEFINE_TSAN_READ_WRITE(8); > > > +DEFINE_TSAN_READ_WRITE(16); > > > + > > > +/* > > > + * Not all supported compiler versions distinguish aligned/unaligned= accesses, > > > + * but e.g. recent versions of Clang do. > > > + */ > > > +#define DEFINE_TSAN_UNALIGNED_READ_WRITE(size) = \ > > > + void __tsan_unaligned_read##size(void *ptr) = \ > > > + { = \ > > > + __kcsan_check_access(ptr, size, false); = \ > > > + } = \ > > > + EXPORT_SYMBOL(__tsan_unaligned_read##size); = \ > > > + void __tsan_unaligned_write##size(void *ptr) = \ > > > + { = \ > > > + __kcsan_check_access(ptr, size, true); = \ > > > + } = \ > > > + EXPORT_SYMBOL(__tsan_unaligned_write##size) > > > + > > > +DEFINE_TSAN_UNALIGNED_READ_WRITE(2); > > > +DEFINE_TSAN_UNALIGNED_READ_WRITE(4); > > > +DEFINE_TSAN_UNALIGNED_READ_WRITE(8); > > > +DEFINE_TSAN_UNALIGNED_READ_WRITE(16); > > > + > > > +void __tsan_read_range(void *ptr, size_t size) > > > +{ > > > + __kcsan_check_access(ptr, size, false); > > > +} > > > +EXPORT_SYMBOL(__tsan_read_range); > > > + > > > +void __tsan_write_range(void *ptr, size_t size) > > > +{ > > > + __kcsan_check_access(ptr, size, true); > > > +} > > > +EXPORT_SYMBOL(__tsan_write_range); > > > + > > > +/* > > > + * The below are not required KCSAN, but can still be emitted by the= compiler. > > > + */ > > > +void __tsan_func_entry(void *call_pc) > > > +{ > > > +} > > > +EXPORT_SYMBOL(__tsan_func_entry); > > > +void __tsan_func_exit(void) > > > +{ > > > +} > > > +EXPORT_SYMBOL(__tsan_func_exit); > > > +void __tsan_init(void) > > > +{ > > > +} > > > +EXPORT_SYMBOL(__tsan_init); > > [...] --oLBj+sq0vYjzfsbl Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEj5IosQTPz8XU1wRHSXnow7UH+rgFAl2ntP8ACgkQSXnow7UH +rj4IwgAr1ZTnb6a5VMzzEFJsOsttb8ZWdPW5m/sNmxxMh6TIPZzl1rWAzFMMC7R 52lRrsSAQ+3JsII8i8lMPGPFo4Fc4g1ivQa604Zf+KjqHPtM4bBOigkNgRmFkM5r gsrimY5mX0B4O0hg7CtV0kn3FAJKsFTE+daVXj6W0p18pshZ3HgulHPKDH7qrMnh Hc/9JhxxvcnRAN9uUuukBr4vGHq+iDJqqGZqOuykwTufSRnGNlQk9BoGczLX+7+2 zJ+dLh8nSVw+R2tV8eVAZ+84dHfNRTFa+iBPMSW1UQ27RFR0iqY9UmwAgYmUU3YD 4F9k35sBc8/lxL1IGFblpg3dSS/4CQ== =9czZ -----END PGP SIGNATURE----- --oLBj+sq0vYjzfsbl--