From patchwork Wed Apr 18 11:40:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 133619 Delivered-To: patch@linaro.org Received: by 10.46.84.18 with SMTP id i18csp5777658ljb; Wed, 18 Apr 2018 04:45:57 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/z88+YMqls+d7PK5QVnWHKX9m1bXds3+oxow5wjY/jr9/VAYk1M2zIxmPFILawd18pEe0Y X-Received: by 10.98.109.66 with SMTP id i63mr1682714pfc.233.1524051957231; Wed, 18 Apr 2018 04:45:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524051957; cv=none; d=google.com; s=arc-20160816; b=RJU8rODrM5iWS7hKYnd3EyKXCdfgm/sQzY9WnV8/O2vU3/8tn1/cSx3xHa7ebetRMw +2Fj4gJr/EJV3JqpBd6v8ypTVIHnKBaoTQoSbOSRI8IgOK34p+8vBRMj4RQWE7UdxVgu kzX9f3giKgLFcOqVR4/uXXJdxNC1Qo9GGMegT/vDMr7KJuXKm3heyX8non0rHNpWfV7q R8MQplP89HSy001iEsQ+CC9hv4O7wKkfc2lUnGvobpZy2yPFXb50vJcvouipklD2/HMj f/iNkELlprHLK6SiXClEWkUOor9GyQNIF31nyxn5W5Hpxn9xwnYqCHF2muLp6dHvS9Yp pVfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=EZ8qidj7jyKbiTbOzh2PpngLc6kqLEC3BnaImC81G/E=; b=khqhV6Vmk4y5kZxYEcGCxjVYVVQyf4LlZdj9J7vKSjKAj+YMaTtSvTiZobbNPhFm8P 8Vzz5nQ9JjBqx4SSZ0mKr23nw37MfRgGgdzMdlLhzrq4snyL+qPUndMTbtuXbi6HHe9r ivEa+2+izQvof3qjWKLCDcZH1O2sindVuE8ifR87L5BrXAmh1kAzp7WYpj4MXQCawlcT zspdDpg0r+JUCNh2hNq7RaqmqrW4818esndjK3c5IUsXszvtdJrHgUP05FmTni/Z0IIa cAkb+Lnfn3gkZRZKF5PzOHYPLdRMCH/+Xm9tSPkb/FgzAe8o3WLSoLv2xDB6A5U3iOGo S8aQ== 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 w7si977593pgt.678.2018.04.18.04.45.56; Wed, 18 Apr 2018 04:45:57 -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 S1753964AbeDRLns (ORCPT + 29 others); Wed, 18 Apr 2018 07:43:48 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:42218 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753100AbeDRLnp (ORCPT ); Wed, 18 Apr 2018 07:43:45 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 0C62EB0BA56C; Wed, 18 Apr 2018 19:43:41 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.361.1; Wed, 18 Apr 2018 19:43:33 +0800 From: Shameer Kolothum To: , , CC: , , , , , , Shameer Kolothum Subject: [PATCH v6 0/7] vfio/type1: Add support for valid iova list management Date: Wed, 18 Apr 2018 12:40:38 +0100 Message-ID: <20180418114045.7968-1-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This series introduces an iova list associated with a vfio iommu. The list is kept updated taking care of iommu apertures, and reserved regions. Also this series adds checks for any conflict with existing dma mappings whenever a new device group is attached to the domain. User-space can retrieve valid iova ranges using VFIO_IOMMU_GET_INFO ioctl capability chains. Any dma map request outside the valid iova range will be rejected. v5 --> v6 -Rebased to 4.17-rc1 -Changed the ordering such that previous patch#7 "iommu/dma: Move PCI window region reservation back...") is now patch #4. This will avoid any bisection issues pointed out by Alex. -Added Robin's Reviewed-by tag for patch#4 v4 --> v5 Rebased to next-20180315. -Incorporated the corner case bug fix suggested by Alex to patch #5. -Based on suggestions by Alex and Robin, added patch#7. This moves the PCI window reservation back in to DMA specific path. This is to fix the issue reported by Eric[1]. Note: The patch #7 has dependency with [2][3] 1. https://patchwork.kernel.org/patch/10232043/ 2. https://patchwork.kernel.org/patch/10216553/ 3. https://patchwork.kernel.org/patch/10216555/ v3 --> v4 Addressed comments received for v3. -dma_addr_t instead of phys_addr_t -LIST_HEAD() usage. -Free up iova_copy list in case of error. -updated logic in filling the iova caps info(patch #5) RFCv2 --> v3 Removed RFC tag. Addressed comments from Alex and Eric: - Added comments to make iova list management logic more clear. - Use of iova list copy so that original is not altered in case of failure. RFCv1 --> RFCv2 Addressed comments from Alex: -Introduced IOVA list management and added checks for conflicts with existing dma map entries during attach/detach. Shameer Kolothum (7): vfio/type1: Introduce iova list and add iommu aperture validity check vfio/type1: Check reserve region conflict and update iova list vfio/type1: Update iova list on detach iommu/dma: Move PCI window region reservation back into dma specific path. vfio/type1: check dma map request is within a valid iova range vfio/type1: Add IOVA range capability support vfio/type1: remove duplicate retrieval of reserved regions drivers/iommu/dma-iommu.c | 54 ++--- drivers/vfio/vfio_iommu_type1.c | 497 +++++++++++++++++++++++++++++++++++++++- include/uapi/linux/vfio.h | 23 ++ 3 files changed, 533 insertions(+), 41 deletions(-) -- 2.7.4