A few x86 objects are excluded from KCOV only because their coverage is noise for syscall fuzzing: the APIC code (interrupts land in random places), delay.o, and the stack trace, dumpstack and unwinder objects.
Use $(kcov-noisy) for them, so that CONFIG_KCOV_INSTRUMENT_NOISY=y includes them in early boot coverage. With the option off nothing changes. The objects excluded because the kernel does not boot or hangs when they are instrumented (head64.o, cpu/common.o, perf_event.o, tlb.c, mem_encrypt*.c, pgprot.c) stay excluded, as do machine_kexec_64.o and physaddr.o, which must not use KCOV during kexec once load_segments() has invalidated the GS base. With FRED, the system vector wrappers in apic.c are not noinstr and run before the hardirq count is raised, so with this change interrupt PCs such as the LAPIC timer can be recorded as if init_task executed them. The same already happens for the wrappers in irq.c, smp.c and others. Signed-off-by: Yunseong Kim <[email protected]> --- arch/x86/kernel/Makefile | 12 ++++++------ arch/x86/kernel/apic/Makefile | 2 +- arch/x86/lib/Makefile | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index 31f46fd005278..44cfd3781c30a 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile @@ -37,12 +37,12 @@ KMSAN_SANITIZE_nmi.o := n KCOV_INSTRUMENT_head$(BITS).o := n # These are called from save_stack_trace() on debug paths, # and produce large amounts of uninteresting coverage. -KCOV_INSTRUMENT_stacktrace.o := n -KCOV_INSTRUMENT_dumpstack.o := n -KCOV_INSTRUMENT_dumpstack_$(BITS).o := n -KCOV_INSTRUMENT_unwind_orc.o := n -KCOV_INSTRUMENT_unwind_frame.o := n -KCOV_INSTRUMENT_unwind_guess.o := n +KCOV_INSTRUMENT_stacktrace.o := $(kcov-noisy) +KCOV_INSTRUMENT_dumpstack.o := $(kcov-noisy) +KCOV_INSTRUMENT_dumpstack_$(BITS).o := $(kcov-noisy) +KCOV_INSTRUMENT_unwind_orc.o := $(kcov-noisy) +KCOV_INSTRUMENT_unwind_frame.o := $(kcov-noisy) +KCOV_INSTRUMENT_unwind_guess.o := $(kcov-noisy) # Disable KCOV to prevent crashes during kexec: load_segments() invalidates # the GS base, which KCOV relies on for per-CPU data. diff --git a/arch/x86/kernel/apic/Makefile b/arch/x86/kernel/apic/Makefile index 581db89477f92..146cbd766c924 100644 --- a/arch/x86/kernel/apic/Makefile +++ b/arch/x86/kernel/apic/Makefile @@ -5,7 +5,7 @@ # Leads to non-deterministic coverage that is not a function of syscall inputs. # In particular, smp_apic_timer_interrupt() is called in random places. -KCOV_INSTRUMENT := n +KCOV_INSTRUMENT := $(kcov-noisy) obj-$(CONFIG_X86_LOCAL_APIC) += apic.o apic_common.o apic_noop.o ipi.o vector.o init.o obj-y += hw_nmi.o diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile index 2dba7f83ef97c..151ecee2229f3 100644 --- a/arch/x86/lib/Makefile +++ b/arch/x86/lib/Makefile @@ -4,7 +4,7 @@ # # Produces uninteresting flaky coverage. -KCOV_INSTRUMENT_delay.o := n +KCOV_INSTRUMENT_delay.o := $(kcov-noisy) # KCSAN uses udelay for introducing watchpoint delay; avoid recursion. KCSAN_SANITIZE_delay.o := n -- 2.47.3
