All of lore.kernel.org
 help / color / mirror / Atom feed
* [ogabbay:habanalabs-next 39/44] drivers/misc/habanalabs/common/memory_mgr.c:177 hl_mem_mgr_mmap() warn: should 'vma->vm_pgoff << 12' be a 64 bit type?
@ 2022-05-02 16:31 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2022-05-02 16:31 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 4527 bytes --]

CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
CC: linux-kernel(a)vger.kernel.org
TO: Yuri Nudelman <ynudelman@habana.ai>
CC: Oded Gabbay <ogabbay@kernel.org>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/ogabbay/linux.git habanalabs-next
head:   31b4e207e4199cd59aac5e6f4f546bcc8410558b
commit: 7b93ce064842618e135c1eb98d62144a7b42c7f4 [39/44] habanalabs: hide memory manager page shift
:::::: branch date: 4 hours ago
:::::: commit date: 8 hours ago
config: i386-randconfig-m021 (https://download.01.org/0day-ci/archive/20220503/202205030041.4ZAjsOHz-lkp(a)intel.com/config)
compiler: gcc-11 (Debian 11.2.0-20) 11.2.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/misc/habanalabs/common/memory_mgr.c:177 hl_mem_mgr_mmap() warn: should 'vma->vm_pgoff << 12' be a 64 bit type?

vim +177 drivers/misc/habanalabs/common/memory_mgr.c

dbb42df4b94ab9 Yuri Nudelman          2022-03-20  156  
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  157  /**
a2cd87c2d89789 Rajaravi Krishna Katta 2022-04-01  158   * hl_mem_mgr_mmap - map the given buffer to the user
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  159   *
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  160   * @mmg: unifed memory manager
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  161   * @vma: the vma object for which mmap was closed.
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  162   * @args: additional args passed to behavior->mmap
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  163   *
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  164   * Map the buffer specified by the vma->vm_pgoff to the given vma.
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  165   */
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  166  int hl_mem_mgr_mmap(struct hl_mem_mgr *mmg, struct vm_area_struct *vma,
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  167  		    void *args)
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  168  {
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  169  	struct hl_mmap_mem_buf *buf;
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  170  	u64 user_mem_size;
7b93ce06484261 Yuri Nudelman          2022-03-23  171  	u64 handle;
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  172  	int rc;
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  173  
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  174  	/* We use the page offset to hold the idr and thus we need to clear
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  175  	 * it before doing the mmap itself
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  176  	 */
7b93ce06484261 Yuri Nudelman          2022-03-23 @177  	handle = vma->vm_pgoff << PAGE_SHIFT;
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  178  	vma->vm_pgoff = 0;
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  179  
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  180  	/* Reference was taken here */
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  181  	buf = hl_mmap_mem_buf_get(mmg, handle);
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  182  	if (!buf) {
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  183  		dev_err(mmg->dev,
7b93ce06484261 Yuri Nudelman          2022-03-23  184  			"Memory mmap failed, no match to handle %llu\n", handle);
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  185  		return -EINVAL;
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  186  	}
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  187  
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  188  	/* Validation check */
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  189  	user_mem_size = vma->vm_end - vma->vm_start;
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  190  	if (user_mem_size != ALIGN(buf->mappable_size, PAGE_SIZE)) {
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  191  		dev_err(mmg->dev,
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  192  			"Memory mmap failed, mmap VM size 0x%llx != 0x%llx allocated physical mem size\n",
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  193  			user_mem_size, buf->mappable_size);
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  194  		rc = -EINVAL;
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  195  		goto put_mem;
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  196  	}
dbb42df4b94ab9 Yuri Nudelman          2022-03-20  197  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-02 16:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-02 16:31 [ogabbay:habanalabs-next 39/44] drivers/misc/habanalabs/common/memory_mgr.c:177 hl_mem_mgr_mmap() warn: should 'vma->vm_pgoff << 12' be a 64 bit type? 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.