From: Alexander Potapenko <glider@google.com>
To: glider@google.com
Cc: quic_jiangenj@quicinc.com, linux-kernel@vger.kernel.org,
kasan-dev@googlegroups.com, Aleksandr Nogikh <nogikh@google.com>,
Andrey Konovalov <andreyknvl@gmail.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
Dmitry Vyukov <dvyukov@google.com>,
Ingo Molnar <mingo@redhat.com>,
Josh Poimboeuf <jpoimboe@kernel.org>,
Marco Elver <elver@google.com>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH v3 01/10] x86: kcov: disable instrumentation of arch/x86/kernel/tsc.c
Date: Mon, 28 Jul 2025 17:25:39 +0200 [thread overview]
Message-ID: <20250728152548.3969143-2-glider@google.com> (raw)
In-Reply-To: <20250728152548.3969143-1-glider@google.com>
sched_clock() appears to be called from interrupts, producing spurious
coverage, as reported by CONFIG_KCOV_SELFTEST:
RIP: 0010:__sanitizer_cov_trace_pc_guard+0x66/0xe0 kernel/kcov.c:288
...
fault_in_kernel_space+0x17/0x70 arch/x86/mm/fault.c:1119
handle_page_fault arch/x86/mm/fault.c:1477
exc_page_fault+0x56/0x110 arch/x86/mm/fault.c:1538
asm_exc_page_fault+0x26/0x30 ./arch/x86/include/asm/idtentry.h:623
RIP: 0010:__sanitizer_cov_trace_pc_guard+0x66/0xe0 kernel/kcov.c:288
...
sched_clock+0x12/0x70 arch/x86/kernel/tsc.c:284
__lock_pin_lock kernel/locking/lockdep.c:5628
lock_pin_lock+0xd7/0x180 kernel/locking/lockdep.c:5959
rq_pin_lock kernel/sched/sched.h:1761
rq_lock kernel/sched/sched.h:1838
__schedule+0x3a8/0x4b70 kernel/sched/core.c:6691
preempt_schedule_irq+0xbf/0x160 kernel/sched/core.c:7090
irqentry_exit+0x6f/0x90 kernel/entry/common.c:354
asm_sysvec_reschedule_ipi+0x1a/0x20 ./arch/x86/include/asm/idtentry.h:707
RIP: 0010:selftest+0x26/0x60 kernel/kcov.c:1223
...
kcov_init+0x81/0xa0 kernel/kcov.c:1252
do_one_initcall+0x2e1/0x910
do_initcall_level+0xff/0x160 init/main.c:1319
do_initcalls+0x4a/0xa0 init/main.c:1335
kernel_init_freeable+0x448/0x610 init/main.c:1567
kernel_init+0x24/0x230 init/main.c:1457
ret_from_fork+0x60/0x90 arch/x86/kernel/process.c:153
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
Signed-off-by: Alexander Potapenko <glider@google.com>
---
Change-Id: Ica191d73bf5601b31e893d6e517b91be983e986a
---
arch/x86/kernel/Makefile | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 0d2a6d953be91..ca134ce03eea9 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -43,6 +43,8 @@ KCOV_INSTRUMENT_dumpstack_$(BITS).o := n
KCOV_INSTRUMENT_unwind_orc.o := n
KCOV_INSTRUMENT_unwind_frame.o := n
KCOV_INSTRUMENT_unwind_guess.o := n
+# Avoid instrumenting code that produces spurious coverage in interrupts.
+KCOV_INSTRUMENT_tsc.o := n
CFLAGS_head32.o := -fno-stack-protector
CFLAGS_head64.o := -fno-stack-protector
--
2.50.1.470.g6ba607880d-goog
next prev parent reply other threads:[~2025-07-28 15:26 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-28 15:25 [PATCH v3 00/10] Coverage deduplication for KCOV Alexander Potapenko
2025-07-28 15:25 ` Alexander Potapenko [this message]
2025-07-28 15:25 ` [PATCH v3 02/10] kcov: elaborate on using the shared buffer Alexander Potapenko
2025-07-28 15:25 ` [PATCH v3 03/10] kcov: factor out struct kcov_state Alexander Potapenko
2025-07-29 11:09 ` Dmitry Vyukov
2025-07-28 15:25 ` [PATCH v3 04/10] mm/kasan: define __asan_before_dynamic_init, __asan_after_dynamic_init Alexander Potapenko
2025-07-29 11:43 ` kernel test robot
2025-07-31 11:44 ` Alexander Potapenko
2025-07-28 15:25 ` [PATCH v3 05/10] kcov: x86: introduce CONFIG_KCOV_UNIQUE Alexander Potapenko
2025-07-29 11:11 ` Dmitry Vyukov
2025-07-28 15:25 ` [PATCH v3 06/10] kcov: add trace and trace_size to struct kcov_state Alexander Potapenko
2025-07-29 11:11 ` Dmitry Vyukov
2025-07-28 15:25 ` [PATCH v3 07/10] kcov: add ioctl(KCOV_UNIQUE_ENABLE) Alexander Potapenko
2025-07-29 11:14 ` Dmitry Vyukov
2025-07-28 15:25 ` [PATCH v3 08/10] kcov: add ioctl(KCOV_RESET_TRACE) Alexander Potapenko
2025-07-29 11:17 ` Dmitry Vyukov
2025-08-06 9:47 ` Alexander Potapenko
2025-08-06 9:59 ` Dmitry Vyukov
2025-07-28 15:25 ` [PATCH v3 09/10] kcov: selftests: add kcov_test Alexander Potapenko
2025-07-29 11:20 ` Dmitry Vyukov
2025-07-31 8:02 ` Alexander Potapenko
2025-07-28 15:25 ` [PATCH v3 10/10] kcov: use enum kcov_mode in kcov_mode_enabled() Alexander Potapenko
2025-07-29 11:20 ` Dmitry Vyukov
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=20250728152548.3969143-2-glider@google.com \
--to=glider@google.com \
--cc=andreyknvl@gmail.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=jpoimboe@kernel.org \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nogikh@google.com \
--cc=peterz@infradead.org \
--cc=quic_jiangenj@quicinc.com \
--cc=tglx@linutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).