tree: https://github.com/awilliam/linux-vfio.git vfio-huge-fault head: 0b72bf5c1dbf066b3a167e0033d8401ae2e2726f commit: e93ffb9dfe21dc8f7f91afb6947bf30fff79d9a6 [443/453] s390/pci_mmio: Use follow_pfnmap API config: s390-allyesconfig (https://download.01.org/0day-ci/archive/20240808/202408081010.KniYhdHB-lkp@xxxxxxxxx/config) compiler: s390-linux-gcc (GCC) 14.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240808/202408081010.KniYhdHB-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/202408081010.KniYhdHB-lkp@xxxxxxxxx/ All warnings (new ones prefixed by >>): arch/s390/pci/pci_mmio.c: In function '__do_sys_s390_pci_mmio_write': >> arch/s390/pci/pci_mmio.c:127:21: warning: unused variable 'ptl' [-Wunused-variable] 127 | spinlock_t *ptl; | ^~~ >> arch/s390/pci/pci_mmio.c:126:16: warning: unused variable 'ptep' [-Wunused-variable] 126 | pte_t *ptep; | ^~~~ vim +/ptl +127 arch/s390/pci/pci_mmio.c 4eafad7febd482 Alexey Ishchuk 2014-11-14 117 4eafad7febd482 Alexey Ishchuk 2014-11-14 118 SYSCALL_DEFINE3(s390_pci_mmio_write, unsigned long, mmio_addr, 4eafad7febd482 Alexey Ishchuk 2014-11-14 119 const void __user *, user_buffer, size_t, length) 4eafad7febd482 Alexey Ishchuk 2014-11-14 120 { e93ffb9dfe21dc Peter Xu 2024-04-23 121 struct follow_pfnmap_args args = { }; 4eafad7febd482 Alexey Ishchuk 2014-11-14 122 u8 local_buf[64]; 4eafad7febd482 Alexey Ishchuk 2014-11-14 123 void __iomem *io_addr; 4eafad7febd482 Alexey Ishchuk 2014-11-14 124 void *buf; a67a88b0b8de16 Daniel Vetter 2020-10-21 125 struct vm_area_struct *vma; a67a88b0b8de16 Daniel Vetter 2020-10-21 @126 pte_t *ptep; a67a88b0b8de16 Daniel Vetter 2020-10-21 @127 spinlock_t *ptl; 4eafad7febd482 Alexey Ishchuk 2014-11-14 128 long ret; 4eafad7febd482 Alexey Ishchuk 2014-11-14 129 4eafad7febd482 Alexey Ishchuk 2014-11-14 130 if (!zpci_is_enabled()) 4eafad7febd482 Alexey Ishchuk 2014-11-14 131 return -ENODEV; 4eafad7febd482 Alexey Ishchuk 2014-11-14 132 4eafad7febd482 Alexey Ishchuk 2014-11-14 133 if (length <= 0 || PAGE_SIZE - (mmio_addr & ~PAGE_MASK) < length) 4eafad7febd482 Alexey Ishchuk 2014-11-14 134 return -EINVAL; f058599e22d59e Niklas Schnelle 2020-03-26 135 f058599e22d59e Niklas Schnelle 2020-03-26 136 /* 4631f3ca493a7c Niklas Schnelle 2020-07-07 137 * We only support write access to MIO capable devices if we are on 4631f3ca493a7c Niklas Schnelle 2020-07-07 138 * a MIO enabled system. Otherwise we would have to check for every 4631f3ca493a7c Niklas Schnelle 2020-07-07 139 * address if it is a special ZPCI_ADDR and would have to do a67a88b0b8de16 Daniel Vetter 2020-10-21 140 * a pfn lookup which we don't need for MIO capable devices. Currently 4631f3ca493a7c Niklas Schnelle 2020-07-07 141 * ISM devices are the only devices without MIO support and there is no 4631f3ca493a7c Niklas Schnelle 2020-07-07 142 * known need for accessing these from userspace. f058599e22d59e Niklas Schnelle 2020-03-26 143 */ f058599e22d59e Niklas Schnelle 2020-03-26 144 if (static_branch_likely(&have_mio)) { f058599e22d59e Niklas Schnelle 2020-03-26 145 ret = __memcpy_toio_inuser((void __iomem *) mmio_addr, f058599e22d59e Niklas Schnelle 2020-03-26 146 user_buffer, f058599e22d59e Niklas Schnelle 2020-03-26 147 length); f058599e22d59e Niklas Schnelle 2020-03-26 148 return ret; f058599e22d59e Niklas Schnelle 2020-03-26 149 } f058599e22d59e Niklas Schnelle 2020-03-26 150 4eafad7febd482 Alexey Ishchuk 2014-11-14 151 if (length > 64) { 4eafad7febd482 Alexey Ishchuk 2014-11-14 152 buf = kmalloc(length, GFP_KERNEL); 4eafad7febd482 Alexey Ishchuk 2014-11-14 153 if (!buf) 4eafad7febd482 Alexey Ishchuk 2014-11-14 154 return -ENOMEM; 4eafad7febd482 Alexey Ishchuk 2014-11-14 155 } else 4eafad7febd482 Alexey Ishchuk 2014-11-14 156 buf = local_buf; 4eafad7febd482 Alexey Ishchuk 2014-11-14 157 a67a88b0b8de16 Daniel Vetter 2020-10-21 158 ret = -EFAULT; a67a88b0b8de16 Daniel Vetter 2020-10-21 159 if (copy_from_user(buf, user_buffer, length)) a67a88b0b8de16 Daniel Vetter 2020-10-21 160 goto out_free; a67a88b0b8de16 Daniel Vetter 2020-10-21 161 a67a88b0b8de16 Daniel Vetter 2020-10-21 162 mmap_read_lock(current->mm); a67a88b0b8de16 Daniel Vetter 2020-10-21 163 ret = -EINVAL; a8b92b8c1eac8d David Hildenbrand 2021-09-09 164 vma = vma_lookup(current->mm, mmio_addr); a67a88b0b8de16 Daniel Vetter 2020-10-21 165 if (!vma) a67a88b0b8de16 Daniel Vetter 2020-10-21 166 goto out_unlock_mmap; a67a88b0b8de16 Daniel Vetter 2020-10-21 167 if (!(vma->vm_flags & (VM_IO | VM_PFNMAP))) a67a88b0b8de16 Daniel Vetter 2020-10-21 168 goto out_unlock_mmap; a67a88b0b8de16 Daniel Vetter 2020-10-21 169 ret = -EACCES; a67a88b0b8de16 Daniel Vetter 2020-10-21 170 if (!(vma->vm_flags & VM_WRITE)) a67a88b0b8de16 Daniel Vetter 2020-10-21 171 goto out_unlock_mmap; a67a88b0b8de16 Daniel Vetter 2020-10-21 172 e93ffb9dfe21dc Peter Xu 2024-04-23 173 args.address = mmio_addr; e93ffb9dfe21dc Peter Xu 2024-04-23 174 args.vma = vma; e93ffb9dfe21dc Peter Xu 2024-04-23 175 ret = follow_pfnmap_start(&args); 4eafad7febd482 Alexey Ishchuk 2014-11-14 176 if (ret) a67a88b0b8de16 Daniel Vetter 2020-10-21 177 goto out_unlock_mmap; a67a88b0b8de16 Daniel Vetter 2020-10-21 178 e93ffb9dfe21dc Peter Xu 2024-04-23 179 io_addr = (void __iomem *)((args.pfn << PAGE_SHIFT) | f058599e22d59e Niklas Schnelle 2020-03-26 180 (mmio_addr & ~PAGE_MASK)); 4eafad7febd482 Alexey Ishchuk 2014-11-14 181 4eafad7febd482 Alexey Ishchuk 2014-11-14 182 if ((unsigned long) io_addr < ZPCI_IOMAP_ADDR_BASE) a67a88b0b8de16 Daniel Vetter 2020-10-21 183 goto out_unlock_pt; 4eafad7febd482 Alexey Ishchuk 2014-11-14 184 f0483044c1c960 Sebastian Ott 2015-02-25 185 ret = zpci_memcpy_toio(io_addr, buf, length); a67a88b0b8de16 Daniel Vetter 2020-10-21 186 out_unlock_pt: e93ffb9dfe21dc Peter Xu 2024-04-23 187 follow_pfnmap_end(&args); a67a88b0b8de16 Daniel Vetter 2020-10-21 188 out_unlock_mmap: a67a88b0b8de16 Daniel Vetter 2020-10-21 189 mmap_read_unlock(current->mm); a67a88b0b8de16 Daniel Vetter 2020-10-21 190 out_free: 4eafad7febd482 Alexey Ishchuk 2014-11-14 191 if (buf != local_buf) 4eafad7febd482 Alexey Ishchuk 2014-11-14 192 kfree(buf); 4eafad7febd482 Alexey Ishchuk 2014-11-14 193 return ret; 4eafad7febd482 Alexey Ishchuk 2014-11-14 194 } 4eafad7febd482 Alexey Ishchuk 2014-11-14 195 :::::: The code at line 127 was first introduced by commit :::::: a67a88b0b8de16b4cd6ad50bfe0e03605904dc75 s390/pci: remove races against pte updates :::::: TO: Daniel Vetter <daniel.vetter@xxxxxxxx> :::::: CC: Heiko Carstens <hca@xxxxxxxxxxxxx> -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki