Bug 198443 - KCOV: trace arch/x86/kernel code
Summary: KCOV: trace arch/x86/kernel code
Status: NEW
Alias: None
Product: Memory Management
Classification: Unclassified
Component: Sanitizers (show other bugs)
Hardware: All Linux
: P2 enhancement
Assignee: Dmitry Vyukov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-10 14:36 UTC by Dmitry Vyukov
Modified: 2023-06-01 09:44 UTC (History)
2 users (show)

See Also:
Kernel Version: ALL
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Dmitry Vyukov 2018-01-10 14:36:08 UTC
Currently code in arch/x86/kernel/Makefile is not instrumented:

# If instrumentation of this dir is enabled, boot hangs during first second.
# Probably could be more selective here, but note that files related to irqs,
# boot, dumpstack/stacktrace, etc are either non-interesting or can lead to
# non-deterministic coverage.
KCOV_INSTRUMENT			:= n

But the files contain a bunch of syscalls and code invoked from syscalls. E.g. modity_ldt, set_thread_area. Here is what I've tested and it works (enabled code with syscall definitions and mentioning copy_to/from_user):

KCOV_INSTRUMENT_i8237.o			:= n
KCOV_INSTRUMENT_resource.o			:= n
KCOV_INSTRUMENT_machine_kexec_32.o			:= n
KCOV_INSTRUMENT_devicetree.o			:= n
KCOV_INSTRUMENT_apb_timer.o			:= n
KCOV_INSTRUMENT_smpboot.o			:= n
KCOV_INSTRUMENT_pvclock.o			:= n
#KCOV_INSTRUMENT_cpuid.o			:= n
KCOV_INSTRUMENT_e820.o			:= n
KCOV_INSTRUMENT_sysfb_efi.o			:= n
KCOV_INSTRUMENT_setup_percpu.o			:= n
KCOV_INSTRUMENT_io_delay.o			:= n
KCOV_INSTRUMENT_paravirt_patch_32.o			:= n
KCOV_INSTRUMENT_stacktrace.o			:= n
KCOV_INSTRUMENT_pci-swiotlb.o			:= n
KCOV_INSTRUMENT_itmt.o			:= n
KCOV_INSTRUMENT_check.o			:= n
#KCOV_INSTRUMENT_signal.o			:= n
KCOV_INSTRUMENT_idt.o			:= n
KCOV_INSTRUMENT_quirks.o			:= n
KCOV_INSTRUMENT_tsc_sync.o			:= n
KCOV_INSTRUMENT_jump_label.o			:= n
KCOV_INSTRUMENT_time.o			:= n
#KCOV_INSTRUMENT_ioport.o			:= n
KCOV_INSTRUMENT_mmconf-fam10h_64.o			:= n
KCOV_INSTRUMENT_step.o			:= n
KCOV_INSTRUMENT_crash_dump_32.o			:= n
KCOV_INSTRUMENT_ftrace.o			:= n
KCOV_INSTRUMENT_pmem.o			:= n
KCOV_INSTRUMENT_espfix_64.o			:= n
KCOV_INSTRUMENT_unwind_guess.o			:= n
KCOV_INSTRUMENT_kexec-bzimage64.o			:= n
#KCOV_INSTRUMENT_process_64.o			:= n
#KCOV_INSTRUMENT_tls.o			:= n
KCOV_INSTRUMENT_setup.o			:= n
KCOV_INSTRUMENT_tce_64.o			:= n
KCOV_INSTRUMENT_reboot.o			:= n
KCOV_INSTRUMENT_i8253.o			:= n
KCOV_INSTRUMENT_paravirt-spinlocks.o			:= n
KCOV_INSTRUMENT_hw_breakpoint.o			:= n
KCOV_INSTRUMENT_irq_work.o			:= n
KCOV_INSTRUMENT_pci-calgary_64.o			:= n
KCOV_INSTRUMENT_audit_64.o			:= n
KCOV_INSTRUMENT_rtc.o			:= n
KCOV_INSTRUMENT_irq.o			:= n
KCOV_INSTRUMENT_unwind_orc.o			:= n
KCOV_INSTRUMENT_ptrace.o			:= n
KCOV_INSTRUMENT_early-quirks.o			:= n
KCOV_INSTRUMENT_probe_roms.o			:= n
KCOV_INSTRUMENT_traps.o			:= n
KCOV_INSTRUMENT_ksysfs.o			:= n
#KCOV_INSTRUMENT_signal_compat.o			:= n
KCOV_INSTRUMENT_early_printk.o			:= n
#KCOV_INSTRUMENT_uprobes.o			:= n
KCOV_INSTRUMENT_paravirt.o			:= n
KCOV_INSTRUMENT_vsmp_64.o			:= n
KCOV_INSTRUMENT_irq_64.o			:= n
KCOV_INSTRUMENT_mpparse.o			:= n
KCOV_INSTRUMENT_sysfb.o			:= n
KCOV_INSTRUMENT_asm-offsets_64.o			:= n
KCOV_INSTRUMENT_dumpstack.o			:= n
KCOV_INSTRUMENT_aperture_64.o			:= n
KCOV_INSTRUMENT_asm-offsets.o			:= n
KCOV_INSTRUMENT_dumpstack_32.o			:= n
KCOV_INSTRUMENT_head32.o			:= n
KCOV_INSTRUMENT_livepatch.o			:= n
KCOV_INSTRUMENT_irqinit.o			:= n
KCOV_INSTRUMENT_amd_nb.o			:= n
KCOV_INSTRUMENT_tboot.o			:= n
KCOV_INSTRUMENT_tracepoint.o			:= n
KCOV_INSTRUMENT_amd_gart_64.o			:= n
KCOV_INSTRUMENT_unwind_frame.o			:= n
KCOV_INSTRUMENT_head64.o			:= n
KCOV_INSTRUMENT_sysfb_simplefb.o			:= n
KCOV_INSTRUMENT_paravirt_patch_64.o			:= n
KCOV_INSTRUMENT_reboot_fixups_32.o			:= n
KCOV_INSTRUMENT_kvmclock.o			:= n
KCOV_INSTRUMENT_doublefault.o			:= n
KCOV_INSTRUMENT_hpet.o			:= n
KCOV_INSTRUMENT_crash.o			:= n
KCOV_INSTRUMENT_pci-nommu.o			:= n
KCOV_INSTRUMENT_apm_32.o			:= n
KCOV_INSTRUMENT_pci-dma.o			:= n
KCOV_INSTRUMENT_dumpstack_64.o			:= n
KCOV_INSTRUMENT_pci-iommu_table.o			:= n
KCOV_INSTRUMENT_tsc.o			:= n
KCOV_INSTRUMENT_alternative.o			:= n
#KCOV_INSTRUMENT_msr.o			:= n
KCOV_INSTRUMENT_machine_kexec_64.o			:= n
KCOV_INSTRUMENT_nmi.o			:= n
#KCOV_INSTRUMENT_ldt.o			:= n
#KCOV_INSTRUMENT_vm86_32.o			:= n
KCOV_INSTRUMENT_trace_clock.o			:= n
KCOV_INSTRUMENT_perf_regs.o			:= n
KCOV_INSTRUMENT_bootflag.o			:= n
KCOV_INSTRUMENT_i8259.o			:= n
KCOV_INSTRUMENT_nmi_selftest.o			:= n
KCOV_INSTRUMENT_crash_dump_64.o			:= n
KCOV_INSTRUMENT_pcspeaker.o			:= n
KCOV_INSTRUMENT_kvm.o			:= n
KCOV_INSTRUMENT_kdebugfs.o			:= n
KCOV_INSTRUMENT_module.o			:= n
KCOV_INSTRUMENT_x86_init.o			:= n
KCOV_INSTRUMENT_asm-offsets_32.o			:= n
KCOV_INSTRUMENT_kgdb.o			:= n
KCOV_INSTRUMENT_topology.o			:= n
KCOV_INSTRUMENT_irq_32.o			:= n
KCOV_INSTRUMENT_platform-quirks.o			:= n
#KCOV_INSTRUMENT_process_32.o			:= n
#KCOV_INSTRUMENT_sys_x86_64.o			:= n
KCOV_INSTRUMENT_tsc_msr.o			:= n
KCOV_INSTRUMENT_smp.o			:= n
KCOV_INSTRUMENT_ebda.o			:= n
KCOV_INSTRUMENT_eisa.o			:= n
KCOV_INSTRUMENT_process.o			:= n
Need to understand what exactly files need to be disabled and upstream this.
I've also tried the following and it does not yet boot:

KCOV_INSTRUMENT_head$(BITS).o				:= n
KCOV_INSTRUMENT_setup.o					:= n
KCOV_INSTRUMENT_dumpstack.o				:= n
KCOV_INSTRUMENT_dumpstack_$(BITS).o			:= n
KCOV_INSTRUMENT_stacktrace.o				:= n
KCOV_INSTRUMENT_relocate_kernel_$(BITS).o		:= n
KCOV_INSTRUMENT_ftrace_$(BITS).o			:= n
KCOV_INSTRUMENT_test_nx.o				:= n
KCOV_INSTRUMENT_paravirt_patch_$(BITS).o		:= n
KCOV_INSTRUMENT_tsc.o					:= n
KCOV_INSTRUMENT_paravirt-spinlocks.o			:= n
KCOV_INSTRUMENT_pvclock.o				:= n
KCOV_INSTRUMENT_kvmclock.o				:= n
KCOV_INSTRUMENT_ftrace.o				:= n
KCOV_INSTRUMENT_early_printk.o				:= n
Comment 1 Dmitry Vyukov 2023-05-02 06:47:18 UTC
Probably makes more sense to do as a allowlist instead:

KCOV_INSTRUMENT			:= n
KCOV_INSTRUMENT_foo			:= y
Comment 2 xupengfe 2023-05-05 04:46:52 UTC
We also found this issue when syzkaller test.
Is there some one help to fix this issue for KCOV_INSTRUMENT?

Thanks!
BR.
Comment 3 xupengfe 2023-06-01 09:44:20 UTC
I found I could use below item and enable at least SHSTK test.
KCOV_INSTRUMENT_alternative.o                 :=n
KCOV_INSTRUMENT_amd_gart_64.o                 :=n
KCOV_INSTRUMENT_amd_nb.o                      :=n
KCOV_INSTRUMENT_aperture_64.o                 :=n
KCOV_INSTRUMENT_audit_64.o                    :=n
KCOV_INSTRUMENT_bootflag.o                    :=n
KCOV_INSTRUMENT_callthunks.o                  :=n
KCOV_INSTRUMENT_check.o                       :=n
KCOV_INSTRUMENT_cpuid.mod.o                   :=n
KCOV_INSTRUMENT_cpuid.o                       :=n
KCOV_INSTRUMENT_crash_core_64.o               :=n
KCOV_INSTRUMENT_crash_dump_64.o               :=n
KCOV_INSTRUMENT_crash.o                       :=n
KCOV_INSTRUMENT_devicetree.o                  :=n
KCOV_INSTRUMENT_dumpstack_64.o                :=n
KCOV_INSTRUMENT_dumpstack.o                   :=n
KCOV_INSTRUMENT_e820.o                        :=n
KCOV_INSTRUMENT_early_printk.o                :=n
KCOV_INSTRUMENT_early-quirks.o                :=n
KCOV_INSTRUMENT_ebda.o                        :=n
KCOV_INSTRUMENT_espfix_64.o                   :=n
KCOV_INSTRUMENT_ftrace_64.o                   :=n
KCOV_INSTRUMENT_ftrace.o                      :=n
KCOV_INSTRUMENT_head_64.o                     :=n
KCOV_INSTRUMENT_head64.o                      :=n
KCOV_INSTRUMENT_hpet.o                        :=n
KCOV_INSTRUMENT_hw_breakpoint.o               :=n
KCOV_INSTRUMENT_i8237.o                       :=n
KCOV_INSTRUMENT_i8253.o                       :=n
KCOV_INSTRUMENT_i8259.o                       :=n
KCOV_INSTRUMENT_idt.o                         :=n
KCOV_INSTRUMENT_io_delay.o                    :=n
KCOV_INSTRUMENT_ioport.o                      :=n
KCOV_INSTRUMENT_irq_64.o                      :=n
KCOV_INSTRUMENT_irqflags.o                    :=n
KCOV_INSTRUMENT_irqinit.o                     :=n
KCOV_INSTRUMENT_irq.o                         :=n
KCOV_INSTRUMENT_irq_work.o                    :=n
KCOV_INSTRUMENT_itmt.o                        :=n
KCOV_INSTRUMENT_jailhouse.o                   :=n
KCOV_INSTRUMENT_jump_label.o                  :=n
KCOV_INSTRUMENT_kdebugfs.o                    :=n
KCOV_INSTRUMENT_kexec-bzimage64.o             :=n
KCOV_INSTRUMENT_kgdb.o                        :=n
KCOV_INSTRUMENT_ksysfs.o                      :=n
KCOV_INSTRUMENT_kvmclock.o                    :=n
KCOV_INSTRUMENT_kvm.o                         :=n
KCOV_INSTRUMENT_ldt.o                         :=n
KCOV_INSTRUMENT_machine_kexec_64.o            :=n
KCOV_INSTRUMENT_mmconf-fam10h_64.o            :=n
KCOV_INSTRUMENT_module.o                      :=n
KCOV_INSTRUMENT_mpparse.o                     :=n
KCOV_INSTRUMENT_msr.o                         :=n
KCOV_INSTRUMENT_nmi.o                         :=n
KCOV_INSTRUMENT_paravirt.o                    :=n
KCOV_INSTRUMENT_paravirt-spinlocks.o          :=n
KCOV_INSTRUMENT_pci-dma.o                     :=n
KCOV_INSTRUMENT_pcspeaker.o                   :=n
KCOV_INSTRUMENT_perf_regs.o                   :=n
KCOV_INSTRUMENT_platform-quirks.o             :=n
KCOV_INSTRUMENT_pmem.o                        :=n
KCOV_INSTRUMENT_probe_roms.o                  :=n
KCOV_INSTRUMENT_process_64.o                  :=n
KCOV_INSTRUMENT_process.o                     :=n
KCOV_INSTRUMENT_ptrace.o                      :=n
KCOV_INSTRUMENT_pvclock.o                     :=n
KCOV_INSTRUMENT_quirks.o                      :=n
KCOV_INSTRUMENT_reboot.o                      :=n
KCOV_INSTRUMENT_relocate_kernel_64.o          :=n
KCOV_INSTRUMENT_resource.o                    :=n
KCOV_INSTRUMENT_rethook.o                     :=n
KCOV_INSTRUMENT_rtc.o                         :=n
KCOV_INSTRUMENT_sched_ipcc.o                  :=n
KCOV_INSTRUMENT_setup.o                       :=n
KCOV_INSTRUMENT_setup_percpu.o                :=n
KCOV_INSTRUMENT_sev.o                         :=n
KCOV_INSTRUMENT_signal_32.o                   :=n
KCOV_INSTRUMENT_signal_64.o                   :=n
KCOV_INSTRUMENT_signal.o                      :=n
KCOV_INSTRUMENT_smpboot.o                     :=n
KCOV_INSTRUMENT_smp.o                         :=n
KCOV_INSTRUMENT_stacktrace.o                  :=n
KCOV_INSTRUMENT_static_call.o                 :=n
KCOV_INSTRUMENT_step.o                        :=n
KCOV_INSTRUMENT_sys_ia32.o                    :=n
KCOV_INSTRUMENT_sys_x86_64.o                  :=n
KCOV_INSTRUMENT_tboot.o                       :=n
KCOV_INSTRUMENT_time.o                        :=n
KCOV_INSTRUMENT_tls.o                         :=n
KCOV_INSTRUMENT_topology.o                    :=n
KCOV_INSTRUMENT_trace_clock.o                 :=n
KCOV_INSTRUMENT_trace.o                       :=n
KCOV_INSTRUMENT_tracepoint.o                  :=n
KCOV_INSTRUMENT_traps.o                       :=n
KCOV_INSTRUMENT_tsc_msr.o                     :=n
KCOV_INSTRUMENT_tsc.o                         :=n
KCOV_INSTRUMENT_tsc_sync.o                    :=n
KCOV_INSTRUMENT_umip.o                        :=n
KCOV_INSTRUMENT_unwind_frame.o                :=n
KCOV_INSTRUMENT_uprobes.o                     :=n
KCOV_INSTRUMENT_vsmp_64.o                     :=n
KCOV_INSTRUMENT_x86_init.o                    :=n


I will do more testing to think out some good way for it.
Thanks a lot for Dmitry's guidance!

Thanks!

Note You need to log in before you can comment on or make changes to this bug.