From: Marco Elver <elver@google.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
kasan-dev@googlegroups.com,
Nick Desaulniers <ndesaulniers@google.com>,
Nathan Chancellor <nathan@kernel.org>,
Dmitry Vyukov <dvyukov@google.com>,
Andrey Konovalov <andreyknvl@gmail.com>,
Mark Rutland <mark.rutland@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] kcov: fix generic Kconfig dependencies if ARCH_WANTS_NO_INSTR
Date: Thu, 2 Dec 2021 18:38:13 +0100 [thread overview]
Message-ID: <CANpmjNM4nxnwt7iWF+kCT862H21CHL-cshYyugBei0ysGAt5uA@mail.gmail.com> (raw)
In-Reply-To: <YajdN5T8vi2ZzP3D@hirez.programming.kicks-ass.net>
On Thu, 2 Dec 2021 at 18:30, Peter Zijlstra <peterz@infradead.org> 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 <elver@google.com>
> > ---
> > 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) <peterz@infradead.org>
Thanks!
next prev parent reply other threads:[~2021-12-02 17:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-01 15:26 Marco Elver
2021-12-01 15:57 ` Mark Rutland
2021-12-01 16:10 ` Marco Elver
2021-12-01 17:46 ` Mark Rutland
2021-12-01 18:16 ` Marco Elver
2021-12-01 18:28 ` Mark Rutland
2021-12-01 17:16 ` Nathan Chancellor
2021-12-02 14:50 ` Peter Zijlstra
2021-12-02 17:38 ` Marco Elver [this message]
2021-12-02 17:56 ` Peter Zijlstra
2021-12-09 10:00 ` Marco Elver
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CANpmjNM4nxnwt7iWF+kCT862H21CHL-cshYyugBei0ysGAt5uA@mail.gmail.com \
--to=elver@google.com \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@gmail.com \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=dave.hansen@linux.intel.com \
--cc=dvyukov@google.com \
--cc=hpa@zytor.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=will@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox