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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 52CF8C433EF for ; Wed, 1 Dec 2021 17:21:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JctmHzqF1FfY0fwWCpSfNAhX2wEmWxWMObEOOBx6Rg0=; b=SCrBlehiSf0VQi sq4Exy1SHRxBlpyT7xvhdh9fy1Zm4D4aHZVPG+vn6+Wovior2T8GOgcJZnPvgyhssSgPfr80dIlR3 eOWyCp2WTOcZCq+bVZTNkK5wer9pD0kunggLEoWpeyTjLKFbsY3zOmNDsnrkOSlvkHyKEVB58dZ9D k7kbExelgauSLZSvocNgE0jGjGLaMIu1AIdSTCoVXBsYnZVBP4dwO6e0sz+VnD3ot0hLxWpXViaRF FXiREjiWP7KrihOXP6mc7UCDW2favjKi3DSmxnf1askKugZiI8eo1S7EQI3cRrEYtP4yzZHWFairM BVOtyNKsWlw1095mMKIw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1msTGy-009YDE-B8; Wed, 01 Dec 2021 17:20:00 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1msTDq-009X1G-4N for linux-arm-kernel@lists.infradead.org; Wed, 01 Dec 2021 17:16:51 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 74A27CE1FF7; Wed, 1 Dec 2021 17:16:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2980C53FCC; Wed, 1 Dec 2021 17:16:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638379003; bh=m4QfiTILg87tWxt/kfjtoKVqJF2k40c2px3xeNlJk9g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dkBZyK01ewyh9q4uDGAnOVjmQErjlM1r3b++EL27Qez5tP5QhbobJ9LePtCxYAOKE ME4fNuKs/XfPh8qtQ7xNDt+eyExB6jtzZUBKhDd1F1LHizJU5MIvQzpNuBzZyX99KT 8qWGgmkxl8pXgHUuzzHnTfkU5K7OWaaiz97UxwtCE+3P46s3WUP/vQsff6sD/qpsd9 KsLHjHR1nImLNwE/RstP4bAAFu7rxPISLKMltOWElDDfeKo/TbM22yQI8wWfRReUci /l8JprUo/rHJslfYjxF4NwElGUAt612tKxUchl+/+qGa9GyrGMosMaoNwIfupJ/4D2 WNZ3eQZCR7OLg== Date: Wed, 1 Dec 2021 10:16:35 -0700 From: Nathan Chancellor To: Marco Elver Cc: Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, linux-mm@kvack.org, kasan-dev@googlegroups.com, Peter Zijlstra , Nick Desaulniers , Dmitry Vyukov , Andrey Konovalov , Mark Rutland , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] kcov: fix generic Kconfig dependencies if ARCH_WANTS_NO_INSTR Message-ID: References: <20211201152604.3984495-1-elver@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211201152604.3984495-1-elver@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211201_091646_597908_27FE8EA9 X-CRM114-Status: GOOD ( 31.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Dec 01, 2021 at 04:26:04PM +0100, Marco Elver wrote: > Until recent versions of GCC and Clang, it was not possible to disable > KCOV instrumentation via a function attribute. The relevant function > attribute was introduced in 540540d06e9d9 ("kcov: add > __no_sanitize_coverage to fix noinstr for all architectures"). > > x86 was the first architecture to want a working noinstr, and at the > time no compiler support for the attribute existed yet. Therefore, > 0f1441b44e823 ("objtool: Fix noinstr vs KCOV") introduced the ability to > NOP __sanitizer_cov_*() calls in .noinstr.text. > > However, this doesn't work for other architectures like arm64 and s390 > that want a working noinstr per ARCH_WANTS_NO_INSTR. > > At the time of 0f1441b44e823, we didn't yet have ARCH_WANTS_NO_INSTR, > but now we can move the Kconfig dependency checks to the generic KCOV > option. KCOV will be available if: > > - architecture does not care about noinstr, OR > - we have objtool support (like on x86), OR > - GCC is 12.0 or newer, OR > - Clang is 13.0 or newer. > > Signed-off-by: Marco Elver It might have been nice to do a feature check in Kconfig like we do in compiler-{clang,gcc}.h but I assume it's highly unlikely that the GCC change would get backported (and it obviously won't for clang because older versions are not supported) plus the attributes are different between clang and GCC. Reviewed-by: Nathan Chancellor > --- > arch/x86/Kconfig | 2 +- > lib/Kconfig.debug | 2 ++ > 2 files changed, 3 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig > index 95dd1ee01546..c030b2ee93b3 100644 > --- a/arch/x86/Kconfig > +++ b/arch/x86/Kconfig > @@ -78,7 +78,7 @@ config X86 > select ARCH_HAS_FILTER_PGPROT > select ARCH_HAS_FORTIFY_SOURCE > select ARCH_HAS_GCOV_PROFILE_ALL > - select ARCH_HAS_KCOV if X86_64 && STACK_VALIDATION > + select ARCH_HAS_KCOV if X86_64 > select ARCH_HAS_MEM_ENCRYPT > select ARCH_HAS_MEMBARRIER_SYNC_CORE > select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > index 9ef7ce18b4f5..589c8aaa2d5b 100644 > --- a/lib/Kconfig.debug > +++ b/lib/Kconfig.debug > @@ -1977,6 +1977,8 @@ config KCOV > bool "Code coverage for fuzzing" > depends on ARCH_HAS_KCOV > depends on CC_HAS_SANCOV_TRACE_PC || GCC_PLUGINS > + depends on !ARCH_WANTS_NO_INSTR || STACK_VALIDATION || \ > + GCC_VERSION >= 120000 || CLANG_VERSION >= 130000 > select DEBUG_FS > select GCC_PLUGIN_SANCOV if !CC_HAS_SANCOV_TRACE_PC > help > -- > 2.34.0.rc2.393.gf8c9666880-goog > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel