Hi Muhammad, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on next-20221109] [also build test WARNING on v6.1-rc5] [cannot apply to shuah-kselftest/next shuah-kselftest/fixes linus/master v6.1-rc4 v6.1-rc3 v6.1-rc2] [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/Muhammad-Usama-Anjum/Implement-IOCTL-to-get-and-or-the-clear-info-about-PTEs/20221109-182618 patch link: https://lore.kernel.org/r/20221109102303.851281-3-usama.anjum%40collabora.com patch subject: [PATCH v6 2/3] fs/proc/task_mmu: Implement IOCTL to get and/or the clear info about PTEs config: i386-randconfig-s003 compiler: gcc-11 (Debian 11.3.0-8) 11.3.0 reproduce: # apt-get install sparse # sparse version: v0.6.4-39-gce1a6720-dirty # https://github.com/intel-lab-lkp/linux/commit/b329378abd03a741ff7250ec1b60292c893476da git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Muhammad-Usama-Anjum/Implement-IOCTL-to-get-and-or-the-clear-info-about-PTEs/20221109-182618 git checkout b329378abd03a741ff7250ec1b60292c893476da # save the config file mkdir build_dir && cp config build_dir/.config make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash fs/proc/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot sparse warnings: (new ones prefixed by >>) >> fs/proc/task_mmu.c:2014:39: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __user *ptr @@ got struct page_region * @@ fs/proc/task_mmu.c:2014:39: sparse: expected void const [noderef] __user *ptr fs/proc/task_mmu.c:2014:39: sparse: got struct page_region * >> fs/proc/task_mmu.c:2079:35: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void [noderef] __user *to @@ got struct page_region * @@ fs/proc/task_mmu.c:2079:35: sparse: expected void [noderef] __user *to fs/proc/task_mmu.c:2079:35: sparse: got struct page_region * fs/proc/task_mmu.c:631:17: sparse: sparse: context imbalance in 'smaps_pte_range' - unexpected unlock fs/proc/task_mmu.c:1215:28: sparse: sparse: context imbalance in 'clear_refs_pte_range' - unexpected unlock fs/proc/task_mmu.c:1563:28: sparse: sparse: context imbalance in 'pagemap_pmd_range' - unexpected unlock fs/proc/task_mmu.c:1901:28: sparse: sparse: context imbalance in 'pagemap_scan_pmd_entry' - unexpected unlock >> fs/proc/task_mmu.c:2009:9: sparse: sparse: dereference of noderef expression fs/proc/task_mmu.c:2010:15: sparse: sparse: dereference of noderef expression fs/proc/task_mmu.c:2010:50: sparse: sparse: dereference of noderef expression fs/proc/task_mmu.c:2010:50: sparse: sparse: dereference of noderef expression fs/proc/task_mmu.c:2035:9: sparse: sparse: dereference of noderef expression fs/proc/task_mmu.c:2035:15: sparse: sparse: dereference of noderef expression fs/proc/task_mmu.c:2057:17: sparse: sparse: dereference of noderef expression fs/proc/task_mmu.c:2057:17: sparse: sparse: dereference of noderef expression fs/proc/task_mmu.c:2057:17: sparse: sparse: dereference of noderef expression fs/proc/task_mmu.c:2057:17: sparse: sparse: dereference of noderef expression fs/proc/task_mmu.c:2064:35: sparse: sparse: dereference of noderef expression fs/proc/task_mmu.c:2064:42: sparse: sparse: dereference of noderef expression >> fs/proc/task_mmu.c:2014:39: sparse: sparse: non size-preserving integer to pointer cast fs/proc/task_mmu.c:2079:56: sparse: sparse: non size-preserving integer to pointer cast vim +2014 fs/proc/task_mmu.c 2001 2002 static long do_pagemap_sd_cmd(struct mm_struct *mm, struct pagemap_scan_arg *arg) 2003 { 2004 struct mmu_notifier_range range; 2005 unsigned long __user start, end; 2006 struct pagemap_scan_private p; 2007 int ret; 2008 > 2009 start = (unsigned long)untagged_addr(arg->start); 2010 if ((!IS_ALIGNED(start, PAGE_SIZE)) || (!access_ok((void __user *)start, arg->len))) 2011 return -EINVAL; 2012 2013 if (IS_GET_OP(arg) && > 2014 ((arg->vec_len == 0) || (!access_ok((struct page_region *)arg->vec, arg->vec_len)))) 2015 return -ENOMEM; 2016 2017 #ifndef CONFIG_MEM_SOFT_DIRTY 2018 if (IS_SD_OP(arg) || (arg->required_mask & PAGE_IS_SOFTDIRTY) || 2019 (arg->anyof_mask & PAGE_IS_SOFTDIRTY)) 2020 return -EINVAL; 2021 #endif 2022 2023 if ((arg->flags & ~PAGEMAP_SD_FLAGS) || (arg->required_mask & ~PAGEMAP_OP_MASK) || 2024 (arg->anyof_mask & ~PAGEMAP_OP_MASK) || (arg->excluded_mask & ~PAGEMAP_OP_MASK) || 2025 (arg->return_mask & ~PAGEMAP_OP_MASK)) 2026 return -EINVAL; 2027 2028 if ((!arg->required_mask && !arg->anyof_mask && !arg->excluded_mask) || !arg->return_mask) 2029 return -EINVAL; 2030 2031 if (IS_SD_OP(arg) && ((arg->required_mask & PAGEMAP_NONSD_OP_MASK) || 2032 (arg->anyof_mask & PAGEMAP_NONSD_OP_MASK))) 2033 return -EINVAL; 2034 2035 end = start + arg->len; 2036 p.max_pages = arg->max_pages; 2037 p.found_pages = 0; 2038 p.flags = arg->flags; 2039 p.required_mask = arg->required_mask; 2040 p.anyof_mask = arg->anyof_mask; 2041 p.excluded_mask = arg->excluded_mask; 2042 p.return_mask = arg->return_mask; 2043 p.vec_index = 0; 2044 p.vec_len = arg->vec_len; 2045 2046 if (IS_GET_OP(arg)) { 2047 p.vec = vzalloc(arg->vec_len * sizeof(struct page_region)); 2048 if (!p.vec) 2049 return -ENOMEM; 2050 } else { 2051 p.vec = NULL; 2052 } 2053 2054 if (IS_CLEAR_OP(arg)) { 2055 mmap_write_lock(mm); 2056 2057 mmu_notifier_range_init(&range, MMU_NOTIFY_SOFT_DIRTY, 0, NULL, mm, start, end); 2058 mmu_notifier_invalidate_range_start(&range); 2059 inc_tlb_flush_pending(mm); 2060 } else { 2061 mmap_read_lock(mm); 2062 } 2063 2064 ret = walk_page_range(mm, start, end, &pagemap_scan_ops, &p); 2065 2066 if (IS_CLEAR_OP(arg)) { 2067 mmu_notifier_invalidate_range_end(&range); 2068 dec_tlb_flush_pending(mm); 2069 2070 mmap_write_unlock(mm); 2071 } else { 2072 mmap_read_unlock(mm); 2073 } 2074 2075 if (ret < 0) 2076 goto free_data; 2077 2078 if (IS_GET_OP(arg) && p.vec_index) { > 2079 if (copy_to_user((struct page_region *)arg->vec, p.vec, 2080 p.vec_index * sizeof(struct page_region))) { 2081 ret = -EFAULT; 2082 goto free_data; 2083 } 2084 ret = p.vec_index; 2085 } else { 2086 ret = 0; 2087 } 2088 2089 free_data: 2090 if (IS_GET_OP(arg)) 2091 vfree(p.vec); 2092 2093 return ret; 2094 } 2095 -- 0-DAY CI Kernel Test Service https://01.org/lkp