2021-05-25 21:25:42

by Marco Elver

[permalink] [raw]
Subject: [PATCH] kcov: add __no_sanitize_coverage to fix noinstr for all architectures

Until now no compiler supported an attribute to disable coverage
instrumentation as used by KCOV.

To work around this limitation on x86, noinstr functions have their
coverage instrumentation turned into nops by objtool. However, this
solution doesn't scale automatically to other architectures, such as
arm64, which are migrating to use the generic entry code.

Clang [1] and GCC [2] have added support for the attribute recently.
[1] https://github.com/llvm/llvm-project/commit/280333021e9550d80f5c1152a34e33e81df1e178
[2] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=cec4d4a6782c9bd8d071839c50a239c49caca689

Add __no_sanitize_coverage for both compilers, and add it to noinstr.

Signed-off-by: Marco Elver <[email protected]>
---
include/linux/compiler-clang.h | 6 ++++++
include/linux/compiler-gcc.h | 6 ++++++
include/linux/compiler_types.h | 2 +-
3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
index adbe76b203e2..370565f4cfde 100644
--- a/include/linux/compiler-clang.h
+++ b/include/linux/compiler-clang.h
@@ -45,6 +45,12 @@
#define __no_sanitize_undefined
#endif

+#if defined(CONFIG_KCOV) && CONFIG_CLANG_VERSION >= 130000
+#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
+#else
+#define __no_sanitize_coverage
+#endif
+
/*
* Not all versions of clang implement the type-generic versions
* of the builtin overflow checkers. Fortunately, clang implements
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index 5d97ef738a57..cb9217fc60af 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -122,6 +122,12 @@
#define __no_sanitize_undefined
#endif

+#if defined(CONFIG_KCOV) && __has_attribute(__no_sanitize_coverage__)
+#define __no_sanitize_coverage __attribute__((no_sanitize_coverage))
+#else
+#define __no_sanitize_coverage
+#endif
+
#if GCC_VERSION >= 50100
#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
#endif
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index d29bda7f6ebd..cc2bee7f0977 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -210,7 +210,7 @@ struct ftrace_likely_data {
/* Section for code which can't be instrumented at all */
#define noinstr \
noinline notrace __attribute((__section__(".noinstr.text"))) \
- __no_kcsan __no_sanitize_address
+ __no_kcsan __no_sanitize_address __no_sanitize_coverage

#endif /* __KERNEL__ */

--
2.31.1.818.g46aad6cb9e-goog


2021-05-25 23:01:50

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] kcov: add __no_sanitize_coverage to fix noinstr for all architectures

Hi Marco,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linux/master]
[also build test WARNING on kees/for-next/pstore linus/master v5.13-rc3 next-20210525]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Marco-Elver/kcov-add-__no_sanitize_coverage-to-fix-noinstr-for-all-architectures/20210526-020046
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git dd860052c99b1e088352bdd4fb7aef46f8d2ef47
config: s390-randconfig-r002-20210525 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 99155e913e9bad5f7f8a247f8bb3a3ff3da74af1)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install s390 cross compiling tool for clang build
# apt-get install binutils-s390x-linux-gnu
# https://github.com/0day-ci/linux/commit/d898fa12bc72a46da1b9466bb7f8369949b714a9
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Marco-Elver/kcov-add-__no_sanitize_coverage-to-fix-noinstr-for-all-architectures/20210526-020046
git checkout d898fa12bc72a46da1b9466bb7f8369949b714a9
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=s390

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

include/uapi/linux/byteorder/big_endian.h:36:59: note: expanded from macro '__le16_to_cpu'
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
#define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
^
In file included from arch/s390/kernel/traps.c:29:
In file included from include/linux/entry-common.h:6:
In file included from include/linux/tracehook.h:50:
In file included from include/linux/memcontrol.h:22:
In file included from include/linux/writeback.h:14:
In file included from include/linux/blk-cgroup.h:23:
In file included from include/linux/blkdev.h:25:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:75:
include/asm-generic/io.h:490:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu'
#define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
^
include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
#define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
^
In file included from arch/s390/kernel/traps.c:29:
In file included from include/linux/entry-common.h:6:
In file included from include/linux/tracehook.h:50:
In file included from include/linux/memcontrol.h:22:
In file included from include/linux/writeback.h:14:
In file included from include/linux/blk-cgroup.h:23:
In file included from include/linux/blkdev.h:25:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:75:
include/asm-generic/io.h:501:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writeb(value, PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:511:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:521:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:609:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
readsb(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:617:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
readsw(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:625:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
readsl(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:634:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
writesb(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:643:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
writesw(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:652:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
writesl(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
In file included from arch/s390/kernel/traps.c:29:
include/linux/entry-common.h:450:18: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
irqentry_state_t noinstr irqentry_enter(struct pt_regs *regs);
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
In file included from arch/s390/kernel/traps.c:29:
include/linux/entry-common.h:476:6: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
void noinstr irqentry_exit(struct pt_regs *regs, irqentry_state_t state);
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
In file included from arch/s390/kernel/traps.c:29:
include/linux/entry-common.h:484:18: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
irqentry_state_t noinstr irqentry_nmi_enter(struct pt_regs *regs);
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
In file included from arch/s390/kernel/traps.c:29:
include/linux/entry-common.h:495:6: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
void noinstr irqentry_nmi_exit(struct pt_regs *regs, irqentry_state_t irq_state);
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
>> arch/s390/kernel/traps.c:299:6: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
void noinstr __do_pgm_check(struct pt_regs *regs)
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
17 warnings generated.
--
include/uapi/linux/byteorder/big_endian.h:36:59: note: expanded from macro '__le16_to_cpu'
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
#define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
^
In file included from arch/s390/kernel/syscall.c:34:
In file included from include/linux/entry-common.h:6:
In file included from include/linux/tracehook.h:50:
In file included from include/linux/memcontrol.h:22:
In file included from include/linux/writeback.h:14:
In file included from include/linux/blk-cgroup.h:23:
In file included from include/linux/blkdev.h:25:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:75:
include/asm-generic/io.h:490:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu'
#define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
^
include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
#define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
^
In file included from arch/s390/kernel/syscall.c:34:
In file included from include/linux/entry-common.h:6:
In file included from include/linux/tracehook.h:50:
In file included from include/linux/memcontrol.h:22:
In file included from include/linux/writeback.h:14:
In file included from include/linux/blk-cgroup.h:23:
In file included from include/linux/blkdev.h:25:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:75:
include/asm-generic/io.h:501:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writeb(value, PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:511:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:521:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:609:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
readsb(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:617:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
readsw(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:625:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
readsl(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:634:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
writesb(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:643:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
writesw(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:652:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
writesl(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
In file included from arch/s390/kernel/syscall.c:34:
include/linux/entry-common.h:450:18: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
irqentry_state_t noinstr irqentry_enter(struct pt_regs *regs);
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
In file included from arch/s390/kernel/syscall.c:34:
include/linux/entry-common.h:476:6: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
void noinstr irqentry_exit(struct pt_regs *regs, irqentry_state_t state);
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
In file included from arch/s390/kernel/syscall.c:34:
include/linux/entry-common.h:484:18: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
irqentry_state_t noinstr irqentry_nmi_enter(struct pt_regs *regs);
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
In file included from arch/s390/kernel/syscall.c:34:
include/linux/entry-common.h:495:6: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
void noinstr irqentry_nmi_exit(struct pt_regs *regs, irqentry_state_t irq_state);
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
>> arch/s390/kernel/syscall.c:143:6: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
void noinstr __do_syscall(struct pt_regs *regs, int per_trap)
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
17 warnings generated.
--
In file included from arch/s390/kernel/nmi.c:33:
In file included from include/linux/kvm_host.h:33:
In file included from include/linux/kvm_para.h:5:
In file included from include/uapi/linux/kvm_para.h:36:
In file included from arch/s390/include/asm/kvm_para.h:25:
In file included from arch/s390/include/asm/diag.h:12:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:31:
In file included from include/linux/dma-mapping.h:10:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:75:
include/asm-generic/io.h:464:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __raw_readb(PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:477:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:36:59: note: expanded from macro '__le16_to_cpu'
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
#define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
^
In file included from arch/s390/kernel/nmi.c:33:
In file included from include/linux/kvm_host.h:33:
In file included from include/linux/kvm_para.h:5:
In file included from include/uapi/linux/kvm_para.h:36:
In file included from arch/s390/include/asm/kvm_para.h:25:
In file included from arch/s390/include/asm/diag.h:12:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:31:
In file included from include/linux/dma-mapping.h:10:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:75:
include/asm-generic/io.h:490:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:34:59: note: expanded from macro '__le32_to_cpu'
#define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
^
include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
#define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
^
In file included from arch/s390/kernel/nmi.c:33:
In file included from include/linux/kvm_host.h:33:
In file included from include/linux/kvm_para.h:5:
In file included from include/uapi/linux/kvm_para.h:36:
In file included from arch/s390/include/asm/kvm_para.h:25:
In file included from arch/s390/include/asm/diag.h:12:
In file included from include/linux/if_ether.h:19:
In file included from include/linux/skbuff.h:31:
In file included from include/linux/dma-mapping.h:10:
In file included from include/linux/scatterlist.h:9:
In file included from arch/s390/include/asm/io.h:75:
include/asm-generic/io.h:501:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writeb(value, PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:511:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:521:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:609:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
readsb(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:617:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
readsw(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:625:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
readsl(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:634:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
writesb(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:643:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
writesw(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:652:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
writesl(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
>> arch/s390/kernel/nmi.c:182:6: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
void noinstr s390_handle_mcck(void)
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
13 warnings generated.
..


vim +/coverage +299 arch/s390/kernel/traps.c

6f8daa2953ecd1 Heiko Carstens 2021-04-07 298
56e62a73702836 Sven Schnelle 2020-11-21 @299 void noinstr __do_pgm_check(struct pt_regs *regs)
56e62a73702836 Sven Schnelle 2020-11-21 300 {
56e62a73702836 Sven Schnelle 2020-11-21 301 unsigned long last_break = S390_lowcore.breaking_event_addr;
56e62a73702836 Sven Schnelle 2020-11-21 302 unsigned int trapnr, syscall_redirect = 0;
56e62a73702836 Sven Schnelle 2020-11-21 303 irqentry_state_t state;
56e62a73702836 Sven Schnelle 2020-11-21 304
bae1cd368c45d1 Sven Schnelle 2021-04-29 305 add_random_kstack_offset();
56e62a73702836 Sven Schnelle 2020-11-21 306 regs->int_code = *(u32 *)&S390_lowcore.pgm_ilc;
56e62a73702836 Sven Schnelle 2020-11-21 307 regs->int_parm_long = S390_lowcore.trans_exc_code;
56e62a73702836 Sven Schnelle 2020-11-21 308
56e62a73702836 Sven Schnelle 2020-11-21 309 state = irqentry_enter(regs);
56e62a73702836 Sven Schnelle 2020-11-21 310
56e62a73702836 Sven Schnelle 2020-11-21 311 if (user_mode(regs)) {
56e62a73702836 Sven Schnelle 2020-11-21 312 update_timer_sys();
56e62a73702836 Sven Schnelle 2020-11-21 313 if (last_break < 4096)
56e62a73702836 Sven Schnelle 2020-11-21 314 last_break = 1;
56e62a73702836 Sven Schnelle 2020-11-21 315 current->thread.last_break = last_break;
56e62a73702836 Sven Schnelle 2020-11-21 316 regs->args[0] = last_break;
56e62a73702836 Sven Schnelle 2020-11-21 317 }
56e62a73702836 Sven Schnelle 2020-11-21 318
56e62a73702836 Sven Schnelle 2020-11-21 319 if (S390_lowcore.pgm_code & 0x0200) {
56e62a73702836 Sven Schnelle 2020-11-21 320 /* transaction abort */
56e62a73702836 Sven Schnelle 2020-11-21 321 memcpy(&current->thread.trap_tdb, &S390_lowcore.pgm_tdb, 256);
56e62a73702836 Sven Schnelle 2020-11-21 322 }
56e62a73702836 Sven Schnelle 2020-11-21 323
56e62a73702836 Sven Schnelle 2020-11-21 324 if (S390_lowcore.pgm_code & PGM_INT_CODE_PER) {
56e62a73702836 Sven Schnelle 2020-11-21 325 if (user_mode(regs)) {
56e62a73702836 Sven Schnelle 2020-11-21 326 struct per_event *ev = &current->thread.per_event;
56e62a73702836 Sven Schnelle 2020-11-21 327
56e62a73702836 Sven Schnelle 2020-11-21 328 set_thread_flag(TIF_PER_TRAP);
56e62a73702836 Sven Schnelle 2020-11-21 329 ev->address = S390_lowcore.per_address;
56e62a73702836 Sven Schnelle 2020-11-21 330 ev->cause = *(u16 *)&S390_lowcore.per_code;
56e62a73702836 Sven Schnelle 2020-11-21 331 ev->paid = S390_lowcore.per_access_id;
56e62a73702836 Sven Schnelle 2020-11-21 332 } else {
56e62a73702836 Sven Schnelle 2020-11-21 333 /* PER event in kernel is kprobes */
56e62a73702836 Sven Schnelle 2020-11-21 334 __arch_local_irq_ssm(regs->psw.mask & ~PSW_MASK_PER);
56e62a73702836 Sven Schnelle 2020-11-21 335 do_per_trap(regs);
56e62a73702836 Sven Schnelle 2020-11-21 336 goto out;
56e62a73702836 Sven Schnelle 2020-11-21 337 }
56e62a73702836 Sven Schnelle 2020-11-21 338 }
56e62a73702836 Sven Schnelle 2020-11-21 339
56e62a73702836 Sven Schnelle 2020-11-21 340 if (!irqs_disabled_flags(regs->psw.mask))
56e62a73702836 Sven Schnelle 2020-11-21 341 trace_hardirqs_on();
56e62a73702836 Sven Schnelle 2020-11-21 342 __arch_local_irq_ssm(regs->psw.mask & ~PSW_MASK_PER);
56e62a73702836 Sven Schnelle 2020-11-21 343
56e62a73702836 Sven Schnelle 2020-11-21 344 trapnr = regs->int_code & PGM_INT_CODE_MASK;
56e62a73702836 Sven Schnelle 2020-11-21 345 if (trapnr)
56e62a73702836 Sven Schnelle 2020-11-21 346 pgm_check_table[trapnr](regs);
56e62a73702836 Sven Schnelle 2020-11-21 347 syscall_redirect = user_mode(regs) && test_pt_regs_flag(regs, PIF_SYSCALL);
56e62a73702836 Sven Schnelle 2020-11-21 348 out:
56e62a73702836 Sven Schnelle 2020-11-21 349 local_irq_disable();
56e62a73702836 Sven Schnelle 2020-11-21 350 irqentry_exit(regs, state);
56e62a73702836 Sven Schnelle 2020-11-21 351
56e62a73702836 Sven Schnelle 2020-11-21 352 if (syscall_redirect) {
56e62a73702836 Sven Schnelle 2020-11-21 353 enter_from_user_mode(regs);
56e62a73702836 Sven Schnelle 2020-11-21 354 local_irq_enable();
56e62a73702836 Sven Schnelle 2020-11-21 355 regs->orig_gpr2 = regs->gprs[2];
56e62a73702836 Sven Schnelle 2020-11-21 356 do_syscall(regs);
56e62a73702836 Sven Schnelle 2020-11-21 357 exit_to_user_mode();
56e62a73702836 Sven Schnelle 2020-11-21 358 }
56e62a73702836 Sven Schnelle 2020-11-21 359 }
6f8daa2953ecd1 Heiko Carstens 2021-04-07 360

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (27.78 kB)
.config.gz (24.14 kB)
Download all attachments

2021-05-25 23:23:18

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] kcov: add __no_sanitize_coverage to fix noinstr for all architectures

Hi Marco,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linux/master]
[also build test WARNING on kees/for-next/pstore linus/master v5.13-rc3 next-20210525]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Marco-Elver/kcov-add-__no_sanitize_coverage-to-fix-noinstr-for-all-architectures/20210526-020046
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git dd860052c99b1e088352bdd4fb7aef46f8d2ef47
config: x86_64-randconfig-a001-20210525 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 99155e913e9bad5f7f8a247f8bb3a3ff3da74af1)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://github.com/0day-ci/linux/commit/d898fa12bc72a46da1b9466bb7f8369949b714a9
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Marco-Elver/kcov-add-__no_sanitize_coverage-to-fix-noinstr-for-all-architectures/20210526-020046
git checkout d898fa12bc72a46da1b9466bb7f8369949b714a9
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

In file included from arch/x86/kernel/traps.c:49:
In file included from arch/x86/include/asm/traps.h:9:
In file included from arch/x86/include/asm/idtentry.h:9:
include/linux/entry-common.h:450:18: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
irqentry_state_t noinstr irqentry_enter(struct pt_regs *regs);
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
In file included from arch/x86/kernel/traps.c:49:
In file included from arch/x86/include/asm/traps.h:9:
In file included from arch/x86/include/asm/idtentry.h:9:
include/linux/entry-common.h:476:6: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
void noinstr irqentry_exit(struct pt_regs *regs, irqentry_state_t state);
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
In file included from arch/x86/kernel/traps.c:49:
In file included from arch/x86/include/asm/traps.h:9:
In file included from arch/x86/include/asm/idtentry.h:9:
include/linux/entry-common.h:484:18: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
irqentry_state_t noinstr irqentry_nmi_enter(struct pt_regs *regs);
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
In file included from arch/x86/kernel/traps.c:49:
In file included from arch/x86/include/asm/traps.h:9:
In file included from arch/x86/include/asm/idtentry.h:9:
include/linux/entry-common.h:495:6: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
void noinstr irqentry_nmi_exit(struct pt_regs *regs, irqentry_state_t irq_state);
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
In file included from arch/x86/kernel/traps.c:49:
In file included from arch/x86/include/asm/traps.h:9:
>> arch/x86/include/asm/idtentry.h:614:1: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
DECLARE_IDTENTRY_VC(X86_TRAP_VC, exc_vmm_communication);
^
arch/x86/include/asm/idtentry.h:315:12: note: expanded from macro 'DECLARE_IDTENTRY_VC'
__visible noinstr void ist_##func(struct pt_regs *regs, unsigned long error_code); \
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
In file included from arch/x86/kernel/traps.c:49:
In file included from arch/x86/include/asm/traps.h:9:
>> arch/x86/include/asm/idtentry.h:614:1: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
arch/x86/include/asm/idtentry.h:316:12: note: expanded from macro 'DECLARE_IDTENTRY_VC'
__visible noinstr void safe_stack_##func(struct pt_regs *regs, unsigned long error_code)
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
In file included from arch/x86/kernel/traps.c:49:
arch/x86/include/asm/traps.h:18:22: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
asmlinkage __visible noinstr struct pt_regs *vc_switch_off_ist(struct pt_regs *eregs);
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
arch/x86/kernel/traps.c:201:1: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
DEFINE_IDTENTRY(exc_divide_error)
^
arch/x86/include/asm/idtentry.h:50:11: note: expanded from macro 'DEFINE_IDTENTRY'
__visible noinstr void func(struct pt_regs *regs) \
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
arch/x86/kernel/traps.c:207:1: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
DEFINE_IDTENTRY(exc_overflow)
^
arch/x86/include/asm/idtentry.h:50:11: note: expanded from macro 'DEFINE_IDTENTRY'
__visible noinstr void func(struct pt_regs *regs) \
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
arch/x86/kernel/traps.c:222:8: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
static noinstr bool handle_bug(struct pt_regs *regs)
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
arch/x86/kernel/traps.c:250:1: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
DEFINE_IDTENTRY_RAW(exc_invalid_op)
^
arch/x86/include/asm/idtentry.h:136:11: note: expanded from macro 'DEFINE_IDTENTRY_RAW'
__visible noinstr void func(struct pt_regs *regs)
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
arch/x86/kernel/traps.c:269:1: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
DEFINE_IDTENTRY(exc_coproc_segment_overrun)
^
arch/x86/include/asm/idtentry.h:50:11: note: expanded from macro 'DEFINE_IDTENTRY'
__visible noinstr void func(struct pt_regs *regs) \
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
arch/x86/kernel/traps.c:275:1: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
DEFINE_IDTENTRY_ERRORCODE(exc_invalid_tss)
^
arch/x86/include/asm/idtentry.h:96:11: note: expanded from macro 'DEFINE_IDTENTRY_ERRORCODE'
__visible noinstr void func(struct pt_regs *regs, \
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
arch/x86/kernel/traps.c:281:1: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
DEFINE_IDTENTRY_ERRORCODE(exc_segment_not_present)
^
arch/x86/include/asm/idtentry.h:96:11: note: expanded from macro 'DEFINE_IDTENTRY_ERRORCODE'
__visible noinstr void func(struct pt_regs *regs, \
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
--
In file included from arch/x86/kernel/idt.c:9:
In file included from arch/x86/include/asm/traps.h:9:
In file included from arch/x86/include/asm/idtentry.h:9:
include/linux/entry-common.h:450:18: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
irqentry_state_t noinstr irqentry_enter(struct pt_regs *regs);
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
In file included from arch/x86/kernel/idt.c:9:
In file included from arch/x86/include/asm/traps.h:9:
In file included from arch/x86/include/asm/idtentry.h:9:
include/linux/entry-common.h:476:6: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
void noinstr irqentry_exit(struct pt_regs *regs, irqentry_state_t state);
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
In file included from arch/x86/kernel/idt.c:9:
In file included from arch/x86/include/asm/traps.h:9:
In file included from arch/x86/include/asm/idtentry.h:9:
include/linux/entry-common.h:484:18: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
irqentry_state_t noinstr irqentry_nmi_enter(struct pt_regs *regs);
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
In file included from arch/x86/kernel/idt.c:9:
In file included from arch/x86/include/asm/traps.h:9:
In file included from arch/x86/include/asm/idtentry.h:9:
include/linux/entry-common.h:495:6: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
void noinstr irqentry_nmi_exit(struct pt_regs *regs, irqentry_state_t irq_state);
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
In file included from arch/x86/kernel/idt.c:9:
In file included from arch/x86/include/asm/traps.h:9:
>> arch/x86/include/asm/idtentry.h:614:1: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
DECLARE_IDTENTRY_VC(X86_TRAP_VC, exc_vmm_communication);
^
arch/x86/include/asm/idtentry.h:315:12: note: expanded from macro 'DECLARE_IDTENTRY_VC'
__visible noinstr void ist_##func(struct pt_regs *regs, unsigned long error_code); \
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
In file included from arch/x86/kernel/idt.c:9:
In file included from arch/x86/include/asm/traps.h:9:
>> arch/x86/include/asm/idtentry.h:614:1: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
arch/x86/include/asm/idtentry.h:316:12: note: expanded from macro 'DECLARE_IDTENTRY_VC'
__visible noinstr void safe_stack_##func(struct pt_regs *regs, unsigned long error_code)
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
In file included from arch/x86/kernel/idt.c:9:
arch/x86/include/asm/traps.h:18:22: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
asmlinkage __visible noinstr struct pt_regs *vc_switch_off_ist(struct pt_regs *eregs);
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
7 warnings generated.
--
In file included from arch/x86/kernel/irq.c:23:
In file included from arch/x86/include/asm/traps.h:9:
In file included from arch/x86/include/asm/idtentry.h:9:
include/linux/entry-common.h:450:18: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
irqentry_state_t noinstr irqentry_enter(struct pt_regs *regs);
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
In file included from arch/x86/kernel/irq.c:23:
In file included from arch/x86/include/asm/traps.h:9:
In file included from arch/x86/include/asm/idtentry.h:9:
include/linux/entry-common.h:476:6: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
void noinstr irqentry_exit(struct pt_regs *regs, irqentry_state_t state);
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
In file included from arch/x86/kernel/irq.c:23:
In file included from arch/x86/include/asm/traps.h:9:
In file included from arch/x86/include/asm/idtentry.h:9:
include/linux/entry-common.h:484:18: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
irqentry_state_t noinstr irqentry_nmi_enter(struct pt_regs *regs);
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
In file included from arch/x86/kernel/irq.c:23:
In file included from arch/x86/include/asm/traps.h:9:
In file included from arch/x86/include/asm/idtentry.h:9:
include/linux/entry-common.h:495:6: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
void noinstr irqentry_nmi_exit(struct pt_regs *regs, irqentry_state_t irq_state);
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
In file included from arch/x86/kernel/irq.c:23:
In file included from arch/x86/include/asm/traps.h:9:
>> arch/x86/include/asm/idtentry.h:614:1: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
DECLARE_IDTENTRY_VC(X86_TRAP_VC, exc_vmm_communication);
^
arch/x86/include/asm/idtentry.h:315:12: note: expanded from macro 'DECLARE_IDTENTRY_VC'
__visible noinstr void ist_##func(struct pt_regs *regs, unsigned long error_code); \
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
In file included from arch/x86/kernel/irq.c:23:
In file included from arch/x86/include/asm/traps.h:9:
>> arch/x86/include/asm/idtentry.h:614:1: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
arch/x86/include/asm/idtentry.h:316:12: note: expanded from macro 'DECLARE_IDTENTRY_VC'
__visible noinstr void safe_stack_##func(struct pt_regs *regs, unsigned long error_code)
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
In file included from arch/x86/kernel/irq.c:23:
arch/x86/include/asm/traps.h:18:22: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
asmlinkage __visible noinstr struct pt_regs *vc_switch_off_ist(struct pt_regs *eregs);
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
arch/x86/kernel/irq.c:240:1: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
DEFINE_IDTENTRY_IRQ(common_interrupt)
^
arch/x86/include/asm/idtentry.h:192:11: note: expanded from macro 'DEFINE_IDTENTRY_IRQ'
__visible noinstr void func(struct pt_regs *regs, \
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
arch/x86/kernel/irq.c:272:1: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
DEFINE_IDTENTRY_SYSVEC(sysvec_x86_platform_ipi)
^
arch/x86/include/asm/idtentry.h:234:11: note: expanded from macro 'DEFINE_IDTENTRY_SYSVEC'
__visible noinstr void func(struct pt_regs *regs) \
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
arch/x86/kernel/irq.c:302:1: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
DEFINE_IDTENTRY_SYSVEC_SIMPLE(sysvec_kvm_posted_intr_ipi)
^
arch/x86/include/asm/idtentry.h:261:11: note: expanded from macro 'DEFINE_IDTENTRY_SYSVEC_SIMPLE'
__visible noinstr void func(struct pt_regs *regs) \
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
arch/x86/kernel/irq.c:311:1: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
DEFINE_IDTENTRY_SYSVEC(sysvec_kvm_posted_intr_wakeup_ipi)
^
arch/x86/include/asm/idtentry.h:234:11: note: expanded from macro 'DEFINE_IDTENTRY_SYSVEC'
__visible noinstr void func(struct pt_regs *regs) \
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
arch/x86/kernel/irq.c:321:1: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
DEFINE_IDTENTRY_SYSVEC_SIMPLE(sysvec_kvm_posted_intr_nested_ipi)
^
arch/x86/include/asm/idtentry.h:261:11: note: expanded from macro 'DEFINE_IDTENTRY_SYSVEC_SIMPLE'
__visible noinstr void func(struct pt_regs *regs) \
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
arch/x86/kernel/irq.c:389:1: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
DEFINE_IDTENTRY_SYSVEC(sysvec_thermal)
^
arch/x86/include/asm/idtentry.h:234:11: note: expanded from macro 'DEFINE_IDTENTRY_SYSVEC'
__visible noinstr void func(struct pt_regs *regs) \
^
include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
__no_kcsan __no_sanitize_address __no_sanitize_coverage
^
include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
^
13 warnings generated.
..


vim +/coverage +614 arch/x86/include/asm/idtentry.h

c29c775a554f70 Thomas Gleixner 2020-02-25 611
0786138c78e793 Tom Lendacky 2020-09-07 612 /* #VC */
0786138c78e793 Tom Lendacky 2020-09-07 613 #ifdef CONFIG_AMD_MEM_ENCRYPT
0786138c78e793 Tom Lendacky 2020-09-07 @614 DECLARE_IDTENTRY_VC(X86_TRAP_VC, exc_vmm_communication);
0786138c78e793 Tom Lendacky 2020-09-07 615 #endif
0786138c78e793 Tom Lendacky 2020-09-07 616

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (28.73 kB)
.config.gz (36.18 kB)
Download all attachments

2021-05-26 01:04:51

by Marco Elver

[permalink] [raw]
Subject: Re: [PATCH] kcov: add __no_sanitize_coverage to fix noinstr for all architectures

On Wed, 26 May 2021 at 00:23, kernel test robot <[email protected]> wrote:
[...]
> [auto build test WARNING on linux/master]
> [also build test WARNING on kees/for-next/pstore linus/master v5.13-rc3 next-20210525]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch]
>
> url: https://github.com/0day-ci/linux/commits/Marco-Elver/kcov-add-__no_sanitize_coverage-to-fix-noinstr-for-all-architectures/20210526-020046
> base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git dd860052c99b1e088352bdd4fb7aef46f8d2ef47
> config: s390-randconfig-r002-20210525 (attached as .config)
> compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 99155e913e9bad5f7f8a247f8bb3a3ff3da74af1)

^^^ you're using a Clang pre-release, breakages are expected until
Clang 13 is final.

I think there was a thread about this at some point. I guess LKP has
decided that testing Clang pre-releases is fair game? I guess it's
useful, but this warning here needs to be ignored. It'll go away when
you rebuild your pre-release Clang 13 from the latest LLVM main
branch.

[...]
> >> arch/s390/kernel/nmi.c:182:6: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
> void noinstr s390_handle_mcck(void)
> ^
> include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
> __no_kcsan __no_sanitize_address __no_sanitize_coverage
> ^
> include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
> #define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
> ^

Clang 13 will support the attribute, but this is a pre-release Clang
13 -- so please ignore the report. FWIW, I tested my patch of course
with a version of Clang 13 that supports the attribute. :-)

Thanks,
-- Marco

2021-05-26 08:23:43

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [PATCH] kcov: add __no_sanitize_coverage to fix noinstr for all architectures

On Tue, May 25, 2021 at 07:58:19PM +0200, Marco Elver wrote:
> Until now no compiler supported an attribute to disable coverage
> instrumentation as used by KCOV.
>
> To work around this limitation on x86, noinstr functions have their
> coverage instrumentation turned into nops by objtool. However, this
> solution doesn't scale automatically to other architectures, such as
> arm64, which are migrating to use the generic entry code.
>
> Clang [1] and GCC [2] have added support for the attribute recently.
> [1] https://github.com/llvm/llvm-project/commit/280333021e9550d80f5c1152a34e33e81df1e178
> [2] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=cec4d4a6782c9bd8d071839c50a239c49caca689
>
> Add __no_sanitize_coverage for both compilers, and add it to noinstr.
>
> Signed-off-by: Marco Elver <[email protected]>

W00t! Thanks guys!

Acked-by: Peter Zijlstra (Intel) <[email protected]>

2021-05-26 11:48:55

by Chen, Rong A

[permalink] [raw]
Subject: Re: [kbuild-all] Re: [PATCH] kcov: add __no_sanitize_coverage to fix noinstr for all architectures



On 5/26/21 6:29 AM, Marco Elver wrote:
> On Wed, 26 May 2021 at 00:23, kernel test robot <[email protected]> wrote:
> [...]
>> [auto build test WARNING on linux/master]
>> [also build test WARNING on kees/for-next/pstore linus/master v5.13-rc3 next-20210525]
>> [If your patch is applied to the wrong git tree, kindly drop us a note.
>> And when submitting patch, we suggest to use '--base' as documented in
>> https://git-scm.com/docs/git-format-patch]
>>
>> url: https://github.com/0day-ci/linux/commits/Marco-Elver/kcov-add-__no_sanitize_coverage-to-fix-noinstr-for-all-architectures/20210526-020046
>> base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git dd860052c99b1e088352bdd4fb7aef46f8d2ef47
>> config: s390-randconfig-r002-20210525 (attached as .config)
>> compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 99155e913e9bad5f7f8a247f8bb3a3ff3da74af1)
> ^^^ you're using a Clang pre-release, breakages are expected until
> Clang 13 is final.

Hi Marco,

I really appreciate for your comment, we'll update clang to the latest
version.

Best Regards,
Rong Chen

>
> I think there was a thread about this at some point. I guess LKP has
> decided that testing Clang pre-releases is fair game? I guess it's
> useful, but this warning here needs to be ignored. It'll go away when
> you rebuild your pre-release Clang 13 from the latest LLVM main
> branch.
>
> [...]
>>>> arch/s390/kernel/nmi.c:182:6: warning: unknown sanitizer 'coverage' ignored [-Wunknown-sanitizers]
>> void noinstr s390_handle_mcck(void)
>> ^
>> include/linux/compiler_types.h:213:35: note: expanded from macro 'noinstr'
>> __no_kcsan __no_sanitize_address __no_sanitize_coverage
>> ^
>> include/linux/compiler-clang.h:49:59: note: expanded from macro '__no_sanitize_coverage'
>> #define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
>> ^
> Clang 13 will support the attribute, but this is a pre-release Clang
> 13 -- so please ignore the report. FWIW, I tested my patch of course
> with a version of Clang 13 that supports the attribute. :-)
>
> Thanks,
> -- Marco
> _______________________________________________
> kbuild-all mailing list -- [email protected]
> To unsubscribe send an email to [email protected]