Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6012218ybl; Tue, 14 Jan 2020 19:52:28 -0800 (PST) X-Google-Smtp-Source: APXvYqzAwrzPZOU1ndwIDYk8Thg06l+mhvnDmCIFJ7qDW9j2Uij/J29CTQ6DAOuO1M8ZAsMM3MZd X-Received: by 2002:aca:39d6:: with SMTP id g205mr18180353oia.122.1579060348038; Tue, 14 Jan 2020 19:52:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579060348; cv=none; d=google.com; s=arc-20160816; b=Wgj0JF16EaQyjy3LJkpNoMVR7i6Fs8My/A8U2q7tWZYV+2pLCZ3jF7UHyhurDKu7Nb VMOL+vS2MXmd1O+nAx35wLKccROIpOust+5rVdvmvgfRvFwCsei2XfYz+CdaVFGZyHYf VYQbQVR7uY1ywEcHa8sUR5+cYYzW3cAuN/W3c4DmXX2vR0fRNae7eiGyPhPTnlbhdpwa R273h6/lXUcpElgEoS8V/BcFMNyIafqLkG0zQ1QiQh0LAjagf9jq5zHubbH2ckVMVXPl 4awlGyTEa6HbuenimjP7kSIGnXQ3t81UbasX2RQkGkrfkOVf8GEIqy2R/iVXJaCenRb4 LIPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=k9/b+Cpw4dvBW9VJQWQ2DRfmbahAQSlci2zgNKUHux0=; b=zOHd7ppek/l1w+wLFCAPNGAcv120Bh7WIqf9FwRLLTk8cEr7g9K6zY7mYOATSfPHUZ kt+u2gXGMTCygRg0UwVLXFt8cVfAGMvWvNuJZNa65o+FCGrBoslnAF174+daFYU5L5vv Zj75eSwUOevgz77ve47u/Go1/8r52S86ApqD6/H7sdl+SIq+BH0E3TIwinvivC871Eyn En8q6AH3gIDFf75v4OSJCETIcsAY2J0N31B+4z3LcK3B0PTSA1IQsIBu7bLWliDTVxyf Ka/Zu+B7X57OJc1mEtLcSOpxtOt7yHetYZIrK/C2eZ09H4gQDm2fb/Jx/5UB4fWxM+Af 74Bg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w24si8112661oic.260.2020.01.14.19.52.16; Tue, 14 Jan 2020 19:52:28 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729061AbgAODvV (ORCPT + 99 others); Tue, 14 Jan 2020 22:51:21 -0500 Received: from mga11.intel.com ([192.55.52.93]:3148 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728884AbgAODvV (ORCPT ); Tue, 14 Jan 2020 22:51:21 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jan 2020 19:51:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,321,1574150400"; d="scan'208";a="213570974" Received: from unknown (HELO joy-OptiPlex-7040.sh.intel.com) ([10.239.13.9]) by orsmga007.jf.intel.com with ESMTP; 14 Jan 2020 19:51:18 -0800 From: Yan Zhao To: alex.williamson@redhat.com, zhenyuw@linux.intel.com Cc: intel-gvt-dev@lists.freedesktop.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, pbonzini@redhat.com, kevin.tian@intel.com, peterx@redhat.com, Yan Zhao Subject: [PATCH v2 0/2] use vfio_dma_rw to read/write IOVAs from CPU side Date: Tue, 14 Jan 2020 22:41:32 -0500 Message-Id: <20200115034132.2753-1-yan.y.zhao@intel.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It is better for a device model to use IOVAs to read/write memory. And because the rw operations come from CPUs, it is not necessary to call vfio_pin_pages() to pin those pages. patch 1 introduces interface vfio_dma_rw in vfio to read/write IOVAs without pinning user space pages. patch 2 let gvt switch from kvm side rw interface to vfio_dma_rw. v2 changelog: - rename vfio_iova_rw to vfio_dma_rw, vfio iommu driver ops .iova_rw to .dma_rw. (Alex). - change iova and len from unsigned long to dma_addr_t and size_t, respectively. (Alex) - fix possible overflow in dma->vaddr + iova - dma->iova + offset (Alex) - split DMAs from on page boundary to on max available size to eliminate redundant searching of vfio_dma and switching mm. (Alex) - add a check for IOMMU_WRITE permission. Yan Zhao (2): vfio: introduce vfio_dma_rw to read/write a range of IOVAs drm/i915/gvt: subsitute kvm_read/write_guest with vfio_dma_rw drivers/gpu/drm/i915/gvt/kvmgt.c | 26 +++-------- drivers/vfio/vfio.c | 45 +++++++++++++++++++ drivers/vfio/vfio_iommu_type1.c | 76 ++++++++++++++++++++++++++++++++ include/linux/vfio.h | 5 +++ 4 files changed, 133 insertions(+), 19 deletions(-) -- 2.17.1