lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Sun, 13 Mar 2022 05:05:48 +0800
From:   kernel test robot <lkp@...el.com>
To:     Liu Yi L <yi.l.liu@...el.com>
Cc:     kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org
Subject: [luxis1999-iommufd:iommufd-v5.17-rc4 26/31]
 drivers/iommu/iommufd/io_pagetable.c:192: undefined reference to
 `interval_tree_remove'

tree:   https://github.com/luxis1999/iommufd iommufd-v5.17-rc4
head:   d0e769d6ae11d7abe38d2f0598926ba499bf3ec1
commit: a117b0048812d24e105878f9608b04d84da8361b [26/31] vfio: Select iommufd
config: i386-randconfig-a016 (https://download.01.org/0day-ci/archive/20220313/202203130550.B8DSnbi0-lkp@intel.com/config)
compiler: gcc-9 (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0
reproduce (this is a W=1 build):
        # https://github.com/luxis1999/iommufd/commit/a117b0048812d24e105878f9608b04d84da8361b
        git remote add luxis1999-iommufd https://github.com/luxis1999/iommufd
        git fetch --no-tags luxis1999-iommufd iommufd-v5.17-rc4
        git checkout a117b0048812d24e105878f9608b04d84da8361b
        # save the config file to linux build tree
        mkdir build_dir
        make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

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

All errors (new ones prefixed by >>):

   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_abort_area':
>> drivers/iommu/iommufd/io_pagetable.c:192: undefined reference to `interval_tree_remove'
   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_area_iter_first':
>> drivers/iommu/iommufd/io_pagetable.h:91: undefined reference to `interval_tree_iter_first'
   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_alloc_iova':
>> drivers/iommu/iommufd/io_pagetable.c:89: undefined reference to `interval_tree_span_iter_first'
>> ld: drivers/iommu/iommufd/io_pagetable.c:97: undefined reference to `interval_tree_span_iter_first'
   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_alloc_area':
>> drivers/iommu/iommufd/io_pagetable.c:179: undefined reference to `interval_tree_insert'
>> ld: drivers/iommu/iommufd/io_pagetable.c:161: undefined reference to `interval_tree_iter_first'
   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_alloc_iova':
>> drivers/iommu/iommufd/io_pagetable.c:101: undefined reference to `interval_tree_span_iter_next'
>> ld: drivers/iommu/iommufd/io_pagetable.c:92: undefined reference to `interval_tree_span_iter_next'
   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_area_iter_first':
>> drivers/iommu/iommufd/io_pagetable.h:91: undefined reference to `interval_tree_iter_first'
>> ld: drivers/iommu/iommufd/io_pagetable.h:91: undefined reference to `interval_tree_iter_first'
>> ld: drivers/iommu/iommufd/io_pagetable.h:91: undefined reference to `interval_tree_iter_first'
   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_area_iter_next':
>> drivers/iommu/iommufd/io_pagetable.h:103: undefined reference to `interval_tree_iter_next'
   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_area_iter_first':
>> drivers/iommu/iommufd/io_pagetable.h:91: undefined reference to `interval_tree_iter_first'
   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_area_iter_next':
>> drivers/iommu/iommufd/io_pagetable.h:103: undefined reference to `interval_tree_iter_next'
   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_area_iter_first':
>> drivers/iommu/iommufd/io_pagetable.h:91: undefined reference to `interval_tree_iter_first'
   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_reserve_iova':
   drivers/iommu/iommufd/io_pagetable.c:528: undefined reference to `interval_tree_insert'
   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_remove_reserved_iova':
>> drivers/iommu/iommufd/io_pagetable.c:537: undefined reference to `interval_tree_iter_first'
>> ld: drivers/iommu/iommufd/io_pagetable.c:543: undefined reference to `interval_tree_iter_next'
>> ld: drivers/iommu/iommufd/io_pagetable.c:546: undefined reference to `interval_tree_remove'
   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_area_iter_first':
>> drivers/iommu/iommufd/io_pagetable.h:91: undefined reference to `interval_tree_iter_first'
   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_area_iter_next':
>> drivers/iommu/iommufd/io_pagetable.h:103: undefined reference to `interval_tree_iter_next'
   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_fill_domain':
   drivers/iommu/iommufd/io_pagetable.c:678: undefined reference to `interval_tree_insert'
   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_area_iter_first':
   drivers/iommu/iommufd/io_pagetable.h:91: undefined reference to `interval_tree_iter_first'
   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_area_iter_next':
   drivers/iommu/iommufd/io_pagetable.h:103: undefined reference to `interval_tree_iter_next'
   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_area_iter_first':
   drivers/iommu/iommufd/io_pagetable.h:91: undefined reference to `interval_tree_iter_first'
   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_area_iter_next':
   drivers/iommu/iommufd/io_pagetable.h:103: undefined reference to `interval_tree_iter_next'
   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_fill_domain':
   drivers/iommu/iommufd/io_pagetable.c:697: undefined reference to `interval_tree_remove'
   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_area_iter_first':
   drivers/iommu/iommufd/io_pagetable.h:91: undefined reference to `interval_tree_iter_first'
   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_unfill_domain':
   drivers/iommu/iommufd/io_pagetable.c:635: undefined reference to `interval_tree_remove'
   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_area_iter_next':
   drivers/iommu/iommufd/io_pagetable.h:103: undefined reference to `interval_tree_iter_next'
   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_area_iter_first':
   drivers/iommu/iommufd/io_pagetable.h:91: undefined reference to `interval_tree_iter_first'
   ld: drivers/iommu/iommufd/io_pagetable.o: in function `iopt_area_iter_next':
   drivers/iommu/iommufd/io_pagetable.h:103: undefined reference to `interval_tree_iter_next'
   ld: drivers/iommu/iommufd/ioas.o: in function `iommufd_ioas_iova_ranges':
   drivers/iommu/iommufd/ioas.c:93: undefined reference to `interval_tree_span_iter_first'
   ld: drivers/iommu/iommufd/ioas.c:96: undefined reference to `interval_tree_span_iter_next'
   ld: drivers/iommu/iommufd/pages.o: in function `pfn_reader_init':
   drivers/iommu/iommufd/pages.c:689: undefined reference to `interval_tree_span_iter_first'
   ld: drivers/iommu/iommufd/pages.o: in function `interval_tree_fully_covers':
   drivers/iommu/iommufd/pages.c:795: undefined reference to `interval_tree_iter_first'
   ld: drivers/iommu/iommufd/pages.o: in function `iopt_pages_get_exact_user':
   drivers/iommu/iommufd/pages.c:1232: undefined reference to `interval_tree_iter_first'
   ld: drivers/iommu/iommufd/pages.c:1233: undefined reference to `interval_tree_iter_next'
   ld: drivers/iommu/iommufd/pages.o: in function `iopt_pages_unpin':
   drivers/iommu/iommufd/pages.c:574: undefined reference to `interval_tree_span_iter_first'
   ld: drivers/iommu/iommufd/pages.c:577: undefined reference to `interval_tree_span_iter_next'
   ld: drivers/iommu/iommufd/pages.c:581: undefined reference to `interval_tree_span_iter_first'
   ld: drivers/iommu/iommufd/pages.c:585: undefined reference to `interval_tree_span_iter_next'
   ld: drivers/iommu/iommufd/pages.c:577: undefined reference to `interval_tree_span_iter_next'
   ld: drivers/iommu/iommufd/pages.o: in function `iopt_pages_find_domain_area':
   drivers/iommu/iommufd/pages.c:164: undefined reference to `interval_tree_iter_first'
   ld: drivers/iommu/iommufd/pages.o: in function `pfn_reader_next':
   drivers/iommu/iommufd/pages.c:653: undefined reference to `interval_tree_span_iter_next'
   ld: drivers/iommu/iommufd/pages.o: in function `iopt_unmap_domain':
   drivers/iommu/iommufd/pages.c:870: undefined reference to `interval_tree_span_iter_first'
   ld: drivers/iommu/iommufd/pages.c:873: undefined reference to `interval_tree_span_iter_next'
   ld: drivers/iommu/iommufd/pages.c:873: undefined reference to `interval_tree_span_iter_next'
   ld: drivers/iommu/iommufd/pages.o: in function `iopt_area_fill_domains':
   drivers/iommu/iommufd/pages.c:988: undefined reference to `interval_tree_insert'
   ld: drivers/iommu/iommufd/pages.o: in function `iopt_area_unfill_domains':
   drivers/iommu/iommufd/pages.c:1046: undefined reference to `interval_tree_remove'
   ld: drivers/iommu/iommufd/pages.o: in function `iopt_pages_unfill_xarray':
   drivers/iommu/iommufd/pages.c:1096: undefined reference to `interval_tree_span_iter_first'
   ld: drivers/iommu/iommufd/pages.c:1099: undefined reference to `interval_tree_span_iter_next'
   ld: drivers/iommu/iommufd/pages.o: in function `iopt_pages_clean_xarray':
   drivers/iommu/iommufd/pages.c:1065: undefined reference to `interval_tree_span_iter_first'
   ld: drivers/iommu/iommufd/pages.c:1068: undefined reference to `interval_tree_span_iter_next'
   ld: drivers/iommu/iommufd/pages.o: in function `iopt_pages_fill_xarray':
   drivers/iommu/iommufd/pages.c:1179: undefined reference to `interval_tree_span_iter_first'
   ld: drivers/iommu/iommufd/pages.c:1182: undefined reference to `interval_tree_span_iter_next'
   ld: drivers/iommu/iommufd/pages.o: in function `iopt_pages_add_user':
   drivers/iommu/iommufd/pages.c:1283: undefined reference to `interval_tree_insert'
   ld: drivers/iommu/iommufd/pages.o: in function `iopt_pages_remove_user':
   drivers/iommu/iommufd/pages.c:1316: undefined reference to `interval_tree_remove'
   ld: drivers/iommu/iommufd/vfio_compat.o: in function `iommufd_fill_cap_iova':
   drivers/iommu/iommufd/vfio_compat.c:249: undefined reference to `interval_tree_span_iter_first'
   ld: drivers/iommu/iommufd/vfio_compat.c:252: undefined reference to `interval_tree_span_iter_next'

Kconfig warnings: (for reference only)
   WARNING: unmet direct dependencies detected for IOMMUFD
   Depends on IOMMU_SUPPORT
   Selected by
   - VFIO && MMU && (X86 || S390 || ARM || ARM64)


vim +192 drivers/iommu/iommufd/io_pagetable.c

7faa632a737a8f4 Jason Gunthorpe 2021-11-11   57  
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   58  /*
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   59   * Automatically find a block of IOVA that is not being used and not reserved.
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   60   * Does not return a 0 IOVA even if it is valid.
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   61   */
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   62  static int iopt_alloc_iova(struct io_pagetable *iopt, unsigned long *iova,
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   63  			   unsigned long uptr, unsigned long length)
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   64  {
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   65  	struct interval_tree_span_iter reserved_span;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   66  	unsigned long page_offset = uptr % PAGE_SIZE;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   67  	struct interval_tree_span_iter area_span;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   68  	unsigned long iova_alignment;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   69  
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   70  	lockdep_assert_held(&iopt->iova_rwsem);
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   71  
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   72  	/* Protect roundup_pow-of_two() from overflow */
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   73  	if (length == 0 || length >= ULONG_MAX / 2)
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   74  		return -EINVAL;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   75  
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   76  	/*
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   77  	 * Keep alignment present in the uptr when building the IOVA, this
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   78  	 * increases the chance we can map a THP.
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   79  	 */
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   80  	if (!uptr)
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   81  		iova_alignment = roundup_pow_of_two(length);
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   82  	else
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   83  		iova_alignment =
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   84  			min_t(unsigned long, roundup_pow_of_two(length),
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   85  			      1UL << __ffs64(uptr));
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   86  
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   87  	if (iova_alignment < iopt->iova_alignment)
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   88  		return -EINVAL;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  @89  	for (interval_tree_span_iter_first(&area_span, &iopt->area_itree,
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   90  					   PAGE_SIZE, ULONG_MAX - PAGE_SIZE);
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   91  	     !interval_tree_span_iter_done(&area_span);
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  @92  	     interval_tree_span_iter_next(&area_span)) {
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   93  		if (!__alloc_iova_check_hole(&area_span, length, iova_alignment,
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   94  					     page_offset))
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   95  			continue;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   96  
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  @97  		for (interval_tree_span_iter_first(
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   98  			     &reserved_span, &iopt->reserved_iova_itree,
7faa632a737a8f4 Jason Gunthorpe 2021-11-11   99  			     area_span.start_hole, area_span.last_hole);
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  100  		     !interval_tree_span_iter_done(&reserved_span);
7faa632a737a8f4 Jason Gunthorpe 2021-11-11 @101  		     interval_tree_span_iter_next(&reserved_span)) {
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  102  			if (!__alloc_iova_check_hole(&reserved_span, length,
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  103  						     iova_alignment,
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  104  						     page_offset))
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  105  				continue;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  106  
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  107  			*iova = reserved_span.start_hole;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  108  			return 0;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  109  		}
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  110  	}
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  111  	return -ENOSPC;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  112  }
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  113  
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  114  /*
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  115   * The area takes a slice of the pages from start_bytes to start_byte + length
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  116   */
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  117  static struct iopt_area *
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  118  iopt_alloc_area(struct io_pagetable *iopt, struct iopt_pages *pages,
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  119  		unsigned long iova, unsigned long start_byte,
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  120  		unsigned long length, int iommu_prot, unsigned int flags)
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  121  {
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  122  	struct iopt_area *area;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  123  	int rc;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  124  
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  125  	area = kzalloc(sizeof(*area), GFP_KERNEL);
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  126  	if (!area)
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  127  		return ERR_PTR(-ENOMEM);
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  128  
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  129  	area->iopt = iopt;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  130  	area->iommu_prot = iommu_prot;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  131  	area->page_offset = start_byte % PAGE_SIZE;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  132  	area->pages_node.start = start_byte / PAGE_SIZE;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  133  	if (check_add_overflow(start_byte, length - 1, &area->pages_node.last))
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  134  		return ERR_PTR(-EINVAL);
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  135  	area->pages_node.last = area->pages_node.last / PAGE_SIZE;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  136  	if (WARN_ON(area->pages_node.last >= pages->npages))
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  137  		return ERR_PTR(-EINVAL);
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  138  
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  139  	down_write(&iopt->iova_rwsem);
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  140  	if (flags & IOPT_ALLOC_IOVA) {
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  141  		rc = iopt_alloc_iova(iopt, &iova,
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  142  				     (uintptr_t)pages->uptr + start_byte,
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  143  				     length);
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  144  		if (rc)
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  145  			goto out_unlock;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  146  	}
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  147  
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  148  	if (check_add_overflow(iova, length - 1, &area->node.last)) {
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  149  		rc = -EOVERFLOW;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  150  		goto out_unlock;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  151  	}
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  152  
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  153  	if (!(flags & IOPT_ALLOC_IOVA)) {
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  154  		if ((iova & (iopt->iova_alignment - 1)) ||
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  155  		    (length & (iopt->iova_alignment - 1)) || !length) {
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  156  			rc = -EINVAL;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  157  			goto out_unlock;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  158  		}
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  159  
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  160  		/* No reserved IOVA intersects the range */
7faa632a737a8f4 Jason Gunthorpe 2021-11-11 @161  		if (interval_tree_iter_first(&iopt->reserved_iova_itree, iova,
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  162  					     area->node.last)) {
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  163  			rc = -ENOENT;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  164  			goto out_unlock;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  165  		}
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  166  
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  167  		/* Check that there is not already a mapping in the range */
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  168  		if (iopt_area_iter_first(iopt, iova, area->node.last)) {
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  169  			rc = -EADDRINUSE;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  170  			goto out_unlock;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  171  		}
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  172  	}
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  173  
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  174  	/*
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  175  	 * The area is inserted with a NULL pages indicating it is not fully
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  176  	 * initialized yet.
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  177  	 */
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  178  	area->node.start = iova;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11 @179  	interval_tree_insert(&area->node, &area->iopt->area_itree);
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  180  	up_write(&iopt->iova_rwsem);
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  181  	return area;
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  182  
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  183  out_unlock:
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  184  	up_write(&iopt->iova_rwsem);
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  185  	kfree(area);
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  186  	return ERR_PTR(rc);
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  187  }
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  188  
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  189  static void iopt_abort_area(struct iopt_area *area)
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  190  {
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  191  	down_write(&area->iopt->iova_rwsem);
7faa632a737a8f4 Jason Gunthorpe 2021-11-11 @192  	interval_tree_remove(&area->node, &area->iopt->area_itree);
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  193  	up_write(&area->iopt->iova_rwsem);
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  194  	kfree(area);
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  195  }
7faa632a737a8f4 Jason Gunthorpe 2021-11-11  196  

:::::: The code at line 192 was first introduced by commit
:::::: 7faa632a737a8f47a479eed52aca8fc54bbc7003 iommufd: Data structure to provide IOVA to PFN mapping

:::::: TO: Jason Gunthorpe <jgg@...dia.com>
:::::: CC: Jason Gunthorpe <jgg@...dia.com>

---
0-DAY CI Kernel Test Service
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ