CC: [email protected] TO: Christoph Hellwig <[email protected]> tree: git://git.infradead.org/users/hch/misc.git vfio-iommu-groups head: 4f52d5eda95ccd5c301f4b92a96fcd819bb5fe7b commit: a01ec97a8a84adeb27d961d6b279d26bec711177 [29/30] vfio_iommu_type1: remove the "external" domain :::::: branch date: 19 hours ago :::::: commit date: 19 hours ago config: x86_64-randconfig-m001-20210804 (attached as .config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> New smatch warnings: drivers/vfio/vfio_iommu_type1.c:2358 vfio_iommu_type1_attach_group() warn: inconsistent returns '&iommu->lock'. Old smatch warnings: drivers/vfio/vfio_iommu_type1.c:2356 vfio_iommu_type1_attach_group() warn: '&group->next' not removed from list vim +2358 drivers/vfio/vfio_iommu_type1.c 572f64c71e0fe3 Zenghui Yu 2020-10-22 2171 73fa0d10d077d9 Alex Williamson 2012-07-31 2172 static int vfio_iommu_type1_attach_group(void *iommu_data, c039d23cabc047 Christoph Hellwig 2021-08-03 2173 struct iommu_group *iommu_group, unsigned int flags) 73fa0d10d077d9 Alex Williamson 2012-07-31 2174 { 73fa0d10d077d9 Alex Williamson 2012-07-31 2175 struct vfio_iommu *iommu = iommu_data; c7396f2eac2bf9 Max Gurtovoy 2021-06-08 2176 struct vfio_iommu_group *group; 1ef3e2bc04223f Alex Williamson 2014-02-26 2177 struct vfio_domain *domain, *d; be068fa236c3d6 Lu Baolu 2019-04-12 2178 struct bus_type *bus = NULL; 73fa0d10d077d9 Alex Williamson 2012-07-31 2179 int ret; 9d72f87babf144 Eric Auger 2017-01-19 2180 bool resv_msi, msi_remap; 95f89e090618ef Joerg Roedel 2019-10-15 2181 phys_addr_t resv_msi_base = 0; bc9a05eef113e7 Christoph Hellwig 2021-04-01 2182 struct iommu_domain_geometry *geo; 1108696aecf048 Shameer Kolothum 2019-07-23 2183 LIST_HEAD(iova_copy); af029169b8fdae Shameer Kolothum 2019-07-23 2184 LIST_HEAD(group_resv_regions); 73fa0d10d077d9 Alex Williamson 2012-07-31 2185 73fa0d10d077d9 Alex Williamson 2012-07-31 2186 mutex_lock(&iommu->lock); 73fa0d10d077d9 Alex Williamson 2012-07-31 2187 572f64c71e0fe3 Zenghui Yu 2020-10-22 2188 /* Check for duplicates */ 572f64c71e0fe3 Zenghui Yu 2020-10-22 2189 if (vfio_iommu_find_iommu_group(iommu, iommu_group)) { 73fa0d10d077d9 Alex Williamson 2012-07-31 2190 mutex_unlock(&iommu->lock); 73fa0d10d077d9 Alex Williamson 2012-07-31 2191 return -EINVAL; 73fa0d10d077d9 Alex Williamson 2012-07-31 2192 } a54eb55045ae9b Kirti Wankhede 2016-11-17 2193 1ef3e2bc04223f Alex Williamson 2014-02-26 2194 group = kzalloc(sizeof(*group), GFP_KERNEL); a01ec97a8a84ad Christoph Hellwig 2021-08-03 2195 if (!group) a01ec97a8a84ad Christoph Hellwig 2021-08-03 2196 return -ENOMEM; 1ef3e2bc04223f Alex Williamson 2014-02-26 2197 group->iommu_group = iommu_group; 1ef3e2bc04223f Alex Williamson 2014-02-26 2198 c039d23cabc047 Christoph Hellwig 2021-08-03 2199 if (flags & VFIO_MEDIATED) { a01ec97a8a84ad Christoph Hellwig 2021-08-03 2200 list_add(&group->next, &iommu->mediated_groups); 95fc87b44104d9 Kirti Wankhede 2020-05-29 2201 /* c570e6a2605c7e Christoph Hellwig 2021-05-07 2202 * Non-iommu backed group cannot dirty memory directly, it can c570e6a2605c7e Christoph Hellwig 2021-05-07 2203 * only use interfaces that provide dirty tracking. c570e6a2605c7e Christoph Hellwig 2021-05-07 2204 * The iommu scope can only be promoted with the addition of a c570e6a2605c7e Christoph Hellwig 2021-05-07 2205 * dirty tracking group. 95fc87b44104d9 Kirti Wankhede 2020-05-29 2206 */ 95fc87b44104d9 Kirti Wankhede 2020-05-29 2207 group->pinned_page_dirty_scope = true; a54eb55045ae9b Kirti Wankhede 2016-11-17 2208 mutex_unlock(&iommu->lock); be068fa236c3d6 Lu Baolu 2019-04-12 2209 a54eb55045ae9b Kirti Wankhede 2016-11-17 2210 return 0; a54eb55045ae9b Kirti Wankhede 2016-11-17 2211 } be068fa236c3d6 Lu Baolu 2019-04-12 2212 a01ec97a8a84ad Christoph Hellwig 2021-08-03 2213 /* Determine bus_type in order to allocate a domain */ a01ec97a8a84ad Christoph Hellwig 2021-08-03 2214 ret = iommu_group_for_each_dev(iommu_group, &bus, vfio_bus_type); a01ec97a8a84ad Christoph Hellwig 2021-08-03 2215 if (ret) a01ec97a8a84ad Christoph Hellwig 2021-08-03 2216 goto out_free_group; a01ec97a8a84ad Christoph Hellwig 2021-08-03 2217 a01ec97a8a84ad Christoph Hellwig 2021-08-03 2218 ret = -ENOMEM; a01ec97a8a84ad Christoph Hellwig 2021-08-03 2219 domain = kzalloc(sizeof(*domain), GFP_KERNEL); a01ec97a8a84ad Christoph Hellwig 2021-08-03 2220 if (!domain) a01ec97a8a84ad Christoph Hellwig 2021-08-03 2221 goto out_free_group; a01ec97a8a84ad Christoph Hellwig 2021-08-03 2222 1ef3e2bc04223f Alex Williamson 2014-02-26 2223 ret = -EIO; a01ec97a8a84ad Christoph Hellwig 2021-08-03 2224 domain->domain = iommu_domain_alloc(bus); a01ec97a8a84ad Christoph Hellwig 2021-08-03 2225 if (!domain->domain) a01ec97a8a84ad Christoph Hellwig 2021-08-03 2226 goto out_free_domain; 1ef3e2bc04223f Alex Williamson 2014-02-26 2227 f5c9ecebaf2a2c Will Deacon 2014-09-29 2228 if (iommu->nesting) { 7e147547783a90 Christoph Hellwig 2021-04-01 2229 ret = iommu_enable_nesting(domain->domain); f5c9ecebaf2a2c Will Deacon 2014-09-29 2230 if (ret) f5c9ecebaf2a2c Will Deacon 2014-09-29 2231 goto out_domain; f5c9ecebaf2a2c Will Deacon 2014-09-29 2232 } f5c9ecebaf2a2c Will Deacon 2014-09-29 2233 c570e6a2605c7e Christoph Hellwig 2021-05-07 2234 ret = iommu_attach_group(domain->domain, group->iommu_group); 1ef3e2bc04223f Alex Williamson 2014-02-26 2235 if (ret) 1ef3e2bc04223f Alex Williamson 2014-02-26 2236 goto out_domain; 1ef3e2bc04223f Alex Williamson 2014-02-26 2237 1108696aecf048 Shameer Kolothum 2019-07-23 2238 /* Get aperture info */ bc9a05eef113e7 Christoph Hellwig 2021-04-01 2239 geo = &domain->domain->geometry; bc9a05eef113e7 Christoph Hellwig 2021-04-01 2240 if (vfio_iommu_aper_conflict(iommu, geo->aperture_start, bc9a05eef113e7 Christoph Hellwig 2021-04-01 2241 geo->aperture_end)) { 1108696aecf048 Shameer Kolothum 2019-07-23 2242 ret = -EINVAL; 1108696aecf048 Shameer Kolothum 2019-07-23 2243 goto out_detach; 1108696aecf048 Shameer Kolothum 2019-07-23 2244 } 1108696aecf048 Shameer Kolothum 2019-07-23 2245 af029169b8fdae Shameer Kolothum 2019-07-23 2246 ret = iommu_get_group_resv_regions(iommu_group, &group_resv_regions); af029169b8fdae Shameer Kolothum 2019-07-23 2247 if (ret) af029169b8fdae Shameer Kolothum 2019-07-23 2248 goto out_detach; af029169b8fdae Shameer Kolothum 2019-07-23 2249 af029169b8fdae Shameer Kolothum 2019-07-23 2250 if (vfio_iommu_resv_conflict(iommu, &group_resv_regions)) { af029169b8fdae Shameer Kolothum 2019-07-23 2251 ret = -EINVAL; af029169b8fdae Shameer Kolothum 2019-07-23 2252 goto out_detach; af029169b8fdae Shameer Kolothum 2019-07-23 2253 } af029169b8fdae Shameer Kolothum 2019-07-23 2254 1108696aecf048 Shameer Kolothum 2019-07-23 2255 /* 1108696aecf048 Shameer Kolothum 2019-07-23 2256 * We don't want to work on the original iova list as the list 1108696aecf048 Shameer Kolothum 2019-07-23 2257 * gets modified and in case of failure we have to retain the 1108696aecf048 Shameer Kolothum 2019-07-23 2258 * original list. Get a copy here. 1108696aecf048 Shameer Kolothum 2019-07-23 2259 */ 1108696aecf048 Shameer Kolothum 2019-07-23 2260 ret = vfio_iommu_iova_get_copy(iommu, &iova_copy); 1108696aecf048 Shameer Kolothum 2019-07-23 2261 if (ret) 1108696aecf048 Shameer Kolothum 2019-07-23 2262 goto out_detach; 1108696aecf048 Shameer Kolothum 2019-07-23 2263 bc9a05eef113e7 Christoph Hellwig 2021-04-01 2264 ret = vfio_iommu_aper_resize(&iova_copy, geo->aperture_start, bc9a05eef113e7 Christoph Hellwig 2021-04-01 2265 geo->aperture_end); 1108696aecf048 Shameer Kolothum 2019-07-23 2266 if (ret) 1108696aecf048 Shameer Kolothum 2019-07-23 2267 goto out_detach; 1108696aecf048 Shameer Kolothum 2019-07-23 2268 af029169b8fdae Shameer Kolothum 2019-07-23 2269 ret = vfio_iommu_resv_exclude(&iova_copy, &group_resv_regions); af029169b8fdae Shameer Kolothum 2019-07-23 2270 if (ret) af029169b8fdae Shameer Kolothum 2019-07-23 2271 goto out_detach; af029169b8fdae Shameer Kolothum 2019-07-23 2272 b09d6e47397409 Shameer Kolothum 2019-07-23 2273 resv_msi = vfio_iommu_has_sw_msi(&group_resv_regions, &resv_msi_base); 5d704992189fe8 Eric Auger 2017-01-19 2274 1ef3e2bc04223f Alex Williamson 2014-02-26 2275 INIT_LIST_HEAD(&domain->group_list); 1ef3e2bc04223f Alex Williamson 2014-02-26 2276 list_add(&group->next, &domain->group_list); 1ef3e2bc04223f Alex Williamson 2014-02-26 2277 db406cc0ac2d5d Robin Murphy 2017-08-10 2278 msi_remap = irq_domain_check_msi_remap() || 9d72f87babf144 Eric Auger 2017-01-19 2279 iommu_capable(bus, IOMMU_CAP_INTR_REMAP); 9d72f87babf144 Eric Auger 2017-01-19 2280 9d72f87babf144 Eric Auger 2017-01-19 2281 if (!allow_unsafe_interrupts && !msi_remap) { 1ef3e2bc04223f Alex Williamson 2014-02-26 2282 pr_warn("%s: No interrupt remapping support. Use the module param \"allow_unsafe_interrupts\" to enable VFIO IOMMU support on this platform\n", 1ef3e2bc04223f Alex Williamson 2014-02-26 2283 __func__); 1ef3e2bc04223f Alex Williamson 2014-02-26 2284 ret = -EPERM; 1ef3e2bc04223f Alex Williamson 2014-02-26 2285 goto out_detach; 1ef3e2bc04223f Alex Williamson 2014-02-26 2286 } 1ef3e2bc04223f Alex Williamson 2014-02-26 2287 eb165f0584d2c0 Joerg Roedel 2014-09-05 2288 if (iommu_capable(bus, IOMMU_CAP_CACHE_COHERENCY)) 1ef3e2bc04223f Alex Williamson 2014-02-26 2289 domain->prot |= IOMMU_CACHE; 1ef3e2bc04223f Alex Williamson 2014-02-26 2290 73fa0d10d077d9 Alex Williamson 2012-07-31 2291 /* 1ef3e2bc04223f Alex Williamson 2014-02-26 2292 * Try to match an existing compatible domain. We don't want to 1ef3e2bc04223f Alex Williamson 2014-02-26 2293 * preclude an IOMMU driver supporting multiple bus_types and being 1ef3e2bc04223f Alex Williamson 2014-02-26 2294 * able to include different bus_types in the same IOMMU domain, so 1ef3e2bc04223f Alex Williamson 2014-02-26 2295 * we test whether the domains use the same iommu_ops rather than 1ef3e2bc04223f Alex Williamson 2014-02-26 2296 * testing if they're on the same bus_type. 73fa0d10d077d9 Alex Williamson 2012-07-31 2297 */ 1ef3e2bc04223f Alex Williamson 2014-02-26 2298 list_for_each_entry(d, &iommu->domain_list, next) { 1ef3e2bc04223f Alex Williamson 2014-02-26 2299 if (d->domain->ops == domain->domain->ops && 1ef3e2bc04223f Alex Williamson 2014-02-26 2300 d->prot == domain->prot) { c570e6a2605c7e Christoph Hellwig 2021-05-07 2301 iommu_detach_group(domain->domain, group->iommu_group); c570e6a2605c7e Christoph Hellwig 2021-05-07 2302 if (!iommu_attach_group(d->domain, c570e6a2605c7e Christoph Hellwig 2021-05-07 2303 group->iommu_group)) { 1ef3e2bc04223f Alex Williamson 2014-02-26 2304 list_add(&group->next, &d->group_list); 1ef3e2bc04223f Alex Williamson 2014-02-26 2305 iommu_domain_free(domain->domain); 1ef3e2bc04223f Alex Williamson 2014-02-26 2306 kfree(domain); 1108696aecf048 Shameer Kolothum 2019-07-23 2307 goto done; 73fa0d10d077d9 Alex Williamson 2012-07-31 2308 } 73fa0d10d077d9 Alex Williamson 2012-07-31 2309 c570e6a2605c7e Christoph Hellwig 2021-05-07 2310 ret = iommu_attach_group(domain->domain, c570e6a2605c7e Christoph Hellwig 2021-05-07 2311 group->iommu_group); 1ef3e2bc04223f Alex Williamson 2014-02-26 2312 if (ret) 1ef3e2bc04223f Alex Williamson 2014-02-26 2313 goto out_domain; 1ef3e2bc04223f Alex Williamson 2014-02-26 2314 } 1ef3e2bc04223f Alex Williamson 2014-02-26 2315 } 1ef3e2bc04223f Alex Williamson 2014-02-26 2316 6fe1010d6d9c02 Alex Williamson 2015-02-06 2317 vfio_test_domain_fgsp(domain); 6fe1010d6d9c02 Alex Williamson 2015-02-06 2318 1ef3e2bc04223f Alex Williamson 2014-02-26 2319 /* replay mappings on new domains */ 1ef3e2bc04223f Alex Williamson 2014-02-26 2320 ret = vfio_iommu_replay(iommu, domain); 1ef3e2bc04223f Alex Williamson 2014-02-26 2321 if (ret) 1ef3e2bc04223f Alex Williamson 2014-02-26 2322 goto out_detach; 1ef3e2bc04223f Alex Williamson 2014-02-26 2323 2c9f1af528a458 Wei Yongjun 2017-02-09 2324 if (resv_msi) { 2c9f1af528a458 Wei Yongjun 2017-02-09 2325 ret = iommu_get_msi_cookie(domain->domain, resv_msi_base); f44efca0493ddc Andre Przywara 2020-04-01 2326 if (ret && ret != -ENODEV) 5d704992189fe8 Eric Auger 2017-01-19 2327 goto out_detach; 2c9f1af528a458 Wei Yongjun 2017-02-09 2328 } 5d704992189fe8 Eric Auger 2017-01-19 2329 1ef3e2bc04223f Alex Williamson 2014-02-26 2330 list_add(&domain->next, &iommu->domain_list); cade075f265b25 Kirti Wankhede 2020-05-29 2331 vfio_update_pgsize_bitmap(iommu); 1108696aecf048 Shameer Kolothum 2019-07-23 2332 done: 1108696aecf048 Shameer Kolothum 2019-07-23 2333 /* Delete the old one and insert new iova list */ 1108696aecf048 Shameer Kolothum 2019-07-23 2334 vfio_iommu_iova_insert_copy(iommu, &iova_copy); 95fc87b44104d9 Kirti Wankhede 2020-05-29 2335 95fc87b44104d9 Kirti Wankhede 2020-05-29 2336 /* 95fc87b44104d9 Kirti Wankhede 2020-05-29 2337 * An iommu backed group can dirty memory directly and therefore 95fc87b44104d9 Kirti Wankhede 2020-05-29 2338 * demotes the iommu scope until it declares itself dirty tracking 95fc87b44104d9 Kirti Wankhede 2020-05-29 2339 * capable via the page pinning interface. 95fc87b44104d9 Kirti Wankhede 2020-05-29 2340 */ 010321565a7d2c Keqian Zhu 2021-01-25 2341 iommu->num_non_pinned_groups++; 73fa0d10d077d9 Alex Williamson 2012-07-31 2342 mutex_unlock(&iommu->lock); af029169b8fdae Shameer Kolothum 2019-07-23 2343 vfio_iommu_resv_free(&group_resv_regions); 73fa0d10d077d9 Alex Williamson 2012-07-31 2344 73fa0d10d077d9 Alex Williamson 2012-07-31 2345 return 0; 1ef3e2bc04223f Alex Williamson 2014-02-26 2346 1ef3e2bc04223f Alex Williamson 2014-02-26 2347 out_detach: c570e6a2605c7e Christoph Hellwig 2021-05-07 2348 iommu_detach_group(domain->domain, group->iommu_group); 1ef3e2bc04223f Alex Williamson 2014-02-26 2349 out_domain: 1ef3e2bc04223f Alex Williamson 2014-02-26 2350 iommu_domain_free(domain->domain); 1108696aecf048 Shameer Kolothum 2019-07-23 2351 vfio_iommu_iova_free(&iova_copy); af029169b8fdae Shameer Kolothum 2019-07-23 2352 vfio_iommu_resv_free(&group_resv_regions); a01ec97a8a84ad Christoph Hellwig 2021-08-03 2353 out_free_domain: 1ef3e2bc04223f Alex Williamson 2014-02-26 2354 kfree(domain); a01ec97a8a84ad Christoph Hellwig 2021-08-03 2355 out_free_group: 1ef3e2bc04223f Alex Williamson 2014-02-26 2356 kfree(group); 1ef3e2bc04223f Alex Williamson 2014-02-26 2357 mutex_unlock(&iommu->lock); 1ef3e2bc04223f Alex Williamson 2014-02-26 @2358 return ret; 1ef3e2bc04223f Alex Williamson 2014-02-26 2359 } 1ef3e2bc04223f Alex Williamson 2014-02-26 2360 :::::: The code at line 2358 was first introduced by commit :::::: 1ef3e2bc04223ff956dc62abaf2dff1f3322a431 vfio/iommu_type1: Multi-IOMMU domain support :::::: TO: Alex Williamson <[email protected]> :::::: CC: Alex Williamson <[email protected]> --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/[email protected]
.config.gz
Description: application/gzip
_______________________________________________ kbuild mailing list -- [email protected] To unsubscribe send an email to [email protected]
