arch/x86/kernel/cpu/sgx/virt.c:59:13: sparse: sparse: incorrect type in assignment (different base types)
From: kernel test robot
Date: Sat Aug 12 2023 - 06:58:20 EST
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: f8de32cc060ba3f63171aaa0e8764d22d8c37978
commit: 540745ddbc70eabdc7dbd3fcc00fe4fb17cd59ba x86/sgx: Introduce virtual EPC for use by KVM guests
date: 2 years, 4 months ago
config: x86_64-allmodconfig (https://download.01.org/0day-ci/archive/20230812/202308121812.AERo19Sw-lkp@xxxxxxxxx/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230812/202308121812.AERo19Sw-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
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308121812.AERo19Sw-lkp@xxxxxxxxx/
sparse warnings: (new ones prefixed by >>)
>> arch/x86/kernel/cpu/sgx/virt.c:59:13: sparse: sparse: incorrect type in assignment (different base types) @@ expected int [assigned] ret @@ got restricted vm_fault_t @@
arch/x86/kernel/cpu/sgx/virt.c:59:13: sparse: expected int [assigned] ret
arch/x86/kernel/cpu/sgx/virt.c:59:13: sparse: got restricted vm_fault_t
>> arch/x86/kernel/cpu/sgx/virt.c:60:20: sparse: sparse: restricted vm_fault_t degrades to integer
arch/x86/kernel/cpu/sgx/virt.c:95:35: sparse: sparse: symbol 'sgx_vepc_vm_ops' was not declared. Should it be static?
vim +59 arch/x86/kernel/cpu/sgx/virt.c
32
33 static int __sgx_vepc_fault(struct sgx_vepc *vepc,
34 struct vm_area_struct *vma, unsigned long addr)
35 {
36 struct sgx_epc_page *epc_page;
37 unsigned long index, pfn;
38 int ret;
39
40 WARN_ON(!mutex_is_locked(&vepc->lock));
41
42 /* Calculate index of EPC page in virtual EPC's page_array */
43 index = vma->vm_pgoff + PFN_DOWN(addr - vma->vm_start);
44
45 epc_page = xa_load(&vepc->page_array, index);
46 if (epc_page)
47 return 0;
48
49 epc_page = sgx_alloc_epc_page(vepc, false);
50 if (IS_ERR(epc_page))
51 return PTR_ERR(epc_page);
52
53 ret = xa_err(xa_store(&vepc->page_array, index, epc_page, GFP_KERNEL));
54 if (ret)
55 goto err_free;
56
57 pfn = PFN_DOWN(sgx_get_epc_phys_addr(epc_page));
58
> 59 ret = vmf_insert_pfn(vma, addr, pfn);
> 60 if (ret != VM_FAULT_NOPAGE) {
61 ret = -EFAULT;
62 goto err_delete;
63 }
64
65 return 0;
66
67 err_delete:
68 xa_erase(&vepc->page_array, index);
69 err_free:
70 sgx_free_epc_page(epc_page);
71 return ret;
72 }
73
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki