Skip to content

Commit bece04b

Browse files
melvertorvalds
authored andcommitted
kcov: fix generic Kconfig dependencies if ARCH_WANTS_NO_INSTR
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 540540d ("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, commit 0f1441b ("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 0f1441b, 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. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Marco Elver <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Dave Hansen <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Nick Desaulniers <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: Andrey Konovalov <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Will Deacon <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent bbd2e05 commit bece04b

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

arch/x86/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ config X86
7878
select ARCH_HAS_FILTER_PGPROT
7979
select ARCH_HAS_FORTIFY_SOURCE
8080
select ARCH_HAS_GCOV_PROFILE_ALL
81-
select ARCH_HAS_KCOV if X86_64 && STACK_VALIDATION
81+
select ARCH_HAS_KCOV if X86_64
8282
select ARCH_HAS_MEM_ENCRYPT
8383
select ARCH_HAS_MEMBARRIER_SYNC_CORE
8484
select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE

lib/Kconfig.debug

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,6 +1979,8 @@ config KCOV
19791979
bool "Code coverage for fuzzing"
19801980
depends on ARCH_HAS_KCOV
19811981
depends on CC_HAS_SANCOV_TRACE_PC || GCC_PLUGINS
1982+
depends on !ARCH_WANTS_NO_INSTR || STACK_VALIDATION || \
1983+
GCC_VERSION >= 120000 || CLANG_VERSION >= 130000
19821984
select DEBUG_FS
19831985
select GCC_PLUGIN_SANCOV if !CC_HAS_SANCOV_TRACE_PC
19841986
help

0 commit comments

Comments
 (0)