Merge tag 'linux-kselftest-kunit-5.10-rc1' of git://git.kernel.org/pub/scm/linux...
authorLinus Torvalds <torvalds@linux-foundation.org>
Sun, 18 Oct 2020 21:45:59 +0000 (14:45 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 18 Oct 2020 21:45:59 +0000 (14:45 -0700)
Pull more Kunit updates from Shuah Khan:

 - add Kunit to kernel_init() and remove KUnit from init calls entirely.

   This addresses the concern that Kunit would not work correctly during
   late init phase.

 - add a linker section where KUnit can put references to its test
   suites.

   This is the first step in transitioning to dispatching all KUnit
   tests from a centralized executor rather than having each as its own
   separate late_initcall.

 - add a centralized executor to dispatch tests rather than relying on
   late_initcall to schedule each test suite separately. Centralized
   execution is for built-in tests only; modules will execute tests when
   loaded.

 - convert bitfield test to use KUnit framework

 - Documentation updates for naming guidelines and how
   kunit_test_suite() works.

 - add test plan to KUnit TAP format

* tag 'linux-kselftest-kunit-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
  lib: kunit: Fix compilation test when using TEST_BIT_FIELD_COMPILE
  lib: kunit: add bitfield test conversion to KUnit
  Documentation: kunit: add a brief blurb about kunit_test_suite
  kunit: test: add test plan to KUnit TAP format
  init: main: add KUnit to kernel init
  kunit: test: create a single centralized executor for all tests
  vmlinux.lds.h: add linker section for KUnit test suites
  Documentation: kunit: Add naming guidelines

1  2 
include/asm-generic/vmlinux.lds.h
include/kunit/test.h
init/main.c
lib/Kconfig.debug
lib/Makefile
lib/kunit/test.c

index e1843976754acc45ae742dde181baf792af88de6,31e08674b542796c7953746ec182c92291c883c5..cd14444bf600516a24894669b4f4473fd4021dd0
@@@ -34,7 -34,6 +34,7 @@@
   *
   *    STABS_DEBUG
   *    DWARF_DEBUG
 + *    ELF_DETAILS
   *
   *    DISCARDS                // must be the last
   * }
        KEEP(*(__jump_table))                                           \
        __stop___jump_table = .;
  
 +#define STATIC_CALL_DATA                                              \
 +      . = ALIGN(8);                                                   \
 +      __start_static_call_sites = .;                                  \
 +      KEEP(*(.static_call_sites))                                     \
 +      __stop_static_call_sites = .;
 +
  /*
   * Allow architectures to handle ro_after_init data on their
   * own by defining an empty RO_AFTER_INIT_DATA.
        __start_ro_after_init = .;                                      \
        *(.data..ro_after_init)                                         \
        JUMP_TABLE_DATA                                                 \
 +      STATIC_CALL_DATA                                                \
        __end_ro_after_init = .;
  #endif
  
   */
  #define TEXT_TEXT                                                     \
                ALIGN_FUNCTION();                                       \
 -              *(.text.hot TEXT_MAIN .text.fixup .text.unlikely)       \
 +              *(.text.hot .text.hot.*)                                \
 +              *(TEXT_MAIN .text.fixup)                                \
 +              *(.text.unlikely .text.unlikely.*)                      \
 +              *(.text.unknown .text.unknown.*)                        \
                NOINSTR_TEXT                                            \
                *(.text..refcount)                                      \
                *(.ref.text)                                            \
                *(.softirqentry.text)                                   \
                __softirqentry_text_end = .;
  
 +#define STATIC_CALL_TEXT                                              \
 +              ALIGN_FUNCTION();                                       \
 +              __static_call_text_start = .;                           \
 +              *(.static_call.text)                                    \
 +              __static_call_text_end = .;
 +
  /* Section used for early init (in .S files) */
  #define HEAD_TEXT  KEEP(*(.head.text))
  
  #define BTF                                                           \
        .BTF : AT(ADDR(.BTF) - LOAD_OFFSET) {                           \
                __start_BTF = .;                                        \
 -              *(.BTF)                                                 \
 +              KEEP(*(.BTF))                                           \
                __stop_BTF = .;                                         \
        }                                                               \
        . = ALIGN(4);                                                   \
        THERMAL_TABLE(governor)                                         \
        EARLYCON_TABLE()                                                \
        LSM_TABLE()                                                     \
-       EARLY_LSM_TABLE()
+       EARLY_LSM_TABLE()                                               \
+       KUNIT_TABLE()
  
  #define INIT_TEXT                                                     \
        *(.init.text .init.text.*)                                      \
                .debug_macro    0 : { *(.debug_macro) }                 \
                .debug_addr     0 : { *(.debug_addr) }
  
 -              /* Stabs debugging sections.  */
 +/* Stabs debugging sections. */
  #define STABS_DEBUG                                                   \
                .stab 0 : { *(.stab) }                                  \
                .stabstr 0 : { *(.stabstr) }                            \
                .stab.excl 0 : { *(.stab.excl) }                        \
                .stab.exclstr 0 : { *(.stab.exclstr) }                  \
                .stab.index 0 : { *(.stab.index) }                      \
 -              .stab.indexstr 0 : { *(.stab.indexstr) }                \
 -              .comment 0 : { *(.comment) }
 +              .stab.indexstr 0 : { *(.stab.indexstr) }
 +
 +/* Required sections not related to debugging. */
 +#define ELF_DETAILS                                                   \
 +              .comment 0 : { *(.comment) }                            \
 +              .symtab 0 : { *(.symtab) }                              \
 +              .strtab 0 : { *(.strtab) }                              \
 +              .shstrtab 0 : { *(.shstrtab) }
  
  #ifdef CONFIG_GENERIC_BUG
  #define BUG_TABLE                                                     \
                KEEP(*(.con_initcall.init))                             \
                __con_initcall_end = .;
  
+ /* Alignment must be consistent with (kunit_suite *) in include/kunit/test.h */
+ #define KUNIT_TABLE()                                                 \
+               . = ALIGN(8);                                           \
+               __kunit_suites_start = .;                               \
+               KEEP(*(.kunit_test_suites))                             \
+               __kunit_suites_end = .;
  #ifdef CONFIG_BLK_DEV_INITRD
  #define INIT_RAM_FS                                                   \
        . = ALIGN(4);                                                   \
        EXIT_DATA
  #endif
  
 +/*
 + * Clang's -fsanitize=kernel-address and -fsanitize=thread produce
 + * unwanted sections (.eh_frame and .init_array.*), but
 + * CONFIG_CONSTRUCTORS wants to keep any .init_array.* sections.
 + * https://bugs.llvm.org/show_bug.cgi?id=46478
 + */
 +#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KCSAN)
 +# ifdef CONFIG_CONSTRUCTORS
 +#  define SANITIZER_DISCARDS                                          \
 +      *(.eh_frame)
 +# else
 +#  define SANITIZER_DISCARDS                                          \
 +      *(.init_array) *(.init_array.*)                                 \
 +      *(.eh_frame)
 +# endif
 +#else
 +# define SANITIZER_DISCARDS
 +#endif
 +
 +#define COMMON_DISCARDS                                                       \
 +      SANITIZER_DISCARDS                                              \
 +      *(.discard)                                                     \
 +      *(.discard.*)                                                   \
 +      *(.modinfo)                                                     \
 +      /* ld.bfd warns about .gnu.version* even when not emitted */    \
 +      *(.gnu.version*)                                                \
 +
  #define DISCARDS                                                      \
        /DISCARD/ : {                                                   \
        EXIT_DISCARDS                                                   \
        EXIT_CALL                                                       \
 -      *(.discard)                                                     \
 -      *(.discard.*)                                                   \
 -      *(.modinfo)                                                     \
 +      COMMON_DISCARDS                                                 \
        }
  
  /**
diff --combined include/kunit/test.h
index 037de35ae0ffa008891ada80e63811cd9bc07aa9,7ea24466e49cddda87dc55e4e40cabb83fc655fd..a423fffefea0505d5df8faef2970c39a7d62dfc7
@@@ -25,7 -25,6 +25,7 @@@ typedef void (*kunit_resource_free_t)(s
  /**
   * struct kunit_resource - represents a *test managed resource*
   * @data: for the user to store arbitrary data.
 + * @name: optional name
   * @free: a user supplied function to free the resource. Populated by
   * kunit_resource_alloc().
   *
   */
  struct kunit_resource {
        void *data;
 -      const char *name;               /* optional name */
 +      const char *name;
 +      kunit_resource_free_t free;
  
        /* private: internal use only. */
 -      kunit_resource_free_t free;
        struct kref refcount;
        struct list_head node;
  };
@@@ -225,11 -224,6 +225,11 @@@ struct kunit 
        struct list_head resources; /* Protected by lock. */
  };
  
 +static inline void kunit_set_failure(struct kunit *test)
 +{
 +      WRITE_ONCE(test->success, false);
 +}
 +
  void kunit_init_test(struct kunit *test, const char *name, char *log);
  
  int kunit_run_tests(struct kunit_suite *suite);
@@@ -239,10 -233,19 +239,19 @@@ size_t kunit_suite_num_test_cases(struc
  unsigned int kunit_test_case_num(struct kunit_suite *suite,
                                 struct kunit_case *test_case);
  
- int __kunit_test_suites_init(struct kunit_suite **suites);
+ int __kunit_test_suites_init(struct kunit_suite * const * const suites);
  
  void __kunit_test_suites_exit(struct kunit_suite **suites);
  
+ #if IS_BUILTIN(CONFIG_KUNIT)
+ int kunit_run_all_tests(void);
+ #else
+ static inline int kunit_run_all_tests(void)
+ {
+       return 0;
+ }
+ #endif /* IS_BUILTIN(CONFIG_KUNIT) */
  /**
   * kunit_test_suites() - used to register one or more &struct kunit_suite
   *                     with KUnit.
   * Registers @suites_list with the test framework. See &struct kunit_suite for
   * more information.
   *
-  * When builtin, KUnit tests are all run as late_initcalls; this means
-  * that they cannot test anything where tests must run at a different init
-  * phase. One significant restriction resulting from this is that KUnit
-  * cannot reliably test anything that is initialize in the late_init phase;
-  * another is that KUnit is useless to test things that need to be run in
-  * an earlier init phase.
-  *
-  * An alternative is to build the tests as a module.  Because modules
-  * do not support multiple late_initcall()s, we need to initialize an
-  * array of suites for a module.
-  *
-  * TODO(brendanhiggins@google.com): Don't run all KUnit tests as
-  * late_initcalls.  I have some future work planned to dispatch all KUnit
-  * tests from the same place, and at the very least to do so after
-  * everything else is definitely initialized.
+  * If a test suite is built-in, module_init() gets translated into
+  * an initcall which we don't want as the idea is that for builtins
+  * the executor will manage execution.  So ensure we do not define
+  * module_{init|exit} functions for the builtin case when registering
+  * suites via kunit_test_suites() below.
   */
- #define kunit_test_suites(suites_list...)                             \
      static struct kunit_suite *suites[] = {suites_list, NULL};      \
-       static int kunit_test_suites_init(void)                         \
+ #ifdef MODULE
#define kunit_test_suites_for_module(__suites)                                \
+       static int __init kunit_test_suites_init(void)                  \
        {                                                               \
-               return __kunit_test_suites_init(suites);                \
+               return __kunit_test_suites_init(__suites);              \
        }                                                               \
-       late_initcall(kunit_test_suites_init);                          \
+       module_init(kunit_test_suites_init);                            \
+                                                                       \
        static void __exit kunit_test_suites_exit(void)                 \
        {                                                               \
-               return __kunit_test_suites_exit(suites);                \
+               return __kunit_test_suites_exit(__suites);              \
        }                                                               \
        module_exit(kunit_test_suites_exit)
+ #else
+ #define kunit_test_suites_for_module(__suites)
+ #endif /* MODULE */
+ #define __kunit_test_suites(unique_array, unique_suites, ...)                \
+       static struct kunit_suite *unique_array[] = { __VA_ARGS__, NULL };     \
+       kunit_test_suites_for_module(unique_array);                            \
+       static struct kunit_suite **unique_suites                              \
+       __used __section(.kunit_test_suites) = unique_array
+ /**
+  * kunit_test_suites() - used to register one or more &struct kunit_suite
+  *                     with KUnit.
+  *
+  * @suites: a statically allocated list of &struct kunit_suite.
+  *
+  * Registers @suites with the test framework. See &struct kunit_suite for
+  * more information.
+  *
+  * When builtin,  KUnit tests are all run via executor; this is done
+  * by placing the array of struct kunit_suite * in the .kunit_test_suites
+  * ELF section.
+  *
+  * An alternative is to build the tests as a module.  Because modules do not
+  * support multiple initcall()s, we need to initialize an array of suites for a
+  * module.
+  *
+  */
+ #define kunit_test_suites(...)                                                \
+       __kunit_test_suites(__UNIQUE_ID(array),                         \
+                           __UNIQUE_ID(suites),                        \
+                           __VA_ARGS__)
  
  #define kunit_test_suite(suite)       kunit_test_suites(&suite)
  
@@@ -349,7 -375,6 +381,7 @@@ static inline void kunit_put_resource(s
   *        none is supplied, the resource data value is simply set to @data.
   *      If an init function is supplied, @data is passed to it instead.
   * @free: a user-supplied function to free the resource (if needed).
 + * @res: The resource.
   * @data: value to pass to init function or set in resource data field.
   */
  int kunit_add_resource(struct kunit *test,
   * @test: The test context object.
   * @init: a user-supplied function to initialize the resource data, if needed.
   * @free: a user-supplied function to free the resource data, if needed.
 - * @name_data: name and data to be set for resource.
 + * @res: The resource.
 + * @name: name to be set for resource.
 + * @data: value to pass to init function or set in resource data field.
   */
  int kunit_add_named_resource(struct kunit *test,
                             kunit_resource_init_t init,
@@@ -503,8 -526,8 +535,8 @@@ static inline int kunit_destroy_named_r
  }
  
  /**
 - * kunit_remove_resource: remove resource from resource list associated with
 - *                      test.
 + * kunit_remove_resource() - remove resource from resource list associated with
 + *                         test.
   * @test: The test context object.
   * @res: The resource to be removed.
   *
diff --combined init/main.c
index 1af84337cb18d5dacd6907ff57b579dafbbf8045,232c8df465eeb4707588e46f867bd2b7146ca096..130376ec10ba06956103521492d0e7a83250a687
@@@ -33,7 -33,6 +33,7 @@@
  #include <linux/nmi.h>
  #include <linux/percpu.h>
  #include <linux/kmod.h>
 +#include <linux/kprobes.h>
  #include <linux/vmalloc.h>
  #include <linux/kernel_stat.h>
  #include <linux/start_kernel.h>
  #define CREATE_TRACE_POINTS
  #include <trace/events/initcall.h>
  
+ #include <kunit/test.h>
  static int kernel_init(void *);
  
  extern void init_IRQ(void);
@@@ -304,7 -305,7 +306,7 @@@ static void * __init get_boot_config_fr
  
  #ifdef CONFIG_BOOT_CONFIG
  
 -char xbc_namebuf[XBC_KEYLEN_MAX] __initdata;
 +static char xbc_namebuf[XBC_KEYLEN_MAX] __initdata;
  
  #define rest(dst, end) ((end) > (dst) ? (end) - (dst) : 0)
  
@@@ -468,7 -469,7 +470,7 @@@ static void __init setup_boot_config(co
  
  static int __init warn_bootconfig(char *str)
  {
 -      pr_warn("WARNING: 'bootconfig' found on the kernel command line but CONFIG_BOOTCONFIG is not set.\n");
 +      pr_warn("WARNING: 'bootconfig' found on the kernel command line but CONFIG_BOOT_CONFIG is not set.\n");
        return 0;
  }
  early_param("bootconfig", warn_bootconfig);
@@@ -1403,7 -1404,6 +1405,7 @@@ static int __ref kernel_init(void *unus
        kernel_init_freeable();
        /* need to finish all async __init code before freeing the memory */
        async_synchronize_full();
 +      kprobe_free_init_mem();
        ftrace_free_init_mem();
        free_initmem();
        mark_readonly();
@@@ -1513,6 -1513,8 +1515,8 @@@ static noinline void __init kernel_init
  
        do_basic_setup();
  
+       kunit_run_all_tests();
        console_on_rootfs();
  
        /*
diff --combined lib/Kconfig.debug
index 279926f5f843e61b837433175a8067077308f9de,4f09c6505a2e890362799f235be259901b0cf976..66d44d35cc97f939db21f14e24432e91b540e09d
@@@ -520,8 -520,8 +520,8 @@@ config DEBUG_FS_ALLOW_NON
  endchoice
  
  source "lib/Kconfig.kgdb"
 -
  source "lib/Kconfig.ubsan"
 +source "lib/Kconfig.kcsan"
  
  endmenu
  
@@@ -1367,27 -1367,6 +1367,27 @@@ config WW_MUTEX_SELFTES
          Say M if you want these self tests to build as a module.
          Say N if you are unsure.
  
 +config SCF_TORTURE_TEST
 +      tristate "torture tests for smp_call_function*()"
 +      depends on DEBUG_KERNEL
 +      select TORTURE_TEST
 +      help
 +        This option provides a kernel module that runs torture tests
 +        on the smp_call_function() family of primitives.  The kernel
 +        module may be built after the fact on the running kernel to
 +        be tested, if desired.
 +
 +config CSD_LOCK_WAIT_DEBUG
 +      bool "Debugging for csd_lock_wait(), called from smp_call_function*()"
 +      depends on DEBUG_KERNEL
 +      depends on 64BIT
 +      default n
 +      help
 +        This option enables debug prints when CPUs are slow to respond
 +        to the smp_call_function*() IPI wrappers.  These debug prints
 +        include the IPI handler function currently executing (if any)
 +        and relevant stack traces.
 +
  endmenu # lock debugging
  
  config TRACE_IRQFLAGS
@@@ -1641,6 -1620,8 +1641,6 @@@ config PROVIDE_OHCI1394_DMA_INI
  
  source "samples/Kconfig"
  
 -source "lib/Kconfig.kcsan"
 -
  config ARCH_HAS_DEVMEM_IS_ALLOWED
        bool
  
@@@ -1789,13 -1770,6 +1789,13 @@@ config FAIL_PAGE_ALLO
        help
          Provide fault-injection capability for alloc_pages().
  
 +config FAULT_INJECTION_USERCOPY
 +      bool "Fault injection capability for usercopy functions"
 +      depends on FAULT_INJECTION
 +      help
 +        Provides fault-injection capability to inject failures
 +        in usercopy functions (copy_from_user(), get_user(), ...).
 +
  config FAIL_MAKE_REQUEST
        bool "Fault-injection capability for disk IO"
        depends on FAULT_INJECTION && BLOCK
@@@ -2063,13 -2037,6 +2063,6 @@@ config TEST_BITMA
  
          If unsure, say N.
  
- config TEST_BITFIELD
-       tristate "Test bitfield functions at runtime"
-       help
-         Enable this option to test the bitfield functions at boot.
-         If unsure, say N.
  config TEST_UUID
        tristate "Test functions located in the uuid module at runtime"
  
@@@ -2219,6 -2186,22 +2212,22 @@@ config TEST_SYSCT
  
          If unsure, say N.
  
+ config BITFIELD_KUNIT
+       tristate "KUnit test bitfield functions at runtime"
+       depends on KUNIT
+       help
+         Enable this option to test the bitfield functions at boot.
+         KUnit tests run during boot and output the results to the debug log
+         in TAP format (http://testanything.org/). Only useful for kernel devs
+         running the KUnit test harness, and not intended for inclusion into a
+         production build.
+         For more information on KUnit and unit tests in general please refer
+         to the KUnit documentation in Documentation/dev-tools/kunit/.
+         If unsure, say N.
  config SYSCTL_KUNIT_TEST
        tristate "KUnit test for sysctl" if !KUNIT_ALL_TESTS
        depends on KUNIT
@@@ -2395,15 -2378,6 +2404,15 @@@ config TEST_HM
  
          If unsure, say N.
  
 +config TEST_FREE_PAGES
 +      tristate "Test freeing pages"
 +      help
 +        Test that a memory leak does not occur due to a race between
 +        freeing a block of pages and a speculative page reference.
 +        Loading this module is safe if your kernel has the bug fixed.
 +        If the bug is not fixed, it will leak gigabytes of memory and
 +        probably OOM your system.
 +
  config TEST_FPU
        tristate "Test floating point operations in kernel space"
        depends on X86 && !KCOV_INSTRUMENT_ALL
diff --combined lib/Makefile
index 1c7577b2e86ad976b130922d1467431de2fc2302,d862d41fdc3d57ad2d8d4c72cebd485e49f7aa4e..ce45af50983a2a5e35823dbd1e632aa425ab3560
@@@ -15,16 -15,11 +15,16 @@@ KCOV_INSTRUMENT_debugobjects.o := 
  KCOV_INSTRUMENT_dynamic_debug.o := n
  KCOV_INSTRUMENT_fault-inject.o := n
  
 +# string.o implements standard library functions like memset/memcpy etc.
 +# Use -ffreestanding to ensure that the compiler does not try to "optimize"
 +# them into calls to themselves.
 +CFLAGS_string.o := -ffreestanding
 +
  # Early boot use of cmdline, don't instrument it
  ifdef CONFIG_AMD_MEM_ENCRYPT
  KASAN_SANITIZE_string.o := n
  
 -CFLAGS_string.o := -fno-stack-protector
 +CFLAGS_string.o += -fno-stack-protector
  endif
  
  # Used by KCSAN while enabled, avoid recursion.
@@@ -65,11 -60,9 +65,11 @@@ CFLAGS_test_bitops.o += -Werro
  obj-$(CONFIG_TEST_SYSCTL) += test_sysctl.o
  obj-$(CONFIG_TEST_HASH) += test_hash.o test_siphash.o
  obj-$(CONFIG_TEST_IDA) += test_ida.o
 -obj-$(CONFIG_TEST_KASAN) += test_kasan.o
 +obj-$(CONFIG_KASAN_KUNIT_TEST) += test_kasan.o
  CFLAGS_test_kasan.o += -fno-builtin
  CFLAGS_test_kasan.o += $(call cc-disable-warning, vla)
 +obj-$(CONFIG_TEST_KASAN_MODULE) += test_kasan_module.o
 +CFLAGS_test_kasan_module.o += -fno-builtin
  obj-$(CONFIG_TEST_UBSAN) += test_ubsan.o
  CFLAGS_test_ubsan.o += $(call cc-disable-warning, vla)
  UBSAN_SANITIZE_test_ubsan.o := y
@@@ -87,7 -80,6 +87,6 @@@ obj-$(CONFIG_TEST_STATIC_KEYS) += test_
  obj-$(CONFIG_TEST_PRINTF) += test_printf.o
  obj-$(CONFIG_TEST_BITMAP) += test_bitmap.o
  obj-$(CONFIG_TEST_STRSCPY) += test_strscpy.o
- obj-$(CONFIG_TEST_BITFIELD) += test_bitfield.o
  obj-$(CONFIG_TEST_UUID) += test_uuid.o
  obj-$(CONFIG_TEST_XARRAY) += test_xarray.o
  obj-$(CONFIG_TEST_PARMAN) += test_parman.o
@@@ -101,7 -93,6 +100,7 @@@ obj-$(CONFIG_TEST_BLACKHOLE_DEV) += tes
  obj-$(CONFIG_TEST_MEMINIT) += test_meminit.o
  obj-$(CONFIG_TEST_LOCKUP) += test_lockup.o
  obj-$(CONFIG_TEST_HMM) += test_hmm.o
 +obj-$(CONFIG_TEST_FREE_PAGES) += test_free_pages.o
  
  #
  # CFLAGS for compiling floating point code inside the kernel. x86/Makefile turns
@@@ -210,7 -201,6 +209,7 @@@ obj-$(CONFIG_AUDIT_COMPAT_GENERIC) += c
  
  obj-$(CONFIG_IOMMU_HELPER) += iommu-helper.o
  obj-$(CONFIG_FAULT_INJECTION) += fault-inject.o
 +obj-$(CONFIG_FAULT_INJECTION_USERCOPY) += fault-inject-usercopy.o
  obj-$(CONFIG_NOTIFIER_ERROR_INJECTION) += notifier-error-inject.o
  obj-$(CONFIG_PM_NOTIFIER_ERROR_INJECT) += pm-notifier-error-inject.o
  obj-$(CONFIG_NETDEV_NOTIFIER_ERROR_INJECT) += netdev-notifier-error-inject.o
@@@ -349,6 -339,7 +348,7 @@@ obj-$(CONFIG_OBJAGG) += objagg.
  obj-$(CONFIG_PLDMFW) += pldmfw/
  
  # KUnit tests
+ obj-$(CONFIG_BITFIELD_KUNIT) += bitfield_kunit.o
  obj-$(CONFIG_LIST_KUNIT_TEST) += list-test.o
  obj-$(CONFIG_LINEAR_RANGES_TEST) += test_linear_ranges.o
  obj-$(CONFIG_BITS_TEST) += test_bits.o
diff --combined lib/kunit/test.c
index dcc35fd30d956b075802cbc76de1dfddab3ff230,de07876b66011dd52da5ad3f2ab413921d6bee62..750704abe89a66fb91cfd081473b884a9c25f9c3
  #include <linux/kernel.h>
  #include <linux/kref.h>
  #include <linux/sched/debug.h>
 +#include <linux/sched.h>
  
  #include "debugfs.h"
  #include "string-stream.h"
  #include "try-catch-impl.h"
  
- static void kunit_print_tap_version(void)
 -static void kunit_set_failure(struct kunit *test)
--{
-       static bool kunit_has_printed_tap_version;
-       if (!kunit_has_printed_tap_version) {
-               pr_info("TAP version 14\n");
-               kunit_has_printed_tap_version = true;
-       }
 -      WRITE_ONCE(test->success, false);
--}
--
  /*
   * Append formatted message to log, size of which is limited to
   * KUNIT_LOG_SIZE bytes (including null terminating byte).
@@@ -65,7 -59,6 +55,6 @@@ EXPORT_SYMBOL_GPL(kunit_suite_num_test_
  
  static void kunit_print_subtest_start(struct kunit_suite *suite)
  {
-       kunit_print_tap_version();
        kunit_log(KERN_INFO, suite, KUNIT_SUBTEST_INDENT "# Subtest: %s",
                  suite->name);
        kunit_log(KERN_INFO, suite, KUNIT_SUBTEST_INDENT "1..%zd",
@@@ -284,10 -277,6 +273,10 @@@ static void kunit_try_run_case(void *da
        struct kunit_suite *suite = ctx->suite;
        struct kunit_case *test_case = ctx->test_case;
  
 +#if (IS_ENABLED(CONFIG_KASAN) && IS_ENABLED(CONFIG_KUNIT))
 +      current->kunit_test = test;
 +#endif /* IS_ENABLED(CONFIG_KASAN) && IS_ENABLED(CONFIG_KUNIT) */
 +
        /*
         * kunit_run_case_internal may encounter a fatal error; if it does,
         * abort will be called, this thread will exit, and finally the parent
@@@ -381,7 -370,7 +370,7 @@@ static void kunit_init_suite(struct kun
        kunit_debugfs_create_suite(suite);
  }
  
- int __kunit_test_suites_init(struct kunit_suite **suites)
+ int __kunit_test_suites_init(struct kunit_suite * const * const suites)
  {
        unsigned int i;
  
@@@ -602,9 -591,6 +591,9 @@@ void kunit_cleanup(struct kunit *test
                spin_unlock(&test->lock);
                kunit_remove_resource(test, res);
        }
 +#if (IS_ENABLED(CONFIG_KASAN) && IS_ENABLED(CONFIG_KUNIT))
 +      current->kunit_test = NULL;
 +#endif /* IS_ENABLED(CONFIG_KASAN) && IS_ENABLED(CONFIG_KUNIT)*/
  }
  EXPORT_SYMBOL_GPL(kunit_cleanup);