Re: [PATCH v1 6/8] vfio/type1: Bind guest page tables to host

From: kbuild test robot
Date: Sun Mar 22 2020 - 14:11:32 EST


Hi Yi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on vfio/next]
[also build test ERROR on v5.6-rc6 next-20200320]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url: https://github.com/0day-ci/linux/commits/Liu-Yi-L/vfio-expose-virtual-Shared-Virtual-Addressing-to-VMs/20200322-213259
base: https://github.com/awilliam/linux-vfio.git next
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=9.2.0 make.cross ARCH=arm64

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@xxxxxxxxx>

All errors (new ones prefixed by >>):

drivers/vfio/vfio_iommu_type1.c: In function 'vfio_iommu_get_stage1_format':
drivers/vfio/vfio_iommu_type1.c:2300:4: error: 'DOMAIN_ATTR_PASID_FORMAT' undeclared (first use in this function)
2300 | DOMAIN_ATTR_PASID_FORMAT, &format)) {
| ^~~~~~~~~~~~~~~~~~~~~~~~
drivers/vfio/vfio_iommu_type1.c:2300:4: note: each undeclared identifier is reported only once for each function it appears in
drivers/vfio/vfio_iommu_type1.c: In function 'vfio_iommu_type1_ioctl':
drivers/vfio/vfio_iommu_type1.c:2464:11: error: implicit declaration of function 'iommu_get_uapi_version' [-Werror=implicit-function-declaration]
2464 | return iommu_get_uapi_version();
| ^~~~~~~~~~~~~~~~~~~~~~
>> drivers/vfio/vfio_iommu_type1.c:2626:15: error: implicit declaration of function 'iommu_uapi_get_data_size' [-Werror=implicit-function-declaration]
2626 | data_size = iommu_uapi_get_data_size(
| ^~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/vfio/vfio_iommu_type1.c:2627:5: error: 'IOMMU_UAPI_BIND_GPASID' undeclared (first use in this function)
2627 | IOMMU_UAPI_BIND_GPASID, version);
| ^~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

vim +/iommu_uapi_get_data_size +2626 drivers/vfio/vfio_iommu_type1.c

2446
2447 static long vfio_iommu_type1_ioctl(void *iommu_data,
2448 unsigned int cmd, unsigned long arg)
2449 {
2450 struct vfio_iommu *iommu = iommu_data;
2451 unsigned long minsz;
2452
2453 if (cmd == VFIO_CHECK_EXTENSION) {
2454 switch (arg) {
2455 case VFIO_TYPE1_IOMMU:
2456 case VFIO_TYPE1v2_IOMMU:
2457 case VFIO_TYPE1_NESTING_IOMMU:
2458 return 1;
2459 case VFIO_DMA_CC_IOMMU:
2460 if (!iommu)
2461 return 0;
2462 return vfio_domains_have_iommu_cache(iommu);
2463 case VFIO_NESTING_IOMMU_UAPI:
2464 return iommu_get_uapi_version();
2465 default:
2466 return 0;
2467 }
2468 } else if (cmd == VFIO_IOMMU_GET_INFO) {
2469 struct vfio_iommu_type1_info info;
2470 struct vfio_info_cap caps = { .buf = NULL, .size = 0 };
2471 unsigned long capsz;
2472 int ret;
2473
2474 minsz = offsetofend(struct vfio_iommu_type1_info, iova_pgsizes);
2475
2476 /* For backward compatibility, cannot require this */
2477 capsz = offsetofend(struct vfio_iommu_type1_info, cap_offset);
2478
2479 if (copy_from_user(&info, (void __user *)arg, minsz))
2480 return -EFAULT;
2481
2482 if (info.argsz < minsz)
2483 return -EINVAL;
2484
2485 if (info.argsz >= capsz) {
2486 minsz = capsz;
2487 info.cap_offset = 0; /* output, no-recopy necessary */
2488 }
2489
2490 info.flags = VFIO_IOMMU_INFO_PGSIZES;
2491
2492 info.iova_pgsizes = vfio_pgsize_bitmap(iommu);
2493
2494 ret = vfio_iommu_iova_build_caps(iommu, &caps);
2495 if (ret)
2496 return ret;
2497
2498 ret = vfio_iommu_info_add_nesting_cap(iommu, &caps);
2499 if (ret)
2500 return ret;
2501
2502 if (caps.size) {
2503 info.flags |= VFIO_IOMMU_INFO_CAPS;
2504
2505 if (info.argsz < sizeof(info) + caps.size) {
2506 info.argsz = sizeof(info) + caps.size;
2507 } else {
2508 vfio_info_cap_shift(&caps, sizeof(info));
2509 if (copy_to_user((void __user *)arg +
2510 sizeof(info), caps.buf,
2511 caps.size)) {
2512 kfree(caps.buf);
2513 return -EFAULT;
2514 }
2515 info.cap_offset = sizeof(info);
2516 }
2517
2518 kfree(caps.buf);
2519 }
2520
2521 return copy_to_user((void __user *)arg, &info, minsz) ?
2522 -EFAULT : 0;
2523
2524 } else if (cmd == VFIO_IOMMU_MAP_DMA) {
2525 struct vfio_iommu_type1_dma_map map;
2526 uint32_t mask = VFIO_DMA_MAP_FLAG_READ |
2527 VFIO_DMA_MAP_FLAG_WRITE;
2528
2529 minsz = offsetofend(struct vfio_iommu_type1_dma_map, size);
2530
2531 if (copy_from_user(&map, (void __user *)arg, minsz))
2532 return -EFAULT;
2533
2534 if (map.argsz < minsz || map.flags & ~mask)
2535 return -EINVAL;
2536
2537 return vfio_dma_do_map(iommu, &map);
2538
2539 } else if (cmd == VFIO_IOMMU_UNMAP_DMA) {
2540 struct vfio_iommu_type1_dma_unmap unmap;
2541 long ret;
2542
2543 minsz = offsetofend(struct vfio_iommu_type1_dma_unmap, size);
2544
2545 if (copy_from_user(&unmap, (void __user *)arg, minsz))
2546 return -EFAULT;
2547
2548 if (unmap.argsz < minsz || unmap.flags)
2549 return -EINVAL;
2550
2551 ret = vfio_dma_do_unmap(iommu, &unmap);
2552 if (ret)
2553 return ret;
2554
2555 return copy_to_user((void __user *)arg, &unmap, minsz) ?
2556 -EFAULT : 0;
2557
2558 } else if (cmd == VFIO_IOMMU_PASID_REQUEST) {
2559 struct vfio_iommu_type1_pasid_request req;
2560 unsigned long offset;
2561
2562 minsz = offsetofend(struct vfio_iommu_type1_pasid_request,
2563 flags);
2564
2565 if (copy_from_user(&req, (void __user *)arg, minsz))
2566 return -EFAULT;
2567
2568 if (req.argsz < minsz ||
2569 !vfio_iommu_type1_pasid_req_valid(req.flags))
2570 return -EINVAL;
2571
2572 if (copy_from_user((void *)&req + minsz,
2573 (void __user *)arg + minsz,
2574 sizeof(req) - minsz))
2575 return -EFAULT;
2576
2577 switch (req.flags & VFIO_PASID_REQUEST_MASK) {
2578 case VFIO_IOMMU_PASID_ALLOC:
2579 {
2580 int ret = 0, result;
2581
2582 result = vfio_iommu_type1_pasid_alloc(iommu,
2583 req.alloc_pasid.min,
2584 req.alloc_pasid.max);
2585 if (result > 0) {
2586 offset = offsetof(
2587 struct vfio_iommu_type1_pasid_request,
2588 alloc_pasid.result);
2589 ret = copy_to_user(
2590 (void __user *) (arg + offset),
2591 &result, sizeof(result));
2592 } else {
2593 pr_debug("%s: PASID alloc failed\n", __func__);
2594 ret = -EFAULT;
2595 }
2596 return ret;
2597 }
2598 case VFIO_IOMMU_PASID_FREE:
2599 return vfio_iommu_type1_pasid_free(iommu,
2600 req.free_pasid);
2601 default:
2602 return -EINVAL;
2603 }
2604
2605 } else if (cmd == VFIO_IOMMU_BIND) {
2606 struct vfio_iommu_type1_bind bind;
2607 u32 version;
2608 int data_size;
2609 void *gbind_data;
2610 int ret;
2611
2612 minsz = offsetofend(struct vfio_iommu_type1_bind, flags);
2613
2614 if (copy_from_user(&bind, (void __user *)arg, minsz))
2615 return -EFAULT;
2616
2617 if (bind.argsz < minsz)
2618 return -EINVAL;
2619
2620 /* Get the version of struct iommu_gpasid_bind_data */
2621 if (copy_from_user(&version,
2622 (void __user *) (arg + minsz),
2623 sizeof(version)))
2624 return -EFAULT;
2625
> 2626 data_size = iommu_uapi_get_data_size(
> 2627 IOMMU_UAPI_BIND_GPASID, version);
2628 gbind_data = kzalloc(data_size, GFP_KERNEL);
2629 if (!gbind_data)
2630 return -ENOMEM;
2631
2632 if (copy_from_user(gbind_data,
2633 (void __user *) (arg + minsz), data_size)) {
2634 kfree(gbind_data);
2635 return -EFAULT;
2636 }
2637
2638 switch (bind.flags & VFIO_IOMMU_BIND_MASK) {
2639 case VFIO_IOMMU_BIND_GUEST_PGTBL:
2640 ret = vfio_iommu_type1_bind_gpasid(iommu,
2641 gbind_data);
2642 break;
2643 case VFIO_IOMMU_UNBIND_GUEST_PGTBL:
2644 ret = vfio_iommu_type1_unbind_gpasid(iommu,
2645 gbind_data);
2646 break;
2647 default:
2648 ret = -EINVAL;
2649 break;
2650 }
2651 kfree(gbind_data);
2652 return ret;
2653 }
2654
2655 return -ENOTTY;
2656 }
2657

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip