drivers/gpu/drm/amd/amdgpu/gfxhub_v12_1.c:69 gfxhub_v12_1_xcc_setup_vm_pt_regs() error: buffer overflow 'adev->vmhub' 13 <= 31

kernel test robot <[email protected]>
Newsgroups dev.linux.lists.oe-kbuild
Message-ID <[email protected]>
BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Hawking Zhang <[email protected]>
CC: Alex Deucher <[email protected]>
CC: Le Ma <[email protected]>
CC: Likun Gao <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   3d6d817622b0a9721e3cc404df3469171582be13
commit: e87bfaf55e7311b9587c0163060c6939c36f077e drm/amdgpu: Add gfxhub v12_1 support
date:   8 months ago
:::::: branch date: 21 hours ago
:::::: commit date: 8 months ago
config: s390-randconfig-r071-20260813 (https://download.01.org/0day-ci/archive/20260813/[email protected]/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 6ea395e4fe4db26920d57779ddae98eac6ba945d)
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: e87bfaf55e73 ("drm/amdgpu: Add gfxhub v12_1 support")
| Reported-by: kernel test robot <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

New smatch warnings:
drivers/gpu/drm/amd/amdgpu/gfxhub_v12_1.c:69 gfxhub_v12_1_xcc_setup_vm_pt_regs() error: buffer overflow 'adev->vmhub' 13 <= 31
drivers/gpu/drm/amd/amdgpu/gfxhub_v12_1.c:470 gfxhub_v12_1_xcc_program_invalidation() error: buffer overflow 'adev->vmhub' 13 <= 31
drivers/gpu/drm/amd/amdgpu/gfxhub_v12_1.c:539 gfxhub_v12_1_xcc_gart_disable() error: buffer overflow 'adev->vmhub' 13 <= 31
drivers/gpu/drm/amd/amdgpu/gfxhub_v12_1.c:752 gfxhub_v12_1_xcc_init() error: buffer overflow 'adev->vmhub' 13 <= 31

Old smatch warnings:
drivers/gpu/drm/amd/amdgpu/gfxhub_v12_1.c:412 gfxhub_v12_1_xcc_setup_vmid_config() error: buffer overflow 'adev->vmhub' 13 <= 31

vim +69 drivers/gpu/drm/amd/amdgpu/gfxhub_v12_1.c

e87bfaf55e7311 Hawking Zhang 2025-02-24  59  
e87bfaf55e7311 Hawking Zhang 2025-02-24  60  static void gfxhub_v12_1_xcc_setup_vm_pt_regs(struct amdgpu_device *adev,
e87bfaf55e7311 Hawking Zhang 2025-02-24  61  					      uint32_t vmid,
e87bfaf55e7311 Hawking Zhang 2025-02-24  62  					      uint64_t page_table_base,
e87bfaf55e7311 Hawking Zhang 2025-02-24  63  					      uint32_t xcc_mask)
e87bfaf55e7311 Hawking Zhang 2025-02-24  64  {
e87bfaf55e7311 Hawking Zhang 2025-02-24  65  	struct amdgpu_vmhub *hub;
e87bfaf55e7311 Hawking Zhang 2025-02-24  66  	int i;
e87bfaf55e7311 Hawking Zhang 2025-02-24  67  
e87bfaf55e7311 Hawking Zhang 2025-02-24  68  	for_each_inst(i, xcc_mask) {
e87bfaf55e7311 Hawking Zhang 2025-02-24 @69  		hub = &adev->vmhub[AMDGPU_GFXHUB(i)];
e87bfaf55e7311 Hawking Zhang 2025-02-24  70  		WREG32_SOC15_OFFSET(GC, GET_INST(GC, i),
e87bfaf55e7311 Hawking Zhang 2025-02-24  71  				    regGCVM_CONTEXT0_PAGE_TABLE_BASE_ADDR_LO32,
e87bfaf55e7311 Hawking Zhang 2025-02-24  72  				    hub->ctx_addr_distance * vmid,
e87bfaf55e7311 Hawking Zhang 2025-02-24  73  				    lower_32_bits(page_table_base));
e87bfaf55e7311 Hawking Zhang 2025-02-24  74  
e87bfaf55e7311 Hawking Zhang 2025-02-24  75  		WREG32_SOC15_OFFSET(GC, GET_INST(GC, i),
e87bfaf55e7311 Hawking Zhang 2025-02-24  76  				    regGCVM_CONTEXT0_PAGE_TABLE_BASE_ADDR_HI32,
e87bfaf55e7311 Hawking Zhang 2025-02-24  77  				    hub->ctx_addr_distance * vmid,
e87bfaf55e7311 Hawking Zhang 2025-02-24  78  				    upper_32_bits(page_table_base));
e87bfaf55e7311 Hawking Zhang 2025-02-24  79  	}
e87bfaf55e7311 Hawking Zhang 2025-02-24  80  }
e87bfaf55e7311 Hawking Zhang 2025-02-24  81  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.