From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: Re: [PATCH 1/7] vfio: iommu_type1: Clear added dirty bit when unwind pin
Date: Wed, 16 Dec 2020 10:27:15 +0800 [thread overview]
Message-ID: <202012161025.MPGJwSEb-lkp@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 10464 bytes --]
CC: kbuild-all(a)lists.01.org
In-Reply-To: <20201210073425.25960-2-zhukeqian1@huawei.com>
References: <20201210073425.25960-2-zhukeqian1@huawei.com>
TO: Keqian Zhu <zhukeqian1@huawei.com>
TO: linux-kernel(a)vger.kernel.org
TO: linux-arm-kernel(a)lists.infradead.org
TO: iommu(a)lists.linux-foundation.org
TO: kvm(a)vger.kernel.org
TO: kvmarm(a)lists.cs.columbia.edu
TO: Alex Williamson <alex.williamson@redhat.com>
TO: Cornelia Huck <cohuck@redhat.com>
TO: Marc Zyngier <maz@kernel.org>
TO: Will Deacon <will@kernel.org>
TO: Robin Murphy <robin.murphy@arm.com>
Hi Keqian,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on vfio/next]
[also build test WARNING on linux/master soc/for-next linus/master v5.10 next-20201215]
[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/Keqian-Zhu/vfio-iommu_type1-Some-fixes-and-optimization/20201210-154322
base: https://github.com/awilliam/linux-vfio.git next
:::::: branch date: 6 days ago
:::::: commit date: 6 days ago
config: x86_64-randconfig-m001-20201215 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch warnings:
drivers/vfio/vfio_iommu_type1.c:648 vfio_iommu_type1_pin_pages() warn: variable dereferenced before check 'iommu' (see line 640)
vim +/iommu +648 drivers/vfio/vfio_iommu_type1.c
166fd7d94afdac0 Alex Williamson 2013-06-21 630
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 631 static int vfio_iommu_type1_pin_pages(void *iommu_data,
95fc87b44104d9a Kirti Wankhede 2020-05-29 632 struct iommu_group *iommu_group,
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 633 unsigned long *user_pfn,
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 634 int npage, int prot,
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 635 unsigned long *phys_pfn)
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 636 {
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 637 struct vfio_iommu *iommu = iommu_data;
95fc87b44104d9a Kirti Wankhede 2020-05-29 638 struct vfio_group *group;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 639 int i, j, ret;
2b172c0ea2a6daf Keqian Zhu 2020-12-10 @640 unsigned long pgshift = __ffs(iommu->pgsize_bitmap);
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 641 unsigned long remote_vaddr;
2b172c0ea2a6daf Keqian Zhu 2020-12-10 642 unsigned long bitmap_offset;
2b172c0ea2a6daf Keqian Zhu 2020-12-10 643 unsigned long *bitmap_added;
2b172c0ea2a6daf Keqian Zhu 2020-12-10 644 dma_addr_t iova;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 645 struct vfio_dma *dma;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 646 bool do_accounting;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 647
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 @648 if (!iommu || !user_pfn || !phys_pfn)
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 649 return -EINVAL;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 650
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 651 /* Supported for v2 version only */
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 652 if (!iommu->v2)
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 653 return -EACCES;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 654
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 655 mutex_lock(&iommu->lock);
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 656
2b172c0ea2a6daf Keqian Zhu 2020-12-10 657 bitmap_added = bitmap_zalloc(npage, GFP_KERNEL);
2b172c0ea2a6daf Keqian Zhu 2020-12-10 658 if (!bitmap_added) {
2b172c0ea2a6daf Keqian Zhu 2020-12-10 659 ret = -ENOMEM;
2b172c0ea2a6daf Keqian Zhu 2020-12-10 660 goto pin_done;
2b172c0ea2a6daf Keqian Zhu 2020-12-10 661 }
2b172c0ea2a6daf Keqian Zhu 2020-12-10 662
c086de818dd81c3 Kirti Wankhede 2016-11-17 663 /* Fail if notifier list is empty */
be068fa236c3d69 Lu Baolu 2019-04-12 664 if (!iommu->notifier.head) {
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 665 ret = -EINVAL;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 666 goto pin_done;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 667 }
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 668
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 669 /*
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 670 * If iommu capable domain exist in the container then all pages are
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 671 * already pinned and accounted. Accouting should be done if there is no
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 672 * iommu capable domain in the container.
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 673 */
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 674 do_accounting = !IS_IOMMU_CAP_DOMAIN_IN_CONTAINER(iommu);
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 675
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 676 for (i = 0; i < npage; i++) {
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 677 struct vfio_pfn *vpfn;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 678
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 679 iova = user_pfn[i] << PAGE_SHIFT;
2b8bb1d771f736b Kirti Wankhede 2016-12-06 680 dma = vfio_find_dma(iommu, iova, PAGE_SIZE);
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 681 if (!dma) {
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 682 ret = -EINVAL;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 683 goto pin_unwind;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 684 }
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 685
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 686 if ((dma->prot & prot) != prot) {
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 687 ret = -EPERM;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 688 goto pin_unwind;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 689 }
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 690
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 691 vpfn = vfio_iova_get_vfio_pfn(dma, iova);
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 692 if (vpfn) {
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 693 phys_pfn[i] = vpfn->pfn;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 694 continue;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 695 }
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 696
0ea971f8dcd6dee Yan Zhao 2020-04-08 697 remote_vaddr = dma->vaddr + (iova - dma->iova);
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 698 ret = vfio_pin_page_external(dma, remote_vaddr, &phys_pfn[i],
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 699 do_accounting);
80dbe1fbafbf469 Alex Williamson 2017-04-16 700 if (ret)
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 701 goto pin_unwind;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 702
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 703 ret = vfio_add_to_pfn_list(dma, iova, phys_pfn[i]);
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 704 if (ret) {
2e6cfd496f5b570 Xiaoyang Xu 2020-10-16 705 if (put_pfn(phys_pfn[i], dma->prot) && do_accounting)
2e6cfd496f5b570 Xiaoyang Xu 2020-10-16 706 vfio_lock_acct(dma, -1, true);
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 707 goto pin_unwind;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 708 }
d6a4c185660cb97 Kirti Wankhede 2020-05-29 709
d6a4c185660cb97 Kirti Wankhede 2020-05-29 710 if (iommu->dirty_page_tracking) {
2b172c0ea2a6daf Keqian Zhu 2020-12-10 711 /* Populated with the smallest supported page size */
2b172c0ea2a6daf Keqian Zhu 2020-12-10 712 bitmap_offset = (iova - dma->iova) >> pgshift;
2b172c0ea2a6daf Keqian Zhu 2020-12-10 713 if (!test_and_set_bit(bitmap_offset, dma->bitmap))
2b172c0ea2a6daf Keqian Zhu 2020-12-10 714 set_bit(i, bitmap_added);
d6a4c185660cb97 Kirti Wankhede 2020-05-29 715 }
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 716 }
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 717 ret = i;
95fc87b44104d9a Kirti Wankhede 2020-05-29 718
95fc87b44104d9a Kirti Wankhede 2020-05-29 719 group = vfio_iommu_find_iommu_group(iommu, iommu_group);
95fc87b44104d9a Kirti Wankhede 2020-05-29 720 if (!group->pinned_page_dirty_scope) {
95fc87b44104d9a Kirti Wankhede 2020-05-29 721 group->pinned_page_dirty_scope = true;
95fc87b44104d9a Kirti Wankhede 2020-05-29 722 update_pinned_page_dirty_scope(iommu);
95fc87b44104d9a Kirti Wankhede 2020-05-29 723 }
95fc87b44104d9a Kirti Wankhede 2020-05-29 724
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 725 goto pin_done;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 726
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 727 pin_unwind:
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 728 phys_pfn[i] = 0;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 729 for (j = 0; j < i; j++) {
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 730 iova = user_pfn[j] << PAGE_SHIFT;
2b8bb1d771f736b Kirti Wankhede 2016-12-06 731 dma = vfio_find_dma(iommu, iova, PAGE_SIZE);
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 732 vfio_unpin_page_external(dma, iova, do_accounting);
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 733 phys_pfn[j] = 0;
2b172c0ea2a6daf Keqian Zhu 2020-12-10 734
2b172c0ea2a6daf Keqian Zhu 2020-12-10 735 if (test_bit(j, bitmap_added)) {
2b172c0ea2a6daf Keqian Zhu 2020-12-10 736 bitmap_offset = (iova - dma->iova) >> pgshift;
2b172c0ea2a6daf Keqian Zhu 2020-12-10 737 clear_bit(bitmap_offset, dma->bitmap);
2b172c0ea2a6daf Keqian Zhu 2020-12-10 738 }
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 739 }
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 740 pin_done:
2b172c0ea2a6daf Keqian Zhu 2020-12-10 741 if (bitmap_added)
2b172c0ea2a6daf Keqian Zhu 2020-12-10 742 bitmap_free(bitmap_added);
2b172c0ea2a6daf Keqian Zhu 2020-12-10 743
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 744 mutex_unlock(&iommu->lock);
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 745 return ret;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 746 }
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 747
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 38446 bytes --]
next reply other threads:[~2020-12-16 2:27 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-16 2:27 kernel test robot [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-12-10 7:34 [PATCH 0/7] vfio: iommu_type1: Some fixes and optimization Keqian Zhu
2020-12-10 7:34 ` [PATCH 1/7] vfio: iommu_type1: Clear added dirty bit when unwind pin Keqian Zhu
2020-12-10 7:34 ` Keqian Zhu
2020-12-10 7:34 ` Keqian Zhu
2020-12-10 7:34 ` Keqian Zhu
2020-12-10 19:16 ` Alex Williamson
2020-12-10 19:16 ` Alex Williamson
2020-12-10 19:16 ` Alex Williamson
2020-12-10 19:16 ` Alex Williamson
2020-12-11 6:51 ` zhukeqian
2020-12-11 6:51 ` zhukeqian
2020-12-11 6:51 ` zhukeqian
2020-12-11 6:51 ` zhukeqian
2020-12-15 0:16 ` Alex Williamson
2020-12-15 0:16 ` Alex Williamson
2020-12-15 0:16 ` Alex Williamson
2020-12-15 0:16 ` Alex Williamson
2020-12-16 7:22 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202012161025.MPGJwSEb-lkp@intel.com \
--to=lkp@intel.com \
--cc=kbuild@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.