Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2140616ybi; Thu, 4 Jul 2019 05:52:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqyYjZZ9FJzKt2xc54y7I2EfbW7yZVoIRIpu0w/wCr7CZyWlqGCwb1VHdf4cpw1ZifCKhS5+ X-Received: by 2002:a17:90a:21d0:: with SMTP id q74mr19830472pjc.12.1562244735046; Thu, 04 Jul 2019 05:52:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562244735; cv=none; d=google.com; s=arc-20160816; b=lCAledHGFM0z9FyqEpW+Rih82zm2xl9Cnx2iCMmnDvcpAcXAuyp6w6GSspw5N5DF/n soyqa/oUYfe4iNkyWJdDnHJkNZQnsDPDYyL2i+SUtOVcUwK9yTMHxQvhWyfefmXrizx1 ZdjaXZeTPhox9fVb3znnRaYJMiAQXbB/XGguDMy5BCwPqw9EsScyLWjkLg+n1PJr3L7h UNK4cMTBO686AUAxTa1n+j6CvHpDmrOnsOwUGHVaWNIxxX+jTbrq073dK51oZQajDhbI /BeE6iL7cvnsK+ELooA+bwu+BmxDjna4ogW5p6ATHVW2zUiuG5P7WXYcMk/E5wT0THHe sWiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=fSt1u3rj1mrMb+ZggTWsRUmIIs53f3tcXhpTEBj1deU=; b=hbHgSnNTTZLzOrjllgNuDU0fWqmjoD2doM/iIlFK3yKBcgcRP56EMcAJu/nAQ8IrM9 eNSk+izAysHFg6nlc/FzE96lAEu9X/P0UzIESub3kWzhObrkDlA2PRnuJW1eIJregINC VVAjwhfXgMzJXb/66gYLN0rB9BAha1b9dy4/7NQbwtRZZBQmeoMEhFANw474zOyuE8P9 hbMXILNwXUnXQ7ySHE+e/jIdWUQ8CKpC5IPgMXndYSBj67hG5R7Dxry5wFefPT6I5N68 JUGlx7rkKW8Djn8XfByBDHvNoGASHn/0rldzRG7XQkrpE02mCTZWFFM6gqwUuD3F55U/ awUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s23si5370365plq.7.2019.07.04.05.51.59; Thu, 04 Jul 2019 05:52:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727122AbfGDMvZ convert rfc822-to-8bit (ORCPT + 99 others); Thu, 4 Jul 2019 08:51:25 -0400 Received: from lhrrgout.huawei.com ([185.176.76.210]:33051 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725945AbfGDMvY (ORCPT ); Thu, 4 Jul 2019 08:51:24 -0400 Received: from LHREML714-CAH.china.huawei.com (unknown [172.18.7.107]) by Forcepoint Email with ESMTP id 345369A46D9813235B39; Thu, 4 Jul 2019 13:51:23 +0100 (IST) Received: from LHREML524-MBS.china.huawei.com ([169.254.2.154]) by LHREML714-CAH.china.huawei.com ([10.201.108.37]) with mapi id 14.03.0415.000; Thu, 4 Jul 2019 13:51:14 +0100 From: Shameerali Kolothum Thodi To: Alex Williamson CC: "eric.auger@redhat.com" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "iommu@lists.linux-foundation.org" , Linuxarm , "John Garry" , "xuwei (O)" , "kevin.tian@intel.com" Subject: RE: [PATCH v7 2/6] vfio/type1: Check reserve region conflict and update iova list Thread-Topic: [PATCH v7 2/6] vfio/type1: Check reserve region conflict and update iova list Thread-Index: AQHVLDHlfv32Tq6P8k2BSud+nbtQFqa5VEOAgAEf3kA= Date: Thu, 4 Jul 2019 12:51:13 +0000 Message-ID: <5FC3163CFD30C246ABAA99954A238FA83F2DDB68@lhreml524-mbs.china.huawei.com> References: <20190626151248.11776-1-shameerali.kolothum.thodi@huawei.com> <20190626151248.11776-3-shameerali.kolothum.thodi@huawei.com> <20190703143427.2d63c15f@x1.home> In-Reply-To: <20190703143427.2d63c15f@x1.home> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.34.206.221] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: kvm-owner@vger.kernel.org [mailto:kvm-owner@vger.kernel.org] On > Behalf Of Alex Williamson > Sent: 03 July 2019 21:34 > To: Shameerali Kolothum Thodi > Cc: eric.auger@redhat.com; pmorel@linux.vnet.ibm.com; > kvm@vger.kernel.org; linux-kernel@vger.kernel.org; > iommu@lists.linux-foundation.org; Linuxarm ; John > Garry ; xuwei (O) ; > kevin.tian@intel.com > Subject: Re: [PATCH v7 2/6] vfio/type1: Check reserve region conflict and > update iova list > > On Wed, 26 Jun 2019 16:12:44 +0100 > Shameer Kolothum wrote: > > > This retrieves the reserved regions associated with dev group and > > checks for conflicts with any existing dma mappings. Also update > > the iova list excluding the reserved regions. > > > > Reserved regions with type IOMMU_RESV_DIRECT_RELAXABLE are > > excluded from above checks as they are considered as directly > > mapped regions which are known to be relaxable. > > > > Signed-off-by: Shameer Kolothum > > --- > > drivers/vfio/vfio_iommu_type1.c | 96 > +++++++++++++++++++++++++++++++++ > > 1 file changed, 96 insertions(+) > > > > diff --git a/drivers/vfio/vfio_iommu_type1.c > b/drivers/vfio/vfio_iommu_type1.c > > index 970d1ec06aed..b6bfdfa16c33 100644 > > --- a/drivers/vfio/vfio_iommu_type1.c > > +++ b/drivers/vfio/vfio_iommu_type1.c > > @@ -1559,6 +1641,7 @@ static int vfio_iommu_type1_attach_group(void > *iommu_data, > > phys_addr_t resv_msi_base; > > struct iommu_domain_geometry geo; > > LIST_HEAD(iova_copy); > > + LIST_HEAD(group_resv_regions); > > > > mutex_lock(&iommu->lock); > > > > @@ -1644,6 +1727,13 @@ static int vfio_iommu_type1_attach_group(void > *iommu_data, > > goto out_detach; > > } > > > > + iommu_get_group_resv_regions(iommu_group, &group_resv_regions); > > This can fail and should have an error case. I assume we'd fail the > group attach on failure. Thanks, Right. I will add the check. Do you think we should do the same in vfio_iommu_has_sw_msi() as well? (In fact, it looks like iommu_get_group_resv_regions() ret is not checked anywhere in kernel). Thanks, Shameer