Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4650905pxb; Tue, 5 Oct 2021 07:35:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDv83ELAzwUG0fxWW5iTBbpkQL3fExzAIZsMDYfueiqEM9IZbzLUV2UAdtVcRg7yC673a6 X-Received: by 2002:a05:6402:16d2:: with SMTP id r18mr26568619edx.363.1633444540063; Tue, 05 Oct 2021 07:35:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633444540; cv=none; d=google.com; s=arc-20160816; b=hyWtvJyp6vyZh//R9zUJuiQ9lH9cRYiM5XY6vnjz3qUTRaJK0wjJC7gnReOPaW2Too Qn/JoD/+3pPpWY0YAh+yMSEc0VnrFF3IAJO4FuajzzJt2QKxolU8ASmSGk76aWqz4ean KNWKpoEnktyBCiwLLk3gtK4U2m6ESZW51g9CSsDWmeqYdGa28lUkCVGcEi6HtwgPAa1g rtsPvDE0L5crC6l5WjStb4EKYdDSX3lVvSRaWjow7oOwffusi8jvJogdRj23NtoZjBOm XE1R8YwBWaX4Un5Too3qD0uVvmh3VForq8/Expkn6ZSzIH0k+MPgL3+vHxT80f4faGJA IkRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=gxrMVAw/5LLkca458yv6tDVS/EMHpBVVAHIqFcJ2i40=; b=CMRvVF4vdWmoI37TRXkKILu1t3NnxKuvAtg5HW2vi5TJngQzHHxWWZCvwJRqrEfNBt o76LZmmfiOpy1vb/BzFzH8PULzxzS3y+CxyWExwXFhw5mDIIZIsn8jiX+bHqxrjL0So0 s4zHdHksRX2REg6d4ISwMX1COyHvdTp2Xzex7TCPbSDiwoa4HmxiggPIvthk2qWxbgGw fIqo8wY2O2hvcb7ZTGddi6KZVtqlQ1q9veYBdV7+2ZZze6FTwirYfkkVJ89b2JJbPZ2W 8N7yvuw8LibOCVBqudoYEmD6NhT9HdCR2iE2zL7n1uMlwo+oiz/2+QZVii7OqM8HgQ4c XGvw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f21si1226616ejk.724.2021.10.05.07.35.12; Tue, 05 Oct 2021 07:35:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235530AbhJEOcD (ORCPT + 99 others); Tue, 5 Oct 2021 10:32:03 -0400 Received: from foss.arm.com ([217.140.110.172]:51310 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235090AbhJEOcD (ORCPT ); Tue, 5 Oct 2021 10:32:03 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7E7621FB; Tue, 5 Oct 2021 07:30:12 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.23.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4CA793F70D; Tue, 5 Oct 2021 07:30:06 -0700 (PDT) Date: Tue, 5 Oct 2021 15:30:03 +0100 From: Mark Rutland To: Daniel Axtens Cc: keescook@chromium.org, catalin.marinas@arm.com, clang-built-linux@googlegroups.com, hca@linux.ibm.com, jarmo.tiitto@gmail.com, linux-kernel@vger.kernel.org, lukas.bulwahn@gmail.com, masahiroy@kernel.org, maskray@google.com, morbo@google.com, nathan@kernel.org, ndesaulniers@google.com, oberpar@linux.ibm.com, ojeda@kernel.org, peterz@infradead.org, samitolvanen@google.com, torvalds@linux-foundation.org, wcw@google.com, will@kernel.org Subject: Re: ARCH_WANTS_NO_INSTR (Re: [GIT PULL] Clang feature updates for v5.14-rc1) Message-ID: <20211005143003.GC6678@C02TD0UTHF1T.local> References: <202106281231.E99B92BB13@keescook> <20211005131015.3153458-1-dja@axtens.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211005131015.3153458-1-dja@axtens.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 06, 2021 at 12:10:15AM +1100, Daniel Axtens wrote: > Hi, Hi Daniel, > Apologies, I can't find the original email for this: > > > Kconfig: Introduce ARCH_WANTS_NO_INSTR and CC_HAS_NO_PROFILE_FN_ATTR > > which is now commit 51c2ee6d121c ("Kconfig: Introduce ARCH_WANTS_NO_INSTR and > CC_HAS_NO_PROFILE_FN_ATTR"). It doesn't seem to show up on Google, this was the > best I could find. Unless I've misunderstood, the commit title was rewritten when the patch was applied, from the third link in commit 51c2ee6d121c. For reference, those three links are: Link: https://lore.kernel.org/lkml/YMTn9yjuemKFLbws@hirez.programming.kicks-ass.net/ Link: https://lore.kernel.org/lkml/YMcssV%2Fn5IBGv4f0@hirez.programming.kicks-ass.net/ Link: https://lore.kernel.org/r/20210621231822.2848305-4-ndesaulniers@google.com > Anyway, the commit message reads: > > Kconfig: Introduce ARCH_WANTS_NO_INSTR and CC_HAS_NO_PROFILE_FN_ATTR > > We don't want compiler instrumentation to touch noinstr functions, > which are annotated with the no_profile_instrument_function function > attribute. Add a Kconfig test for this and make GCOV depend on it, and > in the future, PGO. > > If an architecture is using noinstr, it should denote that via this > Kconfig value. That makes Kconfigs that depend on noinstr able to express > dependencies in an architecturally agnostic way. > > However, things in generic code (such as rcu_nmi_enter) are tagged with > `noinstr`, so I'm worried that this commit subtly breaks things like KASAN on > platforms that haven't opted in yet. (I stumbled across this while developing > KASAN on ppc64, but at least riscv and ppc32 have KASAN but not > ARCH_WANTS_NO_INSTR already.) > > As I said, I haven't been able to find the original thread - is there any reason > this shouldn't be always on? Why would an arch not opt in? What's the motivation > for ignoring the noinstr markings? IIRC the thinking was that architectures which have their entry logic in asm could/might avoid the problematic instrumentation by construction, and we didn't want to break functionality for those. As you say, if that asm has to call code which can't safely be instrumented, that's equally broken, and that might have been wrong-headed. > Should generic KASAN/KCSAN/anything else marked in noinstr also have markings > requring ARCH_WANTS_NO_INSTR? AFAICT they should, right? I suspect so, if we could otherwise get unexpected or unsafe recursion between instrumentation. Thanks, Mark.