Re: [PATCH 23/32] KVM: s390: pci: handle refresh of PCI translations

kernel test robot
2021-12-08T08:04:40Z

Hi Matthew,

I love your patch! Perhaps something to improve:

[auto build test WARNING on v5.16-rc4]
[cannot apply to s390/features kvms390/next awilliam-vfio/next next-20211207]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Matthew-Rosato/KVM-s390-enable-zPCI-for-interpretive-execution/20211208-050204
base: 0fcfb00b28c0b7884635dacf38e46d60bf3d4eb1
config: s390-allyesconfig (https://download.01.org/0day-ci/archive/20211208/202112081537.qiFqvLb1-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/84cb5df859beb99f52b3d3b133ff1f9b5a459558
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Matthew-Rosato/KVM-s390-enable-zPCI-for-interpretive-execution/20211208-050204
git checkout 84cb5df859beb99f52b3d3b133ff1f9b5a459558
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=s390 SHELL=/bin/bash arch/s390/kvm/

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

All warnings (new ones prefixed by >>):

>> arch/s390/kvm/pci.c:179:16: warning: no previous prototype for 'dma_walk_guest_cpu_trans' [-Wmissing-prototypes]
179 | unsigned long *dma_walk_guest_cpu_trans(struct kvm_vcpu *vcpu,
| ^~~~~~~~~~~~~~~~~~~~~~~~

vim +/dma_walk_guest_cpu_trans +179 arch/s390/kvm/pci.c

178
> 179 unsigned long *dma_walk_guest_cpu_trans(struct kvm_vcpu *vcpu,
180 struct kvm_zdev_ioat *ioat,
181 dma_addr_t dma_addr)
182 {
183 unsigned long *rto, *sto, *pto;
184 unsigned int rtx, rts, sx, px, idx;
185 struct page *page;
186 gpa_t addr;
187 int i;
188
189 /* Pin guest segment table if needed */
190 rtx = calc_rtx(dma_addr);
191 rto = ioat->head[(rtx / ZPCI_TABLE_ENTRIES_PER_PAGE)];
192 rts = rtx * ZPCI_TABLE_PAGES;
193 if (!ioat->seg[rts]) {
194 if (!reg_entry_isvalid(rto[rtx % ZPCI_TABLE_ENTRIES_PER_PAGE]))
195 return NULL;
196 sto = get_rt_sto(rto[rtx % ZPCI_TABLE_ENTRIES_PER_PAGE]);
197 addr = ((u64)sto & ZPCI_RTE_ADDR_MASK);
198 idx = srcu_read_lock(&vcpu->kvm->srcu);
199 for (i = 0; i < ZPCI_TABLE_PAGES; i++) {
200 page = gfn_to_page(vcpu->kvm, gpa_to_gfn(addr));
201 if (is_error_page(page)) {
202 srcu_read_unlock(&vcpu->kvm->srcu, idx);
203 return NULL;
204 }
205 ioat->seg[rts + i] = page_to_virt(page) +
206 (addr & ~PAGE_MASK);
207 addr += PAGE_SIZE;
208 }
209 srcu_read_unlock(&vcpu->kvm->srcu, idx);
210 }
211
212 /* Allocate pin pointers for another segment table if needed */
213 if (!ioat->pt[rtx]) {
214 ioat->pt[rtx] = kcalloc(ZPCI_TABLE_ENTRIES,
215 (sizeof(unsigned long *)), GFP_KERNEL);
216 if (!ioat->pt[rtx])
217 return NULL;
218 }
219 /* Pin guest page table if needed */
220 sx = calc_sx(dma_addr);
221 sto = ioat->seg[(rts + (sx / ZPCI_TABLE_ENTRIES_PER_PAGE))];
222 if (!ioat->pt[rtx][sx]) {
223 if (!reg_entry_isvalid(sto[sx % ZPCI_TABLE_ENTRIES_PER_PAGE]))
224 return NULL;
225 pto = get_st_pto(sto[sx % ZPCI_TABLE_ENTRIES_PER_PAGE]);
226 if (!pto)
227 return NULL;
228 addr = ((u64)pto & ZPCI_STE_ADDR_MASK);
229 idx = srcu_read_lock(&vcpu->kvm->srcu);
230 page = gfn_to_page(vcpu->kvm, gpa_to_gfn(addr));
231 srcu_read_unlock(&vcpu->kvm->srcu, idx);
232 if (is_error_page(page))
233 return NULL;
234 ioat->pt[rtx][sx] = page_to_virt(page) + (addr & ~PAGE_MASK);
235 }
236 pto = ioat->pt[rtx][sx];
237
238 /* Return guest PTE */
239 px = calc_px(dma_addr);
240 return &pto[px];
241 }
242

---
0-DAY CI Kernel Test Service, Intel Corporation