From: sashiko-bot@kernel.org
To: "Sasha Levin" <sashal@kernel.org>
Cc: "Wentao Zhang" <wentaoz5@illinois.edu>,
"Alexander Potapenko" <glider@google.com>,
"Andrey Konovalov" <andreyknvl@gmail.com>,
"Arnd Bergmann" <arnd@arndb.de>,
"Bill Wendling" <morbo@google.com>,
"Chuck Wolber" <chuck@wolber.net>,
"Dmitry Vyukov" <dvyukov@google.com>,
"Justin Stitt" <justinstitt@google.com>,
kasan-dev@googlegroups.com, linux-kbuild@vger.kernel.org,
"Marco Elver" <elver@google.com>,
"Masami Hiramatsu" <mhiramat@kernel.org>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nick Desaulniers" <ndesaulniers@google.com>,
"Nicolas Schier" <nsc@kernel.org>,
"Peter Oberparleiter" <oberpar@linux.ibm.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Thomas Gleixner" <tglx@kernel.org>
Subject: Re: [PATCH v2 14/20] coverage: add Clang's source-based code coverage
Date: Wed, 04 Nov 2026 01:53:26 +0000 [thread overview]
Message-ID: <sashiko-outbox-196404@kernel.org> (raw)
In-Reply-To: <20261103015238.3780910-15-sashal@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] coverage: LLVM_COV_DATA places non-alloc __llvm_cov* in kernel image
--
commit c6db5401d9d9ff31cd5421cd456c7917bf582166
Author: Sasha Levin <sashal@kernel.org>
coverage: add Clang's source-based code coverage
This commit adds support for Clang's Source-based Code Coverage under
CONFIG_LLVM_COV_KERNEL, exporting raw profile data of the kernel image via
/sys/kernel/debug/coverage/llvm/profraw and defining the LLVM_COV_DATA
linker script macro for the associated compiler-emitted sections.
Link: https://clang.llvm.org/docs/SourceBasedCodeCoverage.html [1]
Link: https://lore.kernel.org/lkml/20210407211704.367039-1-morbo@google.com/ [2]
> diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
> index 3eb732942d699..840899b604336 100644
> --- a/include/asm-generic/vmlinux.lds.h
> +++ b/include/asm-generic/vmlinux.lds.h
> @@ -359,6 +359,42 @@
> #define THERMAL_TABLE(name)
> #endif
>
> +#ifdef CONFIG_LLVM_COV_KERNEL
> +#define LLVM_COV_DATA \
> + __llvm_prf_data : AT(ADDR(__llvm_prf_data) - LOAD_OFFSET) { \
> + BOUNDED_SECTION_POST_LABEL(__llvm_prf_data, \
> + __llvm_prf_data, \
> + _start, _end) \
> + } \
> + __llvm_prf_cnts : AT(ADDR(__llvm_prf_cnts) - LOAD_OFFSET) { \
> + BOUNDED_SECTION_POST_LABEL(__llvm_prf_cnts, \
> + __llvm_prf_cnts, \
> + _start, _end) \
> + } \
> + __llvm_prf_names : AT(ADDR(__llvm_prf_names) - LOAD_OFFSET) { \
> + BOUNDED_SECTION_POST_LABEL(__llvm_prf_names, \
> + __llvm_prf_names, \
> + _start, _end) \
> + } \
> + __llvm_prf_bits : AT(ADDR(__llvm_prf_bits) - LOAD_OFFSET) { \
> + BOUNDED_SECTION_POST_LABEL(__llvm_prf_bits, \
> + __llvm_prf_bits, \
> + _start, _end) \
> + } \
> + __llvm_covfun : AT(ADDR(__llvm_covfun) - LOAD_OFFSET) { \
> + BOUNDED_SECTION_POST_LABEL(__llvm_covfun, \
> + __llvm_covfun, \
> + _start, _end) \
> + } \
> + __llvm_covmap : AT(ADDR(__llvm_covmap) - LOAD_OFFSET) { \
> + BOUNDED_SECTION_POST_LABEL(__llvm_covmap, \
> + __llvm_covmap, \
> + _start, _end) \
> + }
[Severity: Medium]
Should __llvm_covfun and __llvm_covmap in LLVM_COV_DATA be placed outside
the loaded kernel image after _end with a 0 VMA (similar to DWARF_DEBUG,
ELF_DETAILS, or MODINFO) instead of alongside the runtime __llvm_prf_*
sections?
Unlike __llvm_prf_data, __llvm_prf_cnts, __llvm_prf_names, and
__llvm_prf_bits (which are emitted with SHF_ALLOC and accessed at runtime
by llvm_cov_serialize_raw_profile() and llvm_cov_reset()), Clang emits
__llvm_covfun and __llvm_covmap as SHT_PROGBITS sections without SHF_ALLOC
for offline consumption by the host llvm-cov tool, as noted in
scripts/mod/modpost.c:
static const char *const section_white_list[] =
{
...
"__llvm_covfun",
"__llvm_covmap",
...
};
When CONFIG_LLVM_COV_KERNEL=y is linked with GNU ld.bfd (since
CONFIG_LLVM_COV_KERNEL only depends on CC_IS_CLANG, not LD_IS_LLD), placing
__llvm_covfun and __llvm_covmap inside the kernel image without a 0 VMA
causes the linker to advance the location counter "." across the offline
coverage mapping data. This shifts all subsequent kernel sections, inflates
the reserved kernel virtual address range up to _end by tens of megabytes
on CONFIG_COVERAGE_PROFILE_ALL=y builds (risking exceeding the
KERNEL_IMAGE_SIZE link-time assertion on x86_64 when !CONFIG_COMPILE_TEST),
and creates a zero-filled gap in vmlinux.bin.
When linking with ld.lld, ADDR() of these non-SHF_ALLOC sections evaluates
to 0, so AT(ADDR(...) - LOAD_OFFSET) assigns a bogus LMA of -LOAD_OFFSET,
and BOUNDED_SECTION_POST_LABEL() also emits unused __llvm_covfun_start/end
and __llvm_covmap_start/end symbols.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261103015238.3780910-1-sashal@kernel.org?part=14
next prev parent reply other threads:[~2026-11-04 1:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 1:52 [PATCH v2 00/20] Unify code coverage and add Clang source-based coverage with MC/DC Sasha Levin
2026-11-03 1:52 ` [PATCH v2 02/20] kbuild: unify static coverage instrumentation as COVERAGE_PROFILE Sasha Levin
2026-11-04 1:53 ` sashiko-bot
2026-11-03 1:52 ` [PATCH v2 14/20] coverage: add Clang's source-based code coverage Sasha Levin
2026-11-04 1:53 ` sashiko-bot [this message]
2026-11-03 1:52 ` [PATCH v2 16/20] coverage: add MC/DC measurement Sasha Levin
2026-11-03 1:52 ` [PATCH v2 18/20] kconfig: add CC_HAS_CONDITION_COVERAGE for MC/DC support detection Sasha Levin
2026-11-03 1:52 ` [PATCH v2 19/20] gcov: add MC/DC condition coverage support Sasha Levin
2026-11-05 17:56 ` Peter Oberparleiter
2026-11-06 1:05 ` Sasha Levin
2026-11-05 17:36 ` [PATCH v2 00/20] Unify code coverage and add Clang source-based coverage with MC/DC Peter Oberparleiter
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=sashiko-outbox-196404@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=andreyknvl@gmail.com \
--cc=arnd@arndb.de \
--cc=chuck@wolber.net \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=glider@google.com \
--cc=justinstitt@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=nsc@kernel.org \
--cc=oberpar@linux.ibm.com \
--cc=peterz@infradead.org \
--cc=sashal@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tglx@kernel.org \
--cc=wentaoz5@illinois.edu \
/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