drivers/vfio/pci/nvgrace-gpu/main.c:167:9: sparse: sparse: cast from restricted vm_fault_t

From: kernel test robot

Date: Fri Sep 18 2026 - 15:42:10 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: f259f446f5198d98e13756d2cd531812a0ad3064
commit: 9db65489b87298f20baef683e70143c108959793 vfio/nvgrace-gpu: Add support for huge pfnmap
date: 10 months ago
config: s390-randconfig-r1300-20260918 (https://download.01.org/0day-ci/archive/20260919/202609190345.V7aClDxX-lkp@xxxxxxxxx/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 7252edd9aa82ef1c570ff6694ef7f4763a8a5d2f)
sparse: v0.6.5-rc1
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260919/202609190345.V7aClDxX-lkp@xxxxxxxxx/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
| Fixes: 9db65489b872 ("vfio/nvgrace-gpu: Add support for huge pfnmap")
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202609190345.V7aClDxX-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
>> drivers/vfio/pci/nvgrace-gpu/main.c:167:9: sparse: sparse: cast from restricted vm_fault_t

vim +167 drivers/vfio/pci/nvgrace-gpu/main.c

142
143 static vm_fault_t nvgrace_gpu_vfio_pci_huge_fault(struct vm_fault *vmf,
144 unsigned int order)
145 {
146 struct vm_area_struct *vma = vmf->vma;
147 struct nvgrace_gpu_pci_core_device *nvdev = vma->vm_private_data;
148 struct vfio_pci_core_device *vdev = &nvdev->core_device;
149 unsigned int index =
150 vma->vm_pgoff >> (VFIO_PCI_OFFSET_SHIFT - PAGE_SHIFT);
151 vm_fault_t ret = VM_FAULT_FALLBACK;
152 struct mem_region *memregion;
153 unsigned long pfn, addr;
154
155 memregion = nvgrace_gpu_memregion(index, nvdev);
156 if (!memregion)
157 return VM_FAULT_SIGBUS;
158
159 addr = ALIGN_DOWN(vmf->address, PAGE_SIZE << order);
160 pfn = PHYS_PFN(memregion->memphys) + addr_to_pgoff(vma, addr);
161
162 if (is_aligned_for_order(vma, addr, pfn, order)) {
163 scoped_guard(rwsem_read, &vdev->memory_lock)
164 ret = vfio_pci_vmf_insert_pfn(vdev, vmf, pfn, order);
165 }
166
> 167 dev_dbg_ratelimited(&vdev->pdev->dev,
168 "%s order = %d pfn 0x%lx: 0x%x\n",
169 __func__, order, pfn,
170 (unsigned int)ret);
171
172 return ret;
173 }
174

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