All of lore.kernel.org
 help / color / mirror / Atom feed
* [linux-next:master 10774/15793] kernel/kcsan/core.c:829:1: warning: no previous prototype for function '__tsan_volatile_read1'
@ 2020-06-05 17:42 kernel test robot
  2020-06-05 17:57 ` Marco Elver
  0 siblings, 1 reply; 6+ messages in thread
From: kernel test robot @ 2020-06-05 17:42 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 17109 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   af30725c132e2e5c5369b60369ff0771fde7d4ff
commit: 4e23395b9e97562d12b87a330a2fca3bf10c8663 [10774/15793] kcsan: Support distinguishing volatile accesses
config: x86_64-randconfig-r013-20200605 (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 6dd738e2f0609f7d3313b574a1d471263d2d3ba1)
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
        git checkout 4e23395b9e97562d12b87a330a2fca3bf10c8663
        # 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 <lkp@intel.com>

All warnings (new ones prefixed by >>, old ones prefixed by <<):

DEFINE_TSAN_READ_WRITE(4);
^
kernel/kcsan/core.c:757:7: note: expanded from macro 'DEFINE_TSAN_READ_WRITE'
void __tsan_read##size(void *ptr)                                                      ^
<scratch space>:92:1: note: expanded from here
__tsan_read4
^
kernel/kcsan/core.c:776:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
DEFINE_TSAN_READ_WRITE(4);
^
static
kernel/kcsan/core.c:757:2: note: expanded from macro 'DEFINE_TSAN_READ_WRITE'
void __tsan_read##size(void *ptr)                                                 ^
kernel/kcsan/core.c:776:1: warning: no previous prototype for function '__tsan_write4' [-Wmissing-prototypes]
DEFINE_TSAN_READ_WRITE(4);
^
kernel/kcsan/core.c:765:7: note: expanded from macro 'DEFINE_TSAN_READ_WRITE'
void __tsan_write##size(void *ptr)                                                     ^
<scratch space>:126:1: note: expanded from here
__tsan_write4
^
kernel/kcsan/core.c:776:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
kernel/kcsan/core.c:765:2: note: expanded from macro 'DEFINE_TSAN_READ_WRITE'
void __tsan_write##size(void *ptr)                                                ^
kernel/kcsan/core.c:777:1: warning: no previous prototype for function '__tsan_read8' [-Wmissing-prototypes]
DEFINE_TSAN_READ_WRITE(8);
^
kernel/kcsan/core.c:757:7: note: expanded from macro 'DEFINE_TSAN_READ_WRITE'
void __tsan_read##size(void *ptr)                                                      ^
<scratch space>:160:1: note: expanded from here
__tsan_read8
^
kernel/kcsan/core.c:777:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
DEFINE_TSAN_READ_WRITE(8);
^
static
kernel/kcsan/core.c:757:2: note: expanded from macro 'DEFINE_TSAN_READ_WRITE'
void __tsan_read##size(void *ptr)                                                 ^
kernel/kcsan/core.c:777:1: warning: no previous prototype for function '__tsan_write8' [-Wmissing-prototypes]
DEFINE_TSAN_READ_WRITE(8);
^
kernel/kcsan/core.c:765:7: note: expanded from macro 'DEFINE_TSAN_READ_WRITE'
void __tsan_write##size(void *ptr)                                                     ^
<scratch space>:15:1: note: expanded from here
__tsan_write8
^
kernel/kcsan/core.c:777:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
kernel/kcsan/core.c:765:2: note: expanded from macro 'DEFINE_TSAN_READ_WRITE'
void __tsan_write##size(void *ptr)                                                ^
kernel/kcsan/core.c:778:1: warning: no previous prototype for function '__tsan_read16' [-Wmissing-prototypes]
DEFINE_TSAN_READ_WRITE(16);
^
kernel/kcsan/core.c:757:7: note: expanded from macro 'DEFINE_TSAN_READ_WRITE'
void __tsan_read##size(void *ptr)                                                      ^
<scratch space>:49:1: note: expanded from here
__tsan_read16
^
kernel/kcsan/core.c:778:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
DEFINE_TSAN_READ_WRITE(16);
^
static
kernel/kcsan/core.c:757:2: note: expanded from macro 'DEFINE_TSAN_READ_WRITE'
void __tsan_read##size(void *ptr)                                                 ^
kernel/kcsan/core.c:778:1: warning: no previous prototype for function '__tsan_write16' [-Wmissing-prototypes]
DEFINE_TSAN_READ_WRITE(16);
^
kernel/kcsan/core.c:765:7: note: expanded from macro 'DEFINE_TSAN_READ_WRITE'
void __tsan_write##size(void *ptr)                                                     ^
<scratch space>:83:1: note: expanded from here
__tsan_write16
^
kernel/kcsan/core.c:778:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
kernel/kcsan/core.c:765:2: note: expanded from macro 'DEFINE_TSAN_READ_WRITE'
void __tsan_write##size(void *ptr)                                                ^
kernel/kcsan/core.c:780:6: warning: no previous prototype for function '__tsan_read_range' [-Wmissing-prototypes]
void __tsan_read_range(void *ptr, size_t size)
^
kernel/kcsan/core.c:780:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
void __tsan_read_range(void *ptr, size_t size)
^
static
kernel/kcsan/core.c:786:6: warning: no previous prototype for function '__tsan_write_range' [-Wmissing-prototypes]
void __tsan_write_range(void *ptr, size_t size)
^
kernel/kcsan/core.c:786:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
void __tsan_write_range(void *ptr, size_t size)
^
static
>> kernel/kcsan/core.c:829:1: warning: no previous prototype for function '__tsan_volatile_read1' [-Wmissing-prototypes]
DEFINE_TSAN_VOLATILE_READ_WRITE(1);
^
kernel/kcsan/core.c:802:7: note: expanded from macro 'DEFINE_TSAN_VOLATILE_READ_WRITE'
void __tsan_volatile_read##size(void *ptr)                                             ^
<scratch space>:145:1: note: expanded from here
__tsan_volatile_read1
^
kernel/kcsan/core.c:829:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
DEFINE_TSAN_VOLATILE_READ_WRITE(1);
^
static
kernel/kcsan/core.c:802:2: note: expanded from macro 'DEFINE_TSAN_VOLATILE_READ_WRITE'
void __tsan_volatile_read##size(void *ptr)                                        ^
>> kernel/kcsan/core.c:829:1: warning: no previous prototype for function '__tsan_volatile_write1' [-Wmissing-prototypes]
DEFINE_TSAN_VOLATILE_READ_WRITE(1);
^
kernel/kcsan/core.c:814:7: note: expanded from macro 'DEFINE_TSAN_VOLATILE_READ_WRITE'
void __tsan_volatile_write##size(void *ptr)                                            ^
<scratch space>:18:1: note: expanded from here
__tsan_volatile_write1
^
kernel/kcsan/core.c:829:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
kernel/kcsan/core.c:814:2: note: expanded from macro 'DEFINE_TSAN_VOLATILE_READ_WRITE'
void __tsan_volatile_write##size(void *ptr)                                       ^
>> kernel/kcsan/core.c:830:1: warning: no previous prototype for function '__tsan_volatile_read2' [-Wmissing-prototypes]
DEFINE_TSAN_VOLATILE_READ_WRITE(2);
^
kernel/kcsan/core.c:802:7: note: expanded from macro 'DEFINE_TSAN_VOLATILE_READ_WRITE'
void __tsan_volatile_read##size(void *ptr)                                             ^
<scratch space>:56:1: note: expanded from here
__tsan_volatile_read2
^
kernel/kcsan/core.c:830:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
DEFINE_TSAN_VOLATILE_READ_WRITE(2);
^
static
kernel/kcsan/core.c:802:2: note: expanded from macro 'DEFINE_TSAN_VOLATILE_READ_WRITE'
void __tsan_volatile_read##size(void *ptr)                                        ^
>> kernel/kcsan/core.c:830:1: warning: no previous prototype for function '__tsan_volatile_write2' [-Wmissing-prototypes]
DEFINE_TSAN_VOLATILE_READ_WRITE(2);
^
kernel/kcsan/core.c:814:7: note: expanded from macro 'DEFINE_TSAN_VOLATILE_READ_WRITE'
void __tsan_volatile_write##size(void *ptr)                                            ^
<scratch space>:94:1: note: expanded from here
__tsan_volatile_write2
^
kernel/kcsan/core.c:830:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
kernel/kcsan/core.c:814:2: note: expanded from macro 'DEFINE_TSAN_VOLATILE_READ_WRITE'
void __tsan_volatile_write##size(void *ptr)                                       ^
>> kernel/kcsan/core.c:831:1: warning: no previous prototype for function '__tsan_volatile_read4' [-Wmissing-prototypes]
DEFINE_TSAN_VOLATILE_READ_WRITE(4);
^
kernel/kcsan/core.c:802:7: note: expanded from macro 'DEFINE_TSAN_VOLATILE_READ_WRITE'
void __tsan_volatile_read##size(void *ptr)                                             ^
<scratch space>:6:1: note: expanded from here
__tsan_volatile_read4
^
kernel/kcsan/core.c:831:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
DEFINE_TSAN_VOLATILE_READ_WRITE(4);
^
static
kernel/kcsan/core.c:802:2: note: expanded from macro 'DEFINE_TSAN_VOLATILE_READ_WRITE'
void __tsan_volatile_read##size(void *ptr)                                        ^
>> kernel/kcsan/core.c:831:1: warning: no previous prototype for function '__tsan_volatile_write4' [-Wmissing-prototypes]
DEFINE_TSAN_VOLATILE_READ_WRITE(4);
^
kernel/kcsan/core.c:814:7: note: expanded from macro 'DEFINE_TSAN_VOLATILE_READ_WRITE'
void __tsan_volatile_write##size(void *ptr)                                            ^
<scratch space>:44:1: note: expanded from here
__tsan_volatile_write4
^
kernel/kcsan/core.c:831:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
kernel/kcsan/core.c:814:2: note: expanded from macro 'DEFINE_TSAN_VOLATILE_READ_WRITE'
void __tsan_volatile_write##size(void *ptr)                                       ^
>> kernel/kcsan/core.c:832:1: warning: no previous prototype for function '__tsan_volatile_read8' [-Wmissing-prototypes]
DEFINE_TSAN_VOLATILE_READ_WRITE(8);
^
kernel/kcsan/core.c:802:7: note: expanded from macro 'DEFINE_TSAN_VOLATILE_READ_WRITE'
void __tsan_volatile_read##size(void *ptr)                                             ^
<scratch space>:82:1: note: expanded from here
__tsan_volatile_read8
^
kernel/kcsan/core.c:832:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
DEFINE_TSAN_VOLATILE_READ_WRITE(8);
^
static
kernel/kcsan/core.c:802:2: note: expanded from macro 'DEFINE_TSAN_VOLATILE_READ_WRITE'
void __tsan_volatile_read##size(void *ptr)                                        ^
>> kernel/kcsan/core.c:832:1: warning: no previous prototype for function '__tsan_volatile_write8' [-Wmissing-prototypes]
DEFINE_TSAN_VOLATILE_READ_WRITE(8);
^
kernel/kcsan/core.c:814:7: note: expanded from macro 'DEFINE_TSAN_VOLATILE_READ_WRITE'
void __tsan_volatile_write##size(void *ptr)                                            ^
<scratch space>:120:1: note: expanded from here
__tsan_volatile_write8
^
kernel/kcsan/core.c:832:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
kernel/kcsan/core.c:814:2: note: expanded from macro 'DEFINE_TSAN_VOLATILE_READ_WRITE'
void __tsan_volatile_write##size(void *ptr)                                       ^
>> kernel/kcsan/core.c:833:1: warning: no previous prototype for function '__tsan_volatile_read16' [-Wmissing-prototypes]
DEFINE_TSAN_VOLATILE_READ_WRITE(16);
^
kernel/kcsan/core.c:802:7: note: expanded from macro 'DEFINE_TSAN_VOLATILE_READ_WRITE'
void __tsan_volatile_read##size(void *ptr)                                             ^
<scratch space>:30:1: note: expanded from here
__tsan_volatile_read16
^
kernel/kcsan/core.c:833:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
DEFINE_TSAN_VOLATILE_READ_WRITE(16);
^
static
kernel/kcsan/core.c:802:2: note: expanded from macro 'DEFINE_TSAN_VOLATILE_READ_WRITE'
void __tsan_volatile_read##size(void *ptr)                                        ^
>> kernel/kcsan/core.c:833:1: warning: no previous prototype for function '__tsan_volatile_write16' [-Wmissing-prototypes]
DEFINE_TSAN_VOLATILE_READ_WRITE(16);
^
kernel/kcsan/core.c:814:7: note: expanded from macro 'DEFINE_TSAN_VOLATILE_READ_WRITE'
void __tsan_volatile_write##size(void *ptr)                                            ^
<scratch space>:68:1: note: expanded from here
__tsan_volatile_write16
^
kernel/kcsan/core.c:833:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
kernel/kcsan/core.c:814:2: note: expanded from macro 'DEFINE_TSAN_VOLATILE_READ_WRITE'
void __tsan_volatile_write##size(void *ptr)                                       ^
kernel/kcsan/core.c:839:6: warning: no previous prototype for function '__tsan_func_entry' [-Wmissing-prototypes]
void __tsan_func_entry(void *call_pc)
^
kernel/kcsan/core.c:839:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
void __tsan_func_entry(void *call_pc)
^
static
kernel/kcsan/core.c:843:6: warning: no previous prototype for function '__tsan_func_exit' [-Wmissing-prototypes]
void __tsan_func_exit(void)
^
kernel/kcsan/core.c:843:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
void __tsan_func_exit(void)
^
static
kernel/kcsan/core.c:847:6: warning: no previous prototype for function '__tsan_init' [-Wmissing-prototypes]
void __tsan_init(void)
^
kernel/kcsan/core.c:847:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
void __tsan_init(void)
^
static
25 warnings generated.

vim +/__tsan_volatile_read1 +829 kernel/kcsan/core.c

   791	
   792	/*
   793	 * Use of explicit volatile is generally disallowed [1], however, volatile is
   794	 * still used in various concurrent context, whether in low-level
   795	 * synchronization primitives or for legacy reasons.
   796	 * [1] https://lwn.net/Articles/233479/
   797	 *
   798	 * We only consider volatile accesses atomic if they are aligned and would pass
   799	 * the size-check of compiletime_assert_rwonce_type().
   800	 */
   801	#define DEFINE_TSAN_VOLATILE_READ_WRITE(size)                                  \
   802		void __tsan_volatile_read##size(void *ptr)                             \
   803		{                                                                      \
   804			const bool is_atomic = size <= sizeof(long long) &&            \
   805					       IS_ALIGNED((unsigned long)ptr, size);   \
   806			if (IS_ENABLED(CONFIG_KCSAN_IGNORE_ATOMICS) && is_atomic)      \
   807				return;                                                \
   808			check_access(ptr, size, is_atomic ? KCSAN_ACCESS_ATOMIC : 0);  \
   809		}                                                                      \
   810		EXPORT_SYMBOL(__tsan_volatile_read##size);                             \
   811		void __tsan_unaligned_volatile_read##size(void *ptr)                   \
   812			__alias(__tsan_volatile_read##size);                           \
   813		EXPORT_SYMBOL(__tsan_unaligned_volatile_read##size);                   \
   814		void __tsan_volatile_write##size(void *ptr)                            \
   815		{                                                                      \
   816			const bool is_atomic = size <= sizeof(long long) &&            \
   817					       IS_ALIGNED((unsigned long)ptr, size);   \
   818			if (IS_ENABLED(CONFIG_KCSAN_IGNORE_ATOMICS) && is_atomic)      \
   819				return;                                                \
   820			check_access(ptr, size,                                        \
   821				     KCSAN_ACCESS_WRITE |                              \
   822					     (is_atomic ? KCSAN_ACCESS_ATOMIC : 0));   \
   823		}                                                                      \
   824		EXPORT_SYMBOL(__tsan_volatile_write##size);                            \
   825		void __tsan_unaligned_volatile_write##size(void *ptr)                  \
   826			__alias(__tsan_volatile_write##size);                          \
   827		EXPORT_SYMBOL(__tsan_unaligned_volatile_write##size)
   828	
 > 829	DEFINE_TSAN_VOLATILE_READ_WRITE(1);
 > 830	DEFINE_TSAN_VOLATILE_READ_WRITE(2);
 > 831	DEFINE_TSAN_VOLATILE_READ_WRITE(4);
 > 832	DEFINE_TSAN_VOLATILE_READ_WRITE(8);
 > 833	DEFINE_TSAN_VOLATILE_READ_WRITE(16);
   834	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 28992 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [linux-next:master 10774/15793] kernel/kcsan/core.c:829:1: warning: no previous prototype for function '__tsan_volatile_read1'
  2020-06-05 17:42 [linux-next:master 10774/15793] kernel/kcsan/core.c:829:1: warning: no previous prototype for function '__tsan_volatile_read1' kernel test robot
@ 2020-06-05 17:57 ` Marco Elver
  2020-06-05 19:13   ` Nick Desaulniers
  0 siblings, 1 reply; 6+ messages in thread
From: Marco Elver @ 2020-06-05 17:57 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2336 bytes --]

On Fri, 5 Jun 2020 at 19:42, kernel test robot <lkp@intel.com> wrote:
>
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> head:   af30725c132e2e5c5369b60369ff0771fde7d4ff
> commit: 4e23395b9e97562d12b87a330a2fca3bf10c8663 [10774/15793] kcsan: Support distinguishing volatile accesses
> config: x86_64-randconfig-r013-20200605 (attached as .config)
> compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 6dd738e2f0609f7d3313b574a1d471263d2d3ba1)
> 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
>         git checkout 4e23395b9e97562d12b87a330a2fca3bf10c8663
>         # 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 <lkp@intel.com>
>
> All warnings (new ones prefixed by >>, old ones prefixed by <<):
>
> DEFINE_TSAN_READ_WRITE(4);
> ^
> kernel/kcsan/core.c:757:7: note: expanded from macro 'DEFINE_TSAN_READ_WRITE'
> void __tsan_read##size(void *ptr)                                                      ^
> <scratch space>:92:1: note: expanded from here
> __tsan_read4
> ^
> kernel/kcsan/core.c:776:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
> DEFINE_TSAN_READ_WRITE(4);
> ^
> static
> kernel/kcsan/core.c:757:2: note: expanded from macro 'DEFINE_TSAN_READ_WRITE'
> void __tsan_read##size(void *ptr)                                                 ^
> kernel/kcsan/core.c:776:1: warning: no previous prototype for function '__tsan_write4' [-Wmissing-prototypes]
> DEFINE_TSAN_READ_WRITE(4);
> ^
[...]

In the case here (and for all other *SAN or compiler-based
instrumentation), it's clearly fine since the compiler is the one
emitting calls to them.

How is one meant to act on W=1 reports like this? The kernel seems to
be full of these. It seems wrong, just to shut up W=1, to start adding
-Wno-missing-prototypes everywhere.

Thanks,
-- Marco

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [linux-next:master 10774/15793] kernel/kcsan/core.c:829:1: warning: no previous prototype for function '__tsan_volatile_read1'
  2020-06-05 17:57 ` Marco Elver
@ 2020-06-05 19:13   ` Nick Desaulniers
  2020-06-05 19:44     ` Marco Elver
  2020-06-08  0:45     ` Philip Li
  0 siblings, 2 replies; 6+ messages in thread
From: Nick Desaulniers @ 2020-06-05 19:13 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3905 bytes --]

On Fri, Jun 5, 2020 at 10:58 AM 'Marco Elver' via Clang Built Linux
<clang-built-linux@googlegroups.com> wrote:
>
> On Fri, 5 Jun 2020 at 19:42, kernel test robot <lkp@intel.com> wrote:
> >
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> > head:   af30725c132e2e5c5369b60369ff0771fde7d4ff
> > commit: 4e23395b9e97562d12b87a330a2fca3bf10c8663 [10774/15793] kcsan: Support distinguishing volatile accesses
> > config: x86_64-randconfig-r013-20200605 (attached as .config)
> > compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 6dd738e2f0609f7d3313b574a1d471263d2d3ba1)
> > 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
> >         git checkout 4e23395b9e97562d12b87a330a2fca3bf10c8663
> >         # 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 <lkp@intel.com>
> >
> > All warnings (new ones prefixed by >>, old ones prefixed by <<):
> >
> > DEFINE_TSAN_READ_WRITE(4);
> > ^
> > kernel/kcsan/core.c:757:7: note: expanded from macro 'DEFINE_TSAN_READ_WRITE'
> > void __tsan_read##size(void *ptr)                                                      ^
> > <scratch space>:92:1: note: expanded from here
> > __tsan_read4
> > ^
> > kernel/kcsan/core.c:776:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
> > DEFINE_TSAN_READ_WRITE(4);
> > ^
> > static
> > kernel/kcsan/core.c:757:2: note: expanded from macro 'DEFINE_TSAN_READ_WRITE'
> > void __tsan_read##size(void *ptr)                                                 ^
> > kernel/kcsan/core.c:776:1: warning: no previous prototype for function '__tsan_write4' [-Wmissing-prototypes]
> > DEFINE_TSAN_READ_WRITE(4);
> > ^
> [...]
>
> In the case here (and for all other *SAN or compiler-based
> instrumentation), it's clearly fine since the compiler is the one
> emitting calls to them.
>
> How is one meant to act on W=1 reports like this? The kernel seems to
> be full of these. It seems wrong, just to shut up W=1, to start adding
> -Wno-missing-prototypes everywhere.

+ Philip, because the team is probably getting asked this a lot, and
should link to this response.

`make W=1` enabled -Wmissing-prototypes via scripts/Makfile.extrawarn.

Both GCC and Clang will warn for -Wmissing-prototypes when you define
a function without a previous declaration of it, for non-static
functions.  If the linkage is extern, and there was no previous
declaration, then callers may have the wrong signature.  Mostly, this
isn't a bug, which is why it's not an error. But sometimes the
signature has changed but the callers have not been updated, which is
an ABI breakage resulting in a bug.  Mostly this is not an issue due
to -Wimplicit-function-declaration being on by default, which also
helps in this case.

See: https://godbolt.org/z/aYrYfS

Functions with external linkage should have a forward declaration, or
be marked static if in a .c file, or be marked static inline if in a
header file.

For this specific case, it looks like kcsan.h should forward declare
the functions defined by DEFINE_TSAN_READ_WRITE, to avoid any ABI
mismatch due to different call signatures between callers and callee.
Though I can't see where the callees are; if they're only within
kernel/kcsan/core.c, then defining them as static qualified may be
better. (Probably not, since they're exported via EXPORT_SYMBOL).
-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [linux-next:master 10774/15793] kernel/kcsan/core.c:829:1: warning: no previous prototype for function '__tsan_volatile_read1'
  2020-06-05 19:13   ` Nick Desaulniers
@ 2020-06-05 19:44     ` Marco Elver
  2020-06-05 19:54       ` Nick Desaulniers
  2020-06-08  0:45     ` Philip Li
  1 sibling, 1 reply; 6+ messages in thread
From: Marco Elver @ 2020-06-05 19:44 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 5196 bytes --]

On Fri, 5 Jun 2020 at 21:13, Nick Desaulniers <ndesaulniers@google.com> wrote:
>
> On Fri, Jun 5, 2020 at 10:58 AM 'Marco Elver' via Clang Built Linux
> <clang-built-linux@googlegroups.com> wrote:
> >
> > On Fri, 5 Jun 2020 at 19:42, kernel test robot <lkp@intel.com> wrote:
> > >
> > > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> > > head:   af30725c132e2e5c5369b60369ff0771fde7d4ff
> > > commit: 4e23395b9e97562d12b87a330a2fca3bf10c8663 [10774/15793] kcsan: Support distinguishing volatile accesses
> > > config: x86_64-randconfig-r013-20200605 (attached as .config)
> > > compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 6dd738e2f0609f7d3313b574a1d471263d2d3ba1)
> > > 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
> > >         git checkout 4e23395b9e97562d12b87a330a2fca3bf10c8663
> > >         # 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 <lkp@intel.com>
> > >
> > > All warnings (new ones prefixed by >>, old ones prefixed by <<):
> > >
> > > DEFINE_TSAN_READ_WRITE(4);
> > > ^
> > > kernel/kcsan/core.c:757:7: note: expanded from macro 'DEFINE_TSAN_READ_WRITE'
> > > void __tsan_read##size(void *ptr)                                                      ^
> > > <scratch space>:92:1: note: expanded from here
> > > __tsan_read4
> > > ^
> > > kernel/kcsan/core.c:776:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
> > > DEFINE_TSAN_READ_WRITE(4);
> > > ^
> > > static
> > > kernel/kcsan/core.c:757:2: note: expanded from macro 'DEFINE_TSAN_READ_WRITE'
> > > void __tsan_read##size(void *ptr)                                                 ^
> > > kernel/kcsan/core.c:776:1: warning: no previous prototype for function '__tsan_write4' [-Wmissing-prototypes]
> > > DEFINE_TSAN_READ_WRITE(4);
> > > ^
> > [...]
> >
> > In the case here (and for all other *SAN or compiler-based
> > instrumentation), it's clearly fine since the compiler is the one
> > emitting calls to them.

I should have probably said "the compiler is the one emitting calls
due to sanitizer instrumentation" to be clearer.

> > How is one meant to act on W=1 reports like this? The kernel seems to
> > be full of these. It seems wrong, just to shut up W=1, to start adding
> > -Wno-missing-prototypes everywhere.
>
> + Philip, because the team is probably getting asked this a lot, and
> should link to this response.
>
> `make W=1` enabled -Wmissing-prototypes via scripts/Makfile.extrawarn.
>
> Both GCC and Clang will warn for -Wmissing-prototypes when you define
> a function without a previous declaration of it, for non-static
> functions.  If the linkage is extern, and there was no previous
> declaration, then callers may have the wrong signature.  Mostly, this
> isn't a bug, which is why it's not an error. But sometimes the
> signature has changed but the callers have not been updated, which is
> an ABI breakage resulting in a bug.  Mostly this is not an issue due
> to -Wimplicit-function-declaration being on by default, which also
> helps in this case.
>
> See: https://godbolt.org/z/aYrYfS
>
> Functions with external linkage should have a forward declaration, or
> be marked static if in a .c file, or be marked static inline if in a
> header file.
>
> For this specific case, it looks like kcsan.h should forward declare
> the functions defined by DEFINE_TSAN_READ_WRITE, to avoid any ABI
> mismatch due to different call signatures between callers and callee.
> Though I can't see where the callees are; if they're only within
> kernel/kcsan/core.c, then defining them as static qualified may be
> better. (Probably not, since they're exported via EXPORT_SYMBOL).

Thanks for the explanation. And I agree in the general case this is a
fine warning.

However, the functions here should not be forward declared anywhere,
as they should *only* be emitted by the compiler due to sanitizer
instrumentation. In the case here it's "-fsanitize=thread". Same thing
for KASAN with "-fsanitize=kernel-address". Or UBSAN. None of them
should be forward declared for access by other parts of the kernel
explicitly. Forward declaring these also doesn't help prevent ABI
breakage, since it's the compiler generating the calls.

Let me rephrase my question: what is the idiomatic way to deal with
the warnings for the sanitizers, where the functions are runtime
functions only emitted by the compiler due to instrumentation? We can
add forward declarations 1 line above where they are defined, just for
the sake of shutting up the warning specifically for these functions.
I can send a patch if that's what we want.

Thanks,
-- Marco

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [linux-next:master 10774/15793] kernel/kcsan/core.c:829:1: warning: no previous prototype for function '__tsan_volatile_read1'
  2020-06-05 19:44     ` Marco Elver
@ 2020-06-05 19:54       ` Nick Desaulniers
  0 siblings, 0 replies; 6+ messages in thread
From: Nick Desaulniers @ 2020-06-05 19:54 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 882 bytes --]

On Fri, Jun 5, 2020 at 12:44 PM Marco Elver <elver@google.com> wrote:
>
> Let me rephrase my question: what is the idiomatic way to deal with
> the warnings for the sanitizers, where the functions are runtime
> functions only emitted by the compiler due to instrumentation? We can
> add forward declarations 1 line above where they are defined, just for
> the sake of shutting up the warning specifically for these functions.
> I can send a patch if that's what we want.

I don't know that's there's an idiomatic way for the specific case of
compiler emitted calls, but your suggestion sounds fine.  You can test
it with `make W=1` or manually setting `-Wmissing-prototypes` for
KBUILD_CFLAGS. (I think you can even set that variable to that string
in a make command line arg, ie. `make
KBUILD_CFLAGS="-Wmissing-prototypes` (untested).
-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [linux-next:master 10774/15793] kernel/kcsan/core.c:829:1: warning: no previous prototype for function '__tsan_volatile_read1'
  2020-06-05 19:13   ` Nick Desaulniers
  2020-06-05 19:44     ` Marco Elver
@ 2020-06-08  0:45     ` Philip Li
  1 sibling, 0 replies; 6+ messages in thread
From: Philip Li @ 2020-06-08  0:45 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 4266 bytes --]

On Fri, Jun 05, 2020 at 12:13:36PM -0700, Nick Desaulniers wrote:
> On Fri, Jun 5, 2020 at 10:58 AM 'Marco Elver' via Clang Built Linux
> <clang-built-linux@googlegroups.com> wrote:
> >
> > On Fri, 5 Jun 2020 at 19:42, kernel test robot <lkp@intel.com> wrote:
> > >
> > > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> > > head:   af30725c132e2e5c5369b60369ff0771fde7d4ff
> > > commit: 4e23395b9e97562d12b87a330a2fca3bf10c8663 [10774/15793] kcsan: Support distinguishing volatile accesses
> > > config: x86_64-randconfig-r013-20200605 (attached as .config)
> > > compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 6dd738e2f0609f7d3313b574a1d471263d2d3ba1)
> > > 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
> > >         git checkout 4e23395b9e97562d12b87a330a2fca3bf10c8663
> > >         # 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 <lkp@intel.com>
> > >
> > > All warnings (new ones prefixed by >>, old ones prefixed by <<):
> > >
> > > DEFINE_TSAN_READ_WRITE(4);
> > > ^
> > > kernel/kcsan/core.c:757:7: note: expanded from macro 'DEFINE_TSAN_READ_WRITE'
> > > void __tsan_read##size(void *ptr)                                                      ^
> > > <scratch space>:92:1: note: expanded from here
> > > __tsan_read4
> > > ^
> > > kernel/kcsan/core.c:776:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
> > > DEFINE_TSAN_READ_WRITE(4);
> > > ^
> > > static
> > > kernel/kcsan/core.c:757:2: note: expanded from macro 'DEFINE_TSAN_READ_WRITE'
> > > void __tsan_read##size(void *ptr)                                                 ^
> > > kernel/kcsan/core.c:776:1: warning: no previous prototype for function '__tsan_write4' [-Wmissing-prototypes]
> > > DEFINE_TSAN_READ_WRITE(4);
> > > ^
> > [...]
> >
> > In the case here (and for all other *SAN or compiler-based
> > instrumentation), it's clearly fine since the compiler is the one
> > emitting calls to them.
> >
> > How is one meant to act on W=1 reports like this? The kernel seems to
> > be full of these. It seems wrong, just to shut up W=1, to start adding
> > -Wno-missing-prototypes everywhere.
> 
> + Philip, because the team is probably getting asked this a lot, and
> should link to this response.
thanks a lot, i had added your response at https://github.com/intel/lkp-tests/wiki/LKP-FAQ
which is very helpful to explain this.

> 
> `make W=1` enabled -Wmissing-prototypes via scripts/Makfile.extrawarn.
> 
> Both GCC and Clang will warn for -Wmissing-prototypes when you define
> a function without a previous declaration of it, for non-static
> functions.  If the linkage is extern, and there was no previous
> declaration, then callers may have the wrong signature.  Mostly, this
> isn't a bug, which is why it's not an error. But sometimes the
> signature has changed but the callers have not been updated, which is
> an ABI breakage resulting in a bug.  Mostly this is not an issue due
> to -Wimplicit-function-declaration being on by default, which also
> helps in this case.
> 
> See: https://godbolt.org/z/aYrYfS
> 
> Functions with external linkage should have a forward declaration, or
> be marked static if in a .c file, or be marked static inline if in a
> header file.
> 
> For this specific case, it looks like kcsan.h should forward declare
> the functions defined by DEFINE_TSAN_READ_WRITE, to avoid any ABI
> mismatch due to different call signatures between callers and callee.
> Though I can't see where the callees are; if they're only within
> kernel/kcsan/core.c, then defining them as static qualified may be
> better. (Probably not, since they're exported via EXPORT_SYMBOL).
> -- 
> Thanks,
> ~Nick Desaulniers

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-06-08  0:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-05 17:42 [linux-next:master 10774/15793] kernel/kcsan/core.c:829:1: warning: no previous prototype for function '__tsan_volatile_read1' kernel test robot
2020-06-05 17:57 ` Marco Elver
2020-06-05 19:13   ` Nick Desaulniers
2020-06-05 19:44     ` Marco Elver
2020-06-05 19:54       ` Nick Desaulniers
2020-06-08  0:45     ` Philip Li

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.