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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC762C433EF for ; Thu, 2 Dec 2021 17:38:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6B5766B0072; Thu, 2 Dec 2021 12:38:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 663E86B0074; Thu, 2 Dec 2021 12:38:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 52CA66B0075; Thu, 2 Dec 2021 12:38:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0023.hostedemail.com [216.40.44.23]) by kanga.kvack.org (Postfix) with ESMTP id 45B3B6B0072 for ; Thu, 2 Dec 2021 12:38:37 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 0A99A181D75B4 for ; Thu, 2 Dec 2021 17:38:27 +0000 (UTC) X-FDA: 78873563454.15.0EB55D4 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) by imf07.hostedemail.com (Postfix) with ESMTP id 8D62910000AB for ; Thu, 2 Dec 2021 17:38:26 +0000 (UTC) Received: by mail-oi1-f175.google.com with SMTP id bf8so605843oib.6 for ; Thu, 02 Dec 2021 09:38:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ur6dUBVD60Gl/OuuEHFc1N/ZnkqMrKChf9cSJr/RUAk=; b=GeF+Yeygf4IzE1fclg2kIv3h09kKzZsSTiuQW7I2WnPBSEIsRHyIQzA61XlblOkdy0 Dc1IhKLKUHSm7iwAX6nx/48y8jXT00QRCeXdVieyUuHyrQTy+g9zj5S/WiYss0Z7/2xD TVU7p8+TNOgnU27ml6rN/VwY5n7w8xGhFVs3fOj+tvtKbmMP1A3FdRl1DM7/C8VwCm9q BAf2LqhFhr7u45HqGueuy5p/n9EcleJGiW8Wnt3cejzFciPQPgF3jvLLNd+yj+j+4127 RTQ4XE4juuyHAflDsdonn4SqvBaBH6hhPq3iBl0ZOnl3cHSwvJew2vEVy/QqStiZRIe4 DZ6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ur6dUBVD60Gl/OuuEHFc1N/ZnkqMrKChf9cSJr/RUAk=; b=WOx6xEoqukeEM40NBK0/1TbiIZL8szMx7vPJlUV8g+TdV0fZ2kaTcIM+yrjnJn+FwX k1/KjGO0kW0PAqzUcVLrxqOKYiKmL/DFqu6crUbt3sw+HCeR2vR4/eFZyLj2h+SHyD7l eKjc0XgZTD0bezm/jwCQSDwb83On16ICLlaq7mXVRNsxhMBINXVeRfunlAW4VNDhcGPZ V7TtXx+VNStWQI7sFa57/vt2u5dckg/TFuG3iZV9hn45zMqKmsCYDGvDrG+qKRuNfIgy eZ9PuHyElxCoZqoWQO71Ygh9BwOSuUiYIdrbe4jBTLXFxRYH05HE1GHTzVJ4+o5wOr+/ lTaw== X-Gm-Message-State: AOAM5331NqKwCgsP4o0iHEpTuFtoO61ViCUtq21RLgAlNfJNyv0I88t6 fxtK8eUTj0DmpIx6wRbXr+Q8o8V78y9yA+Pi4P62Zg== X-Google-Smtp-Source: ABdhPJxoSpQPlarKGw7YSqx+v17ArOyU4hdSF2CErmLByJpd3JitW9ZlXg2woaikg258p5Q1mVOtLxbAfdJVgbnW7Hs= X-Received: by 2002:a05:6808:118c:: with SMTP id j12mr5492643oil.65.1638466705594; Thu, 02 Dec 2021 09:38:25 -0800 (PST) MIME-Version: 1.0 References: <20211201152604.3984495-1-elver@google.com> In-Reply-To: From: Marco Elver Date: Thu, 2 Dec 2021 18:38:13 +0100 Message-ID: Subject: Re: [PATCH] kcov: fix generic Kconfig dependencies if ARCH_WANTS_NO_INSTR To: Peter Zijlstra 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, Nick Desaulniers , Nathan Chancellor , Dmitry Vyukov , Andrey Konovalov , Mark Rutland , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: fui6jj5ng8ioshhfrf9xm3xikm9poha9 X-Rspamd-Queue-Id: 8D62910000AB X-Rspamd-Server: rspam07 Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=GeF+Yeyg; spf=pass (imf07.hostedemail.com: domain of elver@google.com designates 209.85.167.175 as permitted sender) smtp.mailfrom=elver@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1638466706-868110 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 Thu, 2 Dec 2021 at 18:30, Peter Zijlstra wrote: > > 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 > > --- > > 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 > > Can we write that as something like: > > $(cc-attribute,__no_sanitize_coverage) > > instead? Other than that, yes totally. That'd be nice, but I think we don't have that cc-attribute helper? I checked how e.g. CC_HAS_NO_PROFILE_FN_ATTR does it, but it won't work like that because gcc and clang define the attribute differently and it becomes a mess. That's also what Nathan pointed out here I think: https://lkml.kernel.org/r/Yaet8x/1WYiADlPh@archlinux-ax161 Let's keep it simple. > Acked-by: Peter Zijlstra (Intel) Thanks!