All of lore.kernel.org
 help / color / mirror / Atom feed
* drivers/xen/grant-dma-ops.c:174 xen_grant_dma_map_phys() warn: mask and shift to zero: expr='offset >> 12'
@ 2026-02-16 22:02 kernel test robot
  0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2026-02-16 22:02 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Leon Romanovsky <leonro@nvidia.com>
CC: Marek Szyprowski <m.szyprowski@samsung.com>
CC: Jason Gunthorpe <jgg@nvidia.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   0f2acd3148e0ef42bdacbd477f90e8533f96b2ac
commit: 936a9f0cb16b0646143f8e05afab458adc51d0a0 xen: swiotlb: Convert mapping routine to rely on physical address
date:   4 months ago
:::::: branch date: 18 hours ago
:::::: commit date: 4 months ago
config: arm-randconfig-r072-20260217 (https://download.01.org/0day-ci/archive/20260217/202602170520.TSeikPfm-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 10.5.0
smatch version: v0.5.0-8994-gd50c5a4c

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/202602170520.TSeikPfm-lkp@intel.com/

smatch warnings:
drivers/xen/grant-dma-ops.c:174 xen_grant_dma_map_phys() warn: mask and shift to zero: expr='offset >> 12'

vim +174 drivers/xen/grant-dma-ops.c

d6aca3504c7ded Juergen Gross        2022-06-02  165  
936a9f0cb16b06 Leon Romanovsky      2025-10-15  166  static dma_addr_t xen_grant_dma_map_phys(struct device *dev, phys_addr_t phys,
936a9f0cb16b06 Leon Romanovsky      2025-10-15  167  					 size_t size,
d6aca3504c7ded Juergen Gross        2022-06-02  168  					 enum dma_data_direction dir,
d6aca3504c7ded Juergen Gross        2022-06-02  169  					 unsigned long attrs)
d6aca3504c7ded Juergen Gross        2022-06-02  170  {
d6aca3504c7ded Juergen Gross        2022-06-02  171  	struct xen_grant_dma_data *data;
936a9f0cb16b06 Leon Romanovsky      2025-10-15  172  	unsigned long offset = offset_in_page(phys);
a383dcb1cca830 Oleksandr Tyshchenko 2022-10-08  173  	unsigned long dma_offset = xen_offset_in_page(offset),
a383dcb1cca830 Oleksandr Tyshchenko 2022-10-08 @174  			pfn_offset = XEN_PFN_DOWN(offset);
a383dcb1cca830 Oleksandr Tyshchenko 2022-10-08  175  	unsigned int i, n_pages = XEN_PFN_UP(dma_offset + size);
d6aca3504c7ded Juergen Gross        2022-06-02  176  	grant_ref_t grant;
d6aca3504c7ded Juergen Gross        2022-06-02  177  	dma_addr_t dma_handle;
d6aca3504c7ded Juergen Gross        2022-06-02  178  
936a9f0cb16b06 Leon Romanovsky      2025-10-15  179  	if (unlikely(attrs & DMA_ATTR_MMIO))
936a9f0cb16b06 Leon Romanovsky      2025-10-15  180  		return DMA_MAPPING_ERROR;
936a9f0cb16b06 Leon Romanovsky      2025-10-15  181  
d6aca3504c7ded Juergen Gross        2022-06-02  182  	if (WARN_ON(dir == DMA_NONE))
d6aca3504c7ded Juergen Gross        2022-06-02  183  		return DMA_MAPPING_ERROR;
d6aca3504c7ded Juergen Gross        2022-06-02  184  
d6aca3504c7ded Juergen Gross        2022-06-02  185  	data = find_xen_grant_dma_data(dev);
d6aca3504c7ded Juergen Gross        2022-06-02  186  	if (!data)
d6aca3504c7ded Juergen Gross        2022-06-02  187  		return DMA_MAPPING_ERROR;
d6aca3504c7ded Juergen Gross        2022-06-02  188  
d6aca3504c7ded Juergen Gross        2022-06-02  189  	if (unlikely(data->broken))
d6aca3504c7ded Juergen Gross        2022-06-02  190  		return DMA_MAPPING_ERROR;
d6aca3504c7ded Juergen Gross        2022-06-02  191  
d6aca3504c7ded Juergen Gross        2022-06-02  192  	if (gnttab_alloc_grant_reference_seq(n_pages, &grant))
d6aca3504c7ded Juergen Gross        2022-06-02  193  		return DMA_MAPPING_ERROR;
d6aca3504c7ded Juergen Gross        2022-06-02  194  
d6aca3504c7ded Juergen Gross        2022-06-02  195  	for (i = 0; i < n_pages; i++) {
d6aca3504c7ded Juergen Gross        2022-06-02  196  		gnttab_grant_foreign_access_ref(grant + i, data->backend_domid,
936a9f0cb16b06 Leon Romanovsky      2025-10-15  197  				pfn_to_gfn(page_to_xen_pfn(phys_to_page(phys)) + i + pfn_offset),
875553e317b28e Oleksandr Tyshchenko 2022-10-08  198  				dir == DMA_TO_DEVICE);
d6aca3504c7ded Juergen Gross        2022-06-02  199  	}
d6aca3504c7ded Juergen Gross        2022-06-02  200  
875553e317b28e Oleksandr Tyshchenko 2022-10-08  201  	dma_handle = grant_to_dma(grant) + dma_offset;
d6aca3504c7ded Juergen Gross        2022-06-02  202  
d6aca3504c7ded Juergen Gross        2022-06-02  203  	return dma_handle;
d6aca3504c7ded Juergen Gross        2022-06-02  204  }
d6aca3504c7ded Juergen Gross        2022-06-02  205  

:::::: The code at line 174 was first introduced by commit
:::::: a383dcb1cca8305497877119fba0a320f41fe853 xen/virtio: Convert PAGE_SIZE/PAGE_SHIFT/PFN_UP to Xen counterparts

:::::: TO: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
:::::: CC: Juergen Gross <jgross@suse.com>

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

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

* drivers/xen/grant-dma-ops.c:174 xen_grant_dma_map_phys() warn: mask and shift to zero: expr='offset >> 12'
@ 2026-06-05  1:23 kernel test robot
  0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2026-06-05  1:23 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Leon Romanovsky <leonro@nvidia.com>
CC: Marek Szyprowski <m.szyprowski@samsung.com>
CC: Jason Gunthorpe <jgg@nvidia.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   ddd664bbff63e09e7a7f9acae9c43605d4cf185f
commit: 936a9f0cb16b0646143f8e05afab458adc51d0a0 xen: swiotlb: Convert mapping routine to rely on physical address
date:   7 months ago
:::::: branch date: 4 hours ago
:::::: commit date: 7 months ago
config: x86_64-randconfig-161-20260605 (https://download.01.org/0day-ci/archive/20260605/202606050924.np68TBk4-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
smatch: v0.5.0-9185-gbcc58b9c

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
| Fixes: 936a9f0cb16b ("xen: swiotlb: Convert mapping routine to rely on physical address")
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202606050924.np68TBk4-lkp@intel.com/

smatch warnings:
drivers/xen/grant-dma-ops.c:174 xen_grant_dma_map_phys() warn: mask and shift to zero: expr='offset >> 12'

vim +174 drivers/xen/grant-dma-ops.c

d6aca3504c7ded Juergen Gross        2022-06-02  165  
936a9f0cb16b06 Leon Romanovsky      2025-10-15  166  static dma_addr_t xen_grant_dma_map_phys(struct device *dev, phys_addr_t phys,
936a9f0cb16b06 Leon Romanovsky      2025-10-15  167  					 size_t size,
d6aca3504c7ded Juergen Gross        2022-06-02  168  					 enum dma_data_direction dir,
d6aca3504c7ded Juergen Gross        2022-06-02  169  					 unsigned long attrs)
d6aca3504c7ded Juergen Gross        2022-06-02  170  {
d6aca3504c7ded Juergen Gross        2022-06-02  171  	struct xen_grant_dma_data *data;
936a9f0cb16b06 Leon Romanovsky      2025-10-15  172  	unsigned long offset = offset_in_page(phys);
a383dcb1cca830 Oleksandr Tyshchenko 2022-10-08  173  	unsigned long dma_offset = xen_offset_in_page(offset),
a383dcb1cca830 Oleksandr Tyshchenko 2022-10-08 @174  			pfn_offset = XEN_PFN_DOWN(offset);
a383dcb1cca830 Oleksandr Tyshchenko 2022-10-08  175  	unsigned int i, n_pages = XEN_PFN_UP(dma_offset + size);
d6aca3504c7ded Juergen Gross        2022-06-02  176  	grant_ref_t grant;
d6aca3504c7ded Juergen Gross        2022-06-02  177  	dma_addr_t dma_handle;
d6aca3504c7ded Juergen Gross        2022-06-02  178  
936a9f0cb16b06 Leon Romanovsky      2025-10-15  179  	if (unlikely(attrs & DMA_ATTR_MMIO))
936a9f0cb16b06 Leon Romanovsky      2025-10-15  180  		return DMA_MAPPING_ERROR;
936a9f0cb16b06 Leon Romanovsky      2025-10-15  181  
d6aca3504c7ded Juergen Gross        2022-06-02  182  	if (WARN_ON(dir == DMA_NONE))
d6aca3504c7ded Juergen Gross        2022-06-02  183  		return DMA_MAPPING_ERROR;
d6aca3504c7ded Juergen Gross        2022-06-02  184  
d6aca3504c7ded Juergen Gross        2022-06-02  185  	data = find_xen_grant_dma_data(dev);
d6aca3504c7ded Juergen Gross        2022-06-02  186  	if (!data)
d6aca3504c7ded Juergen Gross        2022-06-02  187  		return DMA_MAPPING_ERROR;
d6aca3504c7ded Juergen Gross        2022-06-02  188  
d6aca3504c7ded Juergen Gross        2022-06-02  189  	if (unlikely(data->broken))
d6aca3504c7ded Juergen Gross        2022-06-02  190  		return DMA_MAPPING_ERROR;
d6aca3504c7ded Juergen Gross        2022-06-02  191  
d6aca3504c7ded Juergen Gross        2022-06-02  192  	if (gnttab_alloc_grant_reference_seq(n_pages, &grant))
d6aca3504c7ded Juergen Gross        2022-06-02  193  		return DMA_MAPPING_ERROR;
d6aca3504c7ded Juergen Gross        2022-06-02  194  
d6aca3504c7ded Juergen Gross        2022-06-02  195  	for (i = 0; i < n_pages; i++) {
d6aca3504c7ded Juergen Gross        2022-06-02  196  		gnttab_grant_foreign_access_ref(grant + i, data->backend_domid,
936a9f0cb16b06 Leon Romanovsky      2025-10-15  197  				pfn_to_gfn(page_to_xen_pfn(phys_to_page(phys)) + i + pfn_offset),
875553e317b28e Oleksandr Tyshchenko 2022-10-08  198  				dir == DMA_TO_DEVICE);
d6aca3504c7ded Juergen Gross        2022-06-02  199  	}
d6aca3504c7ded Juergen Gross        2022-06-02  200  
875553e317b28e Oleksandr Tyshchenko 2022-10-08  201  	dma_handle = grant_to_dma(grant) + dma_offset;
d6aca3504c7ded Juergen Gross        2022-06-02  202  
d6aca3504c7ded Juergen Gross        2022-06-02  203  	return dma_handle;
d6aca3504c7ded Juergen Gross        2022-06-02  204  }
d6aca3504c7ded Juergen Gross        2022-06-02  205  

:::::: The code at line 174 was first introduced by commit
:::::: a383dcb1cca8305497877119fba0a320f41fe853 xen/virtio: Convert PAGE_SIZE/PAGE_SHIFT/PFN_UP to Xen counterparts

:::::: TO: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
:::::: CC: Juergen Gross <jgross@suse.com>

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

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

* drivers/xen/grant-dma-ops.c:174 xen_grant_dma_map_phys() warn: mask and shift to zero: expr='offset >> 12'
@ 2026-09-23 19:11 kernel test robot
  0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2026-09-23 19:11 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Leon Romanovsky <leonro@nvidia.com>
CC: Marek Szyprowski <m.szyprowski@samsung.com>
CC: Jason Gunthorpe <jgg@nvidia.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   fe2ec83746e501645709761605c2464a44fd2929
commit: 936a9f0cb16b0646143f8e05afab458adc51d0a0 xen: swiotlb: Convert mapping routine to rely on physical address
date:   11 months ago
:::::: branch date: 26 hours ago
:::::: commit date: 11 months ago
config: arm64-randconfig-r2201-20260923 (https://download.01.org/0day-ci/archive/20260923/202609232135.404BR1OX-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 945b9128ca6655df0dd372067988fea8d6bb8ed1)
smatch: v0.5.0-9187-g5189e3fb

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
| Fixes: 936a9f0cb16b ("xen: swiotlb: Convert mapping routine to rely on physical address")
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202609232135.404BR1OX-lkp@intel.com/

smatch warnings:
drivers/xen/grant-dma-ops.c:174 xen_grant_dma_map_phys() warn: mask and shift to zero: expr='offset >> 12'

vim +174 drivers/xen/grant-dma-ops.c

d6aca3504c7ded Juergen Gross        2022-06-02  165  
936a9f0cb16b06 Leon Romanovsky      2025-10-15  166  static dma_addr_t xen_grant_dma_map_phys(struct device *dev, phys_addr_t phys,
936a9f0cb16b06 Leon Romanovsky      2025-10-15  167  					 size_t size,
d6aca3504c7ded Juergen Gross        2022-06-02  168  					 enum dma_data_direction dir,
d6aca3504c7ded Juergen Gross        2022-06-02  169  					 unsigned long attrs)
d6aca3504c7ded Juergen Gross        2022-06-02  170  {
d6aca3504c7ded Juergen Gross        2022-06-02  171  	struct xen_grant_dma_data *data;
936a9f0cb16b06 Leon Romanovsky      2025-10-15  172  	unsigned long offset = offset_in_page(phys);
a383dcb1cca830 Oleksandr Tyshchenko 2022-10-08  173  	unsigned long dma_offset = xen_offset_in_page(offset),
a383dcb1cca830 Oleksandr Tyshchenko 2022-10-08 @174  			pfn_offset = XEN_PFN_DOWN(offset);
a383dcb1cca830 Oleksandr Tyshchenko 2022-10-08  175  	unsigned int i, n_pages = XEN_PFN_UP(dma_offset + size);
d6aca3504c7ded Juergen Gross        2022-06-02  176  	grant_ref_t grant;
d6aca3504c7ded Juergen Gross        2022-06-02  177  	dma_addr_t dma_handle;
d6aca3504c7ded Juergen Gross        2022-06-02  178  
936a9f0cb16b06 Leon Romanovsky      2025-10-15  179  	if (unlikely(attrs & DMA_ATTR_MMIO))
936a9f0cb16b06 Leon Romanovsky      2025-10-15  180  		return DMA_MAPPING_ERROR;
936a9f0cb16b06 Leon Romanovsky      2025-10-15  181  
d6aca3504c7ded Juergen Gross        2022-06-02  182  	if (WARN_ON(dir == DMA_NONE))
d6aca3504c7ded Juergen Gross        2022-06-02  183  		return DMA_MAPPING_ERROR;
d6aca3504c7ded Juergen Gross        2022-06-02  184  
d6aca3504c7ded Juergen Gross        2022-06-02  185  	data = find_xen_grant_dma_data(dev);
d6aca3504c7ded Juergen Gross        2022-06-02  186  	if (!data)
d6aca3504c7ded Juergen Gross        2022-06-02  187  		return DMA_MAPPING_ERROR;
d6aca3504c7ded Juergen Gross        2022-06-02  188  
d6aca3504c7ded Juergen Gross        2022-06-02  189  	if (unlikely(data->broken))
d6aca3504c7ded Juergen Gross        2022-06-02  190  		return DMA_MAPPING_ERROR;
d6aca3504c7ded Juergen Gross        2022-06-02  191  
d6aca3504c7ded Juergen Gross        2022-06-02  192  	if (gnttab_alloc_grant_reference_seq(n_pages, &grant))
d6aca3504c7ded Juergen Gross        2022-06-02  193  		return DMA_MAPPING_ERROR;
d6aca3504c7ded Juergen Gross        2022-06-02  194  
d6aca3504c7ded Juergen Gross        2022-06-02  195  	for (i = 0; i < n_pages; i++) {
d6aca3504c7ded Juergen Gross        2022-06-02  196  		gnttab_grant_foreign_access_ref(grant + i, data->backend_domid,
936a9f0cb16b06 Leon Romanovsky      2025-10-15  197  				pfn_to_gfn(page_to_xen_pfn(phys_to_page(phys)) + i + pfn_offset),
875553e317b28e Oleksandr Tyshchenko 2022-10-08  198  				dir == DMA_TO_DEVICE);
d6aca3504c7ded Juergen Gross        2022-06-02  199  	}
d6aca3504c7ded Juergen Gross        2022-06-02  200  
875553e317b28e Oleksandr Tyshchenko 2022-10-08  201  	dma_handle = grant_to_dma(grant) + dma_offset;
d6aca3504c7ded Juergen Gross        2022-06-02  202  
d6aca3504c7ded Juergen Gross        2022-06-02  203  	return dma_handle;
d6aca3504c7ded Juergen Gross        2022-06-02  204  }
d6aca3504c7ded Juergen Gross        2022-06-02  205  

:::::: The code at line 174 was first introduced by commit
:::::: a383dcb1cca8305497877119fba0a320f41fe853 xen/virtio: Convert PAGE_SIZE/PAGE_SHIFT/PFN_UP to Xen counterparts

:::::: TO: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
:::::: CC: Juergen Gross <jgross@suse.com>

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

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

end of thread, other threads:[~2026-09-23 19:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-23 19:11 drivers/xen/grant-dma-ops.c:174 xen_grant_dma_map_phys() warn: mask and shift to zero: expr='offset >> 12' kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2026-06-05  1:23 kernel test robot
2026-02-16 22:02 kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.