Skip to contentSkip to conversation

kcov: add __no_sanitize_coverage to fix noinstr for all architectures

PATCH Superseded Marco Elver 5 participants 12 messages May 25, 2021 – May 26, 2021 Clang/LLVM build support

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 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(-)
include/linux/compiler-clang.h +6 -0
index adbe76b203e2..370565f4cfde 100644
@@ -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
include/linux/compiler-gcc.h +6 -0
index 5d97ef738a57..cb9217fc60af 100644
@@ -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
include/linux/compiler_types.h +1 -1
index d29bda7f6ebd..cc2bee7f0977 100644
@@ -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__ */
 
Signature · 1 line
2.31.1.818.g46aad6cb9e-goog
#1 lore raw
Quoted 2 lines · Marco Elver

+#if defined(CONFIG_KCOV) && CONFIG_CLANG_VERSION >= 130000

Is there any reason why Clang does not implement __has_attribute(__no_sanitize_coverage__) like GCC? That way we can merge both (perhaps even in compiler_attributes.h).

Cheers,
Miguel

#2 lore raw
Quoted 7 lines · Miguel Ojeda
Quoted 2 lines · Marco Elver

+#if defined(CONFIG_KCOV) && CONFIG_CLANG_VERSION >= 130000

Is there any reason why Clang does not implement __has_attribute(__no_sanitize_coverage__) like GCC? That way we can merge both (perhaps even in compiler_attributes.h).

It's complicated. Clang implements all no_sanitize options via no_sanitize(<string_literal>), except for 3 which are there for backwards-compatibility reasons (no_sanitize_{address,memory,thread}). But otherwise, no_sanitize_sanitizer is deprecated in Clang in favor of no_sanitize("sanitizer") per comment at
https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/Attr.td#L2907.
(That being said, there's already inconsistency due to coverage instrumentation requiring "-fsanitize-coverage=..." and not "-fsanitize=coverage-...". The implementation vs other no_sanitize is also a bit special, see LLVM commit.)

This means we only have __has_attribute(no_sanitize). Which is also the reason why the other __no_sanitize_* defines in compiler-clang.h first check the feature, as feature existence implies attribute existence. But, sadly, this is not the case for coverage instrumentation (where in fact, __has_feature(coverage_sanitizer) doesn't work either...)

From a UX perspective, having Clang only give us no_sanitize("...") without the corresponding __has_attribute() support is not great, but passable due to __has_feature() working for other sanitizers. From Clang's perspective, it kept things simpler because we've gotten quite a number of sanitizers recently. The big ones are manageable [1], but UBSan is just too much [2].
[1] https://clang.llvm.org/docs/UsersManual.html#controlling-code-generation
[2] https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#ubsan-checks

This is probably a longer answer to your question, but is a summary of the frustrations I encountered as I looked deeper into Clang's no_sanitize attribute.

Long story short: this is not fixable without more Clang changes. The only way to do it without a version check would be to introduce no_sanitize_coverage attr to Clang, which we probably shouldn't do, and I didn't want to fight it. ;-)

Thanks,
-- Marco

#7 lore raw
In reply to Marco Elver
I love your patch! Perhaps something to improve:

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

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/kbuild-all(a)lists.01.org

#8 lore raw

On Wed, 26 May 2021 at 00:23, kernel test robot <[email protected]> wrote:
[...]

Quoted 10 lines

[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.

[...]

Quoted 9 lines
Quoted 1 line
Quoted 1 line

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

#10 lore raw
In reply to Marco Elver
I love your patch! Perhaps something to improve:

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

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/kbuild-all(a)lists.01.org

#3 lore raw
In reply to Marco Elver
Quoted 5 lines · Marco Elver

Long story short: this is not fixable without more Clang changes. The only way to do it without a version check would be to introduce no_sanitize_coverage attr to Clang, which we probably shouldn't do, and I didn't want to fight it. ;-)

I am not sure I followed why you would not want to support querying for the attributes (if they are intended to be used separately).

But regardless of that, why not the feature flag at least then, to be consistent with the others?

Going back to version checks seems bad -- they should be reserved for e.g. known broken versions and things like that. New compiler features should come with new feature flags...

In fact, for Clang, I do not see any version checks in code at the moment, so this would be the first :(

Cheers,
Miguel

#4 lore raw
Quoted 9 lines · Miguel Ojeda
Quoted 5 lines · Marco Elver

Long story short: this is not fixable without more Clang changes. The only way to do it without a version check would be to introduce no_sanitize_coverage attr to Clang, which we probably shouldn't do, and I didn't want to fight it. ;-)

I am not sure I followed why you would not want to support querying for the attributes (if they are intended to be used separately).

Not my decision, but some historical decision in Clang. Somebody thought "no_sanitize(<string_literal>)" simplifies things. Hence, Clang only knows about the no_sanitize attribute but not its "subattributes".

Quoted 2 lines

But regardless of that, why not the feature flag at least then, to be consistent with the others?

__has_feature(coverage_sanitizer) does not work either (yet).

Quoted 6 lines

Going back to version checks seems bad -- they should be reserved for e.g. known broken versions and things like that. New compiler features should come with new feature flags...

In fact, for Clang, I do not see any version checks in code at the moment, so this would be the first :(

In this instance it's absolutely required (for now). But if you don't like it I'll go back to trying to fix Clang more. I'll check with Clang folks which one we can implement, the feature check or the attribute check.

Quoted 2 lines

Cheers,
Miguel

#9 lore raw
In reply to Marco Elver
Quoted 8 lines · Marco Elver

On Wed, 26 May 2021 at 00:23, kernel test robot <[email protected]> wrote:
[...]

Quoted 6 lines

[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]

Quoted 6 lines
Quoted 4 lines
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

Quoted 26 lines

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.

[...]

Quoted 9 lines
Quoted 1 line
Quoted 1 line

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 -- kbuild-all(a)lists.01.org To unsubscribe send an email to kbuild-all-leave(a)lists.01.org

Acked-by on v1 1/1
#11 lore raw
In reply to Marco Elver
Quoted 8 lines · Marco Elver

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.

Quoted 7 lines

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.

W00t! Thanks guys!

#5 lore raw
In reply to Marco Elver
Quoted 26 lines · Marco Elver
Quoted 9 lines · Miguel Ojeda
Quoted 5 lines · Marco Elver

Long story short: this is not fixable without more Clang changes. The only way to do it without a version check would be to introduce no_sanitize_coverage attr to Clang, which we probably shouldn't do, and I didn't want to fight it. ;-)

I am not sure I followed why you would not want to support querying for the attributes (if they are intended to be used separately).

Not my decision, but some historical decision in Clang. Somebody thought "no_sanitize(<string_literal>)" simplifies things. Hence, Clang only knows about the no_sanitize attribute but not its "subattributes".

Quoted 2 lines

But regardless of that, why not the feature flag at least then, to be consistent with the others?

__has_feature(coverage_sanitizer) does not work either (yet).

Quoted 4 lines

Going back to version checks seems bad -- they should be reserved for e.g. known broken versions and things like that. New compiler features should come with new feature flags...

Quoted 7 lines
Quoted 2 lines

In fact, for Clang, I do not see any version checks in code at the moment, so this would be the first :(

In this instance it's absolutely required (for now). But if you don't like it I'll go back to trying to fix Clang more. I'll check with Clang folks which one we can implement, the feature check or the attribute check.

Ok, let's wait for response to: https://reviews.llvm.org/D103159
If that lands in the LLVM repo I'll change to use __has_feature(coverage_sanitizer), and send a v2. That __has_feature() is a bit of a lie though, because fsanitize-coverage has long been supported, but it just so happens that if we get it, then its availability implies availability of the no_sanitize("coverage") attribute.

Thanks,
-- Marco

#6 lore raw
Quoted 8 lines · Marco Elver

Ok, let's wait for response to: https://reviews.llvm.org/D103159
If that lands in the LLVM repo I'll change to use __has_feature(coverage_sanitizer), and send a v2. That __has_feature() is a bit of a lie though, because fsanitize-coverage has long been supported, but it just so happens that if we get it, then its availability implies availability of the no_sanitize("coverage") attribute.

Thanks a lot for that! Appreciated :)

Cheers,
Miguel