From nobody Tue Jul 1 09:01:39 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491563283938104.78049436526089; Fri, 7 Apr 2017 04:08:03 -0700 (PDT) Received: from localhost ([::1]:50124 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwRkI-0005ev-Li for importer@patchew.org; Fri, 07 Apr 2017 07:08:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57209) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cwRdy-0000zz-7E for qemu-devel@nongnu.org; Fri, 07 Apr 2017 07:01:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cwRdv-0005kC-7q for qemu-devel@nongnu.org; Fri, 07 Apr 2017 07:01:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41154) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cwRdv-0005k1-2o for qemu-devel@nongnu.org; Fri, 07 Apr 2017 07:01:27 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 04AAB3D95D; Fri, 7 Apr 2017 11:01:26 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-8-43.pek2.redhat.com [10.72.8.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FE94179FC; Fri, 7 Apr 2017 11:01:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 04AAB3D95D Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 04AAB3D95D From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 7 Apr 2017 18:59:11 +0800 Message-Id: <1491562755-23867-6-git-send-email-peterx@redhat.com> In-Reply-To: <1491562755-23867-1-git-send-email-peterx@redhat.com> References: <1491562755-23867-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 07 Apr 2017 11:01:26 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v9 5/9] memory: add MemoryRegionIOMMUOps.replay() callback 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: tianyu.lan@intel.com, kevin.tian@intel.com, mst@redhat.com, jan.kiszka@siemens.com, jasowang@redhat.com, peterx@redhat.com, alex.williamson@redhat.com, Marcel Apfelbaum , bd.aviv@gmail.com, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Originally we have one memory_region_iommu_replay() function, which is the default behavior to replay the translations of the whole IOMMU region. However, on some platform like x86, we may want our own replay logic for IOMMU regions. This patch adds one more hook for IOMMUOps for the callback, and it'll override the default if set. Reviewed-by: David Gibson Reviewed-by: Eric Auger Reviewed-by: \"Michael S. Tsirkin\" Signed-off-by: Peter Xu --- include/exec/memory.h | 2 ++ memory.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index 055b3a8..c0280b7 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -191,6 +191,8 @@ struct MemoryRegionIOMMUOps { void (*notify_flag_changed)(MemoryRegion *iommu, IOMMUNotifierFlag old_flags, IOMMUNotifierFlag new_flags); + /* Set this up to provide customized IOMMU replay function */ + void (*replay)(MemoryRegion *iommu, IOMMUNotifier *notifier); }; =20 typedef struct CoalescedMemoryRange CoalescedMemoryRange; diff --git a/memory.c b/memory.c index ded4bf1..b782d5b 100644 --- a/memory.c +++ b/memory.c @@ -1626,6 +1626,12 @@ void memory_region_iommu_replay(MemoryRegion *mr, IO= MMUNotifier *n, hwaddr addr, granularity; IOMMUTLBEntry iotlb; =20 + /* If the IOMMU has its own replay callback, override */ + if (mr->iommu_ops->replay) { + mr->iommu_ops->replay(mr, n); + return; + } + granularity =3D memory_region_iommu_get_min_page_size(mr); =20 for (addr =3D 0; addr < memory_region_size(mr); addr +=3D granularity)= { --=20 2.7.4