From nobody Tue May 7 14:53:17 2024 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 1493285778205389.10712646610057; Thu, 27 Apr 2017 02:36:18 -0700 (PDT) Received: from localhost ([::1]:59629 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3fqS-0004Bo-OE for importer@patchew.org; Thu, 27 Apr 2017 05:36:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47273) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3fp6-0003Fe-EK for qemu-devel@nongnu.org; Thu, 27 Apr 2017 05:34:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3fp4-0003rp-OS for qemu-devel@nongnu.org; Thu, 27 Apr 2017 05:34:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35920) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3fp4-0003rJ-F0 for qemu-devel@nongnu.org; Thu, 27 Apr 2017 05:34:50 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5BAA9683E8; Thu, 27 Apr 2017 09:34:49 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-8-65.pek2.redhat.com [10.72.8.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1477117180; Thu, 27 Apr 2017 09:34:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5BAA9683E8 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5BAA9683E8 From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 27 Apr 2017 17:34:13 +0800 Message-Id: <1493285660-4470-2-git-send-email-peterx@redhat.com> In-Reply-To: <1493285660-4470-1-git-send-email-peterx@redhat.com> References: <1493285660-4470-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 27 Apr 2017 09:34:49 +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] [RFC PATCH 1/8] memory: rename IOMMU_NOTIFIER_* 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, yi.l.liu@intel.com, Jason Wang , peterx@redhat.com, Alex Williamson , Paolo Bonzini , 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" IOMMU notifiers before are mostly used for [dev-]IOTLB stuffs. It is not suitable for other kind of notifiers (one example would be the future virt-svm support). Considering that current notifiers are targeted for per memory region, renaming all the notifier types from IOMMU_NOTIFIER_* prefix into IOMMU_MR_EVENT_* to better show its usage (for memory regions). Alongside, renaming IOMMUNotifierFlag into IOMMUMREventFlag. Signed-off-by: Peter Xu Reviewed-by: David Gibson --- hw/i386/amd_iommu.c | 6 +++--- hw/i386/intel_iommu.c | 12 ++++++------ hw/ppc/spapr_iommu.c | 8 ++++---- hw/vfio/common.c | 2 +- hw/virtio/vhost.c | 2 +- include/exec/memory.h | 20 ++++++++++---------- memory.c | 12 ++++++------ 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index f86a40a..315ec2a 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -1067,12 +1067,12 @@ static const MemoryRegionOps mmio_mem_ops =3D { }; =20 static void amdvi_iommu_notify_flag_changed(MemoryRegion *iommu, - IOMMUNotifierFlag old, - IOMMUNotifierFlag new) + IOMMUMREventFlags old, + IOMMUMREventFlags new) { AMDVIAddressSpace *as =3D container_of(iommu, AMDVIAddressSpace, iommu= ); =20 - if (new & IOMMU_NOTIFIER_MAP) { + if (new & IOMMU_MR_EVENT_MAP) { error_report("device %02x.%02x.%x requires iommu notifier which is= not " "currently supported", as->bus_num, PCI_SLOT(as->devf= n), PCI_FUNC(as->devfn)); diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 02f047c..dce1ee8 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -1132,7 +1132,7 @@ static void vtd_context_device_invalidate(IntelIOMMUS= tate *s, /* * So a device is moving out of (or moving into) a * domain, a replay() suites here to notify all the - * IOMMU_NOTIFIER_MAP registers about this change. + * IOMMU_MR_EVENT_MAP registers about this change. * This won't bring bad even if we have no such * notifier registered - the IOMMU notification * framework will skip MAP notifications if that @@ -2253,21 +2253,21 @@ static IOMMUTLBEntry vtd_iommu_translate(MemoryRegi= on *iommu, hwaddr addr, } =20 static void vtd_iommu_notify_flag_changed(MemoryRegion *iommu, - IOMMUNotifierFlag old, - IOMMUNotifierFlag new) + IOMMUMREventFlags old, + IOMMUMREventFlags new) { VTDAddressSpace *vtd_as =3D container_of(iommu, VTDAddressSpace, iommu= ); IntelIOMMUState *s =3D vtd_as->iommu_state; IntelIOMMUNotifierNode *node =3D NULL; IntelIOMMUNotifierNode *next_node =3D NULL; =20 - if (!s->caching_mode && new & IOMMU_NOTIFIER_MAP) { + if (!s->caching_mode && new & IOMMU_MR_EVENT_MAP) { error_report("We need to set cache_mode=3D1 for intel-iommu to ena= ble " "device assignment with IOMMU protection."); exit(1); } =20 - if (old =3D=3D IOMMU_NOTIFIER_NONE) { + if (old =3D=3D IOMMU_MR_EVENT_NONE) { node =3D g_malloc0(sizeof(*node)); node->vtd_as =3D vtd_as; QLIST_INSERT_HEAD(&s->notifiers_list, node, next); @@ -2277,7 +2277,7 @@ static void vtd_iommu_notify_flag_changed(MemoryRegio= n *iommu, /* update notifier node with new flags */ QLIST_FOREACH_SAFE(node, &s->notifiers_list, next, next_node) { if (node->vtd_as =3D=3D vtd_as) { - if (new =3D=3D IOMMU_NOTIFIER_NONE) { + if (new =3D=3D IOMMU_MR_EVENT_NONE) { QLIST_REMOVE(node, next); g_free(node); } diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c index 29c80bb..5e6e70b 100644 --- a/hw/ppc/spapr_iommu.c +++ b/hw/ppc/spapr_iommu.c @@ -158,14 +158,14 @@ static uint64_t spapr_tce_get_min_page_size(MemoryReg= ion *iommu) } =20 static void spapr_tce_notify_flag_changed(MemoryRegion *iommu, - IOMMUNotifierFlag old, - IOMMUNotifierFlag new) + IOMMUMREventFlags old, + IOMMUMREventFlags new) { struct sPAPRTCETable *tbl =3D container_of(iommu, sPAPRTCETable, iommu= ); =20 - if (old =3D=3D IOMMU_NOTIFIER_NONE && new !=3D IOMMU_NOTIFIER_NONE) { + if (old =3D=3D IOMMU_MR_EVENT_NONE && new !=3D IOMMU_MR_EVENT_NONE) { spapr_tce_set_need_vfio(tbl, true); - } else if (old !=3D IOMMU_NOTIFIER_NONE && new =3D=3D IOMMU_NOTIFIER_N= ONE) { + } else if (old !=3D IOMMU_MR_EVENT_NONE && new =3D=3D IOMMU_MR_EVENT_N= ONE) { spapr_tce_set_need_vfio(tbl, false); } } diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 6b33b9f..a6ca10b 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -482,7 +482,7 @@ static void vfio_listener_region_add(MemoryListener *li= stener, section->size); llend =3D int128_sub(llend, int128_one()); iommu_notifier_init(&giommu->n, vfio_iommu_map_notify, - IOMMU_NOTIFIER_ALL, + IOMMU_MR_EVENT_ALL, section->offset_within_region, int128_get64(llend)); QLIST_INSERT_HEAD(&container->giommu_list, giommu, giommu_next); diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 0001e60..2e8d8fc 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -747,7 +747,7 @@ static void vhost_iommu_region_add(MemoryListener *list= ener, section->size); end =3D int128_sub(end, int128_one()); iommu_notifier_init(&iommu->n, vhost_iommu_unmap_notify, - IOMMU_NOTIFIER_UNMAP, + IOMMU_MR_EVENT_UNMAP, section->offset_within_region, int128_get64(end)); iommu->mr =3D section->mr; diff --git a/include/exec/memory.h b/include/exec/memory.h index 99e0f54..90730b1 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -70,14 +70,14 @@ struct IOMMUTLBEntry { * register with one or multiple IOMMU Notifier capability bit(s). */ typedef enum { - IOMMU_NOTIFIER_NONE =3D 0, + IOMMU_MR_EVENT_NONE =3D 0, /* Notify cache invalidations */ - IOMMU_NOTIFIER_UNMAP =3D 0x1, + IOMMU_MR_EVENT_UNMAP =3D 0x1, /* Notify entry changes (newly created entries) */ - IOMMU_NOTIFIER_MAP =3D 0x2, -} IOMMUNotifierFlag; + IOMMU_MR_EVENT_MAP =3D 0x2, +} IOMMUMREventFlags; =20 -#define IOMMU_NOTIFIER_ALL (IOMMU_NOTIFIER_MAP | IOMMU_NOTIFIER_UNMAP) +#define IOMMU_MR_EVENT_ALL (IOMMU_MR_EVENT_MAP | IOMMU_MR_EVENT_UNMAP) =20 struct IOMMUNotifier; typedef void (*IOMMUNotify)(struct IOMMUNotifier *notifier, @@ -85,7 +85,7 @@ typedef void (*IOMMUNotify)(struct IOMMUNotifier *notifie= r, =20 struct IOMMUNotifier { IOMMUNotify notify; - IOMMUNotifierFlag notifier_flags; + IOMMUMREventFlags notifier_flags; /* Notify for address space range start <=3D addr <=3D end */ hwaddr start; hwaddr end; @@ -94,7 +94,7 @@ struct IOMMUNotifier { typedef struct IOMMUNotifier IOMMUNotifier; =20 static inline void iommu_notifier_init(IOMMUNotifier *n, IOMMUNotify fn, - IOMMUNotifierFlag flags, + IOMMUMREventFlags flags, hwaddr start, hwaddr end) { n->notify =3D fn; @@ -191,8 +191,8 @@ struct MemoryRegionIOMMUOps { uint64_t (*get_min_page_size)(MemoryRegion *iommu); /* Called when IOMMU Notifier flag changed */ void (*notify_flag_changed)(MemoryRegion *iommu, - IOMMUNotifierFlag old_flags, - IOMMUNotifierFlag new_flags); + IOMMUMREventFlags old_flags, + IOMMUMREventFlags new_flags); /* Set this up to provide customized IOMMU replay function */ void (*replay)(MemoryRegion *iommu, IOMMUNotifier *notifier); }; @@ -240,7 +240,7 @@ struct MemoryRegion { unsigned ioeventfd_nb; MemoryRegionIoeventfd *ioeventfds; QLIST_HEAD(, IOMMUNotifier) iommu_notify; - IOMMUNotifierFlag iommu_notify_flags; + IOMMUMREventFlags iommu_notify_flags; }; =20 #define IOMMU_NOTIFIER_FOREACH(n, mr) \ diff --git a/memory.c b/memory.c index b727f5e..6237631 100644 --- a/memory.c +++ b/memory.c @@ -1483,7 +1483,7 @@ void memory_region_init_iommu(MemoryRegion *mr, mr->iommu_ops =3D ops, mr->terminates =3D true; /* then re-forwards */ QLIST_INIT(&mr->iommu_notify); - mr->iommu_notify_flags =3D IOMMU_NOTIFIER_NONE; + mr->iommu_notify_flags =3D IOMMU_MR_EVENT_NONE; } =20 static void memory_region_finalize(Object *obj) @@ -1580,7 +1580,7 @@ bool memory_region_is_logging(MemoryRegion *mr, uint8= _t client) =20 static void memory_region_update_iommu_notify_flags(MemoryRegion *mr) { - IOMMUNotifierFlag flags =3D IOMMU_NOTIFIER_NONE; + IOMMUMREventFlags flags =3D IOMMU_MR_EVENT_NONE; IOMMUNotifier *iommu_notifier; =20 IOMMU_NOTIFIER_FOREACH(iommu_notifier, mr) { @@ -1605,7 +1605,7 @@ void memory_region_register_iommu_notifier(MemoryRegi= on *mr, } =20 /* We need to register for at least one bitfield */ - assert(n->notifier_flags !=3D IOMMU_NOTIFIER_NONE); + assert(n->notifier_flags !=3D IOMMU_MR_EVENT_NONE); assert(n->start <=3D n->end); QLIST_INSERT_HEAD(&mr->iommu_notify, n, node); memory_region_update_iommu_notify_flags(mr); @@ -1671,7 +1671,7 @@ void memory_region_unregister_iommu_notifier(MemoryRe= gion *mr, void memory_region_notify_one(IOMMUNotifier *notifier, IOMMUTLBEntry *entry) { - IOMMUNotifierFlag request_flags; + IOMMUMREventFlags request_flags; =20 /* * Skip the notification if the notification does not overlap @@ -1683,9 +1683,9 @@ void memory_region_notify_one(IOMMUNotifier *notifier, } =20 if (entry->perm & IOMMU_RW) { - request_flags =3D IOMMU_NOTIFIER_MAP; + request_flags =3D IOMMU_MR_EVENT_MAP; } else { - request_flags =3D IOMMU_NOTIFIER_UNMAP; + request_flags =3D IOMMU_MR_EVENT_UNMAP; } =20 if (notifier->notifier_flags & request_flags) { --=20 2.7.4 From nobody Tue May 7 14:53:17 2024 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 1493285903233918.1881113441859; Thu, 27 Apr 2017 02:38:23 -0700 (PDT) Received: from localhost ([::1]:59636 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3fsT-0005td-HJ for importer@patchew.org; Thu, 27 Apr 2017 05:38:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47344) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3fpG-0003OY-OR for qemu-devel@nongnu.org; Thu, 27 Apr 2017 05:35:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3fpB-0003w9-Pt for qemu-devel@nongnu.org; Thu, 27 Apr 2017 05:35:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6559) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3fpB-0003vo-Dt for qemu-devel@nongnu.org; Thu, 27 Apr 2017 05:34:57 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5B80D683E8; Thu, 27 Apr 2017 09:34:56 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-8-65.pek2.redhat.com [10.72.8.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01CE91724B; Thu, 27 Apr 2017 09:34:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5B80D683E8 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5B80D683E8 From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 27 Apr 2017 17:34:14 +0800 Message-Id: <1493285660-4470-3-git-send-email-peterx@redhat.com> In-Reply-To: <1493285660-4470-1-git-send-email-peterx@redhat.com> References: <1493285660-4470-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 27 Apr 2017 09:34:56 +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] [RFC PATCH 2/8] memory: rename IOMMUNotifier 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, yi.l.liu@intel.com, Jason Wang , peterx@redhat.com, Alex Williamson , Paolo Bonzini , 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" Renaming it to IOMMUMRNotifier. This is a corresponding change to previous patch, to emphasize that these notifiers are based on memory regions. Signed-off-by: Peter Xu --- hw/i386/intel_iommu.c | 20 ++++++++++---------- hw/vfio/common.c | 2 +- hw/virtio/vhost.c | 2 +- include/exec/memory.h | 28 ++++++++++++++-------------- include/hw/i386/intel_iommu.h | 8 ++++---- include/hw/vfio/vfio-common.h | 2 +- include/hw/virtio/vhost.h | 4 ++-- memory.c | 14 +++++++------- 8 files changed, 40 insertions(+), 40 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index dce1ee8..3306e6a 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -1041,7 +1041,7 @@ static void vtd_interrupt_remap_table_setup(IntelIOMM= UState *s) =20 static void vtd_iommu_replay_all(IntelIOMMUState *s) { - IntelIOMMUNotifierNode *node; + IntelIOMMUMRNotifierNode *node; =20 QLIST_FOREACH(node, &s->notifiers_list, next) { memory_region_iommu_replay_all(&node->vtd_as->iommu); @@ -1185,7 +1185,7 @@ static void vtd_iotlb_global_invalidate(IntelIOMMUSta= te *s) =20 static void vtd_iotlb_domain_invalidate(IntelIOMMUState *s, uint16_t domai= n_id) { - IntelIOMMUNotifierNode *node; + IntelIOMMUMRNotifierNode *node; VTDContextEntry ce; VTDAddressSpace *vtd_as; =20 @@ -1213,7 +1213,7 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOM= MUState *s, uint16_t domain_id, hwaddr addr, uint8_t am) { - IntelIOMMUNotifierNode *node; + IntelIOMMUMRNotifierNode *node; VTDContextEntry ce; int ret; =20 @@ -2258,8 +2258,8 @@ static void vtd_iommu_notify_flag_changed(MemoryRegio= n *iommu, { VTDAddressSpace *vtd_as =3D container_of(iommu, VTDAddressSpace, iommu= ); IntelIOMMUState *s =3D vtd_as->iommu_state; - IntelIOMMUNotifierNode *node =3D NULL; - IntelIOMMUNotifierNode *next_node =3D NULL; + IntelIOMMUMRNotifierNode *node =3D NULL; + IntelIOMMUMRNotifierNode *next_node =3D NULL; =20 if (!s->caching_mode && new & IOMMU_MR_EVENT_MAP) { error_report("We need to set cache_mode=3D1 for intel-iommu to ena= ble " @@ -2702,7 +2702,7 @@ VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, = PCIBus *bus, int devfn) } =20 /* Unmap the whole range in the notifier's scope. */ -static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n) +static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUMRNotifier *= n) { IOMMUTLBEntry entry; hwaddr size; @@ -2757,9 +2757,9 @@ static void vtd_address_space_unmap(VTDAddressSpace *= as, IOMMUNotifier *n) =20 static void vtd_address_space_unmap_all(IntelIOMMUState *s) { - IntelIOMMUNotifierNode *node; + IntelIOMMUMRNotifierNode *node; VTDAddressSpace *vtd_as; - IOMMUNotifier *n; + IOMMUMRNotifier *n; =20 QLIST_FOREACH(node, &s->notifiers_list, next) { vtd_as =3D node->vtd_as; @@ -2771,11 +2771,11 @@ static void vtd_address_space_unmap_all(IntelIOMMUS= tate *s) =20 static int vtd_replay_hook(IOMMUTLBEntry *entry, void *private) { - memory_region_notify_one((IOMMUNotifier *)private, entry); + memory_region_notify_one((IOMMUMRNotifier *)private, entry); return 0; } =20 -static void vtd_iommu_replay(MemoryRegion *mr, IOMMUNotifier *n) +static void vtd_iommu_replay(MemoryRegion *mr, IOMMUMRNotifier *n) { VTDAddressSpace *vtd_as =3D container_of(mr, VTDAddressSpace, iommu); IntelIOMMUState *s =3D vtd_as->iommu_state; diff --git a/hw/vfio/common.c b/hw/vfio/common.c index a6ca10b..bd113b7 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -332,7 +332,7 @@ static bool vfio_get_vaddr(IOMMUTLBEntry *iotlb, void *= *vaddr, return true; } =20 -static void vfio_iommu_map_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb) +static void vfio_iommu_map_notify(IOMMUMRNotifier *n, IOMMUTLBEntry *iotlb) { VFIOGuestIOMMU *giommu =3D container_of(n, VFIOGuestIOMMU, n); VFIOContainer *container =3D giommu->container; diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 2e8d8fc..81a8aea 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -718,7 +718,7 @@ static void vhost_region_del(MemoryListener *listener, } } =20 -static void vhost_iommu_unmap_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotl= b) +static void vhost_iommu_unmap_notify(IOMMUMRNotifier *n, IOMMUTLBEntry *io= tlb) { struct vhost_iommu *iommu =3D container_of(n, struct vhost_iommu, n); struct vhost_dev *hdev =3D iommu->hdev; diff --git a/include/exec/memory.h b/include/exec/memory.h index 90730b1..6be0c02 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -66,7 +66,7 @@ struct IOMMUTLBEntry { }; =20 /* - * Bitmap for different IOMMUNotifier capabilities. Each notifier can + * Bitmap for different IOMMUMRNotifier capabilities. Each notifier can * register with one or multiple IOMMU Notifier capability bit(s). */ typedef enum { @@ -79,21 +79,21 @@ typedef enum { =20 #define IOMMU_MR_EVENT_ALL (IOMMU_MR_EVENT_MAP | IOMMU_MR_EVENT_UNMAP) =20 -struct IOMMUNotifier; -typedef void (*IOMMUNotify)(struct IOMMUNotifier *notifier, +struct IOMMUMRNotifier; +typedef void (*IOMMUNotify)(struct IOMMUMRNotifier *notifier, IOMMUTLBEntry *data); =20 -struct IOMMUNotifier { +struct IOMMUMRNotifier { IOMMUNotify notify; IOMMUMREventFlags notifier_flags; /* Notify for address space range start <=3D addr <=3D end */ hwaddr start; hwaddr end; - QLIST_ENTRY(IOMMUNotifier) node; + QLIST_ENTRY(IOMMUMRNotifier) node; }; -typedef struct IOMMUNotifier IOMMUNotifier; +typedef struct IOMMUMRNotifier IOMMUMRNotifier; =20 -static inline void iommu_notifier_init(IOMMUNotifier *n, IOMMUNotify fn, +static inline void iommu_notifier_init(IOMMUMRNotifier *n, IOMMUNotify fn, IOMMUMREventFlags flags, hwaddr start, hwaddr end) { @@ -194,7 +194,7 @@ struct MemoryRegionIOMMUOps { IOMMUMREventFlags old_flags, IOMMUMREventFlags new_flags); /* Set this up to provide customized IOMMU replay function */ - void (*replay)(MemoryRegion *iommu, IOMMUNotifier *notifier); + void (*replay)(MemoryRegion *iommu, IOMMUMRNotifier *notifier); }; =20 typedef struct CoalescedMemoryRange CoalescedMemoryRange; @@ -239,7 +239,7 @@ struct MemoryRegion { const char *name; unsigned ioeventfd_nb; MemoryRegionIoeventfd *ioeventfds; - QLIST_HEAD(, IOMMUNotifier) iommu_notify; + QLIST_HEAD(, IOMMUMRNotifier) iommu_notify; IOMMUMREventFlags iommu_notify_flags; }; =20 @@ -703,7 +703,7 @@ void memory_region_notify_iommu(MemoryRegion *mr, * replaces all old entries for the same virtual I/O address range. * Deleted entries have .@perm =3D=3D 0. */ -void memory_region_notify_one(IOMMUNotifier *notifier, +void memory_region_notify_one(IOMMUMRNotifier *notifier, IOMMUTLBEntry *entry); =20 /** @@ -711,12 +711,12 @@ void memory_region_notify_one(IOMMUNotifier *notifier, * IOMMU translation entries. * * @mr: the memory region to observe - * @n: the IOMMUNotifier to be added; the notify callback receives a + * @n: the IOMMUMRNotifier to be added; the notify callback receives a * pointer to an #IOMMUTLBEntry as the opaque value; the pointer * ceases to be valid on exit from the notifier. */ void memory_region_register_iommu_notifier(MemoryRegion *mr, - IOMMUNotifier *n); + IOMMUMRNotifier *n); =20 /** * memory_region_iommu_replay: replay existing IOMMU translations to @@ -728,7 +728,7 @@ void memory_region_register_iommu_notifier(MemoryRegion= *mr, * @is_write: Whether to treat the replay as a translate "write" * through the iommu */ -void memory_region_iommu_replay(MemoryRegion *mr, IOMMUNotifier *n, +void memory_region_iommu_replay(MemoryRegion *mr, IOMMUMRNotifier *n, bool is_write); =20 /** @@ -748,7 +748,7 @@ void memory_region_iommu_replay_all(MemoryRegion *mr); * @n: the notifier to be removed. */ void memory_region_unregister_iommu_notifier(MemoryRegion *mr, - IOMMUNotifier *n); + IOMMUMRNotifier *n); =20 /** * memory_region_name: get a memory region's name diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index 3e51876..f9ac0ec 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -63,7 +63,7 @@ typedef union VTD_IR_TableEntry VTD_IR_TableEntry; typedef union VTD_IR_MSIAddress VTD_IR_MSIAddress; typedef struct VTDIrq VTDIrq; typedef struct VTD_MSIMessage VTD_MSIMessage; -typedef struct IntelIOMMUNotifierNode IntelIOMMUNotifierNode; +typedef struct IntelIOMMUMRNotifierNode IntelIOMMUMRNotifierNode; =20 /* Context-Entry */ struct VTDContextEntry { @@ -250,9 +250,9 @@ struct VTD_MSIMessage { /* When IR is enabled, all MSI/MSI-X data bits should be zero */ #define VTD_IR_MSI_DATA (0) =20 -struct IntelIOMMUNotifierNode { +struct IntelIOMMUMRNotifierNode { VTDAddressSpace *vtd_as; - QLIST_ENTRY(IntelIOMMUNotifierNode) next; + QLIST_ENTRY(IntelIOMMUMRNotifierNode) next; }; =20 /* The iommu (DMAR) device state struct */ @@ -293,7 +293,7 @@ struct IntelIOMMUState { GHashTable *vtd_as_by_busptr; /* VTDBus objects indexed by PCIBus* r= eference */ VTDBus *vtd_as_by_bus_num[VTD_PCI_BUS_MAX]; /* VTDBus objects indexed = by bus number */ /* list of registered notifiers */ - QLIST_HEAD(, IntelIOMMUNotifierNode) notifiers_list; + QLIST_HEAD(, IntelIOMMUMRNotifierNode) notifiers_list; =20 /* interrupt remapping */ bool intr_enabled; /* Whether guest enabled IR */ diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index c582de1..348d408 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -96,7 +96,7 @@ typedef struct VFIOGuestIOMMU { VFIOContainer *container; MemoryRegion *iommu; hwaddr iommu_offset; - IOMMUNotifier n; + IOMMUMRNotifier n; QLIST_ENTRY(VFIOGuestIOMMU) giommu_next; } VFIOGuestIOMMU; =20 diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index a450321..091cfad 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -42,7 +42,7 @@ struct vhost_iommu { struct vhost_dev *hdev; MemoryRegion *mr; hwaddr iommu_offset; - IOMMUNotifier n; + IOMMUMRNotifier n; QLIST_ENTRY(vhost_iommu) iommu_next; }; =20 @@ -75,7 +75,7 @@ struct vhost_dev { struct vhost_log *log; QLIST_ENTRY(vhost_dev) entry; QLIST_HEAD(, vhost_iommu) iommu_list; - IOMMUNotifier n; + IOMMUMRNotifier n; }; =20 int vhost_dev_init(struct vhost_dev *hdev, void *opaque, diff --git a/memory.c b/memory.c index 6237631..ffbd020 100644 --- a/memory.c +++ b/memory.c @@ -1581,7 +1581,7 @@ bool memory_region_is_logging(MemoryRegion *mr, uint8= _t client) static void memory_region_update_iommu_notify_flags(MemoryRegion *mr) { IOMMUMREventFlags flags =3D IOMMU_MR_EVENT_NONE; - IOMMUNotifier *iommu_notifier; + IOMMUMRNotifier *iommu_notifier; =20 IOMMU_NOTIFIER_FOREACH(iommu_notifier, mr) { flags |=3D iommu_notifier->notifier_flags; @@ -1597,7 +1597,7 @@ static void memory_region_update_iommu_notify_flags(M= emoryRegion *mr) } =20 void memory_region_register_iommu_notifier(MemoryRegion *mr, - IOMMUNotifier *n) + IOMMUMRNotifier *n) { if (mr->alias) { memory_region_register_iommu_notifier(mr->alias, n); @@ -1620,7 +1620,7 @@ uint64_t memory_region_iommu_get_min_page_size(Memory= Region *mr) return TARGET_PAGE_SIZE; } =20 -void memory_region_iommu_replay(MemoryRegion *mr, IOMMUNotifier *n, +void memory_region_iommu_replay(MemoryRegion *mr, IOMMUMRNotifier *n, bool is_write) { hwaddr addr, granularity; @@ -1650,7 +1650,7 @@ void memory_region_iommu_replay(MemoryRegion *mr, IOM= MUNotifier *n, =20 void memory_region_iommu_replay_all(MemoryRegion *mr) { - IOMMUNotifier *notifier; + IOMMUMRNotifier *notifier; =20 IOMMU_NOTIFIER_FOREACH(notifier, mr) { memory_region_iommu_replay(mr, notifier, false); @@ -1658,7 +1658,7 @@ void memory_region_iommu_replay_all(MemoryRegion *mr) } =20 void memory_region_unregister_iommu_notifier(MemoryRegion *mr, - IOMMUNotifier *n) + IOMMUMRNotifier *n) { if (mr->alias) { memory_region_unregister_iommu_notifier(mr->alias, n); @@ -1668,7 +1668,7 @@ void memory_region_unregister_iommu_notifier(MemoryRe= gion *mr, memory_region_update_iommu_notify_flags(mr); } =20 -void memory_region_notify_one(IOMMUNotifier *notifier, +void memory_region_notify_one(IOMMUMRNotifier *notifier, IOMMUTLBEntry *entry) { IOMMUMREventFlags request_flags; @@ -1696,7 +1696,7 @@ void memory_region_notify_one(IOMMUNotifier *notifier, void memory_region_notify_iommu(MemoryRegion *mr, IOMMUTLBEntry entry) { - IOMMUNotifier *iommu_notifier; + IOMMUMRNotifier *iommu_notifier; =20 assert(memory_region_is_iommu(mr)); =20 --=20 2.7.4 From nobody Tue May 7 14:53:17 2024 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 1493285800100349.60851941119074; Thu, 27 Apr 2017 02:36:40 -0700 (PDT) Received: from localhost ([::1]:59630 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3fqo-0004SS-E3 for importer@patchew.org; Thu, 27 Apr 2017 05:36:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47367) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3fpI-0003Pv-Ml for qemu-devel@nongnu.org; Thu, 27 Apr 2017 05:35:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3fpH-00040D-Mk for qemu-devel@nongnu.org; Thu, 27 Apr 2017 05:35:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60564) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3fpH-0003zc-DW for qemu-devel@nongnu.org; Thu, 27 Apr 2017 05:35:03 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 59E729D409; Thu, 27 Apr 2017 09:35:02 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-8-65.pek2.redhat.com [10.72.8.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id DBA7577E37; Thu, 27 Apr 2017 09:34:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 59E729D409 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 59E729D409 From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 27 Apr 2017 17:34:15 +0800 Message-Id: <1493285660-4470-4-git-send-email-peterx@redhat.com> In-Reply-To: <1493285660-4470-1-git-send-email-peterx@redhat.com> References: <1493285660-4470-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 27 Apr 2017 09:35:02 +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] [RFC PATCH 3/8] memory: rename iommu_notifier_init() 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, yi.l.liu@intel.com, Jason Wang , peterx@redhat.com, Alex Williamson , Paolo Bonzini , 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" It's new name is iommu_mr_notifier_init(). Again, literal changes only. Signed-off-by: Peter Xu --- hw/vfio/common.c | 8 ++++---- hw/virtio/vhost.c | 8 ++++---- include/exec/memory.h | 7 ++++--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index bd113b7..6b3953b 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -481,10 +481,10 @@ static void vfio_listener_region_add(MemoryListener *= listener, llend =3D int128_add(int128_make64(section->offset_within_region), section->size); llend =3D int128_sub(llend, int128_one()); - iommu_notifier_init(&giommu->n, vfio_iommu_map_notify, - IOMMU_MR_EVENT_ALL, - section->offset_within_region, - int128_get64(llend)); + iommu_mr_notifier_init(&giommu->n, vfio_iommu_map_notify, + IOMMU_MR_EVENT_ALL, + section->offset_within_region, + int128_get64(llend)); QLIST_INSERT_HEAD(&container->giommu_list, giommu, giommu_next); =20 memory_region_register_iommu_notifier(giommu->iommu, &giommu->n); diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 81a8aea..7449cf8 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -746,10 +746,10 @@ static void vhost_iommu_region_add(MemoryListener *li= stener, end =3D int128_add(int128_make64(section->offset_within_region), section->size); end =3D int128_sub(end, int128_one()); - iommu_notifier_init(&iommu->n, vhost_iommu_unmap_notify, - IOMMU_MR_EVENT_UNMAP, - section->offset_within_region, - int128_get64(end)); + iommu_mr_notifier_init(&iommu->n, vhost_iommu_unmap_notify, + IOMMU_MR_EVENT_UNMAP, + section->offset_within_region, + int128_get64(end)); iommu->mr =3D section->mr; iommu->iommu_offset =3D section->offset_within_address_space - section->offset_within_region; diff --git a/include/exec/memory.h b/include/exec/memory.h index 6be0c02..8d8dcb2 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -93,9 +93,10 @@ struct IOMMUMRNotifier { }; typedef struct IOMMUMRNotifier IOMMUMRNotifier; =20 -static inline void iommu_notifier_init(IOMMUMRNotifier *n, IOMMUNotify fn, - IOMMUMREventFlags flags, - hwaddr start, hwaddr end) +static inline void iommu_mr_notifier_init(IOMMUMRNotifier *n, + IOMMUNotify fn, + IOMMUMREventFlags flags, + hwaddr start, hwaddr end) { n->notify =3D fn; n->notifier_flags =3D flags; --=20 2.7.4 From nobody Tue May 7 14:53:17 2024 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 1493285921716905.0398468291021; Thu, 27 Apr 2017 02:38:41 -0700 (PDT) Received: from localhost ([::1]:59637 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3fsl-0006AU-C3 for importer@patchew.org; Thu, 27 Apr 2017 05:38:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3fpX-0003fu-UW for qemu-devel@nongnu.org; Thu, 27 Apr 2017 05:35:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3fpT-00049t-0g for qemu-devel@nongnu.org; Thu, 27 Apr 2017 05:35:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46018) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3fpS-00049J-Nm for qemu-devel@nongnu.org; Thu, 27 Apr 2017 05:35:14 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9DF7B7D0E2; Thu, 27 Apr 2017 09:35:13 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-8-65.pek2.redhat.com [10.72.8.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 033B677E37; Thu, 27 Apr 2017 09:35:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9DF7B7D0E2 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9DF7B7D0E2 From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 27 Apr 2017 17:34:16 +0800 Message-Id: <1493285660-4470-5-git-send-email-peterx@redhat.com> In-Reply-To: <1493285660-4470-1-git-send-email-peterx@redhat.com> References: <1493285660-4470-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 27 Apr 2017 09:35:13 +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] [RFC PATCH 4/8] memory: rename *_notify_iommu* 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, yi.l.liu@intel.com, Jason Wang , peterx@redhat.com, Alex Williamson , Paolo Bonzini , 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" Actually it's notifying IOTLB updates (map, or unmap). Let's be explicit on the wording - replacing it with *_notify_iotlb*. Signed-off-by: Peter Xu --- hw/i386/intel_iommu.c | 8 ++++---- hw/ppc/spapr_iommu.c | 2 +- hw/s390x/s390-pci-inst.c | 2 +- include/exec/memory.h | 12 ++++++------ memory.c | 8 ++++---- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 3306e6a..609732b 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -1205,7 +1205,7 @@ static void vtd_iotlb_domain_invalidate(IntelIOMMUSta= te *s, uint16_t domain_id) static int vtd_page_invalidate_notify_hook(IOMMUTLBEntry *entry, void *private) { - memory_region_notify_iommu((MemoryRegion *)private, *entry); + memory_region_notify_iotlb((MemoryRegion *)private, *entry); return 0; } =20 @@ -1709,7 +1709,7 @@ static bool vtd_process_device_iotlb_desc(IntelIOMMUS= tate *s, entry.iova =3D addr; entry.perm =3D IOMMU_NONE; entry.translated_addr =3D 0; - memory_region_notify_iommu(&vtd_dev_as->iommu, entry); + memory_region_notify_iotlb(&vtd_dev_as->iommu, entry); =20 done: return true; @@ -2752,7 +2752,7 @@ static void vtd_address_space_unmap(VTDAddressSpace *= as, IOMMUMRNotifier *n) VTD_PCI_FUNC(as->devfn), entry.iova, size); =20 - memory_region_notify_one(n, &entry); + memory_region_notify_iotlb_one(n, &entry); } =20 static void vtd_address_space_unmap_all(IntelIOMMUState *s) @@ -2771,7 +2771,7 @@ static void vtd_address_space_unmap_all(IntelIOMMUSta= te *s) =20 static int vtd_replay_hook(IOMMUTLBEntry *entry, void *private) { - memory_region_notify_one((IOMMUMRNotifier *)private, entry); + memory_region_notify_iotlb_one((IOMMUMRNotifier *)private, entry); return 0; } =20 diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c index 5e6e70b..9a34495 100644 --- a/hw/ppc/spapr_iommu.c +++ b/hw/ppc/spapr_iommu.c @@ -414,7 +414,7 @@ static target_ulong put_tce_emu(sPAPRTCETable *tcet, ta= rget_ulong ioba, entry.translated_addr =3D tce & page_mask; entry.addr_mask =3D ~page_mask; entry.perm =3D spapr_tce_iommu_access_flags(tce); - memory_region_notify_iommu(&tcet->iommu, entry); + memory_region_notify_iotlb(&tcet->iommu, entry); =20 return H_SUCCESS; } diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index 314a9cb..566eeda 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -635,7 +635,7 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_= t r2) goto out; } =20 - memory_region_notify_iommu(mr, entry); + memory_region_notify_iotlb(mr, entry); start +=3D entry.addr_mask + 1; } =20 diff --git a/include/exec/memory.h b/include/exec/memory.h index 8d8dcb2..09188a6 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -673,7 +673,7 @@ static inline bool memory_region_is_iommu(MemoryRegion = *mr) uint64_t memory_region_iommu_get_min_page_size(MemoryRegion *mr); =20 /** - * memory_region_notify_iommu: notify a change in an IOMMU translation ent= ry. + * memory_region_notify_iotlb: notify a change in an IOMMU translation ent= ry. * * The notification type will be decided by entry.perm bits: * @@ -689,12 +689,12 @@ uint64_t memory_region_iommu_get_min_page_size(Memory= Region *mr); * replaces all old entries for the same virtual I/O address range. * Deleted entries have .@perm =3D=3D 0. */ -void memory_region_notify_iommu(MemoryRegion *mr, +void memory_region_notify_iotlb(MemoryRegion *mr, IOMMUTLBEntry entry); =20 /** - * memory_region_notify_one: notify a change in an IOMMU translation - * entry to a single notifier + * memory_region_notify_iotlb_one: notify a change in an IOMMU translation + * entry to a single notifier * * This works just like memory_region_notify_iommu(), but it only * notifies a specific notifier, not all of them. @@ -704,8 +704,8 @@ void memory_region_notify_iommu(MemoryRegion *mr, * replaces all old entries for the same virtual I/O address range. * Deleted entries have .@perm =3D=3D 0. */ -void memory_region_notify_one(IOMMUMRNotifier *notifier, - IOMMUTLBEntry *entry); +void memory_region_notify_iotlb_one(IOMMUMRNotifier *notifier, + IOMMUTLBEntry *entry); =20 /** * memory_region_register_iommu_notifier: register a notifier for changes = to diff --git a/memory.c b/memory.c index ffbd020..c6532e4 100644 --- a/memory.c +++ b/memory.c @@ -1668,8 +1668,8 @@ void memory_region_unregister_iommu_notifier(MemoryRe= gion *mr, memory_region_update_iommu_notify_flags(mr); } =20 -void memory_region_notify_one(IOMMUMRNotifier *notifier, - IOMMUTLBEntry *entry) +void memory_region_notify_iotlb_one(IOMMUMRNotifier *notifier, + IOMMUTLBEntry *entry) { IOMMUMREventFlags request_flags; =20 @@ -1693,7 +1693,7 @@ void memory_region_notify_one(IOMMUMRNotifier *notifi= er, } } =20 -void memory_region_notify_iommu(MemoryRegion *mr, +void memory_region_notify_iotlb(MemoryRegion *mr, IOMMUTLBEntry entry) { IOMMUMRNotifier *iommu_notifier; @@ -1701,7 +1701,7 @@ void memory_region_notify_iommu(MemoryRegion *mr, assert(memory_region_is_iommu(mr)); =20 IOMMU_NOTIFIER_FOREACH(iommu_notifier, mr) { - memory_region_notify_one(iommu_notifier, &entry); + memory_region_notify_iotlb_one(iommu_notifier, &entry); } } =20 --=20 2.7.4 From nobody Tue May 7 14:53:17 2024 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 149328615038740.89531036759024; Thu, 27 Apr 2017 02:42:30 -0700 (PDT) Received: from localhost ([::1]:59661 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3fwR-0001Kl-SI for importer@patchew.org; Thu, 27 Apr 2017 05:42:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47513) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3fpq-0003uh-Gi for qemu-devel@nongnu.org; Thu, 27 Apr 2017 05:35:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3fpl-0004JS-IM for qemu-devel@nongnu.org; Thu, 27 Apr 2017 05:35:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52190) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3fpl-0004Iw-9A for qemu-devel@nongnu.org; Thu, 27 Apr 2017 05:35:33 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2546146D08D; Thu, 27 Apr 2017 09:35:32 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-8-65.pek2.redhat.com [10.72.8.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 367987F8C6; Thu, 27 Apr 2017 09:35:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2546146D08D Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2546146D08D From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 27 Apr 2017 17:34:17 +0800 Message-Id: <1493285660-4470-6-git-send-email-peterx@redhat.com> In-Reply-To: <1493285660-4470-1-git-send-email-peterx@redhat.com> References: <1493285660-4470-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 27 Apr 2017 09:35:32 +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] [RFC PATCH 5/8] memory: rename *iommu_notifier* 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, yi.l.liu@intel.com, Jason Wang , peterx@redhat.com, Alex Williamson , Paolo Bonzini , 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" Renaming *iommu_notifiers* into *iotlb_notifiers*. Again, let's reserve the iommu_notifier keyword to the notifiers that will be for per-iommu, and let the old per-mr notifier be iotlb_notifiers. Signed-off-by: Peter Xu --- hw/vfio/common.c | 6 +++--- hw/virtio/vhost.c | 4 ++-- include/exec/memory.h | 8 ++++---- memory.c | 20 ++++++++++---------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 6b3953b..7b639ea 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -487,7 +487,7 @@ static void vfio_listener_region_add(MemoryListener *li= stener, int128_get64(llend)); QLIST_INSERT_HEAD(&container->giommu_list, giommu, giommu_next); =20 - memory_region_register_iommu_notifier(giommu->iommu, &giommu->n); + memory_region_register_iotlb_notifier(giommu->iommu, &giommu->n); memory_region_iommu_replay(giommu->iommu, &giommu->n, false); =20 return; @@ -557,7 +557,7 @@ static void vfio_listener_region_del(MemoryListener *li= stener, QLIST_FOREACH(giommu, &container->giommu_list, giommu_next) { if (giommu->iommu =3D=3D section->mr && giommu->n.start =3D=3D section->offset_within_region) { - memory_region_unregister_iommu_notifier(giommu->iommu, + memory_region_unregister_iotlb_notifier(giommu->iommu, &giommu->n); QLIST_REMOVE(giommu, giommu_next); g_free(giommu); @@ -1147,7 +1147,7 @@ static void vfio_disconnect_container(VFIOGroup *grou= p) QLIST_REMOVE(container, next); =20 QLIST_FOREACH_SAFE(giommu, &container->giommu_list, giommu_next, t= mp) { - memory_region_unregister_iommu_notifier(giommu->iommu, &giommu= ->n); + memory_region_unregister_iotlb_notifier(giommu->iommu, &giommu= ->n); QLIST_REMOVE(giommu, giommu_next); g_free(giommu); } diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 7449cf8..a1e03ed 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -754,7 +754,7 @@ static void vhost_iommu_region_add(MemoryListener *list= ener, iommu->iommu_offset =3D section->offset_within_address_space - section->offset_within_region; iommu->hdev =3D dev; - memory_region_register_iommu_notifier(section->mr, &iommu->n); + memory_region_register_iotlb_notifier(section->mr, &iommu->n); QLIST_INSERT_HEAD(&dev->iommu_list, iommu, iommu_next); /* TODO: can replay help performance here? */ } @@ -773,7 +773,7 @@ static void vhost_iommu_region_del(MemoryListener *list= ener, QLIST_FOREACH(iommu, &dev->iommu_list, iommu_next) { if (iommu->mr =3D=3D section->mr && iommu->n.start =3D=3D section->offset_within_region) { - memory_region_unregister_iommu_notifier(iommu->mr, + memory_region_unregister_iotlb_notifier(iommu->mr, &iommu->n); QLIST_REMOVE(iommu, iommu_next); g_free(iommu); diff --git a/include/exec/memory.h b/include/exec/memory.h index 09188a6..e5707b3 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -708,7 +708,7 @@ void memory_region_notify_iotlb_one(IOMMUMRNotifier *no= tifier, IOMMUTLBEntry *entry); =20 /** - * memory_region_register_iommu_notifier: register a notifier for changes = to + * memory_region_register_iotlb_notifier: register a notifier for changes = to * IOMMU translation entries. * * @mr: the memory region to observe @@ -716,7 +716,7 @@ void memory_region_notify_iotlb_one(IOMMUMRNotifier *no= tifier, * pointer to an #IOMMUTLBEntry as the opaque value; the pointer * ceases to be valid on exit from the notifier. */ -void memory_region_register_iommu_notifier(MemoryRegion *mr, +void memory_region_register_iotlb_notifier(MemoryRegion *mr, IOMMUMRNotifier *n); =20 /** @@ -741,14 +741,14 @@ void memory_region_iommu_replay(MemoryRegion *mr, IOM= MUMRNotifier *n, void memory_region_iommu_replay_all(MemoryRegion *mr); =20 /** - * memory_region_unregister_iommu_notifier: unregister a notifier for + * memory_region_unregister_iotlb_notifier: unregister a notifier for * changes to IOMMU translation entries. * * @mr: the memory region which was observed and for which notity_stopped() * needs to be called * @n: the notifier to be removed. */ -void memory_region_unregister_iommu_notifier(MemoryRegion *mr, +void memory_region_unregister_iotlb_notifier(MemoryRegion *mr, IOMMUMRNotifier *n); =20 /** diff --git a/memory.c b/memory.c index c6532e4..6af523e 100644 --- a/memory.c +++ b/memory.c @@ -1581,10 +1581,10 @@ bool memory_region_is_logging(MemoryRegion *mr, uin= t8_t client) static void memory_region_update_iommu_notify_flags(MemoryRegion *mr) { IOMMUMREventFlags flags =3D IOMMU_MR_EVENT_NONE; - IOMMUMRNotifier *iommu_notifier; + IOMMUMRNotifier *iotlb_notifier; =20 - IOMMU_NOTIFIER_FOREACH(iommu_notifier, mr) { - flags |=3D iommu_notifier->notifier_flags; + IOMMU_NOTIFIER_FOREACH(iotlb_notifier, mr) { + flags |=3D iotlb_notifier->notifier_flags; } =20 if (flags !=3D mr->iommu_notify_flags && @@ -1596,11 +1596,11 @@ static void memory_region_update_iommu_notify_flags= (MemoryRegion *mr) mr->iommu_notify_flags =3D flags; } =20 -void memory_region_register_iommu_notifier(MemoryRegion *mr, +void memory_region_register_iotlb_notifier(MemoryRegion *mr, IOMMUMRNotifier *n) { if (mr->alias) { - memory_region_register_iommu_notifier(mr->alias, n); + memory_region_register_iotlb_notifier(mr->alias, n); return; } =20 @@ -1657,11 +1657,11 @@ void memory_region_iommu_replay_all(MemoryRegion *m= r) } } =20 -void memory_region_unregister_iommu_notifier(MemoryRegion *mr, +void memory_region_unregister_iotlb_notifier(MemoryRegion *mr, IOMMUMRNotifier *n) { if (mr->alias) { - memory_region_unregister_iommu_notifier(mr->alias, n); + memory_region_unregister_iotlb_notifier(mr->alias, n); return; } QLIST_REMOVE(n, node); @@ -1696,12 +1696,12 @@ void memory_region_notify_iotlb_one(IOMMUMRNotifier= *notifier, void memory_region_notify_iotlb(MemoryRegion *mr, IOMMUTLBEntry entry) { - IOMMUMRNotifier *iommu_notifier; + IOMMUMRNotifier *iotlb_notifier; =20 assert(memory_region_is_iommu(mr)); =20 - IOMMU_NOTIFIER_FOREACH(iommu_notifier, mr) { - memory_region_notify_iotlb_one(iommu_notifier, &entry); + IOMMU_NOTIFIER_FOREACH(iotlb_notifier, mr) { + memory_region_notify_iotlb_one(iotlb_notifier, &entry); } } =20 --=20 2.7.4 From nobody Tue May 7 14:53:17 2024 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 1493286019982792.8650180885876; Thu, 27 Apr 2017 02:40:19 -0700 (PDT) Received: from localhost ([::1]:59646 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3fuM-0007fm-DG for importer@patchew.org; Thu, 27 Apr 2017 05:40:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47558) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3fpt-0003x3-CN for qemu-devel@nongnu.org; Thu, 27 Apr 2017 05:35:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3fps-0004Np-44 for qemu-devel@nongnu.org; Thu, 27 Apr 2017 05:35:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42780) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3fpr-0004MV-Rl for qemu-devel@nongnu.org; Thu, 27 Apr 2017 05:35:40 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BAE6B3DBE8; Thu, 27 Apr 2017 09:35:38 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-8-65.pek2.redhat.com [10.72.8.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDF1F17180; Thu, 27 Apr 2017 09:35:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BAE6B3DBE8 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 BAE6B3DBE8 From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 27 Apr 2017 17:34:18 +0800 Message-Id: <1493285660-4470-7-git-send-email-peterx@redhat.com> In-Reply-To: <1493285660-4470-1-git-send-email-peterx@redhat.com> References: <1493285660-4470-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 27 Apr 2017 09:35:38 +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] [RFC PATCH 6/8] memory: introduce AddressSpaceOps 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, yi.l.liu@intel.com, Jason Wang , peterx@redhat.com, Alex Williamson , Paolo Bonzini , 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" This is something similar to MemoryRegionOps, it's just for address spaces to store arch-specific hooks. The first hook I would like to introduce is iommu_get(). For systems that have IOMMUs, we will create a special address space per device which is different from system default address space for it (please refer to pci_device_iommu_address_space()). Normally when that happens, there will be one specific IOMMU (or say, translation unit) stands right behind that new address space. This iommu_get() fetches that guy behind the address space. Here, the guy is defined as IOMMUObject, which is currently a (void *). In the future, maybe we can make it a better definition, but imho it's good enough for now, considering it's arch-dependent. Signed-off-by: Peter Xu --- include/exec/memory.h | 30 ++++++++++++++++++++++++++++++ memory.c | 8 ++++++++ 2 files changed, 38 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index e5707b3..0b0b58b 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -183,6 +183,15 @@ struct MemoryRegionOps { const MemoryRegionMmio old_mmio; }; =20 +/* + * This stands for an IOMMU unit. Normally it should be exactly the + * IOMMU device, however this can also be actually anything which is + * related to that translation unit. What it is should be totally + * arch-dependent. Maybe one day we can have something better than a + * (void *) here. + */ +typedef void *IOMMUObject; + typedef struct MemoryRegionIOMMUOps MemoryRegionIOMMUOps; =20 struct MemoryRegionIOMMUOps { @@ -282,6 +291,19 @@ struct MemoryListener { }; =20 /** + * AddressSpaceOps: callbacks structure for address space specific operati= ons + * + * @iommu_get: returns an IOMMU object that backs the address space. + * Normally this should be NULL for generic address + * spaces, and it's only used when there is one + * translation unit behind this address space. + */ +struct AddressSpaceOps { + IOMMUObject *(*iommu_get)(AddressSpace *as); +}; +typedef struct AddressSpaceOps AddressSpaceOps; + +/** * AddressSpace: describes a mapping of addresses to #MemoryRegion objects */ struct AddressSpace { @@ -302,6 +324,7 @@ struct AddressSpace { MemoryListener dispatch_listener; QTAILQ_HEAD(memory_listeners_as, MemoryListener) listeners; QTAILQ_ENTRY(AddressSpace) address_spaces_link; + AddressSpaceOps as_ops; }; =20 /** @@ -1800,6 +1823,13 @@ address_space_write_cached(MemoryRegionCache *cache,= hwaddr addr, address_space_write(cache->as, cache->xlat + addr, MEMTXATTRS_UNSPECIF= IED, buf, len); } =20 +/** + * address_space_iommu_get: Get the backend IOMMU for the address space + * + * @as: the address space to fetch IOMMU from + */ +IOMMUObject *address_space_iommu_get(AddressSpace *as); + #endif =20 #endif diff --git a/memory.c b/memory.c index 6af523e..6aaad45 100644 --- a/memory.c +++ b/memory.c @@ -2500,6 +2500,14 @@ void address_space_destroy(AddressSpace *as) call_rcu(as, do_address_space_destroy, rcu); } =20 +IOMMUObject *address_space_iommu_get(AddressSpace *as) +{ + if (!as->as_ops.iommu_get) { + return NULL; + } + return as->as_ops.iommu_get(as); +} + static const char *memory_region_type(MemoryRegion *mr) { if (memory_region_is_ram_device(mr)) { --=20 2.7.4 From nobody Tue May 7 14:53:17 2024 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 1493286044977339.83502303603984; Thu, 27 Apr 2017 02:40:44 -0700 (PDT) Received: from localhost ([::1]:59652 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3ful-00085y-MO for importer@patchew.org; Thu, 27 Apr 2017 05:40:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3fq2-00043p-JN for qemu-devel@nongnu.org; Thu, 27 Apr 2017 05:35:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3fpy-0004Tg-K7 for qemu-devel@nongnu.org; Thu, 27 Apr 2017 05:35:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35912) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3fpy-0004TC-EK for qemu-devel@nongnu.org; Thu, 27 Apr 2017 05:35:46 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4848880F95; Thu, 27 Apr 2017 09:35:45 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-8-65.pek2.redhat.com [10.72.8.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D14617180; Thu, 27 Apr 2017 09:35:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4848880F95 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4848880F95 From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 27 Apr 2017 17:34:19 +0800 Message-Id: <1493285660-4470-8-git-send-email-peterx@redhat.com> In-Reply-To: <1493285660-4470-1-git-send-email-peterx@redhat.com> References: <1493285660-4470-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 27 Apr 2017 09:35:45 +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] [RFC PATCH 7/8] intel_iommu: provide AddressSpaceOps.iommu_get() 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, yi.l.liu@intel.com, Jason Wang , peterx@redhat.com, Alex Williamson , Paolo Bonzini , 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" Then it'll be the first one to support address_space_iommu_get() API. Signed-off-by: Peter Xu --- hw/i386/intel_iommu.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 609732b..5131329 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2632,6 +2632,12 @@ static const MemoryRegionOps vtd_mem_ir_ops =3D { }, }; =20 +static IOMMUObject *vtd_as_iommu_get(AddressSpace *as) +{ + VTDAddressSpace *vtd_dev_as =3D container_of(as, VTDAddressSpace, as); + return (IOMMUObject *)vtd_dev_as->iommu_state; +} + VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devf= n) { uintptr_t key =3D (uintptr_t)bus; @@ -2692,6 +2698,9 @@ VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, = PCIBus *bus, int devfn) VTD_INTERRUPT_ADDR_FIRST, &vtd_dev_as->iommu_ir, 64); address_space_init(&vtd_dev_as->as, &vtd_dev_as->root, name); + + vtd_dev_as->as.as_ops.iommu_get =3D vtd_as_iommu_get; + memory_region_add_subregion_overlap(&vtd_dev_as->root, 0, &vtd_dev_as->sys_alias, 1); memory_region_add_subregion_overlap(&vtd_dev_as->root, 0, --=20 2.7.4 From nobody Tue May 7 14:53:17 2024 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 149328589900625.21324356641435; Thu, 27 Apr 2017 02:38:19 -0700 (PDT) Received: from localhost ([::1]:59635 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3fsP-0005qn-9l for importer@patchew.org; Thu, 27 Apr 2017 05:38:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47695) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3fq7-00047h-6A for qemu-devel@nongnu.org; Thu, 27 Apr 2017 05:35:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3fq5-0004YQ-3s for qemu-devel@nongnu.org; Thu, 27 Apr 2017 05:35:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36036) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3fq4-0004Xe-Qa for qemu-devel@nongnu.org; Thu, 27 Apr 2017 05:35:53 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BAB1080503; Thu, 27 Apr 2017 09:35:51 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-8-65.pek2.redhat.com [10.72.8.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDD4C1724B; Thu, 27 Apr 2017 09:35:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BAB1080503 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=peterx@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BAB1080503 From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 27 Apr 2017 17:34:20 +0800 Message-Id: <1493285660-4470-9-git-send-email-peterx@redhat.com> In-Reply-To: <1493285660-4470-1-git-send-email-peterx@redhat.com> References: <1493285660-4470-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 27 Apr 2017 09:35:51 +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] [RFC PATCH 8/8] iommu: introduce hw/core/iommu 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, yi.l.liu@intel.com, Jason Wang , peterx@redhat.com, Alex Williamson , Paolo Bonzini , 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" Time to consider a common stuff for IOMMU. Let's start from an common IOMMU object (which should be inlayed in custom IOMMU implementations) and a notifier mechanism. Let VT-d IOMMU be the first user. An example to use this per-iommu notifier: (when registering) iommu =3D address_space_iommu_get(pci_device_iommu_address_space(dev)); notifier =3D iommu_notifier_register(iommu, IOMMU_EVENT_SVM_PASID, func); ... (when notify) IOMMUEvent event =3D { .type =3D IOMMU_EVENT_SVM_PASID ... }; iommu_notify(iommu, &event); ... (when releasing) iommu_notifier_unregister(notifier); notifier =3D NULL; Signed-off-by: Peter Xu --- hw/core/Makefile.objs | 1 + hw/core/iommu.c | 61 ++++++++++++++++++++++++++++++++++++ hw/i386/intel_iommu.c | 2 +- include/exec/memory.h | 10 +----- include/hw/core/iommu.h | 72 +++++++++++++++++++++++++++++++++++++++= ++++ include/hw/i386/intel_iommu.h | 2 ++ 6 files changed, 138 insertions(+), 10 deletions(-) create mode 100644 hw/core/iommu.c create mode 100644 include/hw/core/iommu.h diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs index 91450b2..85cca44 100644 --- a/hw/core/Makefile.objs +++ b/hw/core/Makefile.objs @@ -5,6 +5,7 @@ common-obj-y +=3D fw-path-provider.o # irq.o needed for qdev GPIO handling: common-obj-y +=3D irq.o common-obj-y +=3D hotplug.o +common-obj-y +=3D iommu.o obj-y +=3D nmi.o =20 common-obj-$(CONFIG_EMPTY_SLOT) +=3D empty_slot.o diff --git a/hw/core/iommu.c b/hw/core/iommu.c new file mode 100644 index 0000000..e014e96 --- /dev/null +++ b/hw/core/iommu.c @@ -0,0 +1,61 @@ +/* + * QEMU emulation of IOMMU logic + * + * Copyright (C) 2017 Red Hat Inc. + * + * Authors: Peter Xu , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#include "qemu/osdep.h" +#include "hw/core/iommu.h" + +IOMMUNotifier *iommu_notifier_register(IOMMUObject *iommu, + IOMMUNotifyFn fn, + uint64_t event_mask) +{ + IOMMUNotifier *notifier =3D g_new0(IOMMUNotifier, 1); + + assert((event_mask & ~IOMMU_EVENT_MASK) =3D=3D 0); + notifier->event_mask =3D event_mask; + notifier->iommu_notify =3D fn; + QLIST_INSERT_HEAD(&iommu->iommu_notifiers, notifier, node); + + return notifier; +} + +void iommu_notifier_unregister(IOMMUObject *iommu, + IOMMUNotifier *notifier) +{ + IOMMUNotifier *cur, *next; + + QLIST_FOREACH_SAFE(cur, &iommu->iommu_notifiers, node, next) { + if (cur =3D=3D notifier) { + QLIST_REMOVE(cur, node); + break; + } + } +} + +void iommu_notify(IOMMUObject *iommu, IOMMUEvent *event) +{ + IOMMUNotifier *cur; + + QLIST_FOREACH(cur, &iommu->iommu_notifiers, node) { + if (cur->event_mask & event->type && cur->iommu_notify) { + cur->iommu_notify(cur, event); + } + } +} diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 5131329..d6f6701 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2635,7 +2635,7 @@ static const MemoryRegionOps vtd_mem_ir_ops =3D { static IOMMUObject *vtd_as_iommu_get(AddressSpace *as) { VTDAddressSpace *vtd_dev_as =3D container_of(as, VTDAddressSpace, as); - return (IOMMUObject *)vtd_dev_as->iommu_state; + return &vtd_dev_as->iommu_state->iommu_common; } =20 VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devf= n) diff --git a/include/exec/memory.h b/include/exec/memory.h index 0b0b58b..5ca1dd0 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -27,6 +27,7 @@ #include "qemu/notify.h" #include "qom/object.h" #include "qemu/rcu.h" +#include "hw/core/iommu.h" =20 #define RAM_ADDR_INVALID (~(ram_addr_t)0) =20 @@ -183,15 +184,6 @@ struct MemoryRegionOps { const MemoryRegionMmio old_mmio; }; =20 -/* - * This stands for an IOMMU unit. Normally it should be exactly the - * IOMMU device, however this can also be actually anything which is - * related to that translation unit. What it is should be totally - * arch-dependent. Maybe one day we can have something better than a - * (void *) here. - */ -typedef void *IOMMUObject; - typedef struct MemoryRegionIOMMUOps MemoryRegionIOMMUOps; =20 struct MemoryRegionIOMMUOps { diff --git a/include/hw/core/iommu.h b/include/hw/core/iommu.h new file mode 100644 index 0000000..16e6adf --- /dev/null +++ b/include/hw/core/iommu.h @@ -0,0 +1,72 @@ +/* + * QEMU emulation of IOMMU logic + * + * Copyright (C) 2017 Red Hat Inc. + * + * Authors: Peter Xu , + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#ifndef __PCI_IOMMU_H__ +#define __PCI_IOMMU_H__ + +#include "qemu/queue.h" + +#define IOMMU_EVENT_SVM_PASID (0) +#define IOMMU_EVENT_MASK (IOMMU_EVENT_SVM_PASID) + +struct IOMMUEvent { + uint64_t type; + union { + struct { + /* TODO: fill in correct stuff. */ + int value; + } svm; + } data; +}; +typedef struct IOMMUEvent IOMMUEvent; + +typedef struct IOMMUNotifier IOMMUNotifier; + +typedef void (*IOMMUNotifyFn)(IOMMUNotifier *notifier, IOMMUEvent *event); + +struct IOMMUNotifier { + IOMMUNotifyFn iommu_notify; + /* + * What events we are listening to. Let's allow multiple event + * registrations from beginning. + */ + uint64_t event_mask; + QLIST_ENTRY(IOMMUNotifier) node; +}; + +/* + * This stands for an IOMMU unit. Any translation device should have + * this struct inside its own structure to make sure it can leverage + * common IOMMU functionalities. + */ +struct IOMMUObject { + QLIST_HEAD(, IOMMUNotifier) iommu_notifiers; +}; +typedef struct IOMMUObject IOMMUObject; + +IOMMUNotifier *iommu_notifier_register(IOMMUObject *iommu, + IOMMUNotifyFn fn, + uint64_t event_mask); +void iommu_notifier_unregister(IOMMUObject *iommu, + IOMMUNotifier *notifier); +void iommu_notify(IOMMUObject *iommu, IOMMUEvent *event); + +#endif diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index f9ac0ec..ec696f5 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -26,6 +26,7 @@ #include "hw/i386/x86-iommu.h" #include "hw/i386/ioapic.h" #include "hw/pci/msi.h" +#include "hw/core/iommu.h" #include "hw/sysbus.h" =20 #define TYPE_INTEL_IOMMU_DEVICE "intel-iommu" @@ -258,6 +259,7 @@ struct IntelIOMMUMRNotifierNode { /* The iommu (DMAR) device state struct */ struct IntelIOMMUState { X86IOMMUState x86_iommu; + IOMMUObject iommu_common; MemoryRegion csrmem; uint8_t csr[DMAR_REG_SIZE]; /* register values */ uint8_t wmask[DMAR_REG_SIZE]; /* R/W bytes */ --=20 2.7.4