Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp45939pxu; Wed, 6 Jan 2021 20:48:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHmgDMhJaXIZ2GHpsfmky54SrCfaoYTu4b01vQcK+QVA1Axf8RRnMMW3Ru5T1k8lpgiJZl X-Received: by 2002:a17:906:447:: with SMTP id e7mr5030062eja.172.1609994897947; Wed, 06 Jan 2021 20:48:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609994897; cv=none; d=google.com; s=arc-20160816; b=AHRpC+LXc8NUQNILcVUOzDUfQHFdBAOHeWds4fWuoS24m9RfEt4uDf0QBAdVpzR5ws OhHXy7uO/+5wiUmEKkofBPshhkXi5iNtPGx3Syy0Fa1z5dDa8eCMW0Otq9acPGJtXG08 kSItuwmmMpCm+47Uv0Tu4yY9Kjni1W9UztACCpzeIj4wa49sqV58qirJaz4TJOu8Yhsl SPnTc0QCdW3jiiv44qBIiX94jIhNurBQXq9b6Fwf2yaS2+eZ6kUmIzwDW+1s5ysSkT8E adg00+GfCDERmi1PZALHWjTI2e5qyC4FND6QaZ91nXLhovwAophJv8/TC8+OlNx7IF6d fRmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=rSwXqOoyd/El3bhFBxKPA7rGUv8Ak2nYRSYBIETkJtw=; b=EzkthrzZTB3cdVcGHmwz8oJJKndl308MGgsWw3Yg4JmDLcpAg8Tm5V4Z+bjyGKmHX3 2GUda5Xri9KGzZlUovZ+/RkuNqQ1cKQ3MYHt64oY2dcKt56axDprJ1IzSLoQfH4QOqi7 cC91P/XBqONPfKonlNWmiCmMKRfDmR+9uBJisYnmCeOEjxzeDdfHjvjbsE8eQoXKTmdT E0fQP46kahNd33UhRvG+vdfW8/dIo9LAImY+imK2EQw8xdURQv++NEAp83MblvIjTZDb J5h7yfXDPxQjqy84zJ2No0r3ann8P5I+e3Ej4M/rZo1QJQNCI+5VX2GrOVKqZh0s6u/r 8Crg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e22si1800182edv.437.2021.01.06.20.47.54; Wed, 06 Jan 2021 20:48:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727127AbhAGEpS (ORCPT + 99 others); Wed, 6 Jan 2021 23:45:18 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:9964 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbhAGEpR (ORCPT ); Wed, 6 Jan 2021 23:45:17 -0500 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4DBDC85Jdczj2np; Thu, 7 Jan 2021 12:43:48 +0800 (CST) Received: from DESKTOP-5IS4806.china.huawei.com (10.174.184.42) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.498.0; Thu, 7 Jan 2021 12:44:27 +0800 From: Keqian Zhu To: , , , , , Alex Williamson , Cornelia Huck , Will Deacon , "Marc Zyngier" , Catalin Marinas CC: Mark Rutland , James Morse , Robin Murphy , Joerg Roedel , "Daniel Lezcano" , Thomas Gleixner , Suzuki K Poulose , Julien Thierry , Andrew Morton , Alexios Zavras , , Subject: [PATCH 2/6] vfio/iommu_type1: Ignore external domain when promote pinned_scope Date: Thu, 7 Jan 2021 12:43:57 +0800 Message-ID: <20210107044401.19828-3-zhukeqian1@huawei.com> X-Mailer: git-send-email 2.8.4.windows.1 In-Reply-To: <20210107044401.19828-1-zhukeqian1@huawei.com> References: <20210107044401.19828-1-zhukeqian1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.184.42] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The pinned_scope of external domain's groups are always true, that's to say we can safely ignore external domain when promote pinned_scope status of vfio_iommu. Signed-off-by: Keqian Zhu --- drivers/vfio/vfio_iommu_type1.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 334a8240e1da..110ada24ee91 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -1637,14 +1637,7 @@ static void promote_pinned_page_dirty_scope(struct vfio_iommu *iommu) } } - if (iommu->external_domain) { - domain = iommu->external_domain; - list_for_each_entry(group, &domain->group_list, next) { - if (!group->pinned_page_dirty_scope) - return; - } - } - + /* The external domain always passes check */ iommu->pinned_page_dirty_scope = true; } @@ -2347,7 +2340,6 @@ static void vfio_iommu_type1_detach_group(void *iommu_data, if (iommu->external_domain) { group = find_iommu_group(iommu->external_domain, iommu_group); if (group) { - promote_dirty_scope = !group->pinned_page_dirty_scope; list_del(&group->next); kfree(group); @@ -2360,7 +2352,8 @@ static void vfio_iommu_type1_detach_group(void *iommu_data, kfree(iommu->external_domain); iommu->external_domain = NULL; } - goto detach_group_done; + mutex_unlock(&iommu->lock); + return; } } @@ -2408,7 +2401,6 @@ static void vfio_iommu_type1_detach_group(void *iommu_data, else vfio_iommu_iova_free(&iova_copy); -detach_group_done: /* * Removal of a group without dirty tracking may allow the iommu scope * to be promoted. -- 2.19.1