[2/2] kunit: Use the static key in kunit_fail_current_test()

Message ID 20221021072854.333010-2-davidgow@google.com
State New
Headers
Series [1/2] kunit: Provide a static key to check if KUnit is actively running tests |

Commit Message

David Gow Oct. 21, 2022, 7:28 a.m. UTC
  Speed up the case where kunit_fail_current_test() is called when no test
is running. This should make it convenient for code to call this
unconditionally in some error paths, without fear of causing a
performance problem.

If CONFIG_KUNIT=n, this compiles away to nothing. If CONFIG_KUNIT=y, it
will compile down to a NOP (on most architectures) if no KUnit test is
currently running. kunit_fail_current_test() does not work if KUnit
itself is built as a module, though this is a pre-existing limitation.

Note that the definition of kunit_fail_current_test() still wraps an
empty, inline function if KUnit is not built-in. This is to ensure that
the printf format string __attribute__ will still work.

Signed-off-by: David Gow <davidgow@google.com>
---
 include/kunit/test-bug.h | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
  

Comments

kernel test robot Oct. 21, 2022, 1:57 p.m. UTC | #1
Hi David,

I love your patch! Yet something to improve:

[auto build test ERROR on kees/for-next/pstore]
[also build test ERROR on linus/master v6.1-rc1 next-20221021]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/David-Gow/kunit-Provide-a-static-key-to-check-if-KUnit-is-actively-running-tests/20221021-153225
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/pstore
patch link:    https://lore.kernel.org/r/20221021072854.333010-2-davidgow%40google.com
patch subject: [PATCH 2/2] kunit: Use the static key in kunit_fail_current_test()
config: xtensa-randconfig-r034-20221019
compiler: xtensa-linux-gcc (GCC) 12.1.0
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
        # https://github.com/intel-lab-lkp/linux/commit/6a21df30828089657bb7d56ce48a6188a4468878
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review David-Gow/kunit-Provide-a-static-key-to-check-if-KUnit-is-actively-running-tests/20221021-153225
        git checkout 6a21df30828089657bb7d56ce48a6188a4468878
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=xtensa SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   lib/ubsan.c: In function 'ubsan_prologue':
>> lib/ubsan.c:149:1: error: expected 'while' before 'static'
     149 | static void ubsan_epilogue(void)
         | ^~~~~~
   lib/ubsan.c: In function '__ubsan_handle_divrem_overflow':
>> lib/ubsan.c:179:9: error: implicit declaration of function 'ubsan_epilogue'; did you mean 'ubsan_prologue'? [-Werror=implicit-function-declaration]
     179 |         ubsan_epilogue();
         |         ^~~~~~~~~~~~~~
         |         ubsan_prologue
   lib/ubsan.c: In function 'ubsan_prologue':
>> lib/ubsan.c:161:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     161 | void __ubsan_handle_divrem_overflow(void *_data, void *lhs, void *rhs)
         | ^~~~
>> lib/ubsan.c:183:13: error: invalid storage class for function 'handle_null_ptr_deref'
     183 | static void handle_null_ptr_deref(struct type_mismatch_data_common *data)
         |             ^~~~~~~~~~~~~~~~~~~~~
   lib/ubsan.c:183:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     183 | static void handle_null_ptr_deref(struct type_mismatch_data_common *data)
         | ^~~~~~
>> lib/ubsan.c:197:13: error: invalid storage class for function 'handle_misaligned_access'
     197 | static void handle_misaligned_access(struct type_mismatch_data_common *data,
         |             ^~~~~~~~~~~~~~~~~~~~~~~~
>> lib/ubsan.c:213:13: error: invalid storage class for function 'handle_object_size_mismatch'
     213 | static void handle_object_size_mismatch(struct type_mismatch_data_common *data,
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~
>> lib/ubsan.c:227:13: error: invalid storage class for function 'ubsan_type_mismatch_common'
     227 | static void ubsan_type_mismatch_common(struct type_mismatch_data_common *data,
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~
   lib/ubsan.c:256:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     256 | void __ubsan_handle_type_mismatch_v1(void *_data, void *ptr)
         | ^~~~
   lib/ubsan.c:270:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     270 | void __ubsan_handle_out_of_bounds(void *_data, void *index)
         | ^~~~
   lib/ubsan.c:287:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     287 | void __ubsan_handle_shift_out_of_bounds(void *_data, void *lhs, void *rhs)
         | ^~~~
   lib/ubsan.c:329:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     329 | void __ubsan_handle_builtin_unreachable(void *_data)
         | ^~~~
   lib/ubsan.c:339:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     339 | void __ubsan_handle_load_invalid_value(void *_data, void *val)
         | ^~~~
   lib/ubsan.c:358:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     358 | void __ubsan_handle_alignment_assumption(void *_data, unsigned long ptr,
         | ^~~~
>> lib/ubsan.c:361:6: error: static declaration of '__ubsan_handle_alignment_assumption' follows non-static declaration
     361 | void __ubsan_handle_alignment_assumption(void *_data, unsigned long ptr,
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   lib/ubsan.c:358:6: note: previous declaration of '__ubsan_handle_alignment_assumption' with type 'void(void *, long unsigned int,  long unsigned int,  long unsigned int)'
     358 | void __ubsan_handle_alignment_assumption(void *_data, unsigned long ptr,
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> lib/ubsan.c:387:1: error: expected declaration or statement at end of input
     387 | EXPORT_SYMBOL(__ubsan_handle_alignment_assumption);
         | ^~~~~~~~~~~~~
   lib/ubsan.c: At top level:
   lib/ubsan.c:361:6: warning: '__ubsan_handle_alignment_assumption' defined but not used [-Wunused-function]
     361 | void __ubsan_handle_alignment_assumption(void *_data, unsigned long ptr,
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   lib/ubsan.c:339:6: warning: '__ubsan_handle_load_invalid_value' defined but not used [-Wunused-function]
     339 | void __ubsan_handle_load_invalid_value(void *_data, void *val)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   lib/ubsan.c:329:6: warning: '__ubsan_handle_builtin_unreachable' defined but not used [-Wunused-function]
     329 | void __ubsan_handle_builtin_unreachable(void *_data)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   lib/ubsan.c:287:6: warning: '__ubsan_handle_shift_out_of_bounds' defined but not used [-Wunused-function]
     287 | void __ubsan_handle_shift_out_of_bounds(void *_data, void *lhs, void *rhs)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   lib/ubsan.c:270:6: warning: '__ubsan_handle_out_of_bounds' defined but not used [-Wunused-function]
     270 | void __ubsan_handle_out_of_bounds(void *_data, void *index)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   lib/ubsan.c:256:6: warning: '__ubsan_handle_type_mismatch_v1' defined but not used [-Wunused-function]
     256 | void __ubsan_handle_type_mismatch_v1(void *_data, void *ptr)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   lib/ubsan.c:242:6: warning: '__ubsan_handle_type_mismatch' defined but not used [-Wunused-function]
     242 | void __ubsan_handle_type_mismatch(struct type_mismatch_data *data,
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   lib/ubsan.c:161:6: warning: '__ubsan_handle_divrem_overflow' defined but not used [-Wunused-function]
     161 | void __ubsan_handle_divrem_overflow(void *_data, void *lhs, void *rhs)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +149 lib/ubsan.c

c6d308534aef6c Andrey Ryabinin 2016-01-20  148  
ce5c31db3645b6 Julien Grall    2019-12-04 @149  static void ubsan_epilogue(void)
c6d308534aef6c Andrey Ryabinin 2016-01-20  150  {
c6d308534aef6c Andrey Ryabinin 2016-01-20  151  	dump_stack();
c6d308534aef6c Andrey Ryabinin 2016-01-20  152  	pr_err("========================================"
c6d308534aef6c Andrey Ryabinin 2016-01-20  153  		"========================================\n");
ce5c31db3645b6 Julien Grall    2019-12-04  154  
c6d308534aef6c Andrey Ryabinin 2016-01-20  155  	current->in_ubsan--;
1d28c8d6d076ef Kees Cook       2020-04-06  156  
d83ce027a54068 Tiezhu Yang     2022-03-23  157  	if (panic_on_warn)
1d28c8d6d076ef Kees Cook       2020-04-06  158  		panic("panic_on_warn set ...\n");
1d28c8d6d076ef Kees Cook       2020-04-06  159  }
c6d308534aef6c Andrey Ryabinin 2016-01-20  160  
469cbd016157d2 Arnd Bergmann   2020-06-04 @161  void __ubsan_handle_divrem_overflow(void *_data, void *lhs, void *rhs)
c6d308534aef6c Andrey Ryabinin 2016-01-20  162  {
469cbd016157d2 Arnd Bergmann   2020-06-04  163  	struct overflow_data *data = _data;
c6d308534aef6c Andrey Ryabinin 2016-01-20  164  	char rhs_val_str[VALUE_LENGTH];
c6d308534aef6c Andrey Ryabinin 2016-01-20  165  
c6d308534aef6c Andrey Ryabinin 2016-01-20  166  	if (suppress_report(&data->location))
c6d308534aef6c Andrey Ryabinin 2016-01-20  167  		return;
c6d308534aef6c Andrey Ryabinin 2016-01-20  168  
ef065653e526a0 Kees Cook       2020-04-06  169  	ubsan_prologue(&data->location, "division-overflow");
c6d308534aef6c Andrey Ryabinin 2016-01-20  170  
c6d308534aef6c Andrey Ryabinin 2016-01-20  171  	val_to_string(rhs_val_str, sizeof(rhs_val_str), data->type, rhs);
c6d308534aef6c Andrey Ryabinin 2016-01-20  172  
c6d308534aef6c Andrey Ryabinin 2016-01-20  173  	if (type_is_signed(data->type) && get_signed_val(data->type, rhs) == -1)
c6d308534aef6c Andrey Ryabinin 2016-01-20  174  		pr_err("division of %s by -1 cannot be represented in type %s\n",
c6d308534aef6c Andrey Ryabinin 2016-01-20  175  			rhs_val_str, data->type->type_name);
c6d308534aef6c Andrey Ryabinin 2016-01-20  176  	else
c6d308534aef6c Andrey Ryabinin 2016-01-20  177  		pr_err("division by zero\n");
c6d308534aef6c Andrey Ryabinin 2016-01-20  178  
ce5c31db3645b6 Julien Grall    2019-12-04 @179  	ubsan_epilogue();
c6d308534aef6c Andrey Ryabinin 2016-01-20  180  }
c6d308534aef6c Andrey Ryabinin 2016-01-20  181  EXPORT_SYMBOL(__ubsan_handle_divrem_overflow);
c6d308534aef6c Andrey Ryabinin 2016-01-20  182  
42440c1f9911b4 Andrey Ryabinin 2018-02-06 @183  static void handle_null_ptr_deref(struct type_mismatch_data_common *data)
c6d308534aef6c Andrey Ryabinin 2016-01-20  184  {
42440c1f9911b4 Andrey Ryabinin 2018-02-06  185  	if (suppress_report(data->location))
c6d308534aef6c Andrey Ryabinin 2016-01-20  186  		return;
c6d308534aef6c Andrey Ryabinin 2016-01-20  187  
ef065653e526a0 Kees Cook       2020-04-06  188  	ubsan_prologue(data->location, "null-ptr-deref");
c6d308534aef6c Andrey Ryabinin 2016-01-20  189  
c6d308534aef6c Andrey Ryabinin 2016-01-20  190  	pr_err("%s null pointer of type %s\n",
c6d308534aef6c Andrey Ryabinin 2016-01-20  191  		type_check_kinds[data->type_check_kind],
c6d308534aef6c Andrey Ryabinin 2016-01-20  192  		data->type->type_name);
c6d308534aef6c Andrey Ryabinin 2016-01-20  193  
ce5c31db3645b6 Julien Grall    2019-12-04  194  	ubsan_epilogue();
c6d308534aef6c Andrey Ryabinin 2016-01-20  195  }
c6d308534aef6c Andrey Ryabinin 2016-01-20  196  
42440c1f9911b4 Andrey Ryabinin 2018-02-06 @197  static void handle_misaligned_access(struct type_mismatch_data_common *data,
c6d308534aef6c Andrey Ryabinin 2016-01-20  198  				unsigned long ptr)
c6d308534aef6c Andrey Ryabinin 2016-01-20  199  {
42440c1f9911b4 Andrey Ryabinin 2018-02-06  200  	if (suppress_report(data->location))
c6d308534aef6c Andrey Ryabinin 2016-01-20  201  		return;
c6d308534aef6c Andrey Ryabinin 2016-01-20  202  
ef065653e526a0 Kees Cook       2020-04-06  203  	ubsan_prologue(data->location, "misaligned-access");
c6d308534aef6c Andrey Ryabinin 2016-01-20  204  
c6d308534aef6c Andrey Ryabinin 2016-01-20  205  	pr_err("%s misaligned address %p for type %s\n",
c6d308534aef6c Andrey Ryabinin 2016-01-20  206  		type_check_kinds[data->type_check_kind],
c6d308534aef6c Andrey Ryabinin 2016-01-20  207  		(void *)ptr, data->type->type_name);
c6d308534aef6c Andrey Ryabinin 2016-01-20  208  	pr_err("which requires %ld byte alignment\n", data->alignment);
c6d308534aef6c Andrey Ryabinin 2016-01-20  209  
ce5c31db3645b6 Julien Grall    2019-12-04  210  	ubsan_epilogue();
c6d308534aef6c Andrey Ryabinin 2016-01-20  211  }
c6d308534aef6c Andrey Ryabinin 2016-01-20  212  
42440c1f9911b4 Andrey Ryabinin 2018-02-06 @213  static void handle_object_size_mismatch(struct type_mismatch_data_common *data,
c6d308534aef6c Andrey Ryabinin 2016-01-20  214  					unsigned long ptr)
c6d308534aef6c Andrey Ryabinin 2016-01-20  215  {
42440c1f9911b4 Andrey Ryabinin 2018-02-06  216  	if (suppress_report(data->location))
c6d308534aef6c Andrey Ryabinin 2016-01-20  217  		return;
c6d308534aef6c Andrey Ryabinin 2016-01-20  218  
ef065653e526a0 Kees Cook       2020-04-06  219  	ubsan_prologue(data->location, "object-size-mismatch");
901d805c33fc4c Nicolas Iooss   2016-08-02  220  	pr_err("%s address %p with insufficient space\n",
c6d308534aef6c Andrey Ryabinin 2016-01-20  221  		type_check_kinds[data->type_check_kind],
c6d308534aef6c Andrey Ryabinin 2016-01-20  222  		(void *) ptr);
c6d308534aef6c Andrey Ryabinin 2016-01-20  223  	pr_err("for an object of type %s\n", data->type->type_name);
ce5c31db3645b6 Julien Grall    2019-12-04  224  	ubsan_epilogue();
c6d308534aef6c Andrey Ryabinin 2016-01-20  225  }
c6d308534aef6c Andrey Ryabinin 2016-01-20  226  
42440c1f9911b4 Andrey Ryabinin 2018-02-06 @227  static void ubsan_type_mismatch_common(struct type_mismatch_data_common *data,
c6d308534aef6c Andrey Ryabinin 2016-01-20  228  				unsigned long ptr)
c6d308534aef6c Andrey Ryabinin 2016-01-20  229  {
d08965a27e84ca Peter Zijlstra  2019-04-03  230  	unsigned long flags = user_access_save();
c6d308534aef6c Andrey Ryabinin 2016-01-20  231  
c6d308534aef6c Andrey Ryabinin 2016-01-20  232  	if (!ptr)
c6d308534aef6c Andrey Ryabinin 2016-01-20  233  		handle_null_ptr_deref(data);
c6d308534aef6c Andrey Ryabinin 2016-01-20  234  	else if (data->alignment && !IS_ALIGNED(ptr, data->alignment))
b8fe1120b4ba34 Andrew Morton   2018-02-06  235  		handle_misaligned_access(data, ptr);
c6d308534aef6c Andrey Ryabinin 2016-01-20  236  	else
c6d308534aef6c Andrey Ryabinin 2016-01-20  237  		handle_object_size_mismatch(data, ptr);
d08965a27e84ca Peter Zijlstra  2019-04-03  238  
d08965a27e84ca Peter Zijlstra  2019-04-03  239  	user_access_restore(flags);
c6d308534aef6c Andrey Ryabinin 2016-01-20  240  }
42440c1f9911b4 Andrey Ryabinin 2018-02-06  241
  
Kees Cook Oct. 21, 2022, 2:16 p.m. UTC | #2
On October 21, 2022 12:28:55 AM PDT, David Gow <davidgow@google.com> wrote:
>Speed up the case where kunit_fail_current_test() is called when no test
>is running. This should make it convenient for code to call this
>unconditionally in some error paths, without fear of causing a
>performance problem.

A third patch showing these cases may help in understanding the utility. I get it, but I lack imagination on where/why they would be added. :)

>
>If CONFIG_KUNIT=n, this compiles away to nothing. If CONFIG_KUNIT=y, it
>will compile down to a NOP (on most architectures) if no KUnit test is
>currently running. kunit_fail_current_test() does not work if KUnit
>itself is built as a module, though this is a pre-existing limitation.
>
>Note that the definition of kunit_fail_current_test() still wraps an
>empty, inline function if KUnit is not built-in. This is to ensure that
>the printf format string __attribute__ will still work.
>
>Signed-off-by: David Gow <davidgow@google.com>
>---
> include/kunit/test-bug.h | 19 ++++++++++++++++---
> 1 file changed, 16 insertions(+), 3 deletions(-)
>
>diff --git a/include/kunit/test-bug.h b/include/kunit/test-bug.h
>index 5fc58081d511..ba9558a9f9c0 100644
>--- a/include/kunit/test-bug.h
>+++ b/include/kunit/test-bug.h
>@@ -9,16 +9,29 @@
> #ifndef _KUNIT_TEST_BUG_H
> #define _KUNIT_TEST_BUG_H
> 
>-#define kunit_fail_current_test(fmt, ...) \
>-	__kunit_fail_current_test(__FILE__, __LINE__, fmt, ##__VA_ARGS__)
>-
> #if IS_BUILTIN(CONFIG_KUNIT)
> 
>+#include <linux/jump_label.h> /* For static branch */
>+
>+/* Static key if KUnit is running any tests. */
>+extern struct static_key_false kunit_running;
>+
>+#define kunit_fail_current_test(fmt, ...) do {					\
>+	if (static_branch_unlikely(&kunit_running)) {				\

This trailing { should be dropped.

>+		__kunit_fail_current_test(__FILE__, __LINE__,			\
>+					  fmt, ##__VA_ARGS__);			\

Or a closing one added here. (The {}s are unbalanced, as 0day complained about.)

>+	} while (0)
>+
>+
> extern __printf(3, 4) void __kunit_fail_current_test(const char *file, int line,
> 						    const char *fmt, ...);
> 
> #else
> 
>+/* We define this with an empty helper function so format string warnings work */
>+#define kunit_fail_current_test(fmt, ...) \
>+		__kunit_fail_current_test(__FILE__, __LINE__, fmt, ##__VA_ARGS__)
>+
> static inline __printf(3, 4) void __kunit_fail_current_test(const char *file, int line,
> 							    const char *fmt, ...)
> {
  
kernel test robot Oct. 21, 2022, 2:37 p.m. UTC | #3
Hi David,

I love your patch! Perhaps something to improve:

[auto build test WARNING on kees/for-next/pstore]
[also build test WARNING on linus/master v6.1-rc1 next-20221021]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/David-Gow/kunit-Provide-a-static-key-to-check-if-KUnit-is-actively-running-tests/20221021-153225
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/pstore
patch link:    https://lore.kernel.org/r/20221021072854.333010-2-davidgow%40google.com
patch subject: [PATCH 2/2] kunit: Use the static key in kunit_fail_current_test()
config: x86_64-rhel-8.3-kunit
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/6a21df30828089657bb7d56ce48a6188a4468878
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review David-Gow/kunit-Provide-a-static-key-to-check-if-KUnit-is-actively-running-tests/20221021-153225
        git checkout 6a21df30828089657bb7d56ce48a6188a4468878
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   lib/ubsan.c: In function 'ubsan_prologue':
   lib/ubsan.c:149:1: error: expected 'while' before 'static'
     149 | static void ubsan_epilogue(void)
         | ^~~~~~
   lib/ubsan.c: In function '__ubsan_handle_divrem_overflow':
   lib/ubsan.c:179:9: error: implicit declaration of function 'ubsan_epilogue'; did you mean 'ubsan_prologue'? [-Werror=implicit-function-declaration]
     179 |         ubsan_epilogue();
         |         ^~~~~~~~~~~~~~
         |         ubsan_prologue
   lib/ubsan.c: In function 'ubsan_prologue':
   lib/ubsan.c:161:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     161 | void __ubsan_handle_divrem_overflow(void *_data, void *lhs, void *rhs)
         | ^~~~
   In file included from include/linux/linkage.h:7,
                    from include/linux/printk.h:8,
                    from include/asm-generic/bug.h:22,
                    from arch/x86/include/asm/bug.h:87,
                    from include/linux/bug.h:5,
                    from lib/ubsan.c:10:
   lib/ubsan.c:181:15: error: non-static declaration of '__ubsan_handle_divrem_overflow' follows static declaration
     181 | EXPORT_SYMBOL(__ubsan_handle_divrem_overflow);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/export.h:87:28: note: in definition of macro '___EXPORT_SYMBOL'
      87 |         extern typeof(sym) sym;                                                 \
         |                            ^~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:181:1: note: in expansion of macro 'EXPORT_SYMBOL'
     181 | EXPORT_SYMBOL(__ubsan_handle_divrem_overflow);
         | ^~~~~~~~~~~~~
   lib/ubsan.c:161:6: note: previous definition of '__ubsan_handle_divrem_overflow' with type 'void(void *, void *, void *)'
     161 | void __ubsan_handle_divrem_overflow(void *_data, void *lhs, void *rhs)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/build_bug.h:5,
                    from include/linux/bits.h:22,
                    from include/linux/bitops.h:6,
                    from lib/ubsan.c:9:
>> include/linux/compiler.h:215:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     215 |         static void * __used __attrs \
         |         ^~~~~~
   include/linux/compiler.h:218:9: note: in expansion of macro '___ADDRESSABLE'
     218 |         ___ADDRESSABLE(sym, __section(".discard.addressable"))
         |         ^~~~~~~~~~~~~~
   include/linux/export.h:41:9: note: in expansion of macro '__ADDRESSABLE'
      41 |         __ADDRESSABLE(sym)                                              \
         |         ^~~~~~~~~~~~~
   include/linux/export.h:96:9: note: in expansion of macro '__KSYMTAB_ENTRY'
      96 |         __KSYMTAB_ENTRY(sym, sec)
         |         ^~~~~~~~~~~~~~~
   include/linux/export.h:140:41: note: in expansion of macro '___EXPORT_SYMBOL'
     140 | #define __EXPORT_SYMBOL(sym, sec, ns)   ___EXPORT_SYMBOL(sym, sec, ns)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:181:1: note: in expansion of macro 'EXPORT_SYMBOL'
     181 | EXPORT_SYMBOL(__ubsan_handle_divrem_overflow);
         | ^~~~~~~~~~~~~
   lib/ubsan.c:183:13: error: invalid storage class for function 'handle_null_ptr_deref'
     183 | static void handle_null_ptr_deref(struct type_mismatch_data_common *data)
         |             ^~~~~~~~~~~~~~~~~~~~~
   lib/ubsan.c:183:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     183 | static void handle_null_ptr_deref(struct type_mismatch_data_common *data)
         | ^~~~~~
   lib/ubsan.c:197:13: error: invalid storage class for function 'handle_misaligned_access'
     197 | static void handle_misaligned_access(struct type_mismatch_data_common *data,
         |             ^~~~~~~~~~~~~~~~~~~~~~~~
   lib/ubsan.c:213:13: error: invalid storage class for function 'handle_object_size_mismatch'
     213 | static void handle_object_size_mismatch(struct type_mismatch_data_common *data,
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   lib/ubsan.c:227:13: error: invalid storage class for function 'ubsan_type_mismatch_common'
     227 | static void ubsan_type_mismatch_common(struct type_mismatch_data_common *data,
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/linkage.h:7,
                    from include/linux/printk.h:8,
                    from include/asm-generic/bug.h:22,
                    from arch/x86/include/asm/bug.h:87,
                    from include/linux/bug.h:5,
                    from lib/ubsan.c:10:
   lib/ubsan.c:254:15: error: non-static declaration of '__ubsan_handle_type_mismatch' follows static declaration
     254 | EXPORT_SYMBOL(__ubsan_handle_type_mismatch);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/export.h:87:28: note: in definition of macro '___EXPORT_SYMBOL'
      87 |         extern typeof(sym) sym;                                                 \
         |                            ^~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:254:1: note: in expansion of macro 'EXPORT_SYMBOL'
     254 | EXPORT_SYMBOL(__ubsan_handle_type_mismatch);
         | ^~~~~~~~~~~~~
   lib/ubsan.c:242:6: note: previous definition of '__ubsan_handle_type_mismatch' with type 'void(struct type_mismatch_data *, void *)'
     242 | void __ubsan_handle_type_mismatch(struct type_mismatch_data *data,
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/build_bug.h:5,
                    from include/linux/bits.h:22,
                    from include/linux/bitops.h:6,
                    from lib/ubsan.c:9:
>> include/linux/compiler.h:215:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     215 |         static void * __used __attrs \
         |         ^~~~~~
   include/linux/compiler.h:218:9: note: in expansion of macro '___ADDRESSABLE'
     218 |         ___ADDRESSABLE(sym, __section(".discard.addressable"))
         |         ^~~~~~~~~~~~~~
   include/linux/export.h:41:9: note: in expansion of macro '__ADDRESSABLE'
      41 |         __ADDRESSABLE(sym)                                              \
         |         ^~~~~~~~~~~~~
   include/linux/export.h:96:9: note: in expansion of macro '__KSYMTAB_ENTRY'
      96 |         __KSYMTAB_ENTRY(sym, sec)
         |         ^~~~~~~~~~~~~~~
   include/linux/export.h:140:41: note: in expansion of macro '___EXPORT_SYMBOL'
     140 | #define __EXPORT_SYMBOL(sym, sec, ns)   ___EXPORT_SYMBOL(sym, sec, ns)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:254:1: note: in expansion of macro 'EXPORT_SYMBOL'
     254 | EXPORT_SYMBOL(__ubsan_handle_type_mismatch);
         | ^~~~~~~~~~~~~
   lib/ubsan.c:256:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     256 | void __ubsan_handle_type_mismatch_v1(void *_data, void *ptr)
         | ^~~~
   In file included from include/linux/linkage.h:7,
                    from include/linux/printk.h:8,
                    from include/asm-generic/bug.h:22,
                    from arch/x86/include/asm/bug.h:87,
                    from include/linux/bug.h:5,
                    from lib/ubsan.c:10:
   lib/ubsan.c:268:15: error: non-static declaration of '__ubsan_handle_type_mismatch_v1' follows static declaration
     268 | EXPORT_SYMBOL(__ubsan_handle_type_mismatch_v1);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/export.h:87:28: note: in definition of macro '___EXPORT_SYMBOL'
      87 |         extern typeof(sym) sym;                                                 \
         |                            ^~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:268:1: note: in expansion of macro 'EXPORT_SYMBOL'
     268 | EXPORT_SYMBOL(__ubsan_handle_type_mismatch_v1);
         | ^~~~~~~~~~~~~
   lib/ubsan.c:256:6: note: previous definition of '__ubsan_handle_type_mismatch_v1' with type 'void(void *, void *)'
     256 | void __ubsan_handle_type_mismatch_v1(void *_data, void *ptr)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/build_bug.h:5,
                    from include/linux/bits.h:22,
                    from include/linux/bitops.h:6,
                    from lib/ubsan.c:9:
>> include/linux/compiler.h:215:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     215 |         static void * __used __attrs \
         |         ^~~~~~
   include/linux/compiler.h:218:9: note: in expansion of macro '___ADDRESSABLE'
     218 |         ___ADDRESSABLE(sym, __section(".discard.addressable"))
         |         ^~~~~~~~~~~~~~
   include/linux/export.h:41:9: note: in expansion of macro '__ADDRESSABLE'
      41 |         __ADDRESSABLE(sym)                                              \
         |         ^~~~~~~~~~~~~
   include/linux/export.h:96:9: note: in expansion of macro '__KSYMTAB_ENTRY'
      96 |         __KSYMTAB_ENTRY(sym, sec)
         |         ^~~~~~~~~~~~~~~
   include/linux/export.h:140:41: note: in expansion of macro '___EXPORT_SYMBOL'
     140 | #define __EXPORT_SYMBOL(sym, sec, ns)   ___EXPORT_SYMBOL(sym, sec, ns)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:268:1: note: in expansion of macro 'EXPORT_SYMBOL'
     268 | EXPORT_SYMBOL(__ubsan_handle_type_mismatch_v1);
         | ^~~~~~~~~~~~~
   lib/ubsan.c:270:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     270 | void __ubsan_handle_out_of_bounds(void *_data, void *index)
         | ^~~~
   In file included from include/linux/linkage.h:7,
                    from include/linux/printk.h:8,
                    from include/asm-generic/bug.h:22,
                    from arch/x86/include/asm/bug.h:87,
                    from include/linux/bug.h:5,
                    from lib/ubsan.c:10:
   lib/ubsan.c:285:15: error: non-static declaration of '__ubsan_handle_out_of_bounds' follows static declaration
     285 | EXPORT_SYMBOL(__ubsan_handle_out_of_bounds);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/export.h:87:28: note: in definition of macro '___EXPORT_SYMBOL'
      87 |         extern typeof(sym) sym;                                                 \
         |                            ^~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:285:1: note: in expansion of macro 'EXPORT_SYMBOL'
     285 | EXPORT_SYMBOL(__ubsan_handle_out_of_bounds);
         | ^~~~~~~~~~~~~
   lib/ubsan.c:270:6: note: previous definition of '__ubsan_handle_out_of_bounds' with type 'void(void *, void *)'
     270 | void __ubsan_handle_out_of_bounds(void *_data, void *index)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/build_bug.h:5,
                    from include/linux/bits.h:22,
                    from include/linux/bitops.h:6,
                    from lib/ubsan.c:9:
>> include/linux/compiler.h:215:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     215 |         static void * __used __attrs \
         |         ^~~~~~
   include/linux/compiler.h:218:9: note: in expansion of macro '___ADDRESSABLE'
     218 |         ___ADDRESSABLE(sym, __section(".discard.addressable"))
         |         ^~~~~~~~~~~~~~
   include/linux/export.h:41:9: note: in expansion of macro '__ADDRESSABLE'
      41 |         __ADDRESSABLE(sym)                                              \
         |         ^~~~~~~~~~~~~
   include/linux/export.h:96:9: note: in expansion of macro '__KSYMTAB_ENTRY'
      96 |         __KSYMTAB_ENTRY(sym, sec)
         |         ^~~~~~~~~~~~~~~
   include/linux/export.h:140:41: note: in expansion of macro '___EXPORT_SYMBOL'
     140 | #define __EXPORT_SYMBOL(sym, sec, ns)   ___EXPORT_SYMBOL(sym, sec, ns)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:285:1: note: in expansion of macro 'EXPORT_SYMBOL'
     285 | EXPORT_SYMBOL(__ubsan_handle_out_of_bounds);
         | ^~~~~~~~~~~~~
   lib/ubsan.c:287:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     287 | void __ubsan_handle_shift_out_of_bounds(void *_data, void *lhs, void *rhs)
         | ^~~~
   In file included from include/linux/linkage.h:7,
                    from include/linux/printk.h:8,
                    from include/asm-generic/bug.h:22,
                    from arch/x86/include/asm/bug.h:87,
                    from include/linux/bug.h:5,
                    from lib/ubsan.c:10:
   lib/ubsan.c:326:15: error: non-static declaration of '__ubsan_handle_shift_out_of_bounds' follows static declaration
     326 | EXPORT_SYMBOL(__ubsan_handle_shift_out_of_bounds);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/export.h:87:28: note: in definition of macro '___EXPORT_SYMBOL'
      87 |         extern typeof(sym) sym;                                                 \
         |                            ^~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:326:1: note: in expansion of macro 'EXPORT_SYMBOL'
     326 | EXPORT_SYMBOL(__ubsan_handle_shift_out_of_bounds);
         | ^~~~~~~~~~~~~
   lib/ubsan.c:287:6: note: previous definition of '__ubsan_handle_shift_out_of_bounds' with type 'void(void *, void *, void *)'
     287 | void __ubsan_handle_shift_out_of_bounds(void *_data, void *lhs, void *rhs)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/build_bug.h:5,
                    from include/linux/bits.h:22,
                    from include/linux/bitops.h:6,
                    from lib/ubsan.c:9:
>> include/linux/compiler.h:215:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     215 |         static void * __used __attrs \
         |         ^~~~~~
   include/linux/compiler.h:218:9: note: in expansion of macro '___ADDRESSABLE'
     218 |         ___ADDRESSABLE(sym, __section(".discard.addressable"))
         |         ^~~~~~~~~~~~~~
   include/linux/export.h:41:9: note: in expansion of macro '__ADDRESSABLE'
      41 |         __ADDRESSABLE(sym)                                              \
         |         ^~~~~~~~~~~~~
   include/linux/export.h:96:9: note: in expansion of macro '__KSYMTAB_ENTRY'
      96 |         __KSYMTAB_ENTRY(sym, sec)
         |         ^~~~~~~~~~~~~~~
   include/linux/export.h:140:41: note: in expansion of macro '___EXPORT_SYMBOL'
     140 | #define __EXPORT_SYMBOL(sym, sec, ns)   ___EXPORT_SYMBOL(sym, sec, ns)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:326:1: note: in expansion of macro 'EXPORT_SYMBOL'
     326 | EXPORT_SYMBOL(__ubsan_handle_shift_out_of_bounds);
         | ^~~~~~~~~~~~~
   lib/ubsan.c:329:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     329 | void __ubsan_handle_builtin_unreachable(void *_data)
         | ^~~~
   In file included from include/linux/linkage.h:7,
                    from include/linux/printk.h:8,
                    from include/asm-generic/bug.h:22,
                    from arch/x86/include/asm/bug.h:87,
                    from include/linux/bug.h:5,
                    from lib/ubsan.c:10:
   lib/ubsan.c:337:15: error: non-static declaration of '__ubsan_handle_builtin_unreachable' follows static declaration
     337 | EXPORT_SYMBOL(__ubsan_handle_builtin_unreachable);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/export.h:87:28: note: in definition of macro '___EXPORT_SYMBOL'
      87 |         extern typeof(sym) sym;                                                 \
         |                            ^~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:337:1: note: in expansion of macro 'EXPORT_SYMBOL'
     337 | EXPORT_SYMBOL(__ubsan_handle_builtin_unreachable);
         | ^~~~~~~~~~~~~
   lib/ubsan.c:329:6: note: previous definition of '__ubsan_handle_builtin_unreachable' with type 'void(void *)'
     329 | void __ubsan_handle_builtin_unreachable(void *_data)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/build_bug.h:5,
                    from include/linux/bits.h:22,
                    from include/linux/bitops.h:6,
                    from lib/ubsan.c:9:
>> include/linux/compiler.h:215:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     215 |         static void * __used __attrs \
         |         ^~~~~~
   include/linux/compiler.h:218:9: note: in expansion of macro '___ADDRESSABLE'
     218 |         ___ADDRESSABLE(sym, __section(".discard.addressable"))
         |         ^~~~~~~~~~~~~~
   include/linux/export.h:41:9: note: in expansion of macro '__ADDRESSABLE'
      41 |         __ADDRESSABLE(sym)                                              \
         |         ^~~~~~~~~~~~~
   include/linux/export.h:96:9: note: in expansion of macro '__KSYMTAB_ENTRY'
      96 |         __KSYMTAB_ENTRY(sym, sec)
         |         ^~~~~~~~~~~~~~~
   include/linux/export.h:140:41: note: in expansion of macro '___EXPORT_SYMBOL'
     140 | #define __EXPORT_SYMBOL(sym, sec, ns)   ___EXPORT_SYMBOL(sym, sec, ns)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:337:1: note: in expansion of macro 'EXPORT_SYMBOL'
     337 | EXPORT_SYMBOL(__ubsan_handle_builtin_unreachable);
         | ^~~~~~~~~~~~~
   lib/ubsan.c:339:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     339 | void __ubsan_handle_load_invalid_value(void *_data, void *val)
         | ^~~~
   In file included from include/linux/linkage.h:7,
                    from include/linux/printk.h:8,
                    from include/asm-generic/bug.h:22,
                    from arch/x86/include/asm/bug.h:87,
                    from include/linux/bug.h:5,
                    from lib/ubsan.c:10:
   lib/ubsan.c:356:15: error: non-static declaration of '__ubsan_handle_load_invalid_value' follows static declaration
     356 | EXPORT_SYMBOL(__ubsan_handle_load_invalid_value);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/export.h:87:28: note: in definition of macro '___EXPORT_SYMBOL'
      87 |         extern typeof(sym) sym;                                                 \
         |                            ^~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:356:1: note: in expansion of macro 'EXPORT_SYMBOL'
     356 | EXPORT_SYMBOL(__ubsan_handle_load_invalid_value);
         | ^~~~~~~~~~~~~
   lib/ubsan.c:339:6: note: previous definition of '__ubsan_handle_load_invalid_value' with type 'void(void *, void *)'
     339 | void __ubsan_handle_load_invalid_value(void *_data, void *val)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/build_bug.h:5,
                    from include/linux/bits.h:22,
                    from include/linux/bitops.h:6,
                    from lib/ubsan.c:9:
>> include/linux/compiler.h:215:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     215 |         static void * __used __attrs \
         |         ^~~~~~
   include/linux/compiler.h:218:9: note: in expansion of macro '___ADDRESSABLE'
     218 |         ___ADDRESSABLE(sym, __section(".discard.addressable"))
         |         ^~~~~~~~~~~~~~
   include/linux/export.h:41:9: note: in expansion of macro '__ADDRESSABLE'
      41 |         __ADDRESSABLE(sym)                                              \
         |         ^~~~~~~~~~~~~
   include/linux/export.h:96:9: note: in expansion of macro '__KSYMTAB_ENTRY'
      96 |         __KSYMTAB_ENTRY(sym, sec)
         |         ^~~~~~~~~~~~~~~
   include/linux/export.h:140:41: note: in expansion of macro '___EXPORT_SYMBOL'
     140 | #define __EXPORT_SYMBOL(sym, sec, ns)   ___EXPORT_SYMBOL(sym, sec, ns)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:356:1: note: in expansion of macro 'EXPORT_SYMBOL'
     356 | EXPORT_SYMBOL(__ubsan_handle_load_invalid_value);
         | ^~~~~~~~~~~~~
   lib/ubsan.c:358:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     358 | void __ubsan_handle_alignment_assumption(void *_data, unsigned long ptr,
         | ^~~~
   lib/ubsan.c:361:6: error: static declaration of '__ubsan_handle_alignment_assumption' follows non-static declaration
     361 | void __ubsan_handle_alignment_assumption(void *_data, unsigned long ptr,
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   lib/ubsan.c:358:6: note: previous declaration of '__ubsan_handle_alignment_assumption' with type 'void(void *, long unsigned int,  long unsigned int,  long unsigned int)'
     358 | void __ubsan_handle_alignment_assumption(void *_data, unsigned long ptr,
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/linkage.h:7,
                    from include/linux/printk.h:8,
                    from include/asm-generic/bug.h:22,
                    from arch/x86/include/asm/bug.h:87,
                    from include/linux/bug.h:5,
                    from lib/ubsan.c:10:
   lib/ubsan.c:387:15: error: non-static declaration of '__ubsan_handle_alignment_assumption' follows static declaration
     387 | EXPORT_SYMBOL(__ubsan_handle_alignment_assumption);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/export.h:87:28: note: in definition of macro '___EXPORT_SYMBOL'
      87 |         extern typeof(sym) sym;                                                 \
         |                            ^~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:387:1: note: in expansion of macro 'EXPORT_SYMBOL'
     387 | EXPORT_SYMBOL(__ubsan_handle_alignment_assumption);
         | ^~~~~~~~~~~~~
   lib/ubsan.c:361:6: note: previous definition of '__ubsan_handle_alignment_assumption' with type 'void(void *, long unsigned int,  long unsigned int,  long unsigned int)'
     361 | void __ubsan_handle_alignment_assumption(void *_data, unsigned long ptr,
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/build_bug.h:5,
                    from include/linux/bits.h:22,
                    from include/linux/bitops.h:6,
                    from lib/ubsan.c:9:
>> include/linux/compiler.h:215:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     215 |         static void * __used __attrs \
         |         ^~~~~~
   include/linux/compiler.h:218:9: note: in expansion of macro '___ADDRESSABLE'
     218 |         ___ADDRESSABLE(sym, __section(".discard.addressable"))
         |         ^~~~~~~~~~~~~~
   include/linux/export.h:41:9: note: in expansion of macro '__ADDRESSABLE'
      41 |         __ADDRESSABLE(sym)                                              \
         |         ^~~~~~~~~~~~~
   include/linux/export.h:96:9: note: in expansion of macro '__KSYMTAB_ENTRY'
      96 |         __KSYMTAB_ENTRY(sym, sec)
         |         ^~~~~~~~~~~~~~~
   include/linux/export.h:140:41: note: in expansion of macro '___EXPORT_SYMBOL'
     140 | #define __EXPORT_SYMBOL(sym, sec, ns)   ___EXPORT_SYMBOL(sym, sec, ns)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:387:1: note: in expansion of macro 'EXPORT_SYMBOL'
     387 | EXPORT_SYMBOL(__ubsan_handle_alignment_assumption);
         | ^~~~~~~~~~~~~
   lib/ubsan.c:387:1: error: expected declaration or statement at end of input
   In file included from include/linux/linkage.h:7,
                    from include/linux/printk.h:8,
                    from include/asm-generic/bug.h:22,
                    from arch/x86/include/asm/bug.h:87,
                    from include/linux/bug.h:5,
                    from lib/ubsan.c:10:
>> include/linux/export.h:89:27: warning: unused variable '__kstrtabns___ubsan_handle_alignment_assumption' [-Wunused-variable]
      89 |         extern const char __kstrtabns_##sym[];                                  \
         |                           ^~~~~~~~~~~~
   include/linux/export.h:140:41: note: in expansion of macro '___EXPORT_SYMBOL'
     140 | #define __EXPORT_SYMBOL(sym, sec, ns)   ___EXPORT_SYMBOL(sym, sec, ns)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:387:1: note: in expansion of macro 'EXPORT_SYMBOL'
     387 | EXPORT_SYMBOL(__ubsan_handle_alignment_assumption);
         | ^~~~~~~~~~~~~
>> include/linux/export.h:88:27: warning: unused variable '__kstrtab___ubsan_handle_alignment_assumption' [-Wunused-variable]
      88 |         extern const char __kstrtab_##sym[];                                    \
         |                           ^~~~~~~~~~
   include/linux/export.h:140:41: note: in expansion of macro '___EXPORT_SYMBOL'
     140 | #define __EXPORT_SYMBOL(sym, sec, ns)   ___EXPORT_SYMBOL(sym, sec, ns)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:387:1: note: in expansion of macro 'EXPORT_SYMBOL'
     387 | EXPORT_SYMBOL(__ubsan_handle_alignment_assumption);
         | ^~~~~~~~~~~~~
>> include/linux/export.h:89:27: warning: unused variable '__kstrtabns___ubsan_handle_load_invalid_value' [-Wunused-variable]
      89 |         extern const char __kstrtabns_##sym[];                                  \
         |                           ^~~~~~~~~~~~
   include/linux/export.h:140:41: note: in expansion of macro '___EXPORT_SYMBOL'
     140 | #define __EXPORT_SYMBOL(sym, sec, ns)   ___EXPORT_SYMBOL(sym, sec, ns)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:356:1: note: in expansion of macro 'EXPORT_SYMBOL'
     356 | EXPORT_SYMBOL(__ubsan_handle_load_invalid_value);
         | ^~~~~~~~~~~~~
>> include/linux/export.h:88:27: warning: unused variable '__kstrtab___ubsan_handle_load_invalid_value' [-Wunused-variable]
      88 |         extern const char __kstrtab_##sym[];                                    \
         |                           ^~~~~~~~~~
   include/linux/export.h:140:41: note: in expansion of macro '___EXPORT_SYMBOL'
     140 | #define __EXPORT_SYMBOL(sym, sec, ns)   ___EXPORT_SYMBOL(sym, sec, ns)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:356:1: note: in expansion of macro 'EXPORT_SYMBOL'
     356 | EXPORT_SYMBOL(__ubsan_handle_load_invalid_value);
         | ^~~~~~~~~~~~~
>> include/linux/export.h:89:27: warning: unused variable '__kstrtabns___ubsan_handle_builtin_unreachable' [-Wunused-variable]
      89 |         extern const char __kstrtabns_##sym[];                                  \
         |                           ^~~~~~~~~~~~
   include/linux/export.h:140:41: note: in expansion of macro '___EXPORT_SYMBOL'
     140 | #define __EXPORT_SYMBOL(sym, sec, ns)   ___EXPORT_SYMBOL(sym, sec, ns)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:337:1: note: in expansion of macro 'EXPORT_SYMBOL'
     337 | EXPORT_SYMBOL(__ubsan_handle_builtin_unreachable);
         | ^~~~~~~~~~~~~
>> include/linux/export.h:88:27: warning: unused variable '__kstrtab___ubsan_handle_builtin_unreachable' [-Wunused-variable]
      88 |         extern const char __kstrtab_##sym[];                                    \
         |                           ^~~~~~~~~~
   include/linux/export.h:140:41: note: in expansion of macro '___EXPORT_SYMBOL'
     140 | #define __EXPORT_SYMBOL(sym, sec, ns)   ___EXPORT_SYMBOL(sym, sec, ns)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:337:1: note: in expansion of macro 'EXPORT_SYMBOL'
     337 | EXPORT_SYMBOL(__ubsan_handle_builtin_unreachable);
         | ^~~~~~~~~~~~~
>> include/linux/export.h:89:27: warning: unused variable '__kstrtabns___ubsan_handle_shift_out_of_bounds' [-Wunused-variable]
      89 |         extern const char __kstrtabns_##sym[];                                  \
         |                           ^~~~~~~~~~~~
   include/linux/export.h:140:41: note: in expansion of macro '___EXPORT_SYMBOL'
     140 | #define __EXPORT_SYMBOL(sym, sec, ns)   ___EXPORT_SYMBOL(sym, sec, ns)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:326:1: note: in expansion of macro 'EXPORT_SYMBOL'
     326 | EXPORT_SYMBOL(__ubsan_handle_shift_out_of_bounds);
         | ^~~~~~~~~~~~~
>> include/linux/export.h:88:27: warning: unused variable '__kstrtab___ubsan_handle_shift_out_of_bounds' [-Wunused-variable]
      88 |         extern const char __kstrtab_##sym[];                                    \
         |                           ^~~~~~~~~~
   include/linux/export.h:140:41: note: in expansion of macro '___EXPORT_SYMBOL'
     140 | #define __EXPORT_SYMBOL(sym, sec, ns)   ___EXPORT_SYMBOL(sym, sec, ns)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:326:1: note: in expansion of macro 'EXPORT_SYMBOL'
     326 | EXPORT_SYMBOL(__ubsan_handle_shift_out_of_bounds);
         | ^~~~~~~~~~~~~
>> include/linux/export.h:89:27: warning: unused variable '__kstrtabns___ubsan_handle_out_of_bounds' [-Wunused-variable]
      89 |         extern const char __kstrtabns_##sym[];                                  \
         |                           ^~~~~~~~~~~~
   include/linux/export.h:140:41: note: in expansion of macro '___EXPORT_SYMBOL'
     140 | #define __EXPORT_SYMBOL(sym, sec, ns)   ___EXPORT_SYMBOL(sym, sec, ns)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:285:1: note: in expansion of macro 'EXPORT_SYMBOL'
     285 | EXPORT_SYMBOL(__ubsan_handle_out_of_bounds);
         | ^~~~~~~~~~~~~
>> include/linux/export.h:88:27: warning: unused variable '__kstrtab___ubsan_handle_out_of_bounds' [-Wunused-variable]
      88 |         extern const char __kstrtab_##sym[];                                    \
         |                           ^~~~~~~~~~
   include/linux/export.h:140:41: note: in expansion of macro '___EXPORT_SYMBOL'
     140 | #define __EXPORT_SYMBOL(sym, sec, ns)   ___EXPORT_SYMBOL(sym, sec, ns)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:285:1: note: in expansion of macro 'EXPORT_SYMBOL'
     285 | EXPORT_SYMBOL(__ubsan_handle_out_of_bounds);
         | ^~~~~~~~~~~~~
>> include/linux/export.h:89:27: warning: unused variable '__kstrtabns___ubsan_handle_type_mismatch_v1' [-Wunused-variable]
      89 |         extern const char __kstrtabns_##sym[];                                  \
         |                           ^~~~~~~~~~~~
   include/linux/export.h:140:41: note: in expansion of macro '___EXPORT_SYMBOL'
     140 | #define __EXPORT_SYMBOL(sym, sec, ns)   ___EXPORT_SYMBOL(sym, sec, ns)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:268:1: note: in expansion of macro 'EXPORT_SYMBOL'
     268 | EXPORT_SYMBOL(__ubsan_handle_type_mismatch_v1);
         | ^~~~~~~~~~~~~
>> include/linux/export.h:88:27: warning: unused variable '__kstrtab___ubsan_handle_type_mismatch_v1' [-Wunused-variable]
      88 |         extern const char __kstrtab_##sym[];                                    \
         |                           ^~~~~~~~~~
   include/linux/export.h:140:41: note: in expansion of macro '___EXPORT_SYMBOL'
     140 | #define __EXPORT_SYMBOL(sym, sec, ns)   ___EXPORT_SYMBOL(sym, sec, ns)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:268:1: note: in expansion of macro 'EXPORT_SYMBOL'
     268 | EXPORT_SYMBOL(__ubsan_handle_type_mismatch_v1);
         | ^~~~~~~~~~~~~
   include/linux/export.h:89:27: warning: unused variable '__kstrtabns___ubsan_handle_type_mismatch' [-Wunused-variable]
      89 |         extern const char __kstrtabns_##sym[];                                  \
         |                           ^~~~~~~~~~~~
   include/linux/export.h:140:41: note: in expansion of macro '___EXPORT_SYMBOL'
     140 | #define __EXPORT_SYMBOL(sym, sec, ns)   ___EXPORT_SYMBOL(sym, sec, ns)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:254:1: note: in expansion of macro 'EXPORT_SYMBOL'
     254 | EXPORT_SYMBOL(__ubsan_handle_type_mismatch);
         | ^~~~~~~~~~~~~
   include/linux/export.h:88:27: warning: unused variable '__kstrtab___ubsan_handle_type_mismatch' [-Wunused-variable]
      88 |         extern const char __kstrtab_##sym[];                                    \
         |                           ^~~~~~~~~~
   include/linux/export.h:140:41: note: in expansion of macro '___EXPORT_SYMBOL'
     140 | #define __EXPORT_SYMBOL(sym, sec, ns)   ___EXPORT_SYMBOL(sym, sec, ns)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:254:1: note: in expansion of macro 'EXPORT_SYMBOL'
     254 | EXPORT_SYMBOL(__ubsan_handle_type_mismatch);
         | ^~~~~~~~~~~~~
   include/linux/export.h:89:27: warning: unused variable '__kstrtabns___ubsan_handle_divrem_overflow' [-Wunused-variable]
      89 |         extern const char __kstrtabns_##sym[];                                  \
         |                           ^~~~~~~~~~~~
   include/linux/export.h:140:41: note: in expansion of macro '___EXPORT_SYMBOL'
     140 | #define __EXPORT_SYMBOL(sym, sec, ns)   ___EXPORT_SYMBOL(sym, sec, ns)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:181:1: note: in expansion of macro 'EXPORT_SYMBOL'
     181 | EXPORT_SYMBOL(__ubsan_handle_divrem_overflow);
         | ^~~~~~~~~~~~~
   include/linux/export.h:88:27: warning: unused variable '__kstrtab___ubsan_handle_divrem_overflow' [-Wunused-variable]
      88 |         extern const char __kstrtab_##sym[];                                    \
         |                           ^~~~~~~~~~
   include/linux/export.h:140:41: note: in expansion of macro '___EXPORT_SYMBOL'
     140 | #define __EXPORT_SYMBOL(sym, sec, ns)   ___EXPORT_SYMBOL(sym, sec, ns)
         |                                         ^~~~~~~~~~~~~~~~
   include/linux/export.h:147:41: note: in expansion of macro '__EXPORT_SYMBOL'
     147 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:150:41: note: in expansion of macro '_EXPORT_SYMBOL'
     150 | #define EXPORT_SYMBOL(sym)              _EXPORT_SYMBOL(sym, "")
         |                                         ^~~~~~~~~~~~~~
   lib/ubsan.c:181:1: note: in expansion of macro 'EXPORT_SYMBOL'
     181 | EXPORT_SYMBOL(__ubsan_handle_divrem_overflow);
         | ^~~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +215 include/linux/compiler.h

^1da177e4c3f41 Linus Torvalds 2005-04-16  207  
7290d58095712a Ard Biesheuvel 2018-08-21  208  /*
7290d58095712a Ard Biesheuvel 2018-08-21  209   * Force the compiler to emit 'sym' as a symbol, so that we can reference
7290d58095712a Ard Biesheuvel 2018-08-21  210   * it from inline assembler. Necessary in case 'sym' could be inlined
7290d58095712a Ard Biesheuvel 2018-08-21  211   * otherwise, or eliminated entirely due to lack of references that are
7290d58095712a Ard Biesheuvel 2018-08-21  212   * visible to the compiler.
7290d58095712a Ard Biesheuvel 2018-08-21  213   */
92efda8eb15295 Sami Tolvanen  2022-09-08  214  #define ___ADDRESSABLE(sym, __attrs) \
92efda8eb15295 Sami Tolvanen  2022-09-08 @215  	static void * __used __attrs \
563a02b0c9704f Josh Poimboeuf 2020-08-18  216  		__UNIQUE_ID(__PASTE(__addressable_,sym)) = (void *)&sym;
92efda8eb15295 Sami Tolvanen  2022-09-08  217  #define __ADDRESSABLE(sym) \
92efda8eb15295 Sami Tolvanen  2022-09-08  218  	___ADDRESSABLE(sym, __section(".discard.addressable"))
7290d58095712a Ard Biesheuvel 2018-08-21  219
  
kernel test robot Oct. 21, 2022, 2:47 p.m. UTC | #4
Hi David,

I love your patch! Yet something to improve:

[auto build test ERROR on kees/for-next/pstore]
[also build test ERROR on linus/master v6.1-rc1 next-20221021]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/David-Gow/kunit-Provide-a-static-key-to-check-if-KUnit-is-actively-running-tests/20221021-153225
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/pstore
patch link:    https://lore.kernel.org/r/20221021072854.333010-2-davidgow%40google.com
patch subject: [PATCH 2/2] kunit: Use the static key in kunit_fail_current_test()
config: hexagon-randconfig-r021-20221019
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 791a7ae1ba3efd6bca96338e10ffde557ba83920)
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
        # https://github.com/intel-lab-lkp/linux/commit/6a21df30828089657bb7d56ce48a6188a4468878
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review David-Gow/kunit-Provide-a-static-key-to-check-if-KUnit-is-actively-running-tests/20221021-153225
        git checkout 6a21df30828089657bb7d56ce48a6188a4468878
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> lib/ubsan.c:149:1: error: expected 'while' in do/while loop
   static void ubsan_epilogue(void)
   ^
   lib/ubsan.c:146:2: note: to match this 'do'
           kunit_fail_current_test("%s in %s", reason, loc->file_name);
           ^
   include/kunit/test-bug.h:19:43: note: expanded from macro 'kunit_fail_current_test'
   #define kunit_fail_current_test(fmt, ...) do {                                  \
                                             ^
>> lib/ubsan.c:181:15: error: use of undeclared identifier '__ubsan_handle_divrem_overflow'
   EXPORT_SYMBOL(__ubsan_handle_divrem_overflow);
                 ^
>> lib/ubsan.c:184:1: error: function definition is not allowed here
   {
   ^
   lib/ubsan.c:199:1: error: function definition is not allowed here
   {
   ^
   lib/ubsan.c:215:1: error: function definition is not allowed here
   {
   ^
   lib/ubsan.c:229:1: error: function definition is not allowed here
   {
   ^
   lib/ubsan.c:244:1: error: function definition is not allowed here
   {
   ^
>> lib/ubsan.c:254:15: error: use of undeclared identifier '__ubsan_handle_type_mismatch'
   EXPORT_SYMBOL(__ubsan_handle_type_mismatch);
                 ^
   lib/ubsan.c:257:1: error: function definition is not allowed here
   {
   ^
>> lib/ubsan.c:268:15: error: use of undeclared identifier '__ubsan_handle_type_mismatch_v1'
   EXPORT_SYMBOL(__ubsan_handle_type_mismatch_v1);
                 ^
   lib/ubsan.c:271:1: error: function definition is not allowed here
   {
   ^
>> lib/ubsan.c:285:15: error: use of undeclared identifier '__ubsan_handle_out_of_bounds'
   EXPORT_SYMBOL(__ubsan_handle_out_of_bounds);
                 ^
   lib/ubsan.c:288:1: error: function definition is not allowed here
   {
   ^
>> lib/ubsan.c:326:15: error: use of undeclared identifier '__ubsan_handle_shift_out_of_bounds'
   EXPORT_SYMBOL(__ubsan_handle_shift_out_of_bounds);
                 ^
   lib/ubsan.c:330:1: error: function definition is not allowed here
   {
   ^
>> lib/ubsan.c:337:15: error: use of undeclared identifier '__ubsan_handle_builtin_unreachable'
   EXPORT_SYMBOL(__ubsan_handle_builtin_unreachable);
                 ^
   lib/ubsan.c:340:1: error: function definition is not allowed here
   {
   ^
>> lib/ubsan.c:356:15: error: use of undeclared identifier '__ubsan_handle_load_invalid_value'
   EXPORT_SYMBOL(__ubsan_handle_load_invalid_value);
                 ^
   lib/ubsan.c:364:1: error: function definition is not allowed here
   {
   ^
   fatal error: too many errors emitted, stopping now [-ferror-limit=]
   20 errors generated.


vim +/while +149 lib/ubsan.c

c6d308534aef6c Andrey Ryabinin 2016-01-20  148  
ce5c31db3645b6 Julien Grall    2019-12-04 @149  static void ubsan_epilogue(void)
c6d308534aef6c Andrey Ryabinin 2016-01-20  150  {
c6d308534aef6c Andrey Ryabinin 2016-01-20  151  	dump_stack();
c6d308534aef6c Andrey Ryabinin 2016-01-20  152  	pr_err("========================================"
c6d308534aef6c Andrey Ryabinin 2016-01-20  153  		"========================================\n");
ce5c31db3645b6 Julien Grall    2019-12-04  154  
c6d308534aef6c Andrey Ryabinin 2016-01-20  155  	current->in_ubsan--;
1d28c8d6d076ef Kees Cook       2020-04-06  156  
d83ce027a54068 Tiezhu Yang     2022-03-23  157  	if (panic_on_warn)
1d28c8d6d076ef Kees Cook       2020-04-06  158  		panic("panic_on_warn set ...\n");
1d28c8d6d076ef Kees Cook       2020-04-06  159  }
c6d308534aef6c Andrey Ryabinin 2016-01-20  160  
469cbd016157d2 Arnd Bergmann   2020-06-04  161  void __ubsan_handle_divrem_overflow(void *_data, void *lhs, void *rhs)
c6d308534aef6c Andrey Ryabinin 2016-01-20  162  {
469cbd016157d2 Arnd Bergmann   2020-06-04  163  	struct overflow_data *data = _data;
c6d308534aef6c Andrey Ryabinin 2016-01-20  164  	char rhs_val_str[VALUE_LENGTH];
c6d308534aef6c Andrey Ryabinin 2016-01-20  165  
c6d308534aef6c Andrey Ryabinin 2016-01-20  166  	if (suppress_report(&data->location))
c6d308534aef6c Andrey Ryabinin 2016-01-20  167  		return;
c6d308534aef6c Andrey Ryabinin 2016-01-20  168  
ef065653e526a0 Kees Cook       2020-04-06  169  	ubsan_prologue(&data->location, "division-overflow");
c6d308534aef6c Andrey Ryabinin 2016-01-20  170  
c6d308534aef6c Andrey Ryabinin 2016-01-20  171  	val_to_string(rhs_val_str, sizeof(rhs_val_str), data->type, rhs);
c6d308534aef6c Andrey Ryabinin 2016-01-20  172  
c6d308534aef6c Andrey Ryabinin 2016-01-20  173  	if (type_is_signed(data->type) && get_signed_val(data->type, rhs) == -1)
c6d308534aef6c Andrey Ryabinin 2016-01-20  174  		pr_err("division of %s by -1 cannot be represented in type %s\n",
c6d308534aef6c Andrey Ryabinin 2016-01-20  175  			rhs_val_str, data->type->type_name);
c6d308534aef6c Andrey Ryabinin 2016-01-20  176  	else
c6d308534aef6c Andrey Ryabinin 2016-01-20  177  		pr_err("division by zero\n");
c6d308534aef6c Andrey Ryabinin 2016-01-20  178  
ce5c31db3645b6 Julien Grall    2019-12-04  179  	ubsan_epilogue();
c6d308534aef6c Andrey Ryabinin 2016-01-20  180  }
c6d308534aef6c Andrey Ryabinin 2016-01-20 @181  EXPORT_SYMBOL(__ubsan_handle_divrem_overflow);
c6d308534aef6c Andrey Ryabinin 2016-01-20  182  
42440c1f9911b4 Andrey Ryabinin 2018-02-06  183  static void handle_null_ptr_deref(struct type_mismatch_data_common *data)
c6d308534aef6c Andrey Ryabinin 2016-01-20 @184  {
42440c1f9911b4 Andrey Ryabinin 2018-02-06  185  	if (suppress_report(data->location))
c6d308534aef6c Andrey Ryabinin 2016-01-20  186  		return;
c6d308534aef6c Andrey Ryabinin 2016-01-20  187  
ef065653e526a0 Kees Cook       2020-04-06  188  	ubsan_prologue(data->location, "null-ptr-deref");
c6d308534aef6c Andrey Ryabinin 2016-01-20  189  
c6d308534aef6c Andrey Ryabinin 2016-01-20  190  	pr_err("%s null pointer of type %s\n",
c6d308534aef6c Andrey Ryabinin 2016-01-20  191  		type_check_kinds[data->type_check_kind],
c6d308534aef6c Andrey Ryabinin 2016-01-20  192  		data->type->type_name);
c6d308534aef6c Andrey Ryabinin 2016-01-20  193  
ce5c31db3645b6 Julien Grall    2019-12-04  194  	ubsan_epilogue();
c6d308534aef6c Andrey Ryabinin 2016-01-20  195  }
c6d308534aef6c Andrey Ryabinin 2016-01-20  196  
42440c1f9911b4 Andrey Ryabinin 2018-02-06  197  static void handle_misaligned_access(struct type_mismatch_data_common *data,
c6d308534aef6c Andrey Ryabinin 2016-01-20  198  				unsigned long ptr)
c6d308534aef6c Andrey Ryabinin 2016-01-20  199  {
42440c1f9911b4 Andrey Ryabinin 2018-02-06  200  	if (suppress_report(data->location))
c6d308534aef6c Andrey Ryabinin 2016-01-20  201  		return;
c6d308534aef6c Andrey Ryabinin 2016-01-20  202  
ef065653e526a0 Kees Cook       2020-04-06  203  	ubsan_prologue(data->location, "misaligned-access");
c6d308534aef6c Andrey Ryabinin 2016-01-20  204  
c6d308534aef6c Andrey Ryabinin 2016-01-20  205  	pr_err("%s misaligned address %p for type %s\n",
c6d308534aef6c Andrey Ryabinin 2016-01-20  206  		type_check_kinds[data->type_check_kind],
c6d308534aef6c Andrey Ryabinin 2016-01-20  207  		(void *)ptr, data->type->type_name);
c6d308534aef6c Andrey Ryabinin 2016-01-20  208  	pr_err("which requires %ld byte alignment\n", data->alignment);
c6d308534aef6c Andrey Ryabinin 2016-01-20  209  
ce5c31db3645b6 Julien Grall    2019-12-04  210  	ubsan_epilogue();
c6d308534aef6c Andrey Ryabinin 2016-01-20  211  }
c6d308534aef6c Andrey Ryabinin 2016-01-20  212  
42440c1f9911b4 Andrey Ryabinin 2018-02-06  213  static void handle_object_size_mismatch(struct type_mismatch_data_common *data,
c6d308534aef6c Andrey Ryabinin 2016-01-20  214  					unsigned long ptr)
c6d308534aef6c Andrey Ryabinin 2016-01-20  215  {
42440c1f9911b4 Andrey Ryabinin 2018-02-06  216  	if (suppress_report(data->location))
c6d308534aef6c Andrey Ryabinin 2016-01-20  217  		return;
c6d308534aef6c Andrey Ryabinin 2016-01-20  218  
ef065653e526a0 Kees Cook       2020-04-06  219  	ubsan_prologue(data->location, "object-size-mismatch");
901d805c33fc4c Nicolas Iooss   2016-08-02  220  	pr_err("%s address %p with insufficient space\n",
c6d308534aef6c Andrey Ryabinin 2016-01-20  221  		type_check_kinds[data->type_check_kind],
c6d308534aef6c Andrey Ryabinin 2016-01-20  222  		(void *) ptr);
c6d308534aef6c Andrey Ryabinin 2016-01-20  223  	pr_err("for an object of type %s\n", data->type->type_name);
ce5c31db3645b6 Julien Grall    2019-12-04  224  	ubsan_epilogue();
c6d308534aef6c Andrey Ryabinin 2016-01-20  225  }
c6d308534aef6c Andrey Ryabinin 2016-01-20  226  
42440c1f9911b4 Andrey Ryabinin 2018-02-06  227  static void ubsan_type_mismatch_common(struct type_mismatch_data_common *data,
c6d308534aef6c Andrey Ryabinin 2016-01-20  228  				unsigned long ptr)
c6d308534aef6c Andrey Ryabinin 2016-01-20  229  {
d08965a27e84ca Peter Zijlstra  2019-04-03  230  	unsigned long flags = user_access_save();
c6d308534aef6c Andrey Ryabinin 2016-01-20  231  
c6d308534aef6c Andrey Ryabinin 2016-01-20  232  	if (!ptr)
c6d308534aef6c Andrey Ryabinin 2016-01-20  233  		handle_null_ptr_deref(data);
c6d308534aef6c Andrey Ryabinin 2016-01-20  234  	else if (data->alignment && !IS_ALIGNED(ptr, data->alignment))
b8fe1120b4ba34 Andrew Morton   2018-02-06  235  		handle_misaligned_access(data, ptr);
c6d308534aef6c Andrey Ryabinin 2016-01-20  236  	else
c6d308534aef6c Andrey Ryabinin 2016-01-20  237  		handle_object_size_mismatch(data, ptr);
d08965a27e84ca Peter Zijlstra  2019-04-03  238  
d08965a27e84ca Peter Zijlstra  2019-04-03  239  	user_access_restore(flags);
c6d308534aef6c Andrey Ryabinin 2016-01-20  240  }
42440c1f9911b4 Andrey Ryabinin 2018-02-06  241  
42440c1f9911b4 Andrey Ryabinin 2018-02-06  242  void __ubsan_handle_type_mismatch(struct type_mismatch_data *data,
f0996bc2978e02 Andrey Ryabinin 2019-05-06  243  				void *ptr)
42440c1f9911b4 Andrey Ryabinin 2018-02-06  244  {
42440c1f9911b4 Andrey Ryabinin 2018-02-06  245  	struct type_mismatch_data_common common_data = {
42440c1f9911b4 Andrey Ryabinin 2018-02-06  246  		.location = &data->location,
42440c1f9911b4 Andrey Ryabinin 2018-02-06  247  		.type = data->type,
42440c1f9911b4 Andrey Ryabinin 2018-02-06  248  		.alignment = data->alignment,
42440c1f9911b4 Andrey Ryabinin 2018-02-06  249  		.type_check_kind = data->type_check_kind
42440c1f9911b4 Andrey Ryabinin 2018-02-06  250  	};
42440c1f9911b4 Andrey Ryabinin 2018-02-06  251  
f0996bc2978e02 Andrey Ryabinin 2019-05-06  252  	ubsan_type_mismatch_common(&common_data, (unsigned long)ptr);
42440c1f9911b4 Andrey Ryabinin 2018-02-06  253  }
c6d308534aef6c Andrey Ryabinin 2016-01-20 @254  EXPORT_SYMBOL(__ubsan_handle_type_mismatch);
c6d308534aef6c Andrey Ryabinin 2016-01-20  255  
469cbd016157d2 Arnd Bergmann   2020-06-04  256  void __ubsan_handle_type_mismatch_v1(void *_data, void *ptr)
42440c1f9911b4 Andrey Ryabinin 2018-02-06  257  {
469cbd016157d2 Arnd Bergmann   2020-06-04  258  	struct type_mismatch_data_v1 *data = _data;
42440c1f9911b4 Andrey Ryabinin 2018-02-06  259  	struct type_mismatch_data_common common_data = {
42440c1f9911b4 Andrey Ryabinin 2018-02-06  260  		.location = &data->location,
42440c1f9911b4 Andrey Ryabinin 2018-02-06  261  		.type = data->type,
42440c1f9911b4 Andrey Ryabinin 2018-02-06  262  		.alignment = 1UL << data->log_alignment,
42440c1f9911b4 Andrey Ryabinin 2018-02-06  263  		.type_check_kind = data->type_check_kind
42440c1f9911b4 Andrey Ryabinin 2018-02-06  264  	};
42440c1f9911b4 Andrey Ryabinin 2018-02-06  265  
f0996bc2978e02 Andrey Ryabinin 2019-05-06  266  	ubsan_type_mismatch_common(&common_data, (unsigned long)ptr);
42440c1f9911b4 Andrey Ryabinin 2018-02-06  267  }
42440c1f9911b4 Andrey Ryabinin 2018-02-06 @268  EXPORT_SYMBOL(__ubsan_handle_type_mismatch_v1);
42440c1f9911b4 Andrey Ryabinin 2018-02-06  269  
469cbd016157d2 Arnd Bergmann   2020-06-04  270  void __ubsan_handle_out_of_bounds(void *_data, void *index)
c6d308534aef6c Andrey Ryabinin 2016-01-20  271  {
469cbd016157d2 Arnd Bergmann   2020-06-04  272  	struct out_of_bounds_data *data = _data;
c6d308534aef6c Andrey Ryabinin 2016-01-20  273  	char index_str[VALUE_LENGTH];
c6d308534aef6c Andrey Ryabinin 2016-01-20  274  
c6d308534aef6c Andrey Ryabinin 2016-01-20  275  	if (suppress_report(&data->location))
c6d308534aef6c Andrey Ryabinin 2016-01-20  276  		return;
c6d308534aef6c Andrey Ryabinin 2016-01-20  277  
ef065653e526a0 Kees Cook       2020-04-06  278  	ubsan_prologue(&data->location, "array-index-out-of-bounds");
c6d308534aef6c Andrey Ryabinin 2016-01-20  279  
c6d308534aef6c Andrey Ryabinin 2016-01-20  280  	val_to_string(index_str, sizeof(index_str), data->index_type, index);
c6d308534aef6c Andrey Ryabinin 2016-01-20  281  	pr_err("index %s is out of range for type %s\n", index_str,
c6d308534aef6c Andrey Ryabinin 2016-01-20  282  		data->array_type->type_name);
ce5c31db3645b6 Julien Grall    2019-12-04  283  	ubsan_epilogue();
c6d308534aef6c Andrey Ryabinin 2016-01-20  284  }
c6d308534aef6c Andrey Ryabinin 2016-01-20 @285  EXPORT_SYMBOL(__ubsan_handle_out_of_bounds);
c6d308534aef6c Andrey Ryabinin 2016-01-20  286  
469cbd016157d2 Arnd Bergmann   2020-06-04  287  void __ubsan_handle_shift_out_of_bounds(void *_data, void *lhs, void *rhs)
c6d308534aef6c Andrey Ryabinin 2016-01-20  288  {
469cbd016157d2 Arnd Bergmann   2020-06-04  289  	struct shift_out_of_bounds_data *data = _data;
c6d308534aef6c Andrey Ryabinin 2016-01-20  290  	struct type_descriptor *rhs_type = data->rhs_type;
c6d308534aef6c Andrey Ryabinin 2016-01-20  291  	struct type_descriptor *lhs_type = data->lhs_type;
c6d308534aef6c Andrey Ryabinin 2016-01-20  292  	char rhs_str[VALUE_LENGTH];
c6d308534aef6c Andrey Ryabinin 2016-01-20  293  	char lhs_str[VALUE_LENGTH];
9a50dcaf0416a4 Peter Zijlstra  2019-10-21  294  	unsigned long ua_flags = user_access_save();
c6d308534aef6c Andrey Ryabinin 2016-01-20  295  
c6d308534aef6c Andrey Ryabinin 2016-01-20  296  	if (suppress_report(&data->location))
9a50dcaf0416a4 Peter Zijlstra  2019-10-21  297  		goto out;
c6d308534aef6c Andrey Ryabinin 2016-01-20  298  
ef065653e526a0 Kees Cook       2020-04-06  299  	ubsan_prologue(&data->location, "shift-out-of-bounds");
c6d308534aef6c Andrey Ryabinin 2016-01-20  300  
c6d308534aef6c Andrey Ryabinin 2016-01-20  301  	val_to_string(rhs_str, sizeof(rhs_str), rhs_type, rhs);
c6d308534aef6c Andrey Ryabinin 2016-01-20  302  	val_to_string(lhs_str, sizeof(lhs_str), lhs_type, lhs);
c6d308534aef6c Andrey Ryabinin 2016-01-20  303  
c6d308534aef6c Andrey Ryabinin 2016-01-20  304  	if (val_is_negative(rhs_type, rhs))
c6d308534aef6c Andrey Ryabinin 2016-01-20  305  		pr_err("shift exponent %s is negative\n", rhs_str);
c6d308534aef6c Andrey Ryabinin 2016-01-20  306  
c6d308534aef6c Andrey Ryabinin 2016-01-20  307  	else if (get_unsigned_val(rhs_type, rhs) >=
c6d308534aef6c Andrey Ryabinin 2016-01-20  308  		type_bit_width(lhs_type))
c6d308534aef6c Andrey Ryabinin 2016-01-20  309  		pr_err("shift exponent %s is too large for %u-bit type %s\n",
c6d308534aef6c Andrey Ryabinin 2016-01-20  310  			rhs_str,
c6d308534aef6c Andrey Ryabinin 2016-01-20  311  			type_bit_width(lhs_type),
c6d308534aef6c Andrey Ryabinin 2016-01-20  312  			lhs_type->type_name);
c6d308534aef6c Andrey Ryabinin 2016-01-20  313  	else if (val_is_negative(lhs_type, lhs))
c6d308534aef6c Andrey Ryabinin 2016-01-20  314  		pr_err("left shift of negative value %s\n",
c6d308534aef6c Andrey Ryabinin 2016-01-20  315  			lhs_str);
c6d308534aef6c Andrey Ryabinin 2016-01-20  316  	else
c6d308534aef6c Andrey Ryabinin 2016-01-20  317  		pr_err("left shift of %s by %s places cannot be"
c6d308534aef6c Andrey Ryabinin 2016-01-20  318  			" represented in type %s\n",
c6d308534aef6c Andrey Ryabinin 2016-01-20  319  			lhs_str, rhs_str,
c6d308534aef6c Andrey Ryabinin 2016-01-20  320  			lhs_type->type_name);
c6d308534aef6c Andrey Ryabinin 2016-01-20  321  
ce5c31db3645b6 Julien Grall    2019-12-04  322  	ubsan_epilogue();
9a50dcaf0416a4 Peter Zijlstra  2019-10-21  323  out:
9a50dcaf0416a4 Peter Zijlstra  2019-10-21  324  	user_access_restore(ua_flags);
c6d308534aef6c Andrey Ryabinin 2016-01-20  325  }
c6d308534aef6c Andrey Ryabinin 2016-01-20 @326  EXPORT_SYMBOL(__ubsan_handle_shift_out_of_bounds);
c6d308534aef6c Andrey Ryabinin 2016-01-20  327  
c6d308534aef6c Andrey Ryabinin 2016-01-20  328  
469cbd016157d2 Arnd Bergmann   2020-06-04  329  void __ubsan_handle_builtin_unreachable(void *_data)
c6d308534aef6c Andrey Ryabinin 2016-01-20  330  {
469cbd016157d2 Arnd Bergmann   2020-06-04  331  	struct unreachable_data *data = _data;
ef065653e526a0 Kees Cook       2020-04-06  332  	ubsan_prologue(&data->location, "unreachable");
c6d308534aef6c Andrey Ryabinin 2016-01-20  333  	pr_err("calling __builtin_unreachable()\n");
ce5c31db3645b6 Julien Grall    2019-12-04  334  	ubsan_epilogue();
c6d308534aef6c Andrey Ryabinin 2016-01-20  335  	panic("can't return from __builtin_unreachable()");
c6d308534aef6c Andrey Ryabinin 2016-01-20  336  }
c6d308534aef6c Andrey Ryabinin 2016-01-20 @337  EXPORT_SYMBOL(__ubsan_handle_builtin_unreachable);
c6d308534aef6c Andrey Ryabinin 2016-01-20  338
  
kernel test robot Oct. 21, 2022, 7:31 p.m. UTC | #5
Hi David,

I love your patch! Yet something to improve:

[auto build test ERROR on kees/for-next/pstore]
[also build test ERROR on linus/master v6.1-rc1 next-20221021]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/David-Gow/kunit-Provide-a-static-key-to-check-if-KUnit-is-actively-running-tests/20221021-153225
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/pstore
patch link:    https://lore.kernel.org/r/20221021072854.333010-2-davidgow%40google.com
patch subject: [PATCH 2/2] kunit: Use the static key in kunit_fail_current_test()
config: s390-randconfig-r024-20221019
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 791a7ae1ba3efd6bca96338e10ffde557ba83920)
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/intel-lab-lkp/linux/commit/6a21df30828089657bb7d56ce48a6188a4468878
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review David-Gow/kunit-Provide-a-static-key-to-check-if-KUnit-is-actively-running-tests/20221021-153225
        git checkout 6a21df30828089657bb7d56ce48a6188a4468878
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=s390 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   lib/ubsan.c:149:1: error: expected 'while' in do/while loop
   static void ubsan_epilogue(void)
   ^
   lib/ubsan.c:146:2: note: to match this 'do'
           kunit_fail_current_test("%s in %s", reason, loc->file_name);
           ^
   include/kunit/test-bug.h:19:43: note: expanded from macro 'kunit_fail_current_test'
   #define kunit_fail_current_test(fmt, ...) do {                                  \
                                             ^
   lib/ubsan.c:184:1: error: function definition is not allowed here
   {
   ^
   lib/ubsan.c:199:1: error: function definition is not allowed here
   {
   ^
   lib/ubsan.c:215:1: error: function definition is not allowed here
   {
   ^
   lib/ubsan.c:229:1: error: function definition is not allowed here
   {
   ^
   lib/ubsan.c:244:1: error: function definition is not allowed here
   {
   ^
   lib/ubsan.c:257:1: error: function definition is not allowed here
   {
   ^
   lib/ubsan.c:271:1: error: function definition is not allowed here
   {
   ^
   lib/ubsan.c:288:1: error: function definition is not allowed here
   {
   ^
   lib/ubsan.c:330:1: error: function definition is not allowed here
   {
   ^
   lib/ubsan.c:340:1: error: function definition is not allowed here
   {
   ^
   lib/ubsan.c:364:1: error: function definition is not allowed here
   {
   ^
>> lib/ubsan.c:387:52: error: expected '}'
   EXPORT_SYMBOL(__ubsan_handle_alignment_assumption);
                                                      ^
   lib/ubsan.c:138:1: note: to match this '{'
   {
   ^
>> lib/ubsan.c:358:6: warning: mixing declarations and code is incompatible with standards before C99 [-Wdeclaration-after-statement]
   void __ubsan_handle_alignment_assumption(void *_data, unsigned long ptr,
        ^
   1 warning and 13 errors generated.


vim +387 lib/ubsan.c

28abcc963149e0 Nathan Chancellor 2021-02-04  357  
28abcc963149e0 Nathan Chancellor 2021-02-04 @358  void __ubsan_handle_alignment_assumption(void *_data, unsigned long ptr,
28abcc963149e0 Nathan Chancellor 2021-02-04  359  					 unsigned long align,
28abcc963149e0 Nathan Chancellor 2021-02-04  360  					 unsigned long offset);
28abcc963149e0 Nathan Chancellor 2021-02-04  361  void __ubsan_handle_alignment_assumption(void *_data, unsigned long ptr,
28abcc963149e0 Nathan Chancellor 2021-02-04  362  					 unsigned long align,
28abcc963149e0 Nathan Chancellor 2021-02-04  363  					 unsigned long offset)
28abcc963149e0 Nathan Chancellor 2021-02-04  364  {
28abcc963149e0 Nathan Chancellor 2021-02-04  365  	struct alignment_assumption_data *data = _data;
28abcc963149e0 Nathan Chancellor 2021-02-04  366  	unsigned long real_ptr;
28abcc963149e0 Nathan Chancellor 2021-02-04  367  
28abcc963149e0 Nathan Chancellor 2021-02-04  368  	if (suppress_report(&data->location))
28abcc963149e0 Nathan Chancellor 2021-02-04  369  		return;
28abcc963149e0 Nathan Chancellor 2021-02-04  370  
28abcc963149e0 Nathan Chancellor 2021-02-04  371  	ubsan_prologue(&data->location, "alignment-assumption");
28abcc963149e0 Nathan Chancellor 2021-02-04  372  
28abcc963149e0 Nathan Chancellor 2021-02-04  373  	if (offset)
28abcc963149e0 Nathan Chancellor 2021-02-04  374  		pr_err("assumption of %lu byte alignment (with offset of %lu byte) for pointer of type %s failed",
28abcc963149e0 Nathan Chancellor 2021-02-04  375  		       align, offset, data->type->type_name);
28abcc963149e0 Nathan Chancellor 2021-02-04  376  	else
28abcc963149e0 Nathan Chancellor 2021-02-04  377  		pr_err("assumption of %lu byte alignment for pointer of type %s failed",
28abcc963149e0 Nathan Chancellor 2021-02-04  378  		       align, data->type->type_name);
28abcc963149e0 Nathan Chancellor 2021-02-04  379  
28abcc963149e0 Nathan Chancellor 2021-02-04  380  	real_ptr = ptr - offset;
28abcc963149e0 Nathan Chancellor 2021-02-04  381  	pr_err("%saddress is %lu aligned, misalignment offset is %lu bytes",
28abcc963149e0 Nathan Chancellor 2021-02-04  382  	       offset ? "offset " : "", BIT(real_ptr ? __ffs(real_ptr) : 0),
28abcc963149e0 Nathan Chancellor 2021-02-04  383  	       real_ptr & (align - 1));
28abcc963149e0 Nathan Chancellor 2021-02-04  384  
28abcc963149e0 Nathan Chancellor 2021-02-04  385  	ubsan_epilogue();
28abcc963149e0 Nathan Chancellor 2021-02-04  386  }
28abcc963149e0 Nathan Chancellor 2021-02-04 @387  EXPORT_SYMBOL(__ubsan_handle_alignment_assumption);
  

Patch

diff --git a/include/kunit/test-bug.h b/include/kunit/test-bug.h
index 5fc58081d511..ba9558a9f9c0 100644
--- a/include/kunit/test-bug.h
+++ b/include/kunit/test-bug.h
@@ -9,16 +9,29 @@ 
 #ifndef _KUNIT_TEST_BUG_H
 #define _KUNIT_TEST_BUG_H
 
-#define kunit_fail_current_test(fmt, ...) \
-	__kunit_fail_current_test(__FILE__, __LINE__, fmt, ##__VA_ARGS__)
-
 #if IS_BUILTIN(CONFIG_KUNIT)
 
+#include <linux/jump_label.h> /* For static branch */
+
+/* Static key if KUnit is running any tests. */
+extern struct static_key_false kunit_running;
+
+#define kunit_fail_current_test(fmt, ...) do {					\
+	if (static_branch_unlikely(&kunit_running)) {				\
+		__kunit_fail_current_test(__FILE__, __LINE__,			\
+					  fmt, ##__VA_ARGS__);			\
+	} while (0)
+
+
 extern __printf(3, 4) void __kunit_fail_current_test(const char *file, int line,
 						    const char *fmt, ...);
 
 #else
 
+/* We define this with an empty helper function so format string warnings work */
+#define kunit_fail_current_test(fmt, ...) \
+		__kunit_fail_current_test(__FILE__, __LINE__, fmt, ##__VA_ARGS__)
+
 static inline __printf(3, 4) void __kunit_fail_current_test(const char *file, int line,
 							    const char *fmt, ...)
 {