From patchwork Mon Nov 28 15:51:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aviv B.D." X-Patchwork-Id: 9449729 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B5A90600CB for ; Mon, 28 Nov 2016 15:55:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4DB127D5D for ; Mon, 28 Nov 2016 15:55:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 99AFB27D85; Mon, 28 Nov 2016 15:55:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 412F727D5D for ; Mon, 28 Nov 2016 15:55:19 +0000 (UTC) Received: from localhost ([::1]:59603 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cBOH0-0001pz-8f for patchwork-qemu-devel@patchwork.kernel.org; Mon, 28 Nov 2016 10:55:18 -0500 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=94GHqqrLc4xkSHKpfIvXT0b3lIflaYyuAcHFaO6cDqw=; b=rRvPck294U0JJMjzavamZ2NJXXKC/jMAQ24negAG2BWKmNuGDSGmQb+scqPK+MW2/H 00ej25OrKJUQwWiMi+8rgR+xcyNU0flhz1Vzir5s6/BKN69dNj+V8rCQOubKA3bZI+md WMDkdlDPhzVB8/AjkYotT+MbYzix9MirMe6hxnkEvgDu0aww0vwshsNucxTkpjjFgt/O rDd67yP8/+rK61SkfPN0d/3ZdCk9A6heEtDPzZsue5gs3u7yafKrvlZGcNpWs+oUcIVF gWqWephLX9+9KvDc1GoZVofdpLc0IIAJ9QkTdlxIoQo7L1MI8xER5EYO4c4LtegQqt4u DltA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=94GHqqrLc4xkSHKpfIvXT0b3lIflaYyuAcHFaO6cDqw=; b=Zfidf9DzEcv8ZP+G/xCBbk/9L5yr+Rz2r7R03ASzpOQepeDaeMmo3phP5JyDY6RRwN VypMZ2AKNiK708EYUxkjSxy3txhKUlFHfSCcV38wNXSTD+jDYY8updElXZQspL6a4+IK vadrftGJg4Oax4rmUgiC2VUtttxX3ONLCcKWBdoDCiH14bQ/RpWioyLTI3k1D5tD28YA 0ZZwHEQATzTP8nko5Wyoj83J0YserPIX+tpVmlExpnK/zPmiJScZySrqEabnVb6Nhf5Q iBvrih5N8db7n48HBN9yvbX4ebO/VWqOUOTzMkCaw0vn+0RqwF5mQa/4OTmoy/X9D9Hy RlFQ== X-Gm-Message-State: AKaTC00VI/KIgVsknkhswRV0Fo/aT9KKj3APLQKx1aOI4NVZEcxUeJJWX1XwQK6G7En8Tw== X-Received: by 10.194.187.103 with SMTP id fr7mr18786737wjc.99.1480348357787; Mon, 28 Nov 2016 07:52:37 -0800 (PST) Received: from tapuz2.cslcs.technion.ac.il (tapuz2.cslcs.technion.ac.il. [132.68.206.212]) by smtp.gmail.com with ESMTPSA id jm6sm63173534wjb.27.2016.11.28.07.52.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Nov 2016 07:52:37 -0800 (PST) From: "Aviv B.D" To: qemu-devel@nongnu.org Date: Mon, 28 Nov 2016 17:51:54 +0200 Message-Id: <1480348315-13332-5-git-send-email-bd.aviv@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1480348315-13332-1-git-send-email-bd.aviv@gmail.com> References: <1480348315-13332-1-git-send-email-bd.aviv@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.210.193 Subject: [Qemu-devel] [PATCH v7 4/5] IOMMU: add specific replay function with default implemenation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , Jan Kiszka , Aviv Ben-David , Peter Xu , Alex Williamson , Jason Wang Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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) {