Received: from eggs.gnu.org ([2001:4830:134:3::10]:45866) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBOFQ-00012e-TB for qemu-devel@nongnu.org; Mon, 28 Nov 2016 10:53:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cBOFP-0008Se-4T for qemu-devel@nongnu.org; Mon, 28 Nov 2016 10:53:40 -0500 Received: from mail-wj0-f193.google.com ([209.85.210.193]:35568) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cBOFO-0008SK-U3 for qemu-devel@nongnu.org; Mon, 28 Nov 2016 10:53:39 -0500 Received: by mail-wj0-f193.google.com with SMTP id he10so355505wjc.2 for ; Mon, 28 Nov 2016 07:53:38 -0800 (PST) From: "Aviv B.D" Date: Mon, 28 Nov 2016 17:51:54 +0200 Message-Id: <1480348315-13332-5-git-send-email-bd.aviv@gmail.com> In-Reply-To: <1480348315-13332-1-git-send-email-bd.aviv@gmail.com> References: <1480348315-13332-1-git-send-email-bd.aviv@gmail.com> Subject: [Qemu-devel] [PATCH v7 4/5] IOMMU: add specific replay function with default implemenation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Alex Williamson , Peter Xu , Jan Kiszka , Jason Wang , Aviv Ben-David From: "Aviv Ben-David" The default implementation scans the address space and try to find translation for each page, if exists. This callback enables effiecent implementation for intel_iommu and other subsystems with large address space. Signed-off-by: Aviv Ben-David --- include/exec/memory.h | 4 ++++ memory.c | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index 2d7ee54..a8b3701 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -180,6 +180,10 @@ struct MemoryRegionIOMMUOps { void (*notify_flag_changed)(MemoryRegion *iommu, IOMMUNotifierFlag old_flags, IOMMUNotifierFlag new_flags); + /* Called when region has been moved between iommu domains */ + void (*replay)(MemoryRegion *mr, + IOMMUNotifier *n, + bool is_write); }; typedef struct CoalescedMemoryRange CoalescedMemoryRange; diff --git a/memory.c b/memory.c index 9b88638..562d540 100644 --- a/memory.c +++ b/memory.c @@ -1624,6 +1624,14 @@ void memory_region_iommu_replay(MemoryRegion *mr, IOMMUNotifier *n, hwaddr addr, granularity; IOMMUTLBEntry iotlb; + /* If there is specific implementation, use it */ + assert(memory_region_is_iommu(mr)); + if (mr->iommu_ops && mr->iommu_ops->replay) { + return mr->iommu_ops->replay(mr, n, is_write); + } + + /* No specific implementation for this iommu, fall back to default + * implementation */ granularity = memory_region_iommu_get_min_page_size(mr); for (addr = 0; addr < memory_region_size(mr); addr += granularity) { -- 1.9.1