From patchwork Thu Mar 15 16:35:02 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: 131816 Delivered-To: patch@linaro.org Received: by 10.80.210.197 with SMTP id q5csp1697371edg; Thu, 15 Mar 2018 09:38:09 -0700 (PDT) X-Google-Smtp-Source: AG47ELvwDZGUPhjtzDv7i1owO9MH9sQjTf2Mn0ZeBDEYdI5/a+ibOdmPgYTrnNHfXJZEAPuOlXa+ X-Received: by 10.98.80.150 with SMTP id g22mr2004021pfj.87.1521131888941; Thu, 15 Mar 2018 09:38:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521131888; cv=none; d=google.com; s=arc-20160816; b=B7gZnCMG3olGCERGK4HdXXf50i1mhPSH4A+nAVO29+X6z98D4axeJrQaVy5juSU74p 6dMrPcL35ux82QuMtZ85EwHjvaN1eonRzAQnnxin/E3QHi92NBr1sbxTUHP2nIVaMfDw 6PMyaQfxq2XmaXHSmTNaNa8/XsfDp7VHhGNGJjwNhqiuWKU/wnazLe/nmoDuyUV9ZLVR cFZ94HPKtKyZOQO9vJPOCrC/pSuqdHiecePfEpEgz88jU2y0yr5cKeP4jlZYdzw961lh qqApYQXCFLPhHns4YFWbMx48HCehIQuYRJ/PiSabMNyqJEhCILkpQwFdMQayoNKzbg5w H+1g== 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=cWGgimNPkb4HQ/uNEq9mvy/CiA9oev/U98csm6H5PW0=; b=ksTHE/aIR76tNLdv1s2ippUdcOUQb9UuwLYQ0jArOQ7W8lo6yPoAlR7veW1ceQK16q cAxIeWWeA6dCa4WDdoXeHIqdTIXzedDZTqCe8Lk3uq198KPbpK1qehYalKe2I7S9MC7t yoM0QMYyRbvvD8c2knuB6RiXltg4CyzNzGgGWMTTcZCuwCa58mE1XBDNIprsQZNMIWGs ciozEhUeXVplEwPk2X3ApdjDplYLBevNScJvyE3h4z4A5LkEsX7eq3CgKM5ekW9cqhNm 2lW0vy79kg+0I7xF29mryEabvRAW/k4fq9D5ig3N/k8FgSF8vvV/++JIhZv+Xn8qDBE4 MGIw== 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 g1-v6si4244756pld.236.2018.03.15.09.38.08; Thu, 15 Mar 2018 09:38:08 -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 S1752077AbeCOQiG (ORCPT + 28 others); Thu, 15 Mar 2018 12:38:06 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:39621 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751982AbeCOQiE (ORCPT ); Thu, 15 Mar 2018 12:38:04 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 38424265CBAA9; Fri, 16 Mar 2018 00:37:49 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.361.1; Fri, 16 Mar 2018 00:37:42 +0800 From: Shameer Kolothum To: , , CC: , , , , , , Shameer Kolothum Subject: [PATCH v5 0/7] vfio/type1: Add support for valid iova list management Date: Thu, 15 Mar 2018 16:35:02 +0000 Message-ID: <20180315163509.17740-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. 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 (2): vfio/type1: Add IOVA range capability support iommu/dma: Move PCI window region reservation back into dma specific path. Shameerali Kolothum Thodi (5): 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 vfio/type1: check dma map request is within a valid iova range 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