{"id":2218900,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2218900/?format=json","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.0/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260402022921.298818-6-kshk@linux.ibm.com>","date":"2026-04-02T02:29:11","name":"[05/15] s390x/pci: Move iotlb from S390PCIIOMMU to S390PCIBusDevice","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"d25d41bf04e8b3813417680f762b6641193f09fd","submitter":{"id":90249,"url":"http://patchwork.ozlabs.org/api/1.0/people/90249/?format=json","name":"Konstantin Shkolnyy","email":"kshk@linux.ibm.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260402022921.298818-6-kshk@linux.ibm.com/mbox/","series":[{"id":498419,"url":"http://patchwork.ozlabs.org/api/1.0/series/498419/?format=json","date":"2026-04-02T02:29:08","name":"s390x/pci: Implement migration for emulated devices","version":1,"mbox":"http://patchwork.ozlabs.org/series/498419/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2218900/checks/","tags":{},"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256\n header.s=pp1 header.b=WmuVyNnh;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fmQpk67zZz1yGH\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 02 Apr 2026 13:31:42 +1100 (AEDT)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1w87pG-0004Ym-Co; Wed, 01 Apr 2026 22:30:30 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <kshk@linux.ibm.com>)\n id 1w87oq-0004DW-Tt; Wed, 01 Apr 2026 22:30:05 -0400","from mx0a-001b2d01.pphosted.com ([148.163.156.1])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <kshk@linux.ibm.com>)\n id 1w87oo-0001ki-3S; Wed, 01 Apr 2026 22:30:04 -0400","from pps.filterd (m0356517.ppops.net [127.0.0.1])\n by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 631HE4Tl2879954; Thu, 2 Apr 2026 02:29:57 GMT","from ppma21.wdc07v.mail.ibm.com\n (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91])\n by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d66q3axxq-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n Thu, 02 Apr 2026 02:29:57 +0000 (GMT)","from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1])\n by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id\n 6320GNVr022271;\n Thu, 2 Apr 2026 02:29:56 GMT","from smtprelay04.wdc07v.mail.ibm.com ([172.16.1.71])\n by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4d6tan8a7r-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n Thu, 02 Apr 2026 02:29:56 +0000","from smtpav06.wdc07v.mail.ibm.com (smtpav06.wdc07v.mail.ibm.com\n [10.39.53.233])\n by smtprelay04.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n 6322Ttd854985014\n (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n Thu, 2 Apr 2026 02:29:55 GMT","from smtpav06.wdc07v.mail.ibm.com (unknown [127.0.0.1])\n by IMSVA (Postfix) with ESMTP id 014CA580F4;\n Thu,  2 Apr 2026 02:29:55 +0000 (GMT)","from smtpav06.wdc07v.mail.ibm.com (unknown [127.0.0.1])\n by IMSVA (Postfix) with ESMTP id 6CE93580F6;\n Thu,  2 Apr 2026 02:29:54 +0000 (GMT)","from WIN-DU0DFC9G5VV.ibm.com (unknown [9.61.247.119])\n by smtpav06.wdc07v.mail.ibm.com (Postfix) with ESMTP;\n Thu,  2 Apr 2026 02:29:54 +0000 (GMT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc\n :content-transfer-encoding:date:from:in-reply-to:message-id\n :mime-version:references:subject:to; s=pp1; bh=wxsDkoxMgmqPvy/Tm\n rdPLZWJFFKC712PZ5X5MHIUL4o=; b=WmuVyNnhBQ+FR3oMFwLTRMdOLRferB2Mo\n JsYmO2ydd+t3Q9R7M7VsJHrIhJRhCx/SPlIXm1txPt6Jv4gCA/JL6KwimGl8AksY\n n/LOQQUg8sl/sXWdt5rQxx/2c3EMUW5tfvza+XxMdjYg42ZmIT+0UVnoFeuWyB8C\n q49TD4SZkBWrV8vNyrnqdlfJW24+BcBdU5Veh/WoxJgZhCbqJCcIchJYpIq+ixYy\n hnnSxilKXWTRVSqLhm8GY0qR3t0wyS9n5JMfQKhm83iDAzla380FlNDn1LlgujT2\n PGv1l/wBDTULUj9onV2w6bacShwT0wKvrMkerna5z/eVqtJhl4Jpw==","From":"Konstantin Shkolnyy <kshk@linux.ibm.com>","To":"mjrosato@linux.ibm.com","Cc":"alifm@linux.ibm.com, richard.henderson@linaro.org, iii@linux.ibm.com,\n david@kernel.org, cohuck@redhat.com, pasic@linux.ibm.com,\n borntraeger@linux.ibm.com, qemu-s390x@nongnu.org,\n qemu-devel@nongnu.org, Konstantin Shkolnyy <kshk@linux.ibm.com>","Subject":"[PATCH 05/15] s390x/pci: Move iotlb from S390PCIIOMMU to\n S390PCIBusDevice","Date":"Wed,  1 Apr 2026 21:29:11 -0500","Message-Id":"<20260402022921.298818-6-kshk@linux.ibm.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20260402022921.298818-1-kshk@linux.ibm.com>","References":"<20260402022921.298818-1-kshk@linux.ibm.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-TM-AS-GCONF":"00","X-Proofpoint-GUID":"DWhswv_bvJhkxzrkDy0MrduW2Z-ik0MK","X-Authority-Analysis":"v=2.4 cv=frzRpV4f c=1 sm=1 tr=0 ts=69cdd4a5 cx=c_pps\n a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17\n a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22\n a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=frKy0Gi9Nncm8Rs_nZ4A:9","X-Proofpoint-ORIG-GUID":"DWhswv_bvJhkxzrkDy0MrduW2Z-ik0MK","X-Proofpoint-Spam-Details-Enc":"AW1haW4tMjYwNDAyMDAxOSBTYWx0ZWRfX5ncLkFSNcdA7\n 1HRVF6jP61D5L4/dzqr319xyAcbQPtsb6oxJXLEbPDK/wccYalrCupHktBV5vGdkldjWPMuy5Y/\n p4PqdcgDqrbg0It8zG6E9f3D3kxt2OSKGI7nB2d00nBoxSyac3hrRCcn529EjJbDpKIipKCsaAy\n rbaXWH6EFZ+p0kiSSOP0nOKUBdTgcHPiIVu+Zi06GYtIhNp2MIS4xrDeFoP434LxnbfHlIqoUhE\n yA2F/MSb8iPXpQHvhy4T9WOHfr0UH9ye2/Q9C5lhuE3/g0Yrj3kJfj4oiu215MISGpRHHs35q2b\n f5N1dAdoRnTz1316+kOZiJ/iJKxYoC8jOPdlYKJ5DdP1G+TttjZ8rJhbvYMD8lfvIYmohip5laR\n OeAGZr/RKXoJjAakZmTOJWs8fdaarBswmsXjMMjxP4iZNQZO0YjqQGTSlhGIVt8obTgZkMY+QRu\n zsc6IyKYUgb2OFMUbWw==","X-Proofpoint-Virus-Version":"vendor=baseguard\n engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49\n definitions=2026-04-01_05,2026-04-01_02,2025-10-01_01","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n impostorscore=0 spamscore=0 priorityscore=1501 malwarescore=0 clxscore=1011\n lowpriorityscore=0 bulkscore=0 adultscore=0 suspectscore=0 phishscore=0\n classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0\n reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2604020019","Received-SPF":"pass client-ip=148.163.156.1; envelope-from=kshk@linux.ibm.com;\n helo=mx0a-001b2d01.pphosted.com","X-Spam_score_int":"-6","X-Spam_score":"-0.7","X-Spam_bar":"/","X-Spam_report":"(-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7,\n RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01,\n RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1, RCVD_IN_VALIDITY_RPBL_BLOCKED=1,\n SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no","X-Spam_action":"no action","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"qemu development <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"This field is only used when S390PCIBusDevice exists, so it can be moved\nthere to simplify S390PCIIOMMU which purpose is just to store the \"root\"\nAddressSpace.\n\nSigned-off-by: Konstantin Shkolnyy <kshk@linux.ibm.com>\n---\n hw/s390x/s390-pci-bus.c         | 10 +++++-----\n hw/s390x/s390-pci-inst.c        |  6 +++---\n include/hw/s390x/s390-pci-bus.h |  2 +-\n 3 files changed, 9 insertions(+), 9 deletions(-)","diff":"diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c\nindex 117fd8136e..3f3123e62a 100644\n--- a/hw/s390x/s390-pci-bus.c\n+++ b/hw/s390x/s390-pci-bus.c\n@@ -569,7 +569,7 @@ static IOMMUTLBEntry s390_translate_iommu(IOMMUMemoryRegion *mr, hwaddr addr,\n         goto err;\n     }\n \n-    entry = g_hash_table_lookup(iommu->iotlb, &iova);\n+    entry = g_hash_table_lookup(pbdev->iotlb, &iova);\n     if (entry) {\n         ret.iova = entry->iova;\n         ret.translated_addr = entry->translated_addr;\n@@ -669,8 +669,6 @@ static S390PCIIOMMU *s390_pci_get_iommu(S390pciState *s, PCIBus *bus,\n                                         PCI_FUNC(devfn));\n         memory_region_init(&iommu->mr, OBJECT(iommu), mr_name, UINT64_MAX);\n         address_space_init(&iommu->as, &iommu->mr, as_name);\n-        iommu->iotlb = g_hash_table_new_full(g_int64_hash, g_int64_equal,\n-                                             NULL, g_free);\n         table->iommu[PCI_SLOT(devfn)] = iommu;\n \n         g_free(mr_name);\n@@ -805,7 +803,7 @@ void s390_pci_iommu_disable(S390PCIBusDevice *pbdev)\n {\n     S390PCIIOMMU *iommu = pbdev->iommu;\n     iommu->enabled = false;\n-    g_hash_table_remove_all(iommu->iotlb);\n+    g_hash_table_remove_all(pbdev->iotlb);\n     if (pbdev->dm_mr) {\n         memory_region_del_subregion(&iommu->mr, pbdev->dm_mr);\n         object_unparent(OBJECT(pbdev->dm_mr));\n@@ -829,7 +827,6 @@ static void s390_pci_iommu_free(S390pciState *s, PCIBus *bus, int32_t devfn)\n     }\n \n     table->iommu[PCI_SLOT(devfn)] = NULL;\n-    g_hash_table_destroy(iommu->iotlb);\n     /*\n      * An attached PCI device may have memory listeners, eg. VFIO PCI.\n      * The associated subregion will already have been unmapped in\n@@ -1251,6 +1248,8 @@ static void s390_pcihost_plug(HotplugHandler *hotplug_dev, DeviceState *dev,\n         /* the allocated idx is actually getting used */\n         s->next_idx = (pbdev->idx + 1) & FH_MASK_INDEX;\n         pbdev->fh = pbdev->idx;\n+        pbdev->iotlb = g_hash_table_new_full(g_int64_hash, g_int64_equal,\n+                                             NULL, g_free);\n         QTAILQ_INSERT_TAIL(&s->zpci_devs, pbdev, link);\n         g_hash_table_insert(s->zpci_table, &pbdev->idx, pbdev);\n     } else {\n@@ -1293,6 +1292,7 @@ static void s390_pcihost_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,\n         if (pbdev->iommu && pbdev->iommu->dma_limit) {\n             s390_pci_end_dma_count(s, pbdev->iommu->dma_limit);\n         }\n+        g_hash_table_destroy(pbdev->iotlb);\n         qdev_unrealize(dev);\n     }\n }\ndiff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c\nindex 834a0aec95..8349b44dd4 100644\n--- a/hw/s390x/s390-pci-inst.c\n+++ b/hw/s390x/s390-pci-inst.c\n@@ -617,7 +617,7 @@ uint32_t s390_pci_update_iotlb(S390PCIBusDevice *pbdev,\n                                S390IOTLBEntry *entry)\n {\n     S390PCIIOMMU *iommu = pbdev->iommu;\n-    S390IOTLBEntry *cache = g_hash_table_lookup(iommu->iotlb, &entry->iova);\n+    S390IOTLBEntry *cache = g_hash_table_lookup(pbdev->iotlb, &entry->iova);\n     IOMMUTLBEvent event = {\n         .type = entry->perm ? IOMMU_NOTIFIER_MAP : IOMMU_NOTIFIER_UNMAP,\n         .entry = {\n@@ -633,7 +633,7 @@ uint32_t s390_pci_update_iotlb(S390PCIBusDevice *pbdev,\n         if (!cache) {\n             goto out;\n         }\n-        g_hash_table_remove(iommu->iotlb, &entry->iova);\n+        g_hash_table_remove(pbdev->iotlb, &entry->iova);\n         inc_dma_avail(iommu);\n         /* Don't notify the iommu yet, maybe we can bundle contiguous unmaps */\n         goto out;\n@@ -656,7 +656,7 @@ uint32_t s390_pci_update_iotlb(S390PCIBusDevice *pbdev,\n         cache->translated_addr = entry->translated_addr;\n         cache->len = TARGET_PAGE_SIZE;\n         cache->perm = entry->perm;\n-        g_hash_table_replace(iommu->iotlb, &cache->iova, cache);\n+        g_hash_table_replace(pbdev->iotlb, &cache->iova, cache);\n         dec_dma_avail(iommu);\n     }\n \ndiff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bus.h\nindex f310672584..d9bafd6859 100644\n--- a/include/hw/s390x/s390-pci-bus.h\n+++ b/include/hw/s390x/s390-pci-bus.h\n@@ -281,7 +281,6 @@ struct S390PCIIOMMU {\n     uint64_t pba;\n     uint64_t pal;\n     uint64_t max_dma_limit;\n-    GHashTable *iotlb;\n     S390PCIDMACount *dma_limit;\n };\n \n@@ -354,6 +353,7 @@ struct S390PCIBusDevice {\n     S390PCIIOMMU *iommu;\n     IOMMUMemoryRegion iommu_mr;\n     MemoryRegion *dm_mr;\n+    GHashTable *iotlb;\n     MemoryRegion msix_notify_mr;\n     IndAddr *summary_ind;\n     IndAddr *indicator;\n","prefixes":["05/15"]}