Re: [PATCH 13/43] kmsan: add KMSAN runtime core

kernel test robot
2021-12-14T22:23:34Z

Hi Alexander,

I love your patch! Yet something to improve:

[auto build test ERROR on tip/x86/mm]
[also build test ERROR on linus/master v5.16-rc5]
[cannot apply to tip/x86/core hnaz-mm/master next-20211213]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Alexander-Potapenko/Add-KernelMemorySanitizer-infrastructure/20211215-003033
base: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 35fa745286ac44ee26ed100c2bd2553368ad193b
config: arm64-randconfig-r024-20211214 (https://download.01.org/0day-ci/archive/20211215/202112150609.r62ffy1Q-lkp@intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project b6a2ddb6c8ac29412b1361810972e15221fa021c)
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 arm64 cross compiling tool for clang build
# apt-get install binutils-aarch64-linux-gnu
# https://github.com/0day-ci/linux/commit/ddf3096bf6806b512d7bf5489f2100b46add643a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Alexander-Potapenko/Add-KernelMemorySanitizer-infrastructure/20211215-003033
git checkout ddf3096bf6806b512d7bf5489f2100b46add643a
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm64 prepare

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

All errors (new ones prefixed by >>):

In file included from arch/arm64/kernel/asm-offsets.c:10:
In file included from include/linux/arm_sdei.h:8:
In file included from include/acpi/ghes.h:5:
In file included from include/acpi/apei.h:9:
In file included from include/linux/acpi.h:15:
In file included from include/linux/device.h:15:
In file included from include/linux/dev_printk.h:16:
In file included from include/linux/ratelimit.h:6:
In file included from include/linux/sched.h:17:
In file included from include/linux/kmsan.h:17:
In file included from include/linux/vmalloc.h:13:
In file included from arch/arm64/include/asm/vmalloc.h:5:
>> arch/arm64/include/asm/pgtable.h:299:19: error: incomplete definition of type 'struct task_struct'
if (mm != current->active_mm && atomic_read(&mm->mm_users) <= 1)
~~~~~~~^
arch/arm64/include/asm/current.h:9:8: note: forward declaration of 'struct task_struct'
struct task_struct;
^
1 error generated.
make[2]: *** [scripts/Makefile.build:121: arch/arm64/kernel/asm-offsets.s] Error 1
make[2]: Target '__build' not remade because of errors.
make[1]: *** [Makefile:1198: prepare0] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:219: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.

vim +299 arch/arm64/include/asm/pgtable.h

4f04d8f0054511 Catalin Marinas 2012-03-05 270
2f4b829c625ec3 Catalin Marinas 2015-07-10 271 /*
2f4b829c625ec3 Catalin Marinas 2015-07-10 272 * PTE bits configuration in the presence of hardware Dirty Bit Management
2f4b829c625ec3 Catalin Marinas 2015-07-10 273 * (PTE_WRITE == PTE_DBM):
2f4b829c625ec3 Catalin Marinas 2015-07-10 274 *
2f4b829c625ec3 Catalin Marinas 2015-07-10 275 * Dirty Writable | PTE_RDONLY PTE_WRITE PTE_DIRTY (sw)
2f4b829c625ec3 Catalin Marinas 2015-07-10 276 * 0 0 | 1 0 0
2f4b829c625ec3 Catalin Marinas 2015-07-10 277 * 0 1 | 1 1 0
2f4b829c625ec3 Catalin Marinas 2015-07-10 278 * 1 0 | 1 0 1
2f4b829c625ec3 Catalin Marinas 2015-07-10 279 * 1 1 | 0 1 x
2f4b829c625ec3 Catalin Marinas 2015-07-10 280 *
2f4b829c625ec3 Catalin Marinas 2015-07-10 281 * When hardware DBM is not present, the sofware PTE_DIRTY bit is updated via
2f4b829c625ec3 Catalin Marinas 2015-07-10 282 * the page fault mechanism. Checking the dirty status of a pte becomes:
2f4b829c625ec3 Catalin Marinas 2015-07-10 283 *
b847415ce96efe Catalin Marinas 2015-09-11 284 * PTE_DIRTY || (PTE_WRITE && !PTE_RDONLY)
2f4b829c625ec3 Catalin Marinas 2015-07-10 285 */
9b604722059039 Mark Rutland 2019-06-10 286
9b604722059039 Mark Rutland 2019-06-10 287 static inline void __check_racy_pte_update(struct mm_struct *mm, pte_t *ptep,
9b604722059039 Mark Rutland 2019-06-10 288 pte_t pte)
4f04d8f0054511 Catalin Marinas 2012-03-05 289 {
20a004e7b017cc Will Deacon 2018-02-15 290 pte_t old_pte;
20a004e7b017cc Will Deacon 2018-02-15 291
9b604722059039 Mark Rutland 2019-06-10 292 if (!IS_ENABLED(CONFIG_DEBUG_VM))
9b604722059039 Mark Rutland 2019-06-10 293 return;
9b604722059039 Mark Rutland 2019-06-10 294
9b604722059039 Mark Rutland 2019-06-10 295 old_pte = READ_ONCE(*ptep);
9b604722059039 Mark Rutland 2019-06-10 296
9b604722059039 Mark Rutland 2019-06-10 297 if (!pte_valid(old_pte) || !pte_valid(pte))
9b604722059039 Mark Rutland 2019-06-10 298 return;
9b604722059039 Mark Rutland 2019-06-10 @299 if (mm != current->active_mm && atomic_read(&mm->mm_users) <= 1)
9b604722059039 Mark Rutland 2019-06-10 300 return;
02522463c84748 Will Deacon 2013-01-09 301
2f4b829c625ec3 Catalin Marinas 2015-07-10 302 /*
9b604722059039 Mark Rutland 2019-06-10 303 * Check for potential race with hardware updates of the pte
9b604722059039 Mark Rutland 2019-06-10 304 * (ptep_set_access_flags safely changes valid ptes without going
9b604722059039 Mark Rutland 2019-06-10 305 * through an invalid entry).
2f4b829c625ec3 Catalin Marinas 2015-07-10 306 */
82d340081b6f71 Catalin Marinas 2015-12-08 307 VM_WARN_ONCE(!pte_young(pte),
82d340081b6f71 Catalin Marinas 2015-12-08 308 "%s: racy access flag clearing: 0x%016llx -> 0x%016llx",
20a004e7b017cc Will Deacon 2018-02-15 309 __func__, pte_val(old_pte), pte_val(pte));
20a004e7b017cc Will Deacon 2018-02-15 310 VM_WARN_ONCE(pte_write(old_pte) && !pte_dirty(pte),
82d340081b6f71 Catalin Marinas 2015-12-08 311 "%s: racy dirty state clearing: 0x%016llx -> 0x%016llx",
20a004e7b017cc Will Deacon 2018-02-15 312 __func__, pte_val(old_pte), pte_val(pte));
2f4b829c625ec3 Catalin Marinas 2015-07-10 313 }
2f4b829c625ec3 Catalin Marinas 2015-07-10 314

---
0-DAY CI Kernel Test Service, Intel Corporation