From nobody Sun Feb 8 14:35:33 2026 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.zohomail.com; dkim=fail; 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 1532378117760655.9355853877811; Mon, 23 Jul 2018 13:35:17 -0700 (PDT) Received: from localhost ([::1]:36415 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhY4-0007F7-FZ for importer@patchew.org; Mon, 23 Jul 2018 16:35:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIh-0001or-DC for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIg-00037H-0N for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:23 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:43136) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIf-00036V-O1; Mon, 23 Jul 2018 16:19:21 -0400 Received: by mail-oi0-x242.google.com with SMTP id b15-v6so3460049oib.10; Mon, 23 Jul 2018 13:19:21 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id j193-v6sm7588056oih.55.2018.07.23.13.19.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=kYJKHN5sgkbV+M8ygN86JV5MOglK+efEm7MmkuDOksI=; b=ms9GkGWm3I5SK6bLscUdg5ut+m8BeXX7OAxL2Bw/f1wIrNi32O4oSYU4ZQQj1p8crl rULmz+JCXBsVloBzhdP/fPlFkAze5rcT4ELP1rxQzoTKmiUOSJX3Hq4IovcIjrfulCFr gm68yloII4axUzFW5A7oACuZl2THR+v9fQqeI64yNg8z6GzeprimLUNIAeWODW+fMl7G BwjbHi/qDsVIy0P2soF/QRxMEZnu4gl2VGzMWYl22WoaIHObyrH4yddiQC6/kYMH4JoW BS+W0xE/LcjjiBdYwxeuEviPTecd1sI/R6+tjsKEpBmNTSA35jSodBoMjJeFSmukme1v B28g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=kYJKHN5sgkbV+M8ygN86JV5MOglK+efEm7MmkuDOksI=; b=uFW2r+DXTBKlLw1i9GBOLhB5DXCKNmX0ufMILG5duJuozCIPx7+AUQGXIU/sGMJw58 1mcEgRnAkMcK3cGznWjhX6Rzv0YrELc30eawOFI7epO1r6WDTD74c4cMSqtrKcynXG7p n9cy5MSUhrxxXFE/oroiN132wGUq7rrenAOfegmdm0/C4SCgxTXQIp52afBXX69kVDcL M7ztyru+S69U2Wm5Ki5QnGQut1tPIl/qSnktoT/GEquGeUQxT4qq5Ixz6iFTEsUg++OW iSXrh7Y+BPy10x/7RfP/UMaWNAVwpIIT7kWXTuc7JXF9XgPguV39ZVhaAxJKjYbjjYpX ADDQ== X-Gm-Message-State: AOUpUlGX+WINkpfKCoNxQJjTTa7MUKiwaOtjI2acp3pShmZjFuqCtmOm DREgmIP3pJopLl186WXpwGVvD+XocXs= X-Google-Smtp-Source: AAOMgpe6XXzVTzsk7AQqOARrabEVZQ4CE9P1RbLxuayZgHTQNtXPTRqMVlEy+6DfTrNDZtkPnDHmCA== X-Received: by 2002:aca:3507:: with SMTP id c7-v6mr345150oia.46.1532377160555; Mon, 23 Jul 2018 13:19:20 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:35 -0500 Message-Id: <20180723201748.25573-27-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::242 Subject: [Qemu-devel] [PATCH 26/99] intel-iommu: remove IntelIOMMUNotifierNode 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: qemu-stable@nongnu.org, Peter Xu , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Xu That is not really necessary. Removing that node struct and put the list entry directly into VTDAddressSpace. It simplfies the code a lot. Since at it, rename the old notifiers_list into vtd_as_with_notifiers. CC: QEMU Stable Signed-off-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit b4a4ba0d68f50f218ee3957b6638dbee32a5eeef) Signed-off-by: Michael Roth --- hw/i386/intel_iommu.c | 41 ++++++++++------------------------- include/hw/i386/intel_iommu.h | 9 ++------ 2 files changed, 13 insertions(+), 37 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index b359efd6f9..3df90457f8 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -1248,10 +1248,10 @@ static void vtd_interrupt_remap_table_setup(IntelIO= MMUState *s) =20 static void vtd_iommu_replay_all(IntelIOMMUState *s) { - IntelIOMMUNotifierNode *node; + VTDAddressSpace *vtd_as; =20 - QLIST_FOREACH(node, &s->notifiers_list, next) { - memory_region_iommu_replay_all(&node->vtd_as->iommu); + QLIST_FOREACH(vtd_as, &s->vtd_as_with_notifiers, next) { + memory_region_iommu_replay_all(&vtd_as->iommu); } } =20 @@ -1372,7 +1372,6 @@ 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; VTDContextEntry ce; VTDAddressSpace *vtd_as; =20 @@ -1381,8 +1380,7 @@ static void vtd_iotlb_domain_invalidate(IntelIOMMUSta= te *s, uint16_t domain_id) g_hash_table_foreach_remove(s->iotlb, vtd_hash_remove_by_domain, &domain_id); =20 - QLIST_FOREACH(node, &s->notifiers_list, next) { - vtd_as =3D node->vtd_as; + QLIST_FOREACH(vtd_as, &s->vtd_as_with_notifiers, next) { if (!vtd_dev_to_context_entry(s, pci_bus_num(vtd_as->bus), vtd_as->devfn, &ce) && domain_id =3D=3D VTD_CONTEXT_ENTRY_DID(ce.hi)) { @@ -1402,12 +1400,11 @@ static void vtd_iotlb_page_invalidate_notify(IntelI= OMMUState *s, uint16_t domain_id, hwaddr addr, uint8_t am) { - IntelIOMMUNotifierNode *node; + VTDAddressSpace *vtd_as; VTDContextEntry ce; int ret; =20 - QLIST_FOREACH(node, &(s->notifiers_list), next) { - VTDAddressSpace *vtd_as =3D node->vtd_as; + QLIST_FOREACH(vtd_as, &(s->vtd_as_with_notifiers), next) { ret =3D vtd_dev_to_context_entry(s, pci_bus_num(vtd_as->bus), vtd_as->devfn, &ce); if (!ret && domain_id =3D=3D VTD_CONTEXT_ENTRY_DID(ce.hi)) { @@ -2344,8 +2341,6 @@ static void vtd_iommu_notify_flag_changed(IOMMUMemory= Region *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; =20 if (!s->caching_mode && new & IOMMU_NOTIFIER_MAP) { error_report("We need to set caching-mode=3D1 for intel-iommu to e= nable " @@ -2354,21 +2349,9 @@ static void vtd_iommu_notify_flag_changed(IOMMUMemor= yRegion *iommu, } =20 if (old =3D=3D IOMMU_NOTIFIER_NONE) { - node =3D g_malloc0(sizeof(*node)); - node->vtd_as =3D vtd_as; - QLIST_INSERT_HEAD(&s->notifiers_list, node, next); - return; - } - - /* 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) { - QLIST_REMOVE(node, next); - g_free(node); - } - return; - } + QLIST_INSERT_HEAD(&s->vtd_as_with_notifiers, vtd_as, next); + } else if (new =3D=3D IOMMU_NOTIFIER_NONE) { + QLIST_REMOVE(vtd_as, next); } } =20 @@ -2838,12 +2821,10 @@ static void vtd_address_space_unmap(VTDAddressSpace= *as, IOMMUNotifier *n) =20 static void vtd_address_space_unmap_all(IntelIOMMUState *s) { - IntelIOMMUNotifierNode *node; VTDAddressSpace *vtd_as; IOMMUNotifier *n; =20 - QLIST_FOREACH(node, &s->notifiers_list, next) { - vtd_as =3D node->vtd_as; + QLIST_FOREACH(vtd_as, &s->vtd_as_with_notifiers, next) { IOMMU_NOTIFIER_FOREACH(n, &vtd_as->iommu) { vtd_address_space_unmap(vtd_as, n); } @@ -3088,7 +3069,7 @@ static void vtd_realize(DeviceState *dev, Error **err= p) return; } =20 - QLIST_INIT(&s->notifiers_list); + QLIST_INIT(&s->vtd_as_with_notifiers); memset(s->vtd_as_by_bus_num, 0, sizeof(s->vtd_as_by_bus_num)); memory_region_init_io(&s->csrmem, OBJECT(s), &vtd_mem_ops, s, "intel_iommu", DMAR_REG_SIZE); diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index 45ec8919b6..032e33bcb2 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -67,7 +67,6 @@ 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; =20 /* Context-Entry */ struct VTDContextEntry { @@ -93,6 +92,7 @@ struct VTDAddressSpace { MemoryRegion iommu_ir; /* Interrupt region: 0xfeeXXXXX */ IntelIOMMUState *iommu_state; VTDContextCacheEntry context_cache_entry; + QLIST_ENTRY(VTDAddressSpace) next; }; =20 struct VTDBus { @@ -253,11 +253,6 @@ 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 { - VTDAddressSpace *vtd_as; - QLIST_ENTRY(IntelIOMMUNotifierNode) next; -}; - /* The iommu (DMAR) device state struct */ struct IntelIOMMUState { X86IOMMUState x86_iommu; @@ -295,7 +290,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(, VTDAddressSpace) vtd_as_with_notifiers; =20 /* interrupt remapping */ bool intr_enabled; /* Whether guest enabled IR */ --=20 2.17.1