riscv: enable kcov
PATCH 1/1 riscv: enable kcov
Add ARCH_HAS_KCOV and HAVE_GCC_PLUGINS to the riscv Kconfig. Also disable instrumentation of vdso.
--- arch/riscv/Kconfig | 2 ++ arch/riscv/kernel/vdso/Makefile | 1 + 2 files changed, 3 insertions(+)
arch/riscv/Kconfig +2 -0
@@ -19,6 +19,7 @@ config RISCV select ARCH_HAS_DEBUG_WX select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_GIGANTIC_PAGE + select ARCH_HAS_KCOV select ARCH_HAS_MMIOWB select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_SET_DIRECT_MAP
@@ -57,6 +58,7 @@ config RISCV select HAVE_DMA_CONTIGUOUS if MMU select HAVE_EBPF_JIT if MMU select HAVE_FUTEX_CMPXCHG if FUTEX + select HAVE_GCC_PLUGINS select HAVE_GENERIC_VDSO if MMU && 64BIT select HAVE_PCI select HAVE_PERF_EVENTS
arch/riscv/kernel/vdso/Makefile +1 -0
@@ -29,6 +29,7 @@ CPPFLAGS_vdso.lds += -P -C -U$(ARCH) # Disable gcov profiling for VDSO code GCOV_PROFILE := n +KCOV_INSTRUMENT := n # Force dependency $(obj)/vdso.o: $(obj)/vdso.so
Signature · 7 lines
2.27.0 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 7 lines · Tobias Klauser
Add
ARCH_HAS_KCOVandHAVE_GCC_PLUGINSto the riscvKconfig. Also disable instrumentation of vdso.Cc Björn Töpel <[email protected]>Cc Dmitry Vyukov <[email protected]>Signed-off-by Tobias Klauser <[email protected]>
If it boots:
FWIW for x86 we needed to do much more of this:
$ find arch/x86/ -name Makefile -exec grep KCOV_INSTRUMENT {} \; -print
KCOV_INSTRUMENT := n
arch/x86/kernel/Makefile
KCOV_INSTRUMENT := n
arch/x86/kernel/apic/Makefile
KCOV_INSTRUMENT_common.o := n
KCOV_INSTRUMENT_perf_event.o := n
arch/x86/kernel/cpu/Makefile
KCOV_INSTRUMENT := n
arch/x86/realmode/rm/Makefile
KCOV_INSTRUMENT := n
arch/x86/boot/Makefile
KCOV_INSTRUMENT := n
arch/x86/boot/compressed/Makefile
KCOV_INSTRUMENT := n
arch/x86/entry/Makefile
KCOV_INSTRUMENT := n
arch/x86/entry/vdso/Makefile
KCOV_INSTRUMENT := n
arch/x86/um/vdso/Makefile
KCOV_INSTRUMENT_delay.o := n
KCOV_INSTRUMENT_cmdline.o := n
arch/x86/lib/Makefile
KCOV_INSTRUMENT_tlb.o := n
KCOV_INSTRUMENT_mem_encrypt.o := n
KCOV_INSTRUMENT_mem_encrypt_identity.o := n
arch/x86/mm/Makefile
KCOV_INSTRUMENT := n
arch/x86/purgatory/MakefileQuoted 38 lines
--- arch/riscv/Kconfig | 2 ++ arch/riscv/kernel/vdso/Makefile | 1 + 2 files changed, 3 insertions(+)arch/riscv/Kconfig +2
-0@@ -19,6 +19,7 @@ config RISCV select ARCH_HAS_DEBUG_WX select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_GIGANTIC_PAGE + select ARCH_HAS_KCOV select ARCH_HAS_MMIOWB select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_SET_DIRECT_MAP@@ -57,6 +58,7 @@ config RISCV select HAVE_DMA_CONTIGUOUS if MMU select HAVE_EBPF_JIT if MMU select HAVE_FUTEX_CMPXCHG if FUTEX + select HAVE_GCC_PLUGINS select HAVE_GENERIC_VDSO if MMU && 64BIT select HAVE_PCI select HAVE_PERF_EVENTSarch/riscv/kernel/vdso/Makefile +1
-1@@ -29,6 +29,7 @@ CPPFLAGS_vdso.lds += -P -C -U$(ARCH) # Disable gcov profiling for VDSO code GCOV_PROFILE := n +KCOV_INSTRUMENT := n # Force dependency $(obj)/vdso.o: $(obj)/vdso.so --
Quoted 2 lines
2.27.0
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 5 lines · Dmitry Vyukov
Quoted 4 lines · Tobias Klauser
Add
ARCH_HAS_KCOVandHAVE_GCC_PLUGINSto the riscvKconfig. Also disable instrumentation of vdso.
Quoted 8 lines
Quoted 3 lines
Cc Björn Töpel <[email protected]>Cc Dmitry Vyukov <[email protected]>Signed-off-by Tobias Klauser <[email protected]>If it boots:
Acked-by Dmitry Vyukov <[email protected]>
Yeah turns out I boot-tested this with a kernel which didn't have CONFIG_KCOV enabled :-/ Will send a v2 patch.
Quoted 23 lines
FWIW for x86 we needed to do much more of this:
$ find arch/x86/ -name Makefile -exec grep KCOV_INSTRUMENT {} \; -print KCOV_INSTRUMENT := n arch/x86/kernel/Makefile KCOV_INSTRUMENT := n arch/x86/kernel/apic/Makefile KCOV_INSTRUMENT_common.o := n KCOV_INSTRUMENT_perf_event.o := n arch/x86/kernel/cpu/Makefile KCOV_INSTRUMENT := n arch/x86/realmode/rm/Makefile KCOV_INSTRUMENT := n arch/x86/boot/Makefile KCOV_INSTRUMENT := n arch/x86/boot/compressed/Makefile KCOV_INSTRUMENT := n arch/x86/entry/Makefile KCOV_INSTRUMENT := n arch/x86/entry/vdso/Makefile KCOV_INSTRUMENT := n arch/x86/um/vdso/Makefile KCOV_INSTRUMENT_delay.o := n
Quoted 8 lines
KCOV_INSTRUMENT_cmdline.o := n arch/x86/lib/Makefile KCOV_INSTRUMENT_tlb.o := n KCOV_INSTRUMENT_mem_encrypt.o := n KCOV_INSTRUMENT_mem_encrypt_identity.o := n arch/x86/mm/Makefile KCOV_INSTRUMENT := n arch/x86/purgatory/Makefile
Thanks, that's very helpful.
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
PATCH v2 1/1 riscv: Allow building with kcov coverage
In reply to Tobias KlauserAdd ARCH_HAS_KCOV and HAVE_GCC_PLUGINS to the riscv Kconfig. Also disable instrumentation of some early boot code and vdso.
Boot-tested on QEMU's riscv64 virt machine.
--- arch/riscv/Kconfig | 2 ++ arch/riscv/boot/Makefile | 2 ++ arch/riscv/kernel/vdso/Makefile | 1 + arch/riscv/mm/Makefile | 2 ++ 4 files changed, 7 insertions(+)
arch/riscv/Kconfig +2 -0
@@ -19,6 +19,7 @@ config RISCV select ARCH_HAS_DEBUG_WX select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_GIGANTIC_PAGE + select ARCH_HAS_KCOV select ARCH_HAS_MMIOWB select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_SET_DIRECT_MAP
@@ -57,6 +58,7 @@ config RISCV select HAVE_DMA_CONTIGUOUS if MMU select HAVE_EBPF_JIT if MMU select HAVE_FUTEX_CMPXCHG if FUTEX + select HAVE_GCC_PLUGINS select HAVE_GENERIC_VDSO if MMU && 64BIT select HAVE_PCI select HAVE_PERF_EVENTS
arch/riscv/boot/Makefile +2 -0
@@ -14,6 +14,8 @@ # Based on the ia64 and arm64 boot/Makefile. # +KCOV_INSTRUMENT := n + OBJCOPYFLAGS_Image :=-O binary -R .note -R .note.gnu.build-id -R .comment -S targets := Image loader
arch/riscv/kernel/vdso/Makefile +1 -0
@@ -29,6 +29,7 @@ CPPFLAGS_vdso.lds += -P -C -U$(ARCH) # Disable gcov profiling for VDSO code GCOV_PROFILE := n +KCOV_INSTRUMENT := n # Force dependency $(obj)/vdso.o: $(obj)/vdso.so
arch/riscv/mm/Makefile +2 -0
@@ -5,6 +5,8 @@ ifdef CONFIG_FTRACE CFLAGS_REMOVE_init.o = -pg endif +KCOV_INSTRUMENT_init.o := n + obj-y += init.o obj-y += extable.o obj-$(CONFIG_MMU) += fault.o pageattr.o
Signature · 1 line
2.27.0
Re: [PATCH v2] riscv: Allow building with kcov coverage
Quoted 9 lines · Tobias Klauser
Add
ARCH_HAS_KCOVandHAVE_GCC_PLUGINSto the riscvKconfig. Also disable instrumentation of some early boot code and vdso.Boot-tested on QEMU's riscv64 virt machine.
Cc Björn Töpel <[email protected]>Cc Dmitry Vyukov <[email protected]>Signed-off-by Tobias Klauser <[email protected]>
Assuming it boots now :)
Quoted 68 lines
--- arch/riscv/Kconfig | 2 ++ arch/riscv/boot/Makefile | 2 ++ arch/riscv/kernel/vdso/Makefile | 1 + arch/riscv/mm/Makefile | 2 ++ 4 files changed, 7 insertions(+)arch/riscv/Kconfig +2
-0@@ -19,6 +19,7 @@ config RISCV select ARCH_HAS_DEBUG_WX select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_GIGANTIC_PAGE + select ARCH_HAS_KCOV select ARCH_HAS_MMIOWB select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_SET_DIRECT_MAP@@ -57,6 +58,7 @@ config RISCV select HAVE_DMA_CONTIGUOUS if MMU select HAVE_EBPF_JIT if MMU select HAVE_FUTEX_CMPXCHG if FUTEX + select HAVE_GCC_PLUGINS select HAVE_GENERIC_VDSO if MMU && 64BIT select HAVE_PCI select HAVE_PERF_EVENTSarch/riscv/boot/Makefile +2
-0@@ -14,6 +14,8 @@ # Based on the ia64 and arm64 boot/Makefile. # +KCOV_INSTRUMENT := n + OBJCOPYFLAGS_Image :=-O binary -R .note -R .note.gnu.build-id -R .comment -S targets := Image loaderarch/riscv/kernel/vdso/Makefile +1
-0@@ -29,6 +29,7 @@ CPPFLAGS_vdso.lds += -P -C -U$(ARCH) # Disable gcov profiling for VDSO code GCOV_PROFILE := n +KCOV_INSTRUMENT := n # Force dependency $(obj)/vdso.o: $(obj)/vdso.soarch/riscv/mm/Makefile +2
-1@@ -5,6 +5,8 @@ ifdef CONFIG_FTRACE CFLAGS_REMOVE_init.o = -pg endif +KCOV_INSTRUMENT_init.o := n + obj-y += init.o obj-y += extable.o obj-$(CONFIG_MMU) += fault.o pageattr.o --2.27.0
Palmer Dabbelt
maintainerRe: [PATCH v2] riscv: Allow building with kcov coverage
In reply to Tobias KlauserQuoted 4 lines · On Fri, 26 Jun 2020 05:40:56 PDT (-0700), [email protected] wrote:
Add
ARCH_HAS_KCOVandHAVE_GCC_PLUGINSto the riscvKconfig. Also disable instrumentation of some early boot code and vdso.Boot-tested on QEMU's riscv64 virt machine.
Thanks. This is on for-next (with the ack). I'm boot testing a config with
CONFIG_KCOV=y
CONFIG_KCOV_ENABLE_COMPARISONS=y
but LMK if there's something more interesting to test. I don't see anything coverage-related in the boot log...
Quoted 68 lines
Cc Björn Töpel <[email protected]>Cc Dmitry Vyukov <[email protected]>Signed-off-by Tobias Klauser <[email protected]>--- arch/riscv/Kconfig | 2 ++ arch/riscv/boot/Makefile | 2 ++ arch/riscv/kernel/vdso/Makefile | 1 + arch/riscv/mm/Makefile | 2 ++ 4 files changed, 7 insertions(+)arch/riscv/Kconfig +2
-0@@ -19,6 +19,7 @@ config RISCV select ARCH_HAS_DEBUG_WX select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_GIGANTIC_PAGE + select ARCH_HAS_KCOV select ARCH_HAS_MMIOWB select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_SET_DIRECT_MAP@@ -57,6 +58,7 @@ config RISCV select HAVE_DMA_CONTIGUOUS if MMU select HAVE_EBPF_JIT if MMU select HAVE_FUTEX_CMPXCHG if FUTEX + select HAVE_GCC_PLUGINS select HAVE_GENERIC_VDSO if MMU && 64BIT select HAVE_PCI select HAVE_PERF_EVENTSarch/riscv/boot/Makefile +2
-0@@ -14,6 +14,8 @@ # Based on the ia64 and arm64 boot/Makefile. # +KCOV_INSTRUMENT := n + OBJCOPYFLAGS_Image :=-O binary -R .note -R .note.gnu.build-id -R .comment -S targets := Image loaderarch/riscv/kernel/vdso/Makefile +1
-0@@ -29,6 +29,7 @@ CPPFLAGS_vdso.lds += -P -C -U$(ARCH) # Disable gcov profiling for VDSO code GCOV_PROFILE := n +KCOV_INSTRUMENT := n # Force dependency $(obj)/vdso.o: $(obj)/vdso.soarch/riscv/mm/Makefile +2
-0@@ -5,6 +5,8 @@ ifdef CONFIG_FTRACE CFLAGS_REMOVE_init.o = -pg endif +KCOV_INSTRUMENT_init.o := n + obj-y += init.o obj-y += extable.o obj-$(CONFIG_MMU) += fault.o pageattr.o