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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60658C433F5 for ; Tue, 5 Oct 2021 15:13:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EF2DF6115A for ; Tue, 5 Oct 2021 15:13:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EF2DF6115A Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 6D1086B006C; Tue, 5 Oct 2021 11:13:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 681376B0072; Tue, 5 Oct 2021 11:13:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 54906900002; Tue, 5 Oct 2021 11:13:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0170.hostedemail.com [216.40.44.170]) by kanga.kvack.org (Postfix) with ESMTP id 460296B006C for ; Tue, 5 Oct 2021 11:13:44 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 04E7018041E74 for ; Tue, 5 Oct 2021 15:13:44 +0000 (UTC) X-FDA: 78662728368.39.8949516 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by imf24.hostedemail.com (Postfix) with ESMTP id ABD35B0013AD for ; Tue, 5 Oct 2021 15:13:43 +0000 (UTC) Received: by mail-wr1-f46.google.com with SMTP id r10so21516643wra.12 for ; Tue, 05 Oct 2021 08:13:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=PWCYDGGbLpSMPRQR7ZAmGiH0fGx9oqlU5WKkX0Mb0qU=; b=C1yvQF0yUncj5rEDsqvtLNOh+x9A7zVvyBPM9/XAkJfELhfc8AMhISJj64NOPiegea 6JaYRoh2a4a8Ncik3T0v2Z6LPHWswvBeUX8M6NZ4jCkN4IEr3RdBho3Kd9rLpWJpM0V7 nAz428jBaLXsB3HI0R0UXCgzALnskQ+gT1Wuytyc91NjoM4QkNs6yNoNLLP+H7Kf3aF7 4mPFuU3GM98fENzdmGwNxmmAh6ePRObn3Xcmc0CdJfqyOPb1S20AuzfRXoOXfq0YejFs 5rUMpTiUdv/XOm8Bnfc39Y8QxXGwt9qYF2AbGEI/cO9MnsFx/isXdnG/CQge/XznLXKO qP7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=PWCYDGGbLpSMPRQR7ZAmGiH0fGx9oqlU5WKkX0Mb0qU=; b=w2tdaK30uiS3dGehn17S7cKzqT6kKIQLD4A+ZmK93L6+t1I5vxL2p0FzPXv92eWNjB AcP7K2kE2OfL2yp+Oymm3Bqr2TtuiO9YpFWMG1yn13MxAIOOhby3lpoxnT5JX4oURl54 f7gbEY5OugEx/7ZIYKNb7uLuy4oPtxKAux65PiAlmqNZQYH+qTwB8tnq/QfQK8O9El1T SlC6NfqUNl4EkV0ViUHmYQRT9Q7qEaAIM/WpTnc+IER/EP1y29Wx+IB6Kmj7AcNjQsAg TZIuGJy/+hkHHMcQ2OmxOPpChZzQgnKEZBcOJ84FJ+pyCSHpYb+8z719eHkrGg0cXq9X w0Ng== X-Gm-Message-State: AOAM53290O7kfHiL5AYR/PUbNrE4VJyuRoGCwHtyNlp9KIezES4HxGSD PKzRTKKFIt0y6rOZ3PkGRCDnnw== X-Google-Smtp-Source: ABdhPJyHHQBSLIiixiOSj+09iVqstHSdw/JX82YLQyteKWj/W+BkVDOWUO25EZpQcPNg2mg9qLt/bg== X-Received: by 2002:adf:e6d0:: with SMTP id y16mr22269412wrm.181.1633446822192; Tue, 05 Oct 2021 08:13:42 -0700 (PDT) Received: from elver.google.com ([2a00:79e0:15:13:e44f:5054:55f8:fcb8]) by smtp.gmail.com with ESMTPSA id a2sm4377335wru.82.2021.10.05.08.13.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 08:13:41 -0700 (PDT) Date: Tue, 5 Oct 2021 17:13:35 +0200 From: Marco Elver To: Peter Zijlstra Cc: "Paul E . McKenney" , Alexander Potapenko , Boqun Feng , Borislav Petkov , Dmitry Vyukov , Ingo Molnar , Josh Poimboeuf , Mark Rutland , Thomas Gleixner , Waiman Long , Will Deacon , kasan-dev@googlegroups.com, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: Re: [PATCH -rcu/kcsan 23/23] objtool, kcsan: Remove memory barrier instrumentation from noinstr Message-ID: References: <20211005105905.1994700-1-elver@google.com> <20211005105905.1994700-24-elver@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.0.5 (2021-01-21) X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: ABD35B0013AD X-Stat-Signature: s6pw37d59hf3s9xwf6q7ikrr9bjkk1yn Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=C1yvQF0y; spf=pass (imf24.hostedemail.com: domain of elver@google.com designates 209.85.221.46 as permitted sender) smtp.mailfrom=elver@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1633446823-880940 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 Tue, Oct 05, 2021 at 04:37PM +0200, Peter Zijlstra wrote: > On Tue, Oct 05, 2021 at 12:59:05PM +0200, Marco Elver wrote: > > Teach objtool to turn instrumentation required for memory barrier > > modeling into nops in noinstr text. > > > > The __tsan_func_entry/exit calls are still emitted by compilers even > > with the __no_sanitize_thread attribute. The memory barrier > > instrumentation will be inserted explicitly (without compiler help), and > > thus needs to also explicitly be removed. > > How is arm64 and others using kernel/entry + noinstr going to fix this? > > ISTR they fully rely on the compilers not emitting instrumentation, > since they don't have objtool to fix up stray issues like this. So this is where I'd like to hear if the approach of: | #if !defined(CONFIG_ARCH_WANTS_NO_INSTR) || defined(CONFIG_STACK_VALIDATION) | ... | #else | #define kcsan_noinstr noinstr | static __always_inline bool within_noinstr(unsigned long ip) | { | return (unsigned long)__noinstr_text_start <= ip && | ip < (unsigned long)__noinstr_text_end; | } | #endif and then (using the !STACK_VALIDATION definitions) | kcsan_noinstr void instrumentation_may_appear_in_noinstr(void) | { | if (within_noinstr(_RET_IP_)) | return; works for the non-x86 arches that select ARCH_WANTS_NO_INSTR. If it doesn't I can easily just remove kcsan_noinstr/within_noinstr, and add a "depends on !ARCH_WANTS_NO_INSTR || STACK_VALIDATION" to the KCSAN_WEAK_MEMORY option. Looking at a previous discussion [1], however, I was under the impression that this would work. [1] https://lkml.kernel.org/r/CANpmjNMAZiW-Er=2QDgGP+_3hg1LOvPYcbfGSPMv=aR6MVTB-g@mail.gmail.com