0 day kernel build service
 help / color / mirror / Atom feed
* Re: [PATCH v4 09/25] iommu: Allow an IDENTITY domain as the default_domain in ARM32
@ 2023-06-17  6:28 kernel test robot
  0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2023-06-17  6:28 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <9-v4-874277bde66e+1a9f6-iommu_all_defdom_jgg@nvidia.com>
References: <9-v4-874277bde66e+1a9f6-iommu_all_defdom_jgg@nvidia.com>
TO: Jason Gunthorpe <jgg@nvidia.com>

Hi Jason,

kernel test robot noticed the following build warnings:

[auto build test WARNING on fe420865bd74f5917ff0d8d38a46fbbbe5dd1ea6]

url:    https://github.com/intel-lab-lkp/linux/commits/Jason-Gunthorpe/iommu-Add-iommu_ops-identity_domain/20230617-032631
base:   fe420865bd74f5917ff0d8d38a46fbbbe5dd1ea6
patch link:    https://lore.kernel.org/r/9-v4-874277bde66e%2B1a9f6-iommu_all_defdom_jgg%40nvidia.com
patch subject: [PATCH v4 09/25] iommu: Allow an IDENTITY domain as the default_domain in ARM32
:::::: branch date: 11 hours ago
:::::: commit date: 11 hours ago
config: arm-randconfig-m031-20230611 (https://download.01.org/0day-ci/archive/20230617/202306171458.LfWLILeK-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230617/202306171458.LfWLILeK-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202306171458.LfWLILeK-lkp@intel.com/

smatch warnings:
drivers/iommu/iommu.c:1800 iommu_get_default_domain_type() error: potentially dereferencing uninitialized 'gdev'.

vim +/gdev +1800 drivers/iommu/iommu.c

d72e31c9374627 Alex Williamson 2012-05-30  1746  
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1747  /* A target_type of 0 will select the best domain type and cannot fail */
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1748  static int iommu_get_default_domain_type(struct iommu_group *group,
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1749  					 int target_type)
deac0b3bed26bb Joerg Roedel    2020-04-29  1750  {
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1751  	const struct iommu_ops *ops = dev_iommu_ops(
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1752  		list_first_entry(&group->devices, struct group_device, list)
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1753  			->dev);
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1754  	int best_type = target_type;
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1755  	struct group_device *gdev;
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1756  	struct device *last_dev;
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1757  	int type;
deac0b3bed26bb Joerg Roedel    2020-04-29  1758  
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1759  	lockdep_assert_held(&group->mutex);
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1760  
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1761  	/*
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1762  	 * ARM32 drivers supporting CONFIG_ARM_DMA_USE_IOMMU can declare an
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1763  	 * identity_domain and it will automatically become their default
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1764  	 * domain. Later on ARM_DMA_USE_IOMMU will install its UNMANAGED domain.
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1765  	 * Override the selection to IDENTITY if we are sure the driver supports
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1766  	 * it.
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1767  	 */
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1768  	if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU) && ops->identity_domain) {
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1769  		type = IOMMU_DOMAIN_IDENTITY;
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1770  		if (best_type && type && best_type != type)
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1771  			goto err;
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1772  		best_type = target_type = IOMMU_DOMAIN_IDENTITY;
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1773  	}
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1774  
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1775  	for_each_group_device(group, gdev) {
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1776  		type = best_type;
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1777  		if (ops->def_domain_type) {
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1778  			type = ops->def_domain_type(gdev->dev);
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1779  			if (best_type && type && best_type != type) {
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1780  				/* Stick with the last driver override we saw */
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1781  				best_type = type;
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1782  				goto err;
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1783  			}
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1784  		}
deac0b3bed26bb Joerg Roedel    2020-04-29  1785  
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1786  		/* No ARM32 using systems will set untrusted, it cannot work. */
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1787  		if (dev_is_pci(gdev->dev) && to_pci_dev(gdev->dev)->untrusted &&
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1788  		    !WARN_ON(IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU))) {
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1789  			type = IOMMU_DOMAIN_DMA;
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1790  			if (best_type && type && best_type != type)
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1791  				goto err;
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1792  		}
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1793  		best_type = type;
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1794  		last_dev = gdev->dev;
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1795  	}
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1796  	return best_type;
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1797  
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1798  err:
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1799  	if (target_type) {
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11 @1800  		dev_err_ratelimited(
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1801  			gdev->dev,
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1802  			"Device cannot be in %s domain - it is forcing %s\n",
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1803  			iommu_domain_type_str(target_type),
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1804  			iommu_domain_type_str(type));
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1805  		return -1;
deac0b3bed26bb Joerg Roedel    2020-04-29  1806  	}
deac0b3bed26bb Joerg Roedel    2020-04-29  1807  
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1808  	dev_warn(
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1809  		gdev->dev,
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1810  		"Device needs domain type %s, but device %s in the same iommu group requires type %s - using default\n",
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1811  		iommu_domain_type_str(type), dev_name(last_dev),
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1812  		iommu_domain_type_str(best_type));
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1813  	return best_type;
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1814  }
deac0b3bed26bb Joerg Roedel    2020-04-29  1815  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v4 09/25] iommu: Allow an IDENTITY domain as the default_domain in ARM32
       [not found] <9-v4-874277bde66e+1a9f6-iommu_all_defdom_jgg@nvidia.com>
@ 2023-06-17 11:38 ` Dan Carpenter
  2023-06-19 18:48   ` Jason Gunthorpe
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2023-06-17 11:38 UTC (permalink / raw)
  To: oe-kbuild, Jason Gunthorpe; +Cc: lkp, oe-kbuild-all

Hi Jason,

kernel test robot noticed the following build warnings:

url:    https://github.com/intel-lab-lkp/linux/commits/Jason-Gunthorpe/iommu-Add-iommu_ops-identity_domain/20230617-032631
base:   fe420865bd74f5917ff0d8d38a46fbbbe5dd1ea6
patch link:    https://lore.kernel.org/r/9-v4-874277bde66e%2B1a9f6-iommu_all_defdom_jgg%40nvidia.com
patch subject: [PATCH v4 09/25] iommu: Allow an IDENTITY domain as the default_domain in ARM32
config: arm-randconfig-m031-20230611 (https://download.01.org/0day-ci/archive/20230617/202306171458.LfWLILeK-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230617/202306171458.LfWLILeK-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202306171458.LfWLILeK-lkp@intel.com/

smatch warnings:
drivers/iommu/iommu.c:1800 iommu_get_default_domain_type() error: potentially dereferencing uninitialized 'gdev'.

vim +/gdev +1800 drivers/iommu/iommu.c

8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1748  static int iommu_get_default_domain_type(struct iommu_group *group,
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1749  					 int target_type)
deac0b3bed26bb Joerg Roedel    2020-04-29  1750  {
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1751  	const struct iommu_ops *ops = dev_iommu_ops(
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1752  		list_first_entry(&group->devices, struct group_device, list)
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1753  			->dev);
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1754  	int best_type = target_type;
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1755  	struct group_device *gdev;
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1756  	struct device *last_dev;
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1757  	int type;
deac0b3bed26bb Joerg Roedel    2020-04-29  1758  
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1759  	lockdep_assert_held(&group->mutex);
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1760  
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1761  	/*
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1762  	 * ARM32 drivers supporting CONFIG_ARM_DMA_USE_IOMMU can declare an
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1763  	 * identity_domain and it will automatically become their default
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1764  	 * domain. Later on ARM_DMA_USE_IOMMU will install its UNMANAGED domain.
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1765  	 * Override the selection to IDENTITY if we are sure the driver supports
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1766  	 * it.
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1767  	 */
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1768  	if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU) && ops->identity_domain) {
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1769  		type = IOMMU_DOMAIN_IDENTITY;
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1770  		if (best_type && type && best_type != type)
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1771  			goto err;

gdev is uninitialized.

03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1772  		best_type = target_type = IOMMU_DOMAIN_IDENTITY;
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1773  	}
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1774  
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1775  	for_each_group_device(group, gdev) {
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1776  		type = best_type;
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1777  		if (ops->def_domain_type) {
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1778  			type = ops->def_domain_type(gdev->dev);
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1779  			if (best_type && type && best_type != type) {
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1780  				/* Stick with the last driver override we saw */
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1781  				best_type = type;
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1782  				goto err;
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1783  			}
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1784  		}
deac0b3bed26bb Joerg Roedel    2020-04-29  1785  
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1786  		/* No ARM32 using systems will set untrusted, it cannot work. */
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1787  		if (dev_is_pci(gdev->dev) && to_pci_dev(gdev->dev)->untrusted &&
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1788  		    !WARN_ON(IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU))) {
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1789  			type = IOMMU_DOMAIN_DMA;
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1790  			if (best_type && type && best_type != type)
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1791  				goto err;
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1792  		}
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1793  		best_type = type;
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1794  		last_dev = gdev->dev;
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1795  	}
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1796  	return best_type;
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1797  
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1798  err:
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1799  	if (target_type) {
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11 @1800  		dev_err_ratelimited(
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1801  			gdev->dev,
                                                                        ^^^^^^^^^

ddaf433cac2995 Jason Gunthorpe 2023-06-16  1802  			"Device cannot be in %s domain - it is forcing %s\n",
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1803  			iommu_domain_type_str(target_type),
ddaf433cac2995 Jason Gunthorpe 2023-06-16  1804  			iommu_domain_type_str(type));
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1805  		return -1;
deac0b3bed26bb Joerg Roedel    2020-04-29  1806  	}
deac0b3bed26bb Joerg Roedel    2020-04-29  1807  
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1808  	dev_warn(
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1809  		gdev->dev,
                                                                ^^^^^^^^^

8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1810  		"Device needs domain type %s, but device %s in the same iommu group requires type %s - using default\n",
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1811  		iommu_domain_type_str(type), dev_name(last_dev),
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1812  		iommu_domain_type_str(best_type));
03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1813  	return best_type;
8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1814  }

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v4 09/25] iommu: Allow an IDENTITY domain as the default_domain in ARM32
  2023-06-17 11:38 ` [PATCH v4 09/25] iommu: Allow an IDENTITY domain as the default_domain in ARM32 Dan Carpenter
@ 2023-06-19 18:48   ` Jason Gunthorpe
  0 siblings, 0 replies; 3+ messages in thread
From: Jason Gunthorpe @ 2023-06-19 18:48 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: oe-kbuild, lkp, oe-kbuild-all

On Sat, Jun 17, 2023 at 02:38:04PM +0300, Dan Carpenter wrote:

> 8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1748  static int iommu_get_default_domain_type(struct iommu_group *group,
> 8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1749  					 int target_type)
> deac0b3bed26bb Joerg Roedel    2020-04-29  1750  {
> ddaf433cac2995 Jason Gunthorpe 2023-06-16  1751  	const struct iommu_ops *ops = dev_iommu_ops(
> ddaf433cac2995 Jason Gunthorpe 2023-06-16  1752  		list_first_entry(&group->devices, struct group_device, list)
> ddaf433cac2995 Jason Gunthorpe 2023-06-16  1753  			->dev);
> 8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1754  	int best_type = target_type;
> 8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1755  	struct group_device *gdev;
> 8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1756  	struct device *last_dev;
> ddaf433cac2995 Jason Gunthorpe 2023-06-16  1757  	int type;
> deac0b3bed26bb Joerg Roedel    2020-04-29  1758  
> 8b4eb75ee50e6f Jason Gunthorpe 2023-05-11  1759  	lockdep_assert_held(&group->mutex);
> 03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1760  
> 03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1761  	/*
> 03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1762  	 * ARM32 drivers supporting CONFIG_ARM_DMA_USE_IOMMU can declare an
> 03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1763  	 * identity_domain and it will automatically become their default
> 03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1764  	 * domain. Later on ARM_DMA_USE_IOMMU will install its UNMANAGED domain.
> 03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1765  	 * Override the selection to IDENTITY if we are sure the driver supports
> 03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1766  	 * it.
> 03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1767  	 */
> 03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1768  	if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU) && ops->identity_domain) {
> 03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1769  		type = IOMMU_DOMAIN_IDENTITY;
> 03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1770  		if (best_type && type && best_type != type)
> 03c9e7d1dd3c99 Jason Gunthorpe 2023-06-16  1771  			goto err;
> 
> gdev is uninitialized.

Should be 'return -1;' here, I fixed it up

Thanks,
Jason

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-19 18:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <9-v4-874277bde66e+1a9f6-iommu_all_defdom_jgg@nvidia.com>
2023-06-17 11:38 ` [PATCH v4 09/25] iommu: Allow an IDENTITY domain as the default_domain in ARM32 Dan Carpenter
2023-06-19 18:48   ` Jason Gunthorpe
2023-06-17  6:28 kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox