From nobody Sun Jun 7 22:17:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1780625950; cv=none; d=zohomail.com; s=zohoarc; b=K/2TO8FhgWGh45WAxxuIVwhyvJP5jFgw9KKcg11Rz1mq6ejkHPmc/n56gNtuyRC4ql7Tb/rGbB/0TLtQQ24JB+tVpB1oPInJw9h81sKGC9jzHBZmDdWvNx+ZE0U0brflGnHRHGIbi0TFOIfW/6WZoWaLnd9sf42rg6P59HL2mKM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780625950; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xKaH8/VylfBSI/rISAPTq6UY2nsuNOVzBdGFpBFZyxg=; b=G7YZ+2u4CSenWHCpH5bWhTii8YgK6Q9lBvn/DOJ8CPkR6+xusn5EmKCduzkRLCRfeNHEThYu6ideRsujUGQM46F8rDlIMqJWpi2JiqFiutdlEOu+0Tlb7NtEAq9onQA8x4yr9JZjJ2pq9LSCynX2PqZZP4oolX3ty0I8ObozgUQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780625950235765.3660694839161; Thu, 4 Jun 2026 19:19:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wVK84-0005NI-75; Thu, 04 Jun 2026 22:17:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK80-0005Hd-4t; Thu, 04 Jun 2026 22:17:44 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK7w-0001lw-VS; Thu, 04 Jun 2026 22:17:43 -0400 Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 654LdXTD867987; Fri, 5 Jun 2026 02:17:36 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4efqjqjf1j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:36 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 65529DbS025313; Fri, 5 Jun 2026 02:17:35 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4egcegyh0u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:35 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6552HXmx22610566 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jun 2026 02:17:33 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5C48A58067; Fri, 5 Jun 2026 02:17:33 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3083B5805D; Fri, 5 Jun 2026 02:17:33 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.ibm.com (unknown [9.61.240.22]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Jun 2026 02:17:33 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=xKaH8/VylfBSI/rIS APTq6UY2nsuNOVzBdGFpBFZyxg=; b=q4OIOu4qKXIfod1iZ35I+1fS36br+bf7o r866ZOfg1r+TVZqoLN9RxBraYNt2jE0xa7Hg7WDTN9IEjGuYlxw2bpSPMn8x6YSK MGcY4YKqaPKbBqIU4u1oZZ+1Z0mPrShn91sXX/nQYhix7mQD1WDUbSPGmJ3N/o8m rGRwQeGROP4a6Z8s2m0gYcGgjt1JpFXnW0dDlXCwCx/PT/93msxRg6hdukEWjGdp Ppl7vT2GdUylR7zvG7C9umQh4m2/kYtsPybmZFeWJuR0ycZWn2Cv2nnXhxbfxrhA yxdbSRdBKuxiq3Qg9YE9gvf/X1La5TzKi2VdjwpIwsMa/bLaG4lNw== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, richard.henderson@linaro.org, iii@linux.ibm.com, david@kernel.org, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Konstantin Shkolnyy Subject: [PATCH v3 01/15] s390x/pci: implement IOMMU replay Date: Thu, 4 Jun 2026 21:17:14 -0500 Message-Id: <20260605021728.1125090-2-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260605021728.1125090-1-kshk@linux.ibm.com> References: <20260605021728.1125090-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 53QjjMJwpMqH9KgNUSb6pym-MS6aX4pM X-Proofpoint-GUID: 53QjjMJwpMqH9KgNUSb6pym-MS6aX4pM X-Authority-Analysis: v=2.4 cv=bcVbluPB c=1 sm=1 tr=0 ts=6a2231c0 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=FelO9ux0wxsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=Ne9W6HA6cR8Tgt2TMNYA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjA1MDAxOCBTYWx0ZWRfX7wx2y3bPrLBd o+Y+T8RfL2zCH2TINGNeCNEe4y9vuYDnW0EuXPAB+15Y6o+Q9G6AT+ZgPcMwLR2xxHNJg0Pgibv v3kYRZr98Fw+wu+5kRVMZ1YJvNTQVScQHY4EkPvepT5RBrfg2XkktcuUuJohtX60ahmUuOoEMWt ACVl5xnW/hgOmb+AQc5lXZKAr+CoDliSlFyqpj0SSjgAcz/KybWRQf2gPvQDWVuJou/hV1rfBgM MMowEcI6sYAKmhwa5eyQLz74JA2OnvOPEWAAuHnIXeNL50x/69VhWzOxepFvX9xZgIYZQKrxBzP uA9gBsSwznBZFhsyVohQ1hzAKDTb5z8CZqNd3rBltTFx3HDwKLLV8yMex1e8VqUpw9lGFpMNnmX 6gQsoxThXwpycnns/PE7WnMb3B58/U7KOlYlyTHqDZcdBPpV8NzhlMxizJHtU371Qb6uTaf5rDs kDO8y7VljzDX7V7lcFg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-04_07,2026-05-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 adultscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2606050018 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=kshk@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1780625953771154100 Content-Type: text/plain; charset="utf-8" From: Matthew Rosato There are a few scenarios where IOMMU replay can potentially be needed for zPCI device, namely VFIO device reset scenarios where the guest continues running and expects the contents of its IOMMU to be replayed upon IOAT re-registration and migration scenarios where the destination must reconstruct the IOMMU on the destination. zPCI migration is not supported yet, but the IOMMU replay function is implemented so that it can be called both from IOMMUMemoryRegionClass now and migration post_load later. Signed-off-by: Matthew Rosato Signed-off-by: Konstantin Shkolnyy --- hw/s390x/s390-pci-bus.c | 62 ++++++++++++++++++++++++++++---- hw/s390x/s390-pci-inst.c | 4 +-- include/hw/s390x/s390-pci-inst.h | 1 + 3 files changed, 59 insertions(+), 8 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 4de7b587e8..a104e550b1 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -592,14 +592,64 @@ err: return ret; } =20 -static void s390_pci_iommu_replay(IOMMUMemoryRegion *iommu, +static void s390_pci_ioat_replay(S390PCIIOMMU *iommu) +{ + S390IOTLBEntry entry; + uint16_t error =3D 0; + uint32_t dma_avail; + hwaddr curr, end; + + curr =3D iommu->pba; + end =3D iommu->pal; + + if (iommu->dm_mr) { + /* If direct mapping is used, there are no guest tables to replay = */ + return; + } + + if (iommu->dma_limit) { + dma_avail =3D iommu->dma_limit->avail; + } else { + dma_avail =3D 1; + } + + while (curr < end) { + error =3D s390_guest_io_table_walk(iommu->g_iota, curr, &entry); + if (error) { + pbdev->state =3D ZPCI_FS_ERROR; + s390_pci_generate_error_event(error, pbdev->fh, pbdev->fid, cu= rr, + 0); + error_report("Failure to walk table during iommu remap"); + return; + } + + if (entry.perm !=3D IOMMU_NONE) { + if (dma_avail > 0) { + dma_avail =3D s390_pci_update_iotlb(iommu, &entry); + } else { + /* + * There is no reliable method to request the guest to rel= ease + * mappings other than in response to a RPCIT instruction; + * generate a permanent error condition and require the de= vice + * to be completely re-initialized from the guest side. + */ + pbdev->state =3D ZPCI_FS_ERROR; + s390_pci_generate_error_event(ERR_EVENT_PERMERR, pbdev->fh, + pbdev->fid, 0, 0); + error_report("DMA mappings exhausted: iommu remap failed"); + return; + } + } + curr +=3D entry.len; + } +} + +static void s390_pci_iommu_replay(IOMMUMemoryRegion *mr, IOMMUNotifier *notifier) { - /* It's impossible to plug a pci device on s390x that already has iommu - * mappings which need to be replayed, that is due to the "one iommu p= er - * zpci device" construct. But when we support migration of vfio-pci - * devices in future, we need to revisit this. - */ + S390PCIIOMMU *iommu =3D container_of(mr, S390PCIIOMMU, iommu_mr); + + s390_pci_ioat_replay(iommu); } =20 static S390PCIIOMMU *s390_pci_get_iommu(S390pciState *s, PCIBus *bus, diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index 10066ca618..1834596076 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -613,8 +613,8 @@ int pcistg_service_call(S390CPU *cpu, uint8_t r1, uint8= _t r2, uintptr_t ra) return 0; } =20 -static uint32_t s390_pci_update_iotlb(S390PCIIOMMU *iommu, - S390IOTLBEntry *entry) +uint32_t s390_pci_update_iotlb(S390PCIIOMMU *iommu, + S390IOTLBEntry *entry) { S390IOTLBEntry *cache =3D g_hash_table_lookup(iommu->iotlb, &entry->io= va); IOMMUTLBEvent event =3D { diff --git a/include/hw/s390x/s390-pci-inst.h b/include/hw/s390x/s390-pci-i= nst.h index 5cb8da540b..c782990e3b 100644 --- a/include/hw/s390x/s390-pci-inst.h +++ b/include/hw/s390x/s390-pci-inst.h @@ -111,6 +111,7 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint6= 4_t fiba, uint8_t ar, int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t = ar, uintptr_t ra); void fmb_timer_free(S390PCIBusDevice *pbdev); +uint32_t s390_pci_update_iotlb(S390PCIIOMMU *iommu, S390IOTLBEntry *entry); =20 #define ZPCI_IO_BAR_MIN 0 #define ZPCI_IO_BAR_MAX 5 --=20 2.34.1 From nobody Sun Jun 7 22:17:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1780625988; cv=none; d=zohomail.com; s=zohoarc; b=PITJwRi5Zt96PeZCLOF2VBTReQ8CchPWfn3v27jmx2HKCy0zKrEDB3b0agOV6k4Q0FAj04vKd5q5adb0JwvT/eQGZT6azOrwRN2/L0HyEZ3HAnkd6AoAsFmS8KBBGyo6tnBHFWp0Q9Sug61mmgS8dC4ixUn4FbmFIU1BhmQCi7o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780625988; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WkDlxvq/dANM5IMpmQNhvTc8dkxHYLZTD3ULR3F4n1o=; b=ZE/Rzlj5FaXuP5i9ubx9BINkcfU03pl1mJcDjy6FT+THxeLlq+KNYtBwOPgJi0RwIizsh5cg5s+nIoVXKom3oWkpb9iFEoKl/Opwny1nmEnDOXcIpi0WPM63QkUNRpqjuN1l7pc63oUZUFFs2IbreWd2/KE3ZtX5ZK+0PjZKkBA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780625988216183.81909174809948; Thu, 4 Jun 2026 19:19:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wVK81-0005Iv-1H; Thu, 04 Jun 2026 22:17:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK7y-0005HE-SE; Thu, 04 Jun 2026 22:17:42 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK7w-0001ls-V9; Thu, 04 Jun 2026 22:17:42 -0400 Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 654KbZOe1502206; Fri, 5 Jun 2026 02:17:36 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4efnaj21af-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:36 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 655296uI029805; Fri, 5 Jun 2026 02:17:35 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4egcwyqdwx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:35 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6552HX0733620680 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jun 2026 02:17:33 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8BC1D58052; Fri, 5 Jun 2026 02:17:33 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6196F58068; Fri, 5 Jun 2026 02:17:33 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.ibm.com (unknown [9.61.240.22]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Jun 2026 02:17:33 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=WkDlxvq/dANM5IMpm QNhvTc8dkxHYLZTD3ULR3F4n1o=; b=psgEUcLuJlDWLd9Y1xqZSM2/w20ic6Rrr z1Rh3ybnuMMW7nIy7VUdT+cWS1KsQXYKMLVqQg+GqrVKkh7TloFr2XNo3fUDqCMp h4nKz5jEPjxdi5sZ7W0LGuX3B9TVF4BXTg5wxwyh/z/I1AGsbO0YVH0jhguK9Qz+ GWGOLJjRKcI+4Z+5G2z4YsFNC3HR9iToZEx5TgNLHG7xYBn5ZNUuNyTt5InzNxDf tZ50a/yD7z/9/r0PFfB0pg8EA/PgXiScD4hfbPEc7P0K6DBBq7vZdtmgPPfB4tHG ghT4tsYoyiz6eNT5FwyA9gdZLWoYj0vFM8CUwwNjhMFAKW9A2PpVg== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, richard.henderson@linaro.org, iii@linux.ibm.com, david@kernel.org, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Konstantin Shkolnyy Subject: [PATCH v3 02/15] s390x/pci: Create function to contain translation status check Date: Thu, 4 Jun 2026 21:17:15 -0500 Message-Id: <20260605021728.1125090-3-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260605021728.1125090-1-kshk@linux.ibm.com> References: <20260605021728.1125090-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjA1MDAxOCBTYWx0ZWRfX5XXIM/gbqj+Y WgBMNiktwh0+sclM0G2LLKD+pgWER0zJhi6QsmshyIj5Jo0yPzEJiEfHToYnOljLdHoEUeiwQGz F394i0XNvCRKGL0iDmQg0DikznztpInnvKjSSUHE7oBvZuFh5p/884Z7uxRYFvAXrfZxPab33FH sLzFUI36K0WSkrHBJZqyHWweyta0CtL75X6HylDjMZeNPUrD1jsW/4QzF/7mE5ZXCJfoF50iwJL ivjBpF+BdVoJ7yEmC7tw7isPw6Gf96IhX7X5UT32gTOTnH0lN8Bpgf0eTeQqyNq7VMipWuip2lI xEQVdxUcb1e6FgVgyxD12qnTu0YkgDDehWyc0hwOCHSgUkv8hcIXtDbU6kD5WhKwOay1jzfyWxB EOvVYgWinM3tD4tH0mMcudrJLjM6rcgyJ+tu6JEAC5NiUfzkeqO8X2oC/jKQXd5+EUUp53mJkSl aRvvlbE8qN/1VUFMUcA== X-Proofpoint-ORIG-GUID: m-HLo3D8iRSaSeG_lGIEu6P43hs4xqIy X-Authority-Analysis: v=2.4 cv=cOzQdFeN c=1 sm=1 tr=0 ts=6a2231c0 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=FelO9ux0wxsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=aCv-BzsnQx_gTHabB28A:9 X-Proofpoint-GUID: m-HLo3D8iRSaSeG_lGIEu6P43hs4xqIy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-04_07,2026-05-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 spamscore=0 bulkscore=0 malwarescore=0 phishscore=0 suspectscore=0 priorityscore=1501 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2606050018 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=kshk@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1780625989692158500 Content-Type: text/plain; charset="utf-8" Make it more clear what the bit means, and the new function will be called from yet another place in the future. Reviewed-by: Christian Borntraeger Reviewed-by: Matthew Rosato Signed-off-by: Konstantin Shkolnyy --- hw/s390x/s390-pci-inst.c | 7 ++++++- include/hw/s390x/s390-pci-bus.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index 1834596076..7c784b31f3 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -993,6 +993,11 @@ int pci_dereg_irqs(S390PCIBusDevice *pbdev) return 0; } =20 +bool s390_pci_is_translation_enabled(uint64_t g_iota) +{ + return ((g_iota >> 11) & 0x1) !=3D 0; /* "T" bit */ +} + static int reg_ioat(CPUS390XState *env, S390PCIBusDevice *pbdev, ZpciFib f= ib, uintptr_t ra) { @@ -1001,7 +1006,7 @@ static int reg_ioat(CPUS390XState *env, S390PCIBusDev= ice *pbdev, ZpciFib fib, uint64_t pal =3D ldq_be_p(&fib.pal); uint64_t g_iota =3D ldq_be_p(&fib.iota); uint8_t dt =3D (g_iota >> 2) & 0x7; - uint8_t t =3D (g_iota >> 11) & 0x1; + bool t =3D s390_pci_is_translation_enabled(g_iota); =20 pba &=3D ~0xfff; pal |=3D 0xfff; diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bu= s.h index 9228523ce8..eb15cb8b2d 100644 --- a/include/hw/s390x/s390-pci-bus.h +++ b/include/hw/s390x/s390-pci-bus.h @@ -390,6 +390,7 @@ int pci_chsc_sei_nt2_get_event(void *res); int pci_chsc_sei_nt2_have_event(void); void s390_pci_sclp_configure(SCCB *sccb); void s390_pci_sclp_deconfigure(SCCB *sccb); +bool s390_pci_is_translation_enabled(uint64_t g_iota); void s390_pci_iommu_enable(S390PCIIOMMU *iommu); void s390_pci_iommu_direct_map_enable(S390PCIIOMMU *iommu); void s390_pci_iommu_disable(S390PCIIOMMU *iommu); --=20 2.34.1 From nobody Sun Jun 7 22:17:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1780625998; cv=none; d=zohomail.com; s=zohoarc; b=IrPwOzMbBD7Bl6D9Umw7P2qAS2dzSKdKUtvZ0kHyQXP3hcOm+leuglW9tqVCt1Q2/SmgqIfat2b02la/wDfcWzbV1PQlga4nw5EyfU/AereK2HH7Z2r7HpcG8qJs9Q+kZh/wUhMasZBrulHN4luDWO1Q2DdOrZfukgNsYTZc4Ms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780625998; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RigF/br9q0w8WeT2GuxvttQaE831ycLoU0EYZFUQkgc=; b=GNqQyz1cqz5xrLkh2Uy09Osk2sYcNMV8Eja2SdW9fUGWl48ckkPlfWhajc3LGONGG+wa2sjS2JBbfDOg5OAgRfyxFKIL0XnkNjmhZKhGth2eaRP88T/7fTbdvI4t/jdkbJLXtTp9L1oz7oAeVZtb7VewVaSfHDYk4T+LzfuFiHs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17806259984511005.6079155717744; Thu, 4 Jun 2026 19:19:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wVK84-0005Ns-M5; Thu, 04 Jun 2026 22:17:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK80-0005Ik-NI; Thu, 04 Jun 2026 22:17:44 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK7x-0001m5-Ee; Thu, 04 Jun 2026 22:17:44 -0400 Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 654NwCSD3294139; Fri, 5 Jun 2026 02:17:36 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4efnaj21ad-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:35 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 655299Ob010140; Fri, 5 Jun 2026 02:17:35 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4egb7kfspt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:35 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6552HXEu28312232 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jun 2026 02:17:34 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C3DE658056; Fri, 5 Jun 2026 02:17:33 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9127C5805D; Fri, 5 Jun 2026 02:17:33 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.ibm.com (unknown [9.61.240.22]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Jun 2026 02:17:33 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=RigF/br9q0w8WeT2G uxvttQaE831ycLoU0EYZFUQkgc=; b=MI1esiJIPqR1co2etHCPUfuFpJioVJI/W qW7cWjkcbh3NwTxKbJg95EnxzR6u+YgDp5bsT8lJobc7zxhxyfJbKtebKvxVyFE+ ZXlz+iqLuUqszNMaqJc047/hVr8T29Co+Mn9KVrTHJe+1yHt0r4zlOHR2PRlaCTR e202q+BRFW5mgR3alrNj/KYI0tTqp6MhyGnu1Nh1RPSfQLv6aH8pRzy6dS02iQud YiKGQPCKIO4kut51sAobwmk+tnUNUPtCcLFQH4JA18xfTZFR2UVDJ6weFfX7lMRq lWA+ZFbhoVB8Zz8uZnAdURM1duTYNherb1AADx0vikd25CNeF5gNQ== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, richard.henderson@linaro.org, iii@linux.ibm.com, david@kernel.org, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Konstantin Shkolnyy Subject: [PATCH v3 03/15] s390x/pci: Move iommu_mr from S390PCIIOMMU to S390PCIBusDevice Date: Thu, 4 Jun 2026 21:17:16 -0500 Message-Id: <20260605021728.1125090-4-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260605021728.1125090-1-kshk@linux.ibm.com> References: <20260605021728.1125090-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjA1MDAxOCBTYWx0ZWRfX5tX8MUBwdosp lgjkdW026wd2fXTd6a0MBZMUp3re9NIdMqMEkEuFjXwlG/Dl8ki9Ed+JSn7DwqovEyZDmLB4U8H WjU5KzsbtQowS1KewqVMF/u2fN1+itUgWzoEUAryvCqbyi19ecaid+sFcxEbs4ux3LZ9+VHEhrG TRCNxCXzYeWuTraAbRqHGFTbZLD5ulMSlxwvqxWgfqHrLOtaMFF091nQgua0qqBZG0GH+MgnxQ0 sxtnK3Cw69xGrxtCu3DMTqjOt70KYIurAFaVadAhb5nHkFNg8vYtgCurr3t1PBNdFUPYisvOVEx cAbRTcK9NM9DjvY5VMeCGWhqRbZT2zwNCf5lBG5lh/XE6JHxdyG/yjZH1aw1ESHzwjK7LjFqUVm R5M9aJrUKAO1bZFTTdY/yXbNirpzTeTCO9dxoAoeZof4wYwAy+Uf2DX3dzbFplc46jQ9E5Fg6mX YFDaK6nl4Z9ZAY2inLA== X-Proofpoint-ORIG-GUID: GcZZJFMdnGdQSjqZoPXrOpQjSu5chFsT X-Authority-Analysis: v=2.4 cv=cOzQdFeN c=1 sm=1 tr=0 ts=6a2231bf cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=FelO9ux0wxsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=n4sMxHAKvM-efvCv8lMA:9 X-Proofpoint-GUID: GcZZJFMdnGdQSjqZoPXrOpQjSu5chFsT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-04_07,2026-05-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 spamscore=0 bulkscore=0 malwarescore=0 phishscore=0 suspectscore=0 priorityscore=1501 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2606050018 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=kshk@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1780625999868158500 Content-Type: text/plain; charset="utf-8" This field is only used when S390PCIBusDevice exists, so it can be moved there to simplify S390PCIIOMMU which purpose is just to store the "root" AddressSpace. Signed-off-by: Konstantin Shkolnyy --- hw/s390x/s390-pci-bus.c | 32 ++++++++++++++++++-------------- hw/s390x/s390-pci-inst.c | 28 +++++++++++++++------------- include/hw/s390x/s390-pci-bus.h | 6 +++--- include/hw/s390x/s390-pci-inst.h | 4 ++-- 4 files changed, 38 insertions(+), 32 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index a104e550b1..98f626b57f 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -206,7 +206,7 @@ void s390_pci_sclp_deconfigure(SCCB *sccb) pci_dereg_irqs(pbdev); } if (pbdev->iommu->enabled) { - pci_dereg_ioat(pbdev->iommu); + pci_dereg_ioat(pbdev); } pbdev->state =3D ZPCI_FS_STANDBY; rc =3D SCLP_RC_NORMAL_COMPLETION; @@ -538,7 +538,8 @@ uint16_t s390_guest_io_table_walk(uint64_t g_iota, hwad= dr addr, static IOMMUTLBEntry s390_translate_iommu(IOMMUMemoryRegion *mr, hwaddr ad= dr, IOMMUAccessFlags flag, int iommu= _idx) { - S390PCIIOMMU *iommu =3D container_of(mr, S390PCIIOMMU, iommu_mr); + S390PCIBusDevice *pbdev =3D container_of(mr, S390PCIBusDevice, iommu_m= r); + S390PCIIOMMU *iommu =3D pbdev->iommu; S390IOTLBEntry *entry; uint64_t iova =3D addr & TARGET_PAGE_MASK; uint16_t error =3D 0; @@ -592,12 +593,13 @@ err: return ret; } =20 -static void s390_pci_ioat_replay(S390PCIIOMMU *iommu) +static void s390_pci_ioat_replay(S390PCIBusDevice *pbdev) { S390IOTLBEntry entry; uint16_t error =3D 0; uint32_t dma_avail; hwaddr curr, end; + S390PCIIOMMU *iommu =3D pbdev->iommu; =20 curr =3D iommu->pba; end =3D iommu->pal; @@ -625,7 +627,7 @@ static void s390_pci_ioat_replay(S390PCIIOMMU *iommu) =20 if (entry.perm !=3D IOMMU_NONE) { if (dma_avail > 0) { - dma_avail =3D s390_pci_update_iotlb(iommu, &entry); + dma_avail =3D s390_pci_update_iotlb(pbdev, &entry); } else { /* * There is no reliable method to request the guest to rel= ease @@ -647,9 +649,9 @@ static void s390_pci_ioat_replay(S390PCIIOMMU *iommu) static void s390_pci_iommu_replay(IOMMUMemoryRegion *mr, IOMMUNotifier *notifier) { - S390PCIIOMMU *iommu =3D container_of(mr, S390PCIIOMMU, iommu_mr); + S390PCIBusDevice *pbdev =3D container_of(mr, S390PCIBusDevice, iommu_m= r); =20 - s390_pci_ioat_replay(iommu); + s390_pci_ioat_replay(pbdev); } =20 static S390PCIIOMMU *s390_pci_get_iommu(S390pciState *s, PCIBus *bus, @@ -771,19 +773,20 @@ static const MemoryRegionOps s390_msi_ctrl_ops =3D { .endianness =3D DEVICE_LITTLE_ENDIAN, }; =20 -void s390_pci_iommu_enable(S390PCIIOMMU *iommu) +void s390_pci_iommu_enable(S390PCIBusDevice *pbdev) { + S390PCIIOMMU *iommu =3D pbdev->iommu; /* * The iommu region is initialized against a 0-mapped address space, * so the smallest IOMMU region we can define runs from 0 to the end * of the PCI address space. */ char *name =3D g_strdup_printf("iommu-s390-%04x", iommu->pbdev->uid); - memory_region_init_iommu(&iommu->iommu_mr, sizeof(iommu->iommu_mr), + memory_region_init_iommu(&pbdev->iommu_mr, sizeof(pbdev->iommu_mr), TYPE_S390_IOMMU_MEMORY_REGION, OBJECT(&iommu-= >mr), name, iommu->pal + 1); iommu->enabled =3D true; - memory_region_add_subregion(&iommu->mr, 0, MEMORY_REGION(&iommu->iommu= _mr)); + memory_region_add_subregion(&iommu->mr, 0, MEMORY_REGION(&pbdev->iommu= _mr)); g_free(name); } =20 @@ -809,8 +812,9 @@ void s390_pci_iommu_direct_map_enable(S390PCIIOMMU *iom= mu) iommu->dm_mr); } =20 -void s390_pci_iommu_disable(S390PCIIOMMU *iommu) +void s390_pci_iommu_disable(S390PCIBusDevice *pbdev) { + S390PCIIOMMU *iommu =3D pbdev->iommu; iommu->enabled =3D false; g_hash_table_remove_all(iommu->iotlb); if (iommu->dm_mr) { @@ -820,8 +824,8 @@ void s390_pci_iommu_disable(S390PCIIOMMU *iommu) iommu->dm_mr =3D NULL; } else { memory_region_del_subregion(&iommu->mr, - MEMORY_REGION(&iommu->iommu_mr)); - object_unparent(OBJECT(&iommu->iommu_mr)); + MEMORY_REGION(&pbdev->iommu_mr)); + object_unparent(OBJECT(&pbdev->iommu_mr)); } } =20 @@ -1420,7 +1424,7 @@ static void s390_pcihost_reset(DeviceState *dev) pci_dereg_irqs(pbdev); } if (pbdev->iommu->enabled) { - pci_dereg_ioat(pbdev->iommu); + pci_dereg_ioat(pbdev); } pbdev->state =3D ZPCI_FS_STANDBY; s390_pci_perform_unplug(pbdev); @@ -1561,7 +1565,7 @@ static void s390_pci_device_reset(DeviceState *dev) pci_dereg_irqs(pbdev); } if (pbdev->iommu->enabled) { - pci_dereg_ioat(pbdev->iommu); + pci_dereg_ioat(pbdev); } =20 fmb_timer_free(pbdev); diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index 7c784b31f3..ed60e6100e 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -613,9 +613,10 @@ int pcistg_service_call(S390CPU *cpu, uint8_t r1, uint= 8_t r2, uintptr_t ra) return 0; } =20 -uint32_t s390_pci_update_iotlb(S390PCIIOMMU *iommu, +uint32_t s390_pci_update_iotlb(S390PCIBusDevice *pbdev, S390IOTLBEntry *entry) { + S390PCIIOMMU *iommu =3D pbdev->iommu; S390IOTLBEntry *cache =3D g_hash_table_lookup(iommu->iotlb, &entry->io= va); IOMMUTLBEvent event =3D { .type =3D entry->perm ? IOMMU_NOTIFIER_MAP : IOMMU_NOTIFIER_UNMAP, @@ -645,7 +646,7 @@ uint32_t s390_pci_update_iotlb(S390PCIIOMMU *iommu, =20 event.type =3D IOMMU_NOTIFIER_UNMAP; event.entry.perm =3D IOMMU_NONE; - memory_region_notify_iommu(&iommu->iommu_mr, 0, event); + memory_region_notify_iommu(&pbdev->iommu_mr, 0, event); event.type =3D IOMMU_NOTIFIER_MAP; event.entry.perm =3D entry->perm; } @@ -663,13 +664,13 @@ uint32_t s390_pci_update_iotlb(S390PCIIOMMU *iommu, * All associated iotlb entries have already been cleared, trigger the * unmaps. */ - memory_region_notify_iommu(&iommu->iommu_mr, 0, event); + memory_region_notify_iommu(&pbdev->iommu_mr, 0, event); =20 out: return iommu->dma_limit ? iommu->dma_limit->avail : 1; } =20 -static void s390_pci_batch_unmap(S390PCIIOMMU *iommu, uint64_t iova, +static void s390_pci_batch_unmap(S390PCIBusDevice *pbdev, uint64_t iova, uint64_t len) { uint64_t remain =3D len, start =3D iova, end =3D start + len - 1, mask= , size; @@ -687,7 +688,7 @@ static void s390_pci_batch_unmap(S390PCIIOMMU *iommu, u= int64_t iova, size =3D mask + 1; event.entry.iova =3D start; event.entry.addr_mask =3D mask; - memory_region_notify_iommu(&iommu->iommu_mr, 0, event); + memory_region_notify_iommu(&pbdev->iommu_mr, 0, event); start +=3D size; remain -=3D size; } @@ -778,14 +779,14 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint= 8_t r2, uintptr_t ra) coalesce +=3D entry.len; } else if (coalesce > 0) { /* Unleash the coalesced unmap before processing a new map */ - s390_pci_batch_unmap(iommu, iova, coalesce); + s390_pci_batch_unmap(pbdev, iova, coalesce); coalesce =3D 0; } =20 start +=3D entry.len; while (entry.iova < start && entry.iova < end) { if (dma_avail > 0 || entry.perm =3D=3D IOMMU_NONE) { - dma_avail =3D s390_pci_update_iotlb(iommu, &entry); + dma_avail =3D s390_pci_update_iotlb(pbdev, &entry); entry.iova +=3D TARGET_PAGE_SIZE; entry.translated_addr +=3D TARGET_PAGE_SIZE; } else { @@ -801,7 +802,7 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_= t r2, uintptr_t ra) } if (coalesce) { /* Unleash the coalesced unmap before finishing rpcit */ - s390_pci_batch_unmap(iommu, iova, coalesce); + s390_pci_batch_unmap(pbdev, iova, coalesce); coalesce =3D 0; } if (again && dma_avail > 0) @@ -1031,7 +1032,7 @@ static int reg_ioat(CPUS390XState *env, S390PCIBusDev= ice *pbdev, ZpciFib fib, iommu->g_iota =3D g_iota; =20 if (t) { - s390_pci_iommu_enable(iommu); + s390_pci_iommu_enable(pbdev); } else { s390_pci_iommu_direct_map_enable(iommu); } @@ -1039,9 +1040,10 @@ static int reg_ioat(CPUS390XState *env, S390PCIBusDe= vice *pbdev, ZpciFib fib, return 0; } =20 -void pci_dereg_ioat(S390PCIIOMMU *iommu) +void pci_dereg_ioat(S390PCIBusDevice *pbdev) { - s390_pci_iommu_disable(iommu); + S390PCIIOMMU *iommu =3D pbdev->iommu; + s390_pci_iommu_disable(pbdev); iommu->pba =3D 0; iommu->pal =3D 0; iommu->g_iota =3D 0; @@ -1265,7 +1267,7 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uin= t64_t fiba, uint8_t ar, cc =3D ZPCI_PCI_LS_ERR; s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE); } else { - pci_dereg_ioat(pbdev->iommu); + pci_dereg_ioat(pbdev); } break; case ZPCI_MOD_FC_REREG_IOAT: @@ -1276,7 +1278,7 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uin= t64_t fiba, uint8_t ar, cc =3D ZPCI_PCI_LS_ERR; s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE); } else { - pci_dereg_ioat(pbdev->iommu); + pci_dereg_ioat(pbdev); if (reg_ioat(env, pbdev, fib, ra)) { cc =3D ZPCI_PCI_LS_ERR; s390_set_status_code(env, r1, ZPCI_MOD_ST_INSUF_RES); diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bu= s.h index eb15cb8b2d..a71f562dfc 100644 --- a/include/hw/s390x/s390-pci-bus.h +++ b/include/hw/s390x/s390-pci-bus.h @@ -276,7 +276,6 @@ struct S390PCIIOMMU { S390PCIBusDevice *pbdev; AddressSpace as; MemoryRegion mr; - IOMMUMemoryRegion iommu_mr; MemoryRegion *dm_mr; bool enabled; uint64_t g_iota; @@ -354,6 +353,7 @@ struct S390PCIBusDevice { S390MsixInfo msix; AdapterRoutes routes; S390PCIIOMMU *iommu; + IOMMUMemoryRegion iommu_mr; MemoryRegion msix_notify_mr; IndAddr *summary_ind; IndAddr *indicator; @@ -391,9 +391,9 @@ int pci_chsc_sei_nt2_have_event(void); void s390_pci_sclp_configure(SCCB *sccb); void s390_pci_sclp_deconfigure(SCCB *sccb); bool s390_pci_is_translation_enabled(uint64_t g_iota); -void s390_pci_iommu_enable(S390PCIIOMMU *iommu); +void s390_pci_iommu_enable(S390PCIBusDevice *pbdev); void s390_pci_iommu_direct_map_enable(S390PCIIOMMU *iommu); -void s390_pci_iommu_disable(S390PCIIOMMU *iommu); +void s390_pci_iommu_disable(S390PCIBusDevice *pbdev); void s390_pci_generate_error_event(uint16_t pec, uint32_t fh, uint32_t fid, uint64_t faddr, uint32_t e); uint16_t s390_guest_io_table_walk(uint64_t g_iota, hwaddr addr, diff --git a/include/hw/s390x/s390-pci-inst.h b/include/hw/s390x/s390-pci-i= nst.h index c782990e3b..38268c256e 100644 --- a/include/hw/s390x/s390-pci-inst.h +++ b/include/hw/s390x/s390-pci-inst.h @@ -99,7 +99,7 @@ typedef struct ZpciFib { } QEMU_PACKED ZpciFib; =20 int pci_dereg_irqs(S390PCIBusDevice *pbdev); -void pci_dereg_ioat(S390PCIIOMMU *iommu); +void pci_dereg_ioat(S390PCIBusDevice *pbdev); int clp_service_call(S390CPU *cpu, uint8_t r2, uintptr_t ra); int pcilg_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2, uintptr_t ra); int pcistg_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2, uintptr_t ra= ); @@ -111,7 +111,7 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint6= 4_t fiba, uint8_t ar, int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t = ar, uintptr_t ra); void fmb_timer_free(S390PCIBusDevice *pbdev); -uint32_t s390_pci_update_iotlb(S390PCIIOMMU *iommu, S390IOTLBEntry *entry); +uint32_t s390_pci_update_iotlb(S390PCIBusDevice *pbdev, S390IOTLBEntry *en= try); =20 #define ZPCI_IO_BAR_MIN 0 #define ZPCI_IO_BAR_MAX 5 --=20 2.34.1 From nobody Sun Jun 7 22:17:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1780625968; cv=none; d=zohomail.com; s=zohoarc; b=TAZPMBRR5I3awb92ANq7fGEbst+2u45CZS0ZCdsFIoD0/Gx4bQlDIIUNK9jTcRGMZj4+0eR1RI1YlAGDWoTKWX3qeOvMKFXp0OFnNjYpiihssXMJ2q5qKgAw6nbXYRpuHyQBc3gZ5OabUS1yhyadAHnb599b6QoJ64dWOCz0MAw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780625968; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UIaylNNXq0cHhJQSAtSXdaqx4JW2JxL8EaQybK7BT6I=; b=mviGamQgcCKVBYdlHYuxWgnGn08EPYkEBZ/kixudbIKo5+Ey9+pa3sloWaYBj78LQ/gakrmVjnf25uYR/y9KdKntysbwpSSfdix2edGigH9Y44qPsRlL+e7/ZVkmMOtpsknUv7kgGIGQr3WBgU41gnvE5xFUyNUwExqC/P/WKNA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780625968652610.1280535303104; Thu, 4 Jun 2026 19:19:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wVK81-0005Ix-0a; Thu, 04 Jun 2026 22:17:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK7z-0005HG-07; Thu, 04 Jun 2026 22:17:43 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK7w-0001lS-TZ; Thu, 04 Jun 2026 22:17:42 -0400 Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 654KkAPK1260942; Fri, 5 Jun 2026 02:17:36 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4efqd4jkhh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:35 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 655296uH029805; Fri, 5 Jun 2026 02:17:34 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4egcwyqdwv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:34 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6552HYbR6226668 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jun 2026 02:17:34 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 012055805D; Fri, 5 Jun 2026 02:17:34 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C8C8658068; Fri, 5 Jun 2026 02:17:33 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.ibm.com (unknown [9.61.240.22]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Jun 2026 02:17:33 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=UIaylNNXq0cHhJQSA tSXdaqx4JW2JxL8EaQybK7BT6I=; b=HOFm5t0pByI/5SiwJLLcrXkbbWGqC27HA f0L3HdbzMeq3HcpN0wjUT9v4fMJO/SbJv1peg9/QvHfc8T8zxixBytrbp9ZT1fO5 cRX+qfeVa/3sOZeGFfKp85A5AimnXdui2g6xiQ8FB0mZJHMRk8ej1HCBojRJ75Nf H73VQMk2tbayUND685g5sL/YmpizblkcX2a+a98uYgNbtY5YqBbGjLH3gYLRbsCU t6AHhjJ2MaQ+lBU1tKwk65FGnCOaiSFyctRiYProhA32/e9pv1qo0X0eS4w/k2tg HCU/g3W+n4hFvjbDSjKLNVE/Mw4gv52GCX3t+t0g4C97s+OOuveLg== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, richard.henderson@linaro.org, iii@linux.ibm.com, david@kernel.org, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Konstantin Shkolnyy Subject: [PATCH v3 04/15] s390x/pci: Move dm_mr from S390PCIIOMMU to S390PCIBusDevice Date: Thu, 4 Jun 2026 21:17:17 -0500 Message-Id: <20260605021728.1125090-5-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260605021728.1125090-1-kshk@linux.ibm.com> References: <20260605021728.1125090-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjA1MDAxOCBTYWx0ZWRfXwQDE6S06aQ89 IwQvSEP/ky2erD34EUgfAceqNxXmvPtQGP0l8uoPuS/Cj3OHm1fjkzAce5ygfW8ZxEuN4A5p+Yo We8sUzSsXiQsURasno3mFwmxSrYczn/Q65qtmUyspnAGAsQbtEUyq+0jKhDhsjIscSEvPl5oDAJ D72f7sa3/PuZJkGTrMAr/ywDCE8yUy7pkOIapzlJ9KcT1Ll16EexsC3sRId6xa+J0sBj2gb/m0L JfA28Hd5yRzhbg60mb6lcYgfA7dKqAMbsL1kwWJow4os4/o0gyV9UO8l1LIXLDDefz7VHHug7Ie 3E68mnl02ASyExJwynkrHKSHuYhPIb9FAJNUxRoFfW5f92XmQYTmUtmAfCZ7r4r1Ze+D/QYIv4m fHEsOLtU8Pdd7B8I03NaeIKeBhjdBmztkGdKtWDpd6nMUxjcTdJ2nRZg2spQuu4MzJVFs95y/5C sFIRHGR8jIFxvplPa8Q== X-Proofpoint-GUID: VZI0MhYO9sikhrBfJgRM2X4J0zRHQixb X-Proofpoint-ORIG-GUID: VZI0MhYO9sikhrBfJgRM2X4J0zRHQixb X-Authority-Analysis: v=2.4 cv=DZknbPtW c=1 sm=1 tr=0 ts=6a2231bf cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=FelO9ux0wxsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=jDWEBKAz6ZLYevfwb9sA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-04_07,2026-05-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 suspectscore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2606050018 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=kshk@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1780625970051154100 Content-Type: text/plain; charset="utf-8" This field is only used when S390PCIBusDevice exists, so it can be moved there to simplify S390PCIIOMMU which purpose is just to store the "root" AddressSpace. Signed-off-by: Konstantin Shkolnyy --- hw/s390x/s390-pci-bus.c | 21 +++++++++++---------- hw/s390x/s390-pci-inst.c | 2 +- include/hw/s390x/s390-pci-bus.h | 4 ++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 98f626b57f..f09d85da8f 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -604,7 +604,7 @@ static void s390_pci_ioat_replay(S390PCIBusDevice *pbde= v) curr =3D iommu->pba; end =3D iommu->pal; =20 - if (iommu->dm_mr) { + if (pbdev->dm_mr) { /* If direct mapping is used, there are no guest tables to replay = */ return; } @@ -790,8 +790,9 @@ void s390_pci_iommu_enable(S390PCIBusDevice *pbdev) g_free(name); } =20 -void s390_pci_iommu_direct_map_enable(S390PCIIOMMU *iommu) +void s390_pci_iommu_direct_map_enable(S390PCIBusDevice *pbdev) { + S390PCIIOMMU *iommu =3D pbdev->iommu; MachineState *ms =3D MACHINE(qdev_get_machine()); S390CcwMachineState *s390ms =3D S390_CCW_MACHINE(ms); =20 @@ -803,13 +804,13 @@ void s390_pci_iommu_direct_map_enable(S390PCIIOMMU *i= ommu) g_autofree char *name =3D g_strdup_printf("iommu-dm-s390-%04x", iommu->pbdev->uid); =20 - iommu->dm_mr =3D g_malloc0(sizeof(*iommu->dm_mr)); - memory_region_init_alias(iommu->dm_mr, OBJECT(&iommu->mr), name, + pbdev->dm_mr =3D g_malloc0(sizeof(*pbdev->dm_mr)); + memory_region_init_alias(pbdev->dm_mr, OBJECT(&iommu->mr), name, get_system_memory(), 0, s390_get_memory_limit(s390ms)); iommu->enabled =3D true; memory_region_add_subregion(&iommu->mr, iommu->pbdev->zpci_fn.sdma, - iommu->dm_mr); + pbdev->dm_mr); } =20 void s390_pci_iommu_disable(S390PCIBusDevice *pbdev) @@ -817,11 +818,11 @@ void s390_pci_iommu_disable(S390PCIBusDevice *pbdev) S390PCIIOMMU *iommu =3D pbdev->iommu; iommu->enabled =3D false; g_hash_table_remove_all(iommu->iotlb); - if (iommu->dm_mr) { - memory_region_del_subregion(&iommu->mr, iommu->dm_mr); - object_unparent(OBJECT(iommu->dm_mr)); - g_free(iommu->dm_mr); - iommu->dm_mr =3D NULL; + if (pbdev->dm_mr) { + memory_region_del_subregion(&iommu->mr, pbdev->dm_mr); + object_unparent(OBJECT(pbdev->dm_mr)); + g_free(pbdev->dm_mr); + pbdev->dm_mr =3D NULL; } else { memory_region_del_subregion(&iommu->mr, MEMORY_REGION(&pbdev->iommu_mr)); diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index ed60e6100e..834a0aec95 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -1034,7 +1034,7 @@ static int reg_ioat(CPUS390XState *env, S390PCIBusDev= ice *pbdev, ZpciFib fib, if (t) { s390_pci_iommu_enable(pbdev); } else { - s390_pci_iommu_direct_map_enable(iommu); + s390_pci_iommu_direct_map_enable(pbdev); } =20 return 0; diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bu= s.h index a71f562dfc..f310672584 100644 --- a/include/hw/s390x/s390-pci-bus.h +++ b/include/hw/s390x/s390-pci-bus.h @@ -276,7 +276,6 @@ struct S390PCIIOMMU { S390PCIBusDevice *pbdev; AddressSpace as; MemoryRegion mr; - MemoryRegion *dm_mr; bool enabled; uint64_t g_iota; uint64_t pba; @@ -354,6 +353,7 @@ struct S390PCIBusDevice { AdapterRoutes routes; S390PCIIOMMU *iommu; IOMMUMemoryRegion iommu_mr; + MemoryRegion *dm_mr; MemoryRegion msix_notify_mr; IndAddr *summary_ind; IndAddr *indicator; @@ -392,7 +392,7 @@ void s390_pci_sclp_configure(SCCB *sccb); void s390_pci_sclp_deconfigure(SCCB *sccb); bool s390_pci_is_translation_enabled(uint64_t g_iota); void s390_pci_iommu_enable(S390PCIBusDevice *pbdev); -void s390_pci_iommu_direct_map_enable(S390PCIIOMMU *iommu); +void s390_pci_iommu_direct_map_enable(S390PCIBusDevice *pbdev); void s390_pci_iommu_disable(S390PCIBusDevice *pbdev); void s390_pci_generate_error_event(uint16_t pec, uint32_t fh, uint32_t fid, uint64_t faddr, uint32_t e); --=20 2.34.1 From nobody Sun Jun 7 22:17:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1780625995; cv=none; d=zohomail.com; s=zohoarc; b=g2Ie3V95pFDF0YLSDqIdYom4bcRJTGtNTg+N3RSSIOZ2QruewQSv/hc8EPGw1LUSK5EWHqs1nNxt/aS4c3KBfw480qEu098u/RjTUrFHWHgrD55vocr7NEQDkU//VqSUkkT0JKuBnhjBbj/LanjkTHt4EEVOtyJYUNodydNpgLY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780625995; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sp03wwf9BkZT3FkYF5OTBqZYQ0HnN+j6Vfu+FLoJaDo=; b=evtOu0e2Je7/Hj9/BNra9oK4+L1gVtwb5sVResItdvFIn27ZSVutZE9ad0XGJ9rTjlbhWtZGdPQYCdEtpD9G422YKvzXAsgE/9nv6uCcm6gb2qSVyHmnmveeOytG3KfAz1WZAuXX2zmraY1Vfw9q5ouR+0SCUjPyX4rvV5utdqU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780625995689324.68607173123826; Thu, 4 Jun 2026 19:19:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wVK85-0005P9-Jl; Thu, 04 Jun 2026 22:17:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK80-0005I1-Db; Thu, 04 Jun 2026 22:17:44 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK7x-0001m7-O7; Thu, 04 Jun 2026 22:17:44 -0400 Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6550EM7S2061758; Fri, 5 Jun 2026 02:17:36 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4efqm5aem7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:36 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 655296T0010132; Fri, 5 Jun 2026 02:17:35 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4egb7kfsps-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:35 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6552HY6S24838676 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jun 2026 02:17:34 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2FDE158052; Fri, 5 Jun 2026 02:17:34 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 05B2958065; Fri, 5 Jun 2026 02:17:34 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.ibm.com (unknown [9.61.240.22]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Jun 2026 02:17:33 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=sp03wwf9BkZT3FkYF 5OTBqZYQ0HnN+j6Vfu+FLoJaDo=; b=CeFVwHJzYG6P4jsYXqfhmUsP02QQcPwLv O00mLh24bmB0ZkYgUsxgZZ6U5QcN0kxkoeXonRFFgsM8JXa0pOXuDvdEsQP/f/Er bZR2xmfr8tkoZ08m9HjzoacDAnK9ZTgcz9nAqegfjI0jSO/5mKG/L2hDy3bSmqm4 e49Mj2TnmWZIbE3WFYqp/hehDSmEEAiyrg9Ic53n3jI0iJkgQhCRo1q/G/UBrUyf sZdHfhU14AKe/6AloSwJTRvzD8HUXD7YS/oOSE+mJadkqbGYNTL59Mi16AScv22r LZlBGASe7hi6QfbBOl0rR08Yx1Fde2PPYtZk5V4nZSTDBXMzgsNWA== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, richard.henderson@linaro.org, iii@linux.ibm.com, david@kernel.org, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Konstantin Shkolnyy Subject: [PATCH v3 05/15] s390x/pci: Move iotlb from S390PCIIOMMU to S390PCIBusDevice Date: Thu, 4 Jun 2026 21:17:18 -0500 Message-Id: <20260605021728.1125090-6-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260605021728.1125090-1-kshk@linux.ibm.com> References: <20260605021728.1125090-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ruXMDHoogNZpMyxZ_HxZVAtwvx_Bn7qq X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjA1MDAxOCBTYWx0ZWRfXwCBlGMJ2WXtT QY/bujg/iVwKnmQ6/ZxCCzjDQfGT8keDPlhSAncRw3Zm3nt021JSk0AAY49A4cc21Y6TICzM9Qn 5Llldj99pi7c1ql39Q3LVGCptsIYOTMgIvMOCl/wNjb5arMPXXYcuWOj1cNKAV29uK+YHEba2Wt iFVfefxJLXRb1zkO48TswknCidBqEo+OW6cwmizpxfZhGOJyi/ZAEemK3R7AVSlDBYgHS2X9YyA inA5QIKoMnYqzDXD5I3mS1DLMg4A1VNK+hvCo+G8pKw7ZrwzTQtHNuqYNDB0Jzv6UZhA70quUdT /m/ryFMHbA1IIHINTiJzI/L6SbjYwqnrGH0e/KN7YfKblKvs3bHK8w3RyKfs/OK7Utzi3JnHT3t jCKht1MMoxHfL4goxIiXmI3CZ3NrOOkvwD/aGYjWv+beeta7w3d+DGseomwx2UPnLdtO6lapPPt cvRH2q8PfZFDROUIjxA== X-Proofpoint-ORIG-GUID: ruXMDHoogNZpMyxZ_HxZVAtwvx_Bn7qq X-Authority-Analysis: v=2.4 cv=Vf3H+lp9 c=1 sm=1 tr=0 ts=6a2231c0 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=FelO9ux0wxsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=frKy0Gi9Nncm8Rs_nZ4A:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-04_07,2026-05-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 adultscore=0 bulkscore=0 impostorscore=0 phishscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2606050018 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=kshk@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1780625997788158500 Content-Type: text/plain; charset="utf-8" This field is only used when S390PCIBusDevice exists, so it can be moved there to simplify S390PCIIOMMU which purpose is just to store the "root" AddressSpace. Signed-off-by: Konstantin Shkolnyy --- hw/s390x/s390-pci-bus.c | 10 +++++----- hw/s390x/s390-pci-inst.c | 6 +++--- include/hw/s390x/s390-pci-bus.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index f09d85da8f..34dcc7c3bd 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -569,7 +569,7 @@ static IOMMUTLBEntry s390_translate_iommu(IOMMUMemoryRe= gion *mr, hwaddr addr, goto err; } =20 - entry =3D g_hash_table_lookup(iommu->iotlb, &iova); + entry =3D g_hash_table_lookup(pbdev->iotlb, &iova); if (entry) { ret.iova =3D entry->iova; ret.translated_addr =3D entry->translated_addr; @@ -681,8 +681,6 @@ static S390PCIIOMMU *s390_pci_get_iommu(S390pciState *s= , PCIBus *bus, PCI_FUNC(devfn)); memory_region_init(&iommu->mr, OBJECT(iommu), mr_name, UINT64_MAX); address_space_init(&iommu->as, &iommu->mr, as_name); - iommu->iotlb =3D g_hash_table_new_full(g_int64_hash, g_int64_equal, - NULL, g_free); table->iommu[PCI_SLOT(devfn)] =3D iommu; =20 g_free(mr_name); @@ -817,7 +815,7 @@ void s390_pci_iommu_disable(S390PCIBusDevice *pbdev) { S390PCIIOMMU *iommu =3D pbdev->iommu; iommu->enabled =3D false; - g_hash_table_remove_all(iommu->iotlb); + g_hash_table_remove_all(pbdev->iotlb); if (pbdev->dm_mr) { memory_region_del_subregion(&iommu->mr, pbdev->dm_mr); object_unparent(OBJECT(pbdev->dm_mr)); @@ -841,7 +839,6 @@ static void s390_pci_iommu_free(S390pciState *s, PCIBus= *bus, int32_t devfn) } =20 table->iommu[PCI_SLOT(devfn)] =3D NULL; - g_hash_table_destroy(iommu->iotlb); /* * An attached PCI device may have memory listeners, eg. VFIO PCI. * The associated subregion will already have been unmapped in @@ -1263,6 +1260,8 @@ static void s390_pcihost_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, /* the allocated idx is actually getting used */ s->next_idx =3D (pbdev->idx + 1) & FH_MASK_INDEX; pbdev->fh =3D pbdev->idx; + pbdev->iotlb =3D g_hash_table_new_full(g_int64_hash, g_int64_equal, + NULL, g_free); QTAILQ_INSERT_TAIL(&s->zpci_devs, pbdev, link); g_hash_table_insert(s->zpci_table, &pbdev->idx, pbdev); } else { @@ -1305,6 +1304,7 @@ static void s390_pcihost_unplug(HotplugHandler *hotpl= ug_dev, DeviceState *dev, if (pbdev->iommu && pbdev->iommu->dma_limit) { s390_pci_end_dma_count(s, pbdev->iommu->dma_limit); } + g_hash_table_destroy(pbdev->iotlb); qdev_unrealize(dev); } } diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index 834a0aec95..8349b44dd4 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -617,7 +617,7 @@ uint32_t s390_pci_update_iotlb(S390PCIBusDevice *pbdev, S390IOTLBEntry *entry) { S390PCIIOMMU *iommu =3D pbdev->iommu; - S390IOTLBEntry *cache =3D g_hash_table_lookup(iommu->iotlb, &entry->io= va); + S390IOTLBEntry *cache =3D g_hash_table_lookup(pbdev->iotlb, &entry->io= va); IOMMUTLBEvent event =3D { .type =3D entry->perm ? IOMMU_NOTIFIER_MAP : IOMMU_NOTIFIER_UNMAP, .entry =3D { @@ -633,7 +633,7 @@ uint32_t s390_pci_update_iotlb(S390PCIBusDevice *pbdev, if (!cache) { goto out; } - g_hash_table_remove(iommu->iotlb, &entry->iova); + g_hash_table_remove(pbdev->iotlb, &entry->iova); inc_dma_avail(iommu); /* Don't notify the iommu yet, maybe we can bundle contiguous unma= ps */ goto out; @@ -656,7 +656,7 @@ uint32_t s390_pci_update_iotlb(S390PCIBusDevice *pbdev, cache->translated_addr =3D entry->translated_addr; cache->len =3D TARGET_PAGE_SIZE; cache->perm =3D entry->perm; - g_hash_table_replace(iommu->iotlb, &cache->iova, cache); + g_hash_table_replace(pbdev->iotlb, &cache->iova, cache); dec_dma_avail(iommu); } =20 diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bu= s.h index f310672584..d9bafd6859 100644 --- a/include/hw/s390x/s390-pci-bus.h +++ b/include/hw/s390x/s390-pci-bus.h @@ -281,7 +281,6 @@ struct S390PCIIOMMU { uint64_t pba; uint64_t pal; uint64_t max_dma_limit; - GHashTable *iotlb; S390PCIDMACount *dma_limit; }; =20 @@ -354,6 +353,7 @@ struct S390PCIBusDevice { S390PCIIOMMU *iommu; IOMMUMemoryRegion iommu_mr; MemoryRegion *dm_mr; + GHashTable *iotlb; MemoryRegion msix_notify_mr; IndAddr *summary_ind; IndAddr *indicator; --=20 2.34.1 From nobody Sun Jun 7 22:17:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1780625918; cv=none; d=zohomail.com; s=zohoarc; b=EQZVE/efCd7QgL7G+1QMXlPowBnIvjHj41FRr25M917R/Ge08RHCzRlfH4fsl8qh/y33g5t/lU021fGaKhGfFLM2kar4xcz9NaiJi4/aC434wyVWewgPbIgcgLKEz6068VYUYj6zbu/qvDmYndeK+fY7ZsHlqiBKioKkvcnoq7Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780625918; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=S/tTamghUevwWDC6rcH4H69UqETHLaclMR2oHQE2rNY=; b=fKGIA7zqzO89uL54I+M14bY0/s7vh3amGFs3f5XVji7PLvT1CJoaR3fcwuBVnAOnn4k1DCMj2iR4jxOBGRxpUzWxaMyzi7U5V2SFFKApUpzxNEu7qJ+UNRFL0fGRtWlllRkZ3KjvwLqQy9rH0DYSsJ+uhw+FBEjxoGKvUVoPr7U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780625918559934.7426705742298; Thu, 4 Jun 2026 19:18:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wVK82-0005L0-Ai; Thu, 04 Jun 2026 22:17:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK80-0005He-5w; Thu, 04 Jun 2026 22:17:44 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK7x-0001lx-K9; Thu, 04 Jun 2026 22:17:43 -0400 Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 654G9DGn2841744; Fri, 5 Jun 2026 02:17:36 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4efnaj21ae-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:36 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 65529D5a029852; Fri, 5 Jun 2026 02:17:35 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4egcwyqdwy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:35 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6552HY0W24838678 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jun 2026 02:17:34 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5F49B58052; Fri, 5 Jun 2026 02:17:34 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3544C5805D; Fri, 5 Jun 2026 02:17:34 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.ibm.com (unknown [9.61.240.22]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Jun 2026 02:17:34 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=S/tTamghUevwWDC6r cH4H69UqETHLaclMR2oHQE2rNY=; b=VRA6TSMhddYwWewkAdeP5iQGn98uDYTK0 qZujjQ0hU1rhhW/xmjF7utbpB6ZP06BkOjMFvg1yJ5U0MFyH43S3ZKNpcjaexOlD uBJ/dq8JweDXQkKmjPE5qSmDs3288NNKa8CrtnQVqhZamp05iFsIGT3nKVfZNoMz PLWTrs4WZHaYYulnWdiy7wPPKytv0vT39nG07XCLI1+RliBcqE6dwaNHi3xiXQ5K sME32mnBZ7evE9CjrpeSHQmvNWU4KkmYFBDnvrPhP9GSz7iULwwXLigWcZSngWy1 yrPrWXtYKj8YXebsAhiHNYRgVBPc5ZvqqPyBrZc/aOo2ErGH5f9aQ== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, richard.henderson@linaro.org, iii@linux.ibm.com, david@kernel.org, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Konstantin Shkolnyy Subject: [PATCH v3 06/15] s390x/pci: Remove a ptr to S390PCIBusDevice from S390PCIIOMMU Date: Thu, 4 Jun 2026 21:17:19 -0500 Message-Id: <20260605021728.1125090-7-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260605021728.1125090-1-kshk@linux.ibm.com> References: <20260605021728.1125090-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjA1MDAxOCBTYWx0ZWRfX5xEMXJjC+eqe nQqx2dv59k/Vo9Ck8Au2q+qP55lQ6UTYiw+nN3lCtvvMXra81XeAlV5w8GS3ef/tEWG2CVDTBYm wB+ee7B7x6LQtnDUGZbtTUVMB1M6lmdgcCCApfRyTe5k9D91E+feZxwgor1EswTYezWl7LEDokB TGqsjy6PjuBW/cvm3A8Hlm4zJJyINL82HVSFrT+WT155Nki4hHPq/26okW2aQZrFT650JBLbQnV B5h8nscsOVCnxevN+8Wqycya6+n3UD+xYG8kNjz9ubNYtO6nr4u6ujQgfr+OrSNpj5/QYD9iMBc xD9mcwwF7z20ZeK201z+8FiIK5e+dsKT8eWAbY5YbuyH4s7erCDhXm5oSHmY5ptpMwW5d5k9UF/ ZSipH+RwyJF0qbEaJfi2QmeDZidyKXIc0g4YnQgPmPVmwAOy4KDrVm6yxZUYQj6UDzuNc7oun5X 0N1v1VwyBAvJJO6uxQA== X-Proofpoint-ORIG-GUID: QUH_-Al4c59Q_V-l_cVhBQDwwM456-QN X-Authority-Analysis: v=2.4 cv=cOzQdFeN c=1 sm=1 tr=0 ts=6a2231c0 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=FelO9ux0wxsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=yINFAIt2aqTEABBYJGoA:9 X-Proofpoint-GUID: QUH_-Al4c59Q_V-l_cVhBQDwwM456-QN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-04_07,2026-05-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 spamscore=0 bulkscore=0 malwarescore=0 phishscore=0 suspectscore=0 priorityscore=1501 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2606050018 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=kshk@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1780625919735158500 Content-Type: text/plain; charset="utf-8" This pointer is no longer used, after fields were moved from S390PCIIOMMU to S390PCIBusDevice. Signed-off-by: Konstantin Shkolnyy --- hw/s390x/s390-pci-bus.c | 15 +++++++-------- include/hw/s390x/s390-pci-bus.h | 1 - 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 34dcc7c3bd..21455d9233 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -551,7 +551,7 @@ static IOMMUTLBEntry s390_translate_iommu(IOMMUMemoryRe= gion *mr, hwaddr addr, .perm =3D IOMMU_NONE, }; =20 - switch (iommu->pbdev->state) { + switch (pbdev->state) { case ZPCI_FS_ENABLED: case ZPCI_FS_BLOCKED: if (!iommu->enabled) { @@ -586,9 +586,9 @@ static IOMMUTLBEntry s390_translate_iommu(IOMMUMemoryRe= gion *mr, hwaddr addr, } err: if (error) { - iommu->pbdev->state =3D ZPCI_FS_ERROR; - s390_pci_generate_error_event(error, iommu->pbdev->fh, - iommu->pbdev->fid, addr, 0); + pbdev->state =3D ZPCI_FS_ERROR; + s390_pci_generate_error_event(error, pbdev->fh, + pbdev->fid, addr, 0); } return ret; } @@ -779,7 +779,7 @@ void s390_pci_iommu_enable(S390PCIBusDevice *pbdev) * so the smallest IOMMU region we can define runs from 0 to the end * of the PCI address space. */ - char *name =3D g_strdup_printf("iommu-s390-%04x", iommu->pbdev->uid); + char *name =3D g_strdup_printf("iommu-s390-%04x", pbdev->uid); memory_region_init_iommu(&pbdev->iommu_mr, sizeof(pbdev->iommu_mr), TYPE_S390_IOMMU_MEMORY_REGION, OBJECT(&iommu-= >mr), name, iommu->pal + 1); @@ -800,14 +800,14 @@ void s390_pci_iommu_direct_map_enable(S390PCIBusDevic= e *pbdev) * IOVA X + SDMA. VFIO will handle pinning via its memory listener. */ g_autofree char *name =3D g_strdup_printf("iommu-dm-s390-%04x", - iommu->pbdev->uid); + pbdev->uid); =20 pbdev->dm_mr =3D g_malloc0(sizeof(*pbdev->dm_mr)); memory_region_init_alias(pbdev->dm_mr, OBJECT(&iommu->mr), name, get_system_memory(), 0, s390_get_memory_limit(s390ms)); iommu->enabled =3D true; - memory_region_add_subregion(&iommu->mr, iommu->pbdev->zpci_fn.sdma, + memory_region_add_subregion(&iommu->mr, pbdev->zpci_fn.sdma, pbdev->dm_mr); } =20 @@ -1199,7 +1199,6 @@ static void s390_pcihost_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, =20 pbdev->pdev =3D pdev; pbdev->iommu =3D s390_pci_get_iommu(s, pci_get_bus(pdev), pdev->de= vfn); - pbdev->iommu->pbdev =3D pbdev; pbdev->state =3D ZPCI_FS_DISABLED; set_pbdev_info(pbdev); =20 diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bu= s.h index d9bafd6859..fcaaf19512 100644 --- a/include/hw/s390x/s390-pci-bus.h +++ b/include/hw/s390x/s390-pci-bus.h @@ -273,7 +273,6 @@ typedef struct S390PCIDMACount { =20 struct S390PCIIOMMU { Object parent_obj; - S390PCIBusDevice *pbdev; AddressSpace as; MemoryRegion mr; bool enabled; --=20 2.34.1 From nobody Sun Jun 7 22:17:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1780626008; cv=none; d=zohomail.com; s=zohoarc; b=UXMfr2vRw4TZqjWDQ2frV9K6KA9mBWtc6Ip2uobxL1crBvQd6bp767xcfn1qgfmJ5bFnJovZY2r2JxyAYh49SQObHsuUuGEt+tM2ZT86n8SPVPPBVASsJyt5wKzGF6VirM+QPj9T3wEhXKnr8hAPmn+vctQQRsFaQECCivmln1Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780626008; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GUZWUPev3WujroXLTOkvx/fjGGVWtZypC0zZqpplTXU=; b=HfFqz/t+s1nCWliPNXoiO7IQHRh4Fj819Zj+kxnlEYCCNKzF87/k1gHQWJTL00lpYA12CkfYFuHj8Ii3tsMllR3cZeKnPs1izVqqaHdgS7307cBSmqciWPB/+x+uHm4RZPHYPDUX6AbAOoK7O0c0/HgmDulRQFMgorvyMsQEfDQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780626008423203.79257721501006; Thu, 4 Jun 2026 19:20:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wVK85-0005PC-OA; Thu, 04 Jun 2026 22:17:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK83-0005Ls-3s; Thu, 04 Jun 2026 22:17:47 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK7z-0001mc-1P; Thu, 04 Jun 2026 22:17:46 -0400 Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6551ZCoH1268894; Fri, 5 Jun 2026 02:17:36 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4efqjqjf1m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:36 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 655295Nn030509; Fri, 5 Jun 2026 02:17:35 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4ega7qqx3j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:35 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6552HYNp24838680 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jun 2026 02:17:34 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9011558052; Fri, 5 Jun 2026 02:17:34 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6498A58056; Fri, 5 Jun 2026 02:17:34 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.ibm.com (unknown [9.61.240.22]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Jun 2026 02:17:34 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=GUZWUPev3WujroXLT Okvx/fjGGVWtZypC0zZqpplTXU=; b=JyL5xibsMPcmaaZbaxrJjbS3j1OFPEaIs 7+TaWEr2p+OLWKTheG5QZgl+iLWxx406GBiqyJZp529MwRG0IDCwRSOytqsPTosJ 5hbizXKW9e/SgAJlAUf5Hb7+RmFxaOIAZurZtcyG3E5NgLksbI/tqlltX4yoHI9b j4mEYfgjlmDrAwkBwLAFvzFdJNlAtrebdGFvzWKY/L4T50BEkhKjhkOGUtBLCbuI 3TzfWVuJ1oVkf0JQ1sZTsWJrcEjNY3WLFN0jgDyAjeHA0AVJ1JVAaQyd+KnW0zIK IgkjGw8lpLgRGPwvaRPCiurSxRS7KAkJlAQrfJpI/5ozDXl7zNlew== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, richard.henderson@linaro.org, iii@linux.ibm.com, david@kernel.org, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Konstantin Shkolnyy Subject: [PATCH v3 07/15] s390x/pci: Move/rename enabled from S390PCIIOMMU to S390PCIBusDevice Date: Thu, 4 Jun 2026 21:17:20 -0500 Message-Id: <20260605021728.1125090-8-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260605021728.1125090-1-kshk@linux.ibm.com> References: <20260605021728.1125090-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: c9WgZBilgm4Lf89o_uImXWL9XmNcc4cX X-Proofpoint-GUID: c9WgZBilgm4Lf89o_uImXWL9XmNcc4cX X-Authority-Analysis: v=2.4 cv=bcVbluPB c=1 sm=1 tr=0 ts=6a2231c0 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=FelO9ux0wxsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=i0DCopz73FH-yKe2uwYA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjA1MDAxOCBTYWx0ZWRfX00PNKv94lfcf cpMuo3B7IFEAJOFCNqZWenecX2fn9zdkgfbTtCkNGFFZhzWRBbHxRIloxR6v6Ftvwg0rGgx6Oq6 Qo152UMN7ptW3vFXsGpJBzuflCiiEzDCEESrjZ8ihGYw1vVIzh611cMGFtHysgM/GPxEdfQi2nP 8vZcPHUBTEPovXBU0BtMOQdo7pIIAouJ56b6Z/ahsvq/Gq/3WWfPnnGorG0D7MbCZKXzXLIubZx O9bNft/zXhIlCjFrvziyLeVvycKP9+v9PPRw9m/Rtb9La6/YjVtkPuN+A8eXqgeJ5EWh/5d04+f HMFBJomt5lYrk7pZG8uMt6JXwTDXa3aIC6zokiZd1xe5fWdEWNSusnT2LmBVRberU4eQe06nBJN pQZYdoPYm6YK4wmdyhJLPiOvkTLpnM+RkGosqS+PSiiD6PgKUgWsOEcx3+AlD4r8taP4KfkneMr x8Bhy9Pxwtpb3Z3nWHQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-04_07,2026-05-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 adultscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2606050018 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=kshk@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1780626010574154100 Content-Type: text/plain; charset="utf-8" This field is only used when S390PCIBusDevice exists, so it can be moved there to simplify S390PCIIOMMU which purpose is just to store the "root" AddressSpace. This also allows to save/restore this field during migration. Signed-off-by: Konstantin Shkolnyy --- hw/s390x/s390-pci-bus.c | 14 +++++++------- hw/s390x/s390-pci-inst.c | 8 ++++---- include/hw/s390x/s390-pci-bus.h | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 21455d9233..ccbccc8972 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -205,7 +205,7 @@ void s390_pci_sclp_deconfigure(SCCB *sccb) } else if (pbdev->summary_ind) { pci_dereg_irqs(pbdev); } - if (pbdev->iommu->enabled) { + if (pbdev->iommu_enabled) { pci_dereg_ioat(pbdev); } pbdev->state =3D ZPCI_FS_STANDBY; @@ -554,7 +554,7 @@ static IOMMUTLBEntry s390_translate_iommu(IOMMUMemoryRe= gion *mr, hwaddr addr, switch (pbdev->state) { case ZPCI_FS_ENABLED: case ZPCI_FS_BLOCKED: - if (!iommu->enabled) { + if (!pbdev->iommu_enabled) { return ret; } break; @@ -783,7 +783,7 @@ void s390_pci_iommu_enable(S390PCIBusDevice *pbdev) memory_region_init_iommu(&pbdev->iommu_mr, sizeof(pbdev->iommu_mr), TYPE_S390_IOMMU_MEMORY_REGION, OBJECT(&iommu-= >mr), name, iommu->pal + 1); - iommu->enabled =3D true; + pbdev->iommu_enabled =3D true; memory_region_add_subregion(&iommu->mr, 0, MEMORY_REGION(&pbdev->iommu= _mr)); g_free(name); } @@ -806,7 +806,7 @@ void s390_pci_iommu_direct_map_enable(S390PCIBusDevice = *pbdev) memory_region_init_alias(pbdev->dm_mr, OBJECT(&iommu->mr), name, get_system_memory(), 0, s390_get_memory_limit(s390ms)); - iommu->enabled =3D true; + pbdev->iommu_enabled =3D true; memory_region_add_subregion(&iommu->mr, pbdev->zpci_fn.sdma, pbdev->dm_mr); } @@ -814,7 +814,7 @@ void s390_pci_iommu_direct_map_enable(S390PCIBusDevice = *pbdev) void s390_pci_iommu_disable(S390PCIBusDevice *pbdev) { S390PCIIOMMU *iommu =3D pbdev->iommu; - iommu->enabled =3D false; + pbdev->iommu_enabled =3D false; g_hash_table_remove_all(pbdev->iotlb); if (pbdev->dm_mr) { memory_region_del_subregion(&iommu->mr, pbdev->dm_mr); @@ -1423,7 +1423,7 @@ static void s390_pcihost_reset(DeviceState *dev) } else if (pbdev->summary_ind) { pci_dereg_irqs(pbdev); } - if (pbdev->iommu->enabled) { + if (pbdev->iommu_enabled) { pci_dereg_ioat(pbdev); } pbdev->state =3D ZPCI_FS_STANDBY; @@ -1564,7 +1564,7 @@ static void s390_pci_device_reset(DeviceState *dev) } else if (pbdev->summary_ind) { pci_dereg_irqs(pbdev); } - if (pbdev->iommu->enabled) { + if (pbdev->iommu_enabled) { pci_dereg_ioat(pbdev); } =20 diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index 8349b44dd4..4458eae681 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -1251,7 +1251,7 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uin= t64_t fiba, uint8_t ar, if (dmaas !=3D 0) { cc =3D ZPCI_PCI_LS_ERR; s390_set_status_code(env, r1, ZPCI_MOD_ST_DMAAS_INVAL); - } else if (pbdev->iommu->enabled) { + } else if (pbdev->iommu_enabled) { cc =3D ZPCI_PCI_LS_ERR; s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE); } else if (reg_ioat(env, pbdev, fib, ra)) { @@ -1263,7 +1263,7 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uin= t64_t fiba, uint8_t ar, if (dmaas !=3D 0) { cc =3D ZPCI_PCI_LS_ERR; s390_set_status_code(env, r1, ZPCI_MOD_ST_DMAAS_INVAL); - } else if (!pbdev->iommu->enabled) { + } else if (!pbdev->iommu_enabled) { cc =3D ZPCI_PCI_LS_ERR; s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE); } else { @@ -1274,7 +1274,7 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uin= t64_t fiba, uint8_t ar, if (dmaas !=3D 0) { cc =3D ZPCI_PCI_LS_ERR; s390_set_status_code(env, r1, ZPCI_MOD_ST_DMAAS_INVAL); - } else if (!pbdev->iommu->enabled) { + } else if (!pbdev->iommu_enabled) { cc =3D ZPCI_PCI_LS_ERR; s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE); } else { @@ -1404,7 +1404,7 @@ int stpcifc_service_call(S390CPU *cpu, uint8_t r1, ui= nt64_t fiba, uint8_t ar, /* fallthrough */ case ZPCI_FS_ENABLED: fib.fc |=3D 0x80; - if (pbdev->iommu->enabled) { + if (pbdev->iommu_enabled) { fib.fc |=3D 0x10; } if (!(fh & FH_MASK_ENABLE)) { diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bu= s.h index fcaaf19512..24f6e60786 100644 --- a/include/hw/s390x/s390-pci-bus.h +++ b/include/hw/s390x/s390-pci-bus.h @@ -275,7 +275,6 @@ struct S390PCIIOMMU { Object parent_obj; AddressSpace as; MemoryRegion mr; - bool enabled; uint64_t g_iota; uint64_t pba; uint64_t pal; @@ -350,6 +349,7 @@ struct S390PCIBusDevice { S390MsixInfo msix; AdapterRoutes routes; S390PCIIOMMU *iommu; + bool iommu_enabled; IOMMUMemoryRegion iommu_mr; MemoryRegion *dm_mr; GHashTable *iotlb; --=20 2.34.1 From nobody Sun Jun 7 22:17:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1780625919; cv=none; d=zohomail.com; s=zohoarc; b=DfuQjnD4LsRp94JVkooo2MZBjeDz/mb6y9Xo/rHAYTUZJzb/7+FzyMUx0ZYs9NLY0TbTm2iR3GNspkp6idt7CvAkcH90VVMu/te84sWkx8NHLqGxsmNphugqjiOPmJHZpHHFQYQagbWBrD7rI/Bt1RFlXvtKR8PnJcNYxrabk1U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780625919; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/8719CYMB7cCjlmQaPPooZc+MU3l/kHaf/Ric8dTqZU=; b=QFayKKGmyAVUqLilzSLjso4Ccdo71mkzn7IRfkrga+gU9oVJhOXKurhgLIxW6CbJf1RklqEcfsa/Mcy8fQOiq9yqbKchVb6u3m9ZfMwRhKf6HWlWkIN95be7ppZSwM5yTQs1NZEpwTaaEbMg2X43t7mCxm3XS6Yssk4NfGgvMdA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780625918998606.856928301795; Thu, 4 Jun 2026 19:18:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wVK82-0005LP-QB; Thu, 04 Jun 2026 22:17:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK81-0005Jj-IJ; Thu, 04 Jun 2026 22:17:45 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK7y-0001mP-JY; Thu, 04 Jun 2026 22:17:45 -0400 Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 654KG4Qa2665699; Fri, 5 Jun 2026 02:17:36 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4efqhtht0n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:36 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 65529C7u009455; Fri, 5 Jun 2026 02:17:35 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4egbqhqncf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:35 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6552HYnK24838682 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jun 2026 02:17:34 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C1AE958052; Fri, 5 Jun 2026 02:17:34 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 958B75805D; Fri, 5 Jun 2026 02:17:34 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.ibm.com (unknown [9.61.240.22]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Jun 2026 02:17:34 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=/8719CYMB7cCjlmQa PPooZc+MU3l/kHaf/Ric8dTqZU=; b=e6idUXGcQmyBxWmG//QNOUhMl/+ldZo7r Jz2dXCubE5SbUG7NdQ7KquA0Nyu3+YRhQoJU935HxkYeC4Q0D40deKMKfwpQvkzp S3wN404T4+h/ENzTzinV0dIrkZn3s3dAWsJlD3O6j94tq/HVOO+Hd5S7J0uYnurn qgT3VH45poJ7ibmOBDo0vxlXDKH3NS60fxySW+0QC+r5mZio5XDNwg3GeOKEcOcj ACfxIxDDK3kEwZEwCBMlZbcT8drn0n/gCfruCkb2YOxDO6nb/gMg0DPCPNfcm+Jo aQjgLgIUH0YpGeynWlhAesZ7Tqzo378Jerwh9Amgi1aDiMJ+nZDYQ== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, richard.henderson@linaro.org, iii@linux.ibm.com, david@kernel.org, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Konstantin Shkolnyy Subject: [PATCH v3 08/15] s390x/pci: Move dma_limit from S390PCIIOMMU to S390PCIBusDevice Date: Thu, 4 Jun 2026 21:17:21 -0500 Message-Id: <20260605021728.1125090-9-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260605021728.1125090-1-kshk@linux.ibm.com> References: <20260605021728.1125090-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: MTiidoZ38NgrsEzdTn-lu7MLfXkPAUwG X-Authority-Analysis: v=2.4 cv=fv/sol4f c=1 sm=1 tr=0 ts=6a2231c0 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=FelO9ux0wxsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=NXusJeJlOfVlo0NZOjUA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjA1MDAxOCBTYWx0ZWRfXzuY6D0GX1BPL 5ATzesk1Qcgq0pLVkzOUgdTG1x/EeEjHcr+e3do/ZhHdD2Nv1SH5hS2WjyzUkP/A0tC3yd4AyhD LjDqoRbYmmlH0pHvFfrLGJ6bWvmqeN4TULUcYtRu/SSPNBFv3DECBw0vbeyftzAQ4nd67YbVyP0 Qf9o/nGl4E+EKj2VAh2+5cjMAIDfEuJ5fYArzTEpIsPzpxhC0kGT9uNgQh/b/Pjr0/7svWP7AEE EGmWcUXEqY20FmKSvOtNFzcYjOtpVJ0cb5GtnS9acWqz1IYlNRjLfh1WW0Ifkt5VupfNvLfKTgg 2I1Ftl/9KQ5DUooHAf43z+NYP8psfDKlnqnLlXVUCYBZrHYEpHahaRW6t7ubU0ms0eGicTrk+uJ X7tvSCmKbChqeGiXRSm9B+fzNaCZiHqzy/YX7cTrdxkDy+vxV9PEB36/7YjDCLPPQKK8JGTVk/9 29HTcggbUlCtixK4bTA== X-Proofpoint-ORIG-GUID: MTiidoZ38NgrsEzdTn-lu7MLfXkPAUwG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-04_07,2026-05-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 spamscore=0 phishscore=0 clxscore=1015 impostorscore=0 suspectscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2606050018 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=kshk@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1780625921325158500 Content-Type: text/plain; charset="utf-8" This field is only used when S390PCIBusDevice exists, so it can be moved there to simplify S390PCIIOMMU which purpose is just to store the "root" AddressSpace. Signed-off-by: Konstantin Shkolnyy --- hw/s390x/s390-pci-bus.c | 10 +++++----- hw/s390x/s390-pci-inst.c | 23 +++++++++++------------ include/hw/s390x/s390-pci-bus.h | 2 +- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index ccbccc8972..f70aaf4425 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -609,8 +609,8 @@ static void s390_pci_ioat_replay(S390PCIBusDevice *pbde= v) return; } =20 - if (iommu->dma_limit) { - dma_avail =3D iommu->dma_limit->avail; + if (pbdev->dma_limit) { + dma_avail =3D pbdev->dma_limit->avail; } else { dma_avail =3D 1; } @@ -1222,7 +1222,7 @@ static void s390_pcihost_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, pbdev->forwarding_assist =3D false; } } - pbdev->iommu->dma_limit =3D s390_pci_start_dma_count(s, pbdev); + pbdev->dma_limit =3D s390_pci_start_dma_count(s, pbdev); /* Fill in CLP information passed via the vfio region */ s390_pci_get_clp_info(pbdev); if (!pbdev->interp) { @@ -1300,8 +1300,8 @@ static void s390_pcihost_unplug(HotplugHandler *hotpl= ug_dev, DeviceState *dev, pbdev->fid =3D 0; QTAILQ_REMOVE(&s->zpci_devs, pbdev, link); g_hash_table_remove(s->zpci_table, &pbdev->idx); - if (pbdev->iommu && pbdev->iommu->dma_limit) { - s390_pci_end_dma_count(s, pbdev->iommu->dma_limit); + if (pbdev->dma_limit) { + s390_pci_end_dma_count(s, pbdev->dma_limit); } g_hash_table_destroy(pbdev->iotlb); qdev_unrealize(dev); diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index 4458eae681..ac4e7f412d 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -28,17 +28,17 @@ =20 #include "trace.h" =20 -static inline void inc_dma_avail(S390PCIIOMMU *iommu) +static inline void inc_dma_avail(S390PCIBusDevice *pbdev) { - if (iommu->dma_limit) { - iommu->dma_limit->avail++; + if (pbdev->dma_limit) { + pbdev->dma_limit->avail++; } } =20 -static inline void dec_dma_avail(S390PCIIOMMU *iommu) +static inline void dec_dma_avail(S390PCIBusDevice *pbdev) { - if (iommu->dma_limit) { - iommu->dma_limit->avail--; + if (pbdev->dma_limit) { + pbdev->dma_limit->avail--; } } =20 @@ -616,7 +616,6 @@ int pcistg_service_call(S390CPU *cpu, uint8_t r1, uint8= _t r2, uintptr_t ra) uint32_t s390_pci_update_iotlb(S390PCIBusDevice *pbdev, S390IOTLBEntry *entry) { - S390PCIIOMMU *iommu =3D pbdev->iommu; S390IOTLBEntry *cache =3D g_hash_table_lookup(pbdev->iotlb, &entry->io= va); IOMMUTLBEvent event =3D { .type =3D entry->perm ? IOMMU_NOTIFIER_MAP : IOMMU_NOTIFIER_UNMAP, @@ -634,7 +633,7 @@ uint32_t s390_pci_update_iotlb(S390PCIBusDevice *pbdev, goto out; } g_hash_table_remove(pbdev->iotlb, &entry->iova); - inc_dma_avail(iommu); + inc_dma_avail(pbdev); /* Don't notify the iommu yet, maybe we can bundle contiguous unma= ps */ goto out; } else { @@ -657,7 +656,7 @@ uint32_t s390_pci_update_iotlb(S390PCIBusDevice *pbdev, cache->len =3D TARGET_PAGE_SIZE; cache->perm =3D entry->perm; g_hash_table_replace(pbdev->iotlb, &cache->iova, cache); - dec_dma_avail(iommu); + dec_dma_avail(pbdev); } =20 /* @@ -667,7 +666,7 @@ uint32_t s390_pci_update_iotlb(S390PCIBusDevice *pbdev, memory_region_notify_iommu(&pbdev->iommu_mr, 0, event); =20 out: - return iommu->dma_limit ? iommu->dma_limit->avail : 1; + return pbdev->dma_limit ? pbdev->dma_limit->avail : 1; } =20 static void s390_pci_batch_unmap(S390PCIBusDevice *pbdev, uint64_t iova, @@ -744,8 +743,8 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_= t r2, uintptr_t ra) } =20 iommu =3D pbdev->iommu; - if (iommu->dma_limit) { - dma_avail =3D iommu->dma_limit->avail; + if (pbdev->dma_limit) { + dma_avail =3D pbdev->dma_limit->avail; } else { dma_avail =3D 1; } diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bu= s.h index 24f6e60786..126a50c98b 100644 --- a/include/hw/s390x/s390-pci-bus.h +++ b/include/hw/s390x/s390-pci-bus.h @@ -279,7 +279,6 @@ struct S390PCIIOMMU { uint64_t pba; uint64_t pal; uint64_t max_dma_limit; - S390PCIDMACount *dma_limit; }; =20 typedef struct S390PCIIOMMUTable { @@ -353,6 +352,7 @@ struct S390PCIBusDevice { IOMMUMemoryRegion iommu_mr; MemoryRegion *dm_mr; GHashTable *iotlb; + S390PCIDMACount *dma_limit; MemoryRegion msix_notify_mr; IndAddr *summary_ind; IndAddr *indicator; --=20 2.34.1 From nobody Sun Jun 7 22:17:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1780625918; cv=none; d=zohomail.com; s=zohoarc; b=hfXuuJkh7N+iUyE3ygGLO+OkReD0V3fv4QRs6J1Xgk4oBd41YkPqvP0738e5VkVm4yM91rWOi1iv2QgzVFe9ER1r5ZtROAHScMqvQvZae6YkfpKbWHLgYflLU2bbwynrzjQeu0Cz6yCflJ5D/ypiTlRLbJYmHAqfy0xcAmsMTnM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780625918; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2+5lWx+qr0Jqf2r2E+XX+jWd3PfpTQSq5ezvrZXEdVo=; b=HijudiUh//dDBn0SKxkNYYU2eqFamNKKpfRxHgJ96DDvKJHwQSti0wxtGNIB/zz2McuCSmKTwRiwYUlbnK6ml+JwjIWxreU74wvM5b84FiO1T8x69A6MMe8Pa3sYY+h422G4oq7CV9PibQWGRB1rkqmSWkOO2dMCaY08A1ciDeE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780625918830297.03475967805275; Thu, 4 Jun 2026 19:18:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wVK86-0005QF-S7; Thu, 04 Jun 2026 22:17:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK83-0005MZ-Db; Thu, 04 Jun 2026 22:17:47 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK7z-0001mv-F8; Thu, 04 Jun 2026 22:17:47 -0400 Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 654Gohsq569575; Fri, 5 Jun 2026 02:17:37 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4efqd4jkhm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:36 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 65529BRP029835; Fri, 5 Jun 2026 02:17:35 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4egcwyqdx1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:35 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6552HZBB14746350 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jun 2026 02:17:35 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F215A58052; Fri, 5 Jun 2026 02:17:34 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C734558056; Fri, 5 Jun 2026 02:17:34 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.ibm.com (unknown [9.61.240.22]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Jun 2026 02:17:34 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=2+5lWx+qr0Jqf2r2E +XX+jWd3PfpTQSq5ezvrZXEdVo=; b=Bs9yiT8zFqZN3KJ7NzWFTxSR70KPXPiTF f1tNCU9/BRo6oC5x30XzEs/Y4oNwVxzR5cVMsQVBL7hu2/puLzBBCKPzbsvm81ez 8NJEFe57p8xZGZZgGnZJJWqluqcK3TU+p+ZEObpnW0rQqvwPYwi9RE2Mmxfwbvoy vG9/XaUgoyfJxr5AlqaW5PV+YJ3hFjniRV6xV1V9HYGvuI72jIFpfqNZZ2CIPFk1 VEwJxKYOMXpdODIEyXlftsSOlXor1ftzxDMq01I56Zf0HvA44m72+vJ/cPwFmvzO H8Rn2GtwuzXXlLyPcn+X7IEXML+Ii8NMY4PwVmpSY4S5HTtGXPIcg== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, richard.henderson@linaro.org, iii@linux.ibm.com, david@kernel.org, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Konstantin Shkolnyy Subject: [PATCH v3 09/15] s390x/pci: Move g_iota from S390PCIIOMMU to S390PCIBusDevice Date: Thu, 4 Jun 2026 21:17:22 -0500 Message-Id: <20260605021728.1125090-10-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260605021728.1125090-1-kshk@linux.ibm.com> References: <20260605021728.1125090-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjA1MDAxOCBTYWx0ZWRfX4Or0oVehERJK b2PA5mcU8kDKY9+x3/tuJsqditRoplU2DJZwXn5WZeO+f/rqs9ydjy2XvSU77LnlsKG/+f/ucc+ Y9SgSFIJj4+Gtima0u0QglXWAXBUki0ARURXyQsqdgOjBKe/8Ft0MGWbFyznxU1yU1ohoefPfyR V3Oi9njxmCsXVmTvV11CKu4edX8GSeF8Icafe7yUxpnqdQGBym5MGgqBnuIM127UaL8lcd/5IJl 4ibVpzGYwa5SjvCWYfiQuPjYwPCW8OB/2+YIsHw5Mdaxzs9RpzAK34J/urMlM2Cx8aVjcOfG64g FkL8guY0Ju6geZYBcZijq4aQ0ktc7VgJPG0KvHoNctRXXbWsQQv6UqWZwyrRQkXIoFlUecOqe8V QShod87TtHDgw2OCcApseE6naKhiQfIPPAXQI2FkpLmtTRm06UrZofqeHNtCVa0/MfPisfg7Lr8 ZRr6pz4hhfO/RkGWbvQ== X-Proofpoint-GUID: Ab7YQJT5wxbHvFPslVMAeWPiZC8j7pV1 X-Proofpoint-ORIG-GUID: Ab7YQJT5wxbHvFPslVMAeWPiZC8j7pV1 X-Authority-Analysis: v=2.4 cv=DZknbPtW c=1 sm=1 tr=0 ts=6a2231c0 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=FelO9ux0wxsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=FDQAEqGjsTQLeQouP1gA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-04_07,2026-05-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 suspectscore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2606050018 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=kshk@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1780625919770158500 Content-Type: text/plain; charset="utf-8" This field is only used when S390PCIBusDevice exists, so it can be moved there to simplify S390PCIIOMMU which purpose is just to store the "root" AddressSpace. This also allows to save/restore this field during migration. Signed-off-by: Konstantin Shkolnyy --- hw/s390x/s390-pci-bus.c | 2 +- hw/s390x/s390-pci-inst.c | 10 +++++----- include/hw/s390x/s390-pci-bus.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index f70aaf4425..3acd15ee0a 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -616,7 +616,7 @@ static void s390_pci_ioat_replay(S390PCIBusDevice *pbde= v) } =20 while (curr < end) { - error =3D s390_guest_io_table_walk(iommu->g_iota, curr, &entry); + error =3D s390_guest_io_table_walk(pbdev->g_iota, curr, &entry); if (error) { pbdev->state =3D ZPCI_FS_ERROR; s390_pci_generate_error_event(error, pbdev->fh, pbdev->fid, cu= rr, diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index ac4e7f412d..f4ec299614 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -748,7 +748,7 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_= t r2, uintptr_t ra) } else { dma_avail =3D 1; } - if (!iommu->g_iota) { + if (!pbdev->g_iota) { error =3D ERR_EVENT_INVALAS; goto err; } @@ -762,7 +762,7 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_= t r2, uintptr_t ra) start =3D sstart; again =3D false; while (start < end) { - error =3D s390_guest_io_table_walk(iommu->g_iota, start, &entry); + error =3D s390_guest_io_table_walk(pbdev->g_iota, start, &entry); if (error) { break; } @@ -1028,7 +1028,7 @@ static int reg_ioat(CPUS390XState *env, S390PCIBusDev= ice *pbdev, ZpciFib fib, =20 iommu->pba =3D pba; iommu->pal =3D pal; - iommu->g_iota =3D g_iota; + pbdev->g_iota =3D g_iota; =20 if (t) { s390_pci_iommu_enable(pbdev); @@ -1045,7 +1045,7 @@ void pci_dereg_ioat(S390PCIBusDevice *pbdev) s390_pci_iommu_disable(pbdev); iommu->pba =3D 0; iommu->pal =3D 0; - iommu->g_iota =3D 0; + pbdev->g_iota =3D 0; } =20 void fmb_timer_free(S390PCIBusDevice *pbdev) @@ -1418,7 +1418,7 @@ int stpcifc_service_call(S390CPU *cpu, uint8_t r1, ui= nt64_t fiba, uint8_t ar, =20 stq_be_p(&fib.pba, pbdev->iommu->pba); stq_be_p(&fib.pal, pbdev->iommu->pal); - stq_be_p(&fib.iota, pbdev->iommu->g_iota); + stq_be_p(&fib.iota, pbdev->g_iota); stq_be_p(&fib.aibv, pbdev->routes.adapter.ind_addr); stq_be_p(&fib.aisb, pbdev->routes.adapter.summary_addr); stq_be_p(&fib.fmb_addr, pbdev->fmb_addr); diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bu= s.h index 126a50c98b..a7d1f1ade2 100644 --- a/include/hw/s390x/s390-pci-bus.h +++ b/include/hw/s390x/s390-pci-bus.h @@ -275,7 +275,6 @@ struct S390PCIIOMMU { Object parent_obj; AddressSpace as; MemoryRegion mr; - uint64_t g_iota; uint64_t pba; uint64_t pal; uint64_t max_dma_limit; @@ -352,6 +351,7 @@ struct S390PCIBusDevice { IOMMUMemoryRegion iommu_mr; MemoryRegion *dm_mr; GHashTable *iotlb; + uint64_t g_iota; S390PCIDMACount *dma_limit; MemoryRegion msix_notify_mr; IndAddr *summary_ind; --=20 2.34.1 From nobody Sun Jun 7 22:17:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1780626004; cv=none; d=zohomail.com; s=zohoarc; b=d8rLvz8ZyeOtyVhHISWwakoGOXpT3S2pBPWngtbrScSxQzY4plSNBAXblv360J/aA9cIDkm+iVuuCZ+qIH6KDVdNfRhHj3m2btLzTn16Gm/rgzZDePiXz5SHFy6qY3EXAwzKA2BBJQQi8u+yn7uwCZD6ZUpranclb0pyijeSA+8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780626004; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JEv6EbVInQgX5oWqNI4k0/yMfWrQCm7uy4nN+gJFiHI=; b=SutGJL8PMzMIhMfbQ3OD1xJuU0U7X7Iciv5+Rs5wH5Wz2iZ0ZpjclCtqykqnUj6/hgHckFE57nKMY9c12TrShMZcg3foawJnHU3r2a9Nfwgd0/XE/hU192pvRjKHZIGE5SflPp7Bk78EfTS9K0h+ih0tjaHrhauTndOB6RyNRzw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780626004575858.4096867612974; Thu, 4 Jun 2026 19:20:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wVK84-0005NY-Bt; Thu, 04 Jun 2026 22:17:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK81-0005JN-CZ; Thu, 04 Jun 2026 22:17:45 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK7y-0001mN-Ig; Thu, 04 Jun 2026 22:17:45 -0400 Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 655104Of1080233; Fri, 5 Jun 2026 02:17:37 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4efqhtht0p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:36 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 65529GRY030561; Fri, 5 Jun 2026 02:17:36 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4ega7qqx3k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:36 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6552HZXR28639782 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jun 2026 02:17:35 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2EEA158065; Fri, 5 Jun 2026 02:17:35 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0383C5805D; Fri, 5 Jun 2026 02:17:35 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.ibm.com (unknown [9.61.240.22]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Jun 2026 02:17:34 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=JEv6EbVInQgX5oWqN I4k0/yMfWrQCm7uy4nN+gJFiHI=; b=iHSFkQx17hrGDb6Sl1i6ccncFpN9d4+QP oKKy1thcWoZE/BjVG5dzWtiMJAQiu4NICJU2JKW9AHgOtbA04S5V5wJaAeR/OsFW c+eblqkuAvIPMFMbqI4osmyLoZqlGN26t7B6UpIFRtMVIKWRrh4LH+yEUD0IoGhU 1wUS8hycXl8a2r/0CMgRmJv/V1qdiU4sC3lOgjVuZgD7CE6T2hey3CyzPmyLlW2B LZBkgEau/THg8+B1ZiYNfa8RWAHrnnP2iZ8bepGIMB9dVRdO4EAIUCgJXse+eCbw kbascpV2QN1bNcLNMFg+fXBUfUI/RSHr4NIBJpgCjLl4QH9r18wuA== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, richard.henderson@linaro.org, iii@linux.ibm.com, david@kernel.org, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Konstantin Shkolnyy Subject: [PATCH v3 10/15] s390x/pci: Move pba from S390PCIIOMMU to S390PCIBusDevice Date: Thu, 4 Jun 2026 21:17:23 -0500 Message-Id: <20260605021728.1125090-11-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260605021728.1125090-1-kshk@linux.ibm.com> References: <20260605021728.1125090-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: qGldNdWlYwiCL4qH2s30sE46CfsotaEy X-Authority-Analysis: v=2.4 cv=fv/sol4f c=1 sm=1 tr=0 ts=6a2231c0 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=FelO9ux0wxsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=THYS1zffzJpO_GefUMYA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjA1MDAxOCBTYWx0ZWRfX6pjaf+ESnKJB gBIwURW8TBsF5dLkCj8AXuVLuL0cLvgHET3W/lm7/hh4+Jdq75Np0apkltg2zQPZdmrta/0G2pD 8rztlvZ+IN1W1eAFQ3H/9m/mza5xQCgaF9+xHqpHNLaw+gEt1APnOyW/Tm197rqfYK+j2+HWjwY Ddj7tl5ADKmgsR82rHnkn52xdLlWfwKfC/C3w+k4uLpxQL2DBkleUfiDlPCRriklS6fdAoeONZC rLCOxF9vRTNvzzmL6dqXRS3btp1KMNgbCl4AV7G0Ocoods3f1NFnZL1ogkHtu3Deuze9Bl+gHWy duOY7N2tiR+kkwTOwITdm1NS3jQYrmiiw802k4o42Y398abDgFA089QsJAb3zS3qyKJki5tLA4v GVhwPPafolkZ3U+HHViFhRJ5LKfEWd5WzRwjN7wyL4Yu8s7lqKK6+SUhwlje3Kbvwv8qauB/7yg +nUCBqqcPtr391hEyBQ== X-Proofpoint-ORIG-GUID: qGldNdWlYwiCL4qH2s30sE46CfsotaEy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-04_07,2026-05-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 spamscore=0 phishscore=0 clxscore=1015 impostorscore=0 suspectscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2606050018 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=kshk@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1780626006581154100 Content-Type: text/plain; charset="utf-8" This field is only used when S390PCIBusDevice exists, so it can be moved there to simplify S390PCIIOMMU which purpose is just to store the "root" AddressSpace. This also allows to save/restore this field during migration. Signed-off-by: Konstantin Shkolnyy --- hw/s390x/s390-pci-bus.c | 4 ++-- hw/s390x/s390-pci-inst.c | 8 ++++---- include/hw/s390x/s390-pci-bus.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 3acd15ee0a..b7d350606c 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -564,7 +564,7 @@ static IOMMUTLBEntry s390_translate_iommu(IOMMUMemoryRe= gion *mr, hwaddr addr, =20 trace_s390_pci_iommu_xlate(addr); =20 - if (addr < iommu->pba || addr > iommu->pal) { + if (addr < pbdev->pba || addr > iommu->pal) { error =3D ERR_EVENT_OORANGE; goto err; } @@ -601,7 +601,7 @@ static void s390_pci_ioat_replay(S390PCIBusDevice *pbde= v) hwaddr curr, end; S390PCIIOMMU *iommu =3D pbdev->iommu; =20 - curr =3D iommu->pba; + curr =3D pbdev->pba; end =3D iommu->pal; =20 if (pbdev->dm_mr) { diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index f4ec299614..7680d87080 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -753,7 +753,7 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_= t r2, uintptr_t ra) goto err; } =20 - if (end < iommu->pba || start > iommu->pal) { + if (end < pbdev->pba || start > iommu->pal) { error =3D ERR_EVENT_OORANGE; goto err; } @@ -1026,7 +1026,7 @@ static int reg_ioat(CPUS390XState *env, S390PCIBusDev= ice *pbdev, ZpciFib fib, return -EINVAL; } =20 - iommu->pba =3D pba; + pbdev->pba =3D pba; iommu->pal =3D pal; pbdev->g_iota =3D g_iota; =20 @@ -1043,7 +1043,7 @@ void pci_dereg_ioat(S390PCIBusDevice *pbdev) { S390PCIIOMMU *iommu =3D pbdev->iommu; s390_pci_iommu_disable(pbdev); - iommu->pba =3D 0; + pbdev->pba =3D 0; iommu->pal =3D 0; pbdev->g_iota =3D 0; } @@ -1416,7 +1416,7 @@ int stpcifc_service_call(S390CPU *cpu, uint8_t r1, ui= nt64_t fiba, uint8_t ar, return 0; } =20 - stq_be_p(&fib.pba, pbdev->iommu->pba); + stq_be_p(&fib.pba, pbdev->pba); stq_be_p(&fib.pal, pbdev->iommu->pal); stq_be_p(&fib.iota, pbdev->g_iota); stq_be_p(&fib.aibv, pbdev->routes.adapter.ind_addr); diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bu= s.h index a7d1f1ade2..42f39a5cf0 100644 --- a/include/hw/s390x/s390-pci-bus.h +++ b/include/hw/s390x/s390-pci-bus.h @@ -275,7 +275,6 @@ struct S390PCIIOMMU { Object parent_obj; AddressSpace as; MemoryRegion mr; - uint64_t pba; uint64_t pal; uint64_t max_dma_limit; }; @@ -352,6 +351,7 @@ struct S390PCIBusDevice { MemoryRegion *dm_mr; GHashTable *iotlb; uint64_t g_iota; + uint64_t pba; S390PCIDMACount *dma_limit; MemoryRegion msix_notify_mr; IndAddr *summary_ind; --=20 2.34.1 From nobody Sun Jun 7 22:17:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1780625923; cv=none; d=zohomail.com; s=zohoarc; b=KOXY34zd8VFfbm2aiVm2V/BO7Quuj9HSRCRH1Ev5lPozMURaDBq4dNU33i08PBeP+dVHZs07cRD4P6D38ilvYb4CsmNDkFsUtX2xGjBrMXV87/lIIlf+OBcapmZOatCMF+O/9fBvd7XI74oL/aEqrQ71LlPHv1Xu3ywhDWQb45w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780625923; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gr0yjRdPygI5icD+0H1WNUov2F7URKmcV/b0fT9JaHw=; b=Eyl4A8UM+MU4RW7GqhLCQYMwL5ESnp11jU/Lc36db0U0wX63pTjPSP1WL6a8tNgn/+E0zwuYTSiQC+CqYeyOmn/ua3u/Qx3zeGS8RqbeEk3poibBgEsPJMkTAwlSxfW/ywxEEY13eizffdaFpaaxAwyxJJRzoI/hQZ2gROzeA6A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780625923561566.1585667446028; Thu, 4 Jun 2026 19:18:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wVK84-0005OE-TB; Thu, 04 Jun 2026 22:17:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK82-0005Kk-59; Thu, 04 Jun 2026 22:17:46 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK7y-0001ma-Qd; Thu, 04 Jun 2026 22:17:45 -0400 Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6551ZvUa2292567; Fri, 5 Jun 2026 02:17:37 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4efqjqjf1n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:37 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 6552940x025273; Fri, 5 Jun 2026 02:17:36 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4egcegyh10-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:36 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6552HZmM31523454 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jun 2026 02:17:35 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5F37458052; Fri, 5 Jun 2026 02:17:35 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 344AE58067; Fri, 5 Jun 2026 02:17:35 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.ibm.com (unknown [9.61.240.22]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Jun 2026 02:17:35 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=gr0yjRdPygI5icD+0 H1WNUov2F7URKmcV/b0fT9JaHw=; b=rvObHkwemdXBn6mWqN9Nd71Zn0iV11aHh GZxF8J5NhPbCcym9uGqHEW7osHmnsSlEn7lZApCJBJHeohdvcnHEhwPl4mfWKUrg D2iGnVqJ/FWMQuqirwdRb1udJqioudLrzwqKeCzu1pQG//oGS1vrg11R/B9mJRPA 8eG+O9KuX23P4m/tiLOmeLgeduc6/FA6SHiW5m74zQENMT8/joSOjf/MroSFsuf0 3PXjAMe31m2qgYq2yWLAWXKyrd6xuYm+sQ/QXYWBolHkH0LFsW/IFS5m6sRBV2nQ v0Tf5KVxK1xvuvPz2SAALyVaGKnfTwbARHtwDz+y640V3eJKUzw5w== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, richard.henderson@linaro.org, iii@linux.ibm.com, david@kernel.org, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Konstantin Shkolnyy Subject: [PATCH v3 11/15] s390x/pci: Move pal from S390PCIIOMMU to S390PCIBusDevice Date: Thu, 4 Jun 2026 21:17:24 -0500 Message-Id: <20260605021728.1125090-12-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260605021728.1125090-1-kshk@linux.ibm.com> References: <20260605021728.1125090-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: yikHBZDgrkvfme9Yh6srmlXy86iaGfCe X-Proofpoint-GUID: yikHBZDgrkvfme9Yh6srmlXy86iaGfCe X-Authority-Analysis: v=2.4 cv=bcVbluPB c=1 sm=1 tr=0 ts=6a2231c1 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=FelO9ux0wxsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=WfwOUNX5pORHP_P-vIkA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjA1MDAxOCBTYWx0ZWRfX0C/llXnLpSvn OIZiPOV7PuMg9Zj8DAGwO8zLn4a4zZxuuq4ZWPVngO2qCQQy5GRvumRoiZBYkdeRjM5874gVNjC Ym8OxiB4i9k2UfZOZdQwd7tnGW67qQW/CAtZS0XCfhyk4Yjb1FoMmHgTaKauiWy2j6rwwq/cXD+ yToIIKRRqDOBuaiU5j2pFKC6+dMzo5RookZCXfWZd7T2N8TGLrkiLEJrIipGceVV7G7uo4tx++0 lBFeew6DMmw4UJCx3Xzh6aMwr2S6GCeOeIih/UcK2h/J6Ru9uWWiEeA2vVa36hvu+GEdtHDlnaX LWW0N3Sm4KnHVDZF2+VpOnGbNQvnZRJApthm+VNsBCvp9yN9HHOyuzu4k68ZFvtxCtpkucnoQKu w9XJOlr4kceujJi9ukGkV9hq8p54lKKU8CQG9CUiORbspq0nzCv9MBxSFlIW4PfKUgE8x+LMJ1m 1pf3DeC4ZmWY58+7fRw== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-04_07,2026-05-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 adultscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2606050018 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=kshk@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1780625925803154100 Content-Type: text/plain; charset="utf-8" This field is only used when S390PCIBusDevice exists, so it can be moved there to simplify S390PCIIOMMU which purpose is just to store the "root" AddressSpace. This also allows to save/restore this field during migration. Signed-off-by: Konstantin Shkolnyy --- hw/s390x/s390-pci-bus.c | 8 +++----- hw/s390x/s390-pci-inst.c | 12 ++++-------- include/hw/s390x/s390-pci-bus.h | 2 +- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index b7d350606c..8505abcc90 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -539,7 +539,6 @@ static IOMMUTLBEntry s390_translate_iommu(IOMMUMemoryRe= gion *mr, hwaddr addr, IOMMUAccessFlags flag, int iommu= _idx) { S390PCIBusDevice *pbdev =3D container_of(mr, S390PCIBusDevice, iommu_m= r); - S390PCIIOMMU *iommu =3D pbdev->iommu; S390IOTLBEntry *entry; uint64_t iova =3D addr & TARGET_PAGE_MASK; uint16_t error =3D 0; @@ -564,7 +563,7 @@ static IOMMUTLBEntry s390_translate_iommu(IOMMUMemoryRe= gion *mr, hwaddr addr, =20 trace_s390_pci_iommu_xlate(addr); =20 - if (addr < pbdev->pba || addr > iommu->pal) { + if (addr < pbdev->pba || addr > pbdev->pal) { error =3D ERR_EVENT_OORANGE; goto err; } @@ -599,10 +598,9 @@ static void s390_pci_ioat_replay(S390PCIBusDevice *pbd= ev) uint16_t error =3D 0; uint32_t dma_avail; hwaddr curr, end; - S390PCIIOMMU *iommu =3D pbdev->iommu; =20 curr =3D pbdev->pba; - end =3D iommu->pal; + end =3D pbdev->pal; =20 if (pbdev->dm_mr) { /* If direct mapping is used, there are no guest tables to replay = */ @@ -782,7 +780,7 @@ void s390_pci_iommu_enable(S390PCIBusDevice *pbdev) char *name =3D g_strdup_printf("iommu-s390-%04x", pbdev->uid); memory_region_init_iommu(&pbdev->iommu_mr, sizeof(pbdev->iommu_mr), TYPE_S390_IOMMU_MEMORY_REGION, OBJECT(&iommu-= >mr), - name, iommu->pal + 1); + name, pbdev->pal + 1); pbdev->iommu_enabled =3D true; memory_region_add_subregion(&iommu->mr, 0, MEMORY_REGION(&pbdev->iommu= _mr)); g_free(name); diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index 7680d87080..191f549ba7 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -700,7 +700,6 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_= t r2, uintptr_t ra) uint32_t fh; uint16_t error =3D 0; S390PCIBusDevice *pbdev; - S390PCIIOMMU *iommu; S390IOTLBEntry entry; hwaddr start, end, sstart; uint32_t dma_avail; @@ -742,7 +741,6 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_= t r2, uintptr_t ra) break; } =20 - iommu =3D pbdev->iommu; if (pbdev->dma_limit) { dma_avail =3D pbdev->dma_limit->avail; } else { @@ -753,7 +751,7 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_= t r2, uintptr_t ra) goto err; } =20 - if (end < pbdev->pba || start > iommu->pal) { + if (end < pbdev->pba || start > pbdev->pal) { error =3D ERR_EVENT_OORANGE; goto err; } @@ -1001,7 +999,6 @@ bool s390_pci_is_translation_enabled(uint64_t g_iota) static int reg_ioat(CPUS390XState *env, S390PCIBusDevice *pbdev, ZpciFib f= ib, uintptr_t ra) { - S390PCIIOMMU *iommu =3D pbdev->iommu; uint64_t pba =3D ldq_be_p(&fib.pba); uint64_t pal =3D ldq_be_p(&fib.pal); uint64_t g_iota =3D ldq_be_p(&fib.iota); @@ -1027,7 +1024,7 @@ static int reg_ioat(CPUS390XState *env, S390PCIBusDev= ice *pbdev, ZpciFib fib, } =20 pbdev->pba =3D pba; - iommu->pal =3D pal; + pbdev->pal =3D pal; pbdev->g_iota =3D g_iota; =20 if (t) { @@ -1041,10 +1038,9 @@ static int reg_ioat(CPUS390XState *env, S390PCIBusDe= vice *pbdev, ZpciFib fib, =20 void pci_dereg_ioat(S390PCIBusDevice *pbdev) { - S390PCIIOMMU *iommu =3D pbdev->iommu; s390_pci_iommu_disable(pbdev); pbdev->pba =3D 0; - iommu->pal =3D 0; + pbdev->pal =3D 0; pbdev->g_iota =3D 0; } =20 @@ -1417,7 +1413,7 @@ int stpcifc_service_call(S390CPU *cpu, uint8_t r1, ui= nt64_t fiba, uint8_t ar, } =20 stq_be_p(&fib.pba, pbdev->pba); - stq_be_p(&fib.pal, pbdev->iommu->pal); + stq_be_p(&fib.pal, pbdev->pal); stq_be_p(&fib.iota, pbdev->g_iota); stq_be_p(&fib.aibv, pbdev->routes.adapter.ind_addr); stq_be_p(&fib.aisb, pbdev->routes.adapter.summary_addr); diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bu= s.h index 42f39a5cf0..1f5d8d4bd4 100644 --- a/include/hw/s390x/s390-pci-bus.h +++ b/include/hw/s390x/s390-pci-bus.h @@ -275,7 +275,6 @@ struct S390PCIIOMMU { Object parent_obj; AddressSpace as; MemoryRegion mr; - uint64_t pal; uint64_t max_dma_limit; }; =20 @@ -352,6 +351,7 @@ struct S390PCIBusDevice { GHashTable *iotlb; uint64_t g_iota; uint64_t pba; + uint64_t pal; S390PCIDMACount *dma_limit; MemoryRegion msix_notify_mr; IndAddr *summary_ind; --=20 2.34.1 From nobody Sun Jun 7 22:17:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1780625967; cv=none; d=zohomail.com; s=zohoarc; b=mvbEU5lgYwjWv/YA8CT8fHA09vaps81Smw4enbc7S/IAZwldbg4A8GRNrj3iAidrKOZKBZqWqwMTijrY7O7XBgns0ayBl/9vomk0EKIXBCuVGaH0LSJL9n+el9VAYCfC72e2/liTdNViemwebfNSCYZJEJcnZLkLHr652xSl05E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780625967; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=21wAnetksnyEMKaYwFAGBSun5+/pbul82YOTNXBd9SY=; b=iof9QRofv/1HctkHVia5mjU7PXiVWaebhPJSRFlpr32KYDmndQsBnQIVV3q0F7HsKJ6i2DxXYWy6Dig1kPUuaUYSQrI76ZwlLVrQsV2U8kJd0seuuhnL9VHmwU4svulQDqtbNYmG8YDRkCFgVJHHTuHg4DaU+23P2YXyx06PRT8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780625967073563.0848684778987; Thu, 4 Jun 2026 19:19:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wVK85-0005Oa-4i; Thu, 04 Jun 2026 22:17:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK81-0005JW-Hk; Thu, 04 Jun 2026 22:17:45 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK7y-0001mQ-JZ; Thu, 04 Jun 2026 22:17:45 -0400 Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 654HQBPo3444108; Fri, 5 Jun 2026 02:17:38 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4efqd4jkhn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:37 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 655296Mx010128; Fri, 5 Jun 2026 02:17:36 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4egb7kfspx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:36 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6552HZFc31523456 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jun 2026 02:17:35 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8F6DE58052; Fri, 5 Jun 2026 02:17:35 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6478D58056; Fri, 5 Jun 2026 02:17:35 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.ibm.com (unknown [9.61.240.22]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Jun 2026 02:17:35 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=21wAnetksnyEMKaYw FAGBSun5+/pbul82YOTNXBd9SY=; b=UnCW6ZCMJSe2j1CWZ9kKK+iqS0kzpx8rf 9uSV59dkacxlWaHMtPZiqWWc90cWtQmeEywFk3q5cpOZISMpgP6vT0Vptj2qYwCT xn8T+Up+6yaneqYRk7QPwbAQk0rnGCR9/8rc5zcS5ErXBKYAvmBH3SvTKNChSv5B A9TdCMrrJNBdAWdlzOL84IHUp+b91rRzDywFPf6Sr7y2VTV25PeSl3rbVxNWkPy0 4YRDHxz3VcCX1twvlLKBVOPaQbJC4RJLIqPDTMr/MiSkyiTwr9o2l3zBEWTn1W4q 2ulLvhKgtYMq8Vt+IkvJnaJxhA406bKuqUJQiq+XWE/RNYkOgI/oA== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, richard.henderson@linaro.org, iii@linux.ibm.com, david@kernel.org, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Konstantin Shkolnyy Subject: [PATCH v3 12/15] s390x/pci: Move max_dma_limit from S390PCIIOMMU to S390PCIBusDevice Date: Thu, 4 Jun 2026 21:17:25 -0500 Message-Id: <20260605021728.1125090-13-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260605021728.1125090-1-kshk@linux.ibm.com> References: <20260605021728.1125090-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjA1MDAxOCBTYWx0ZWRfX9qIoHBpf0NnW 3ZsAIGdkAsEsW9Ygvc1pktDfoIgWVzRwFeKGJQ05YhRoMS0dAguhB3/no54T7CTd30CI3Hu9gys dgaYI1zhnEzOPBjDJJiG9Tv/9TAj2JB5pXLOfkBwxFnTDBByoYrxqaJ4cqxevANhEDzaVHaMbdC VOAwBpEjvZ+BuRb48KG+h8zoP/oDZzrhqowbD4LuQEZDCLGgq1YAK8GcpwfOlfjq4gxeR4SD8pq nsOqSJjEEcR3i5FepIdeuQn4U+ILo1SjseDycIE76hoAQYTkSp7O7VV4TI3WMw0TMIowGSeMOcN n6/vjxb6cIJxDt/0ATtAwc/5aP1LjFx0LT57giHC7L8RH5gaSn70wmWG6CkUcYLNszJTRcL9xWS Na/zA0cYhwYH36gr5yCpcVCiqILbqEehOxJQTnoWVOeXQNbtlKyyLAuMyvXCOTaWAZq99Ywf0/u dOUN02cVZHYql2LNW3w== X-Proofpoint-GUID: GDMgd9loATVyREYyhHTuctk3W-wSYwUg X-Proofpoint-ORIG-GUID: GDMgd9loATVyREYyhHTuctk3W-wSYwUg X-Authority-Analysis: v=2.4 cv=DZknbPtW c=1 sm=1 tr=0 ts=6a2231c2 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=FelO9ux0wxsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=YlvBUofuDPas7G3Xl8cA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-04_07,2026-05-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 suspectscore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2606050018 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=kshk@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1780625970028154100 Content-Type: text/plain; charset="utf-8" This field is only used when S390PCIBusDevice exists, so it can be moved there to simplify S390PCIIOMMU which purpose is just to store the "root" AddressSpace. This also allows to save/restore this field during migration. Signed-off-by: Konstantin Shkolnyy --- hw/s390x/s390-pci-vfio.c | 4 ++-- include/hw/s390x/s390-pci-bus.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/s390x/s390-pci-vfio.c b/hw/s390x/s390-pci-vfio.c index 7c754b656d..093743f2f0 100644 --- a/hw/s390x/s390-pci-vfio.c +++ b/hw/s390x/s390-pci-vfio.c @@ -90,7 +90,7 @@ S390PCIDMACount *s390_pci_start_dma_count(S390pciState *s, cnt->users =3D 1; cnt->avail =3D avail; QTAILQ_INSERT_TAIL(&s->zpci_dma_limit, cnt, link); - pbdev->iommu->max_dma_limit =3D avail; + pbdev->max_dma_limit =3D avail; return cnt; } =20 @@ -151,7 +151,7 @@ static void s390_pci_read_base(S390PCIBusDevice *pbdev, * to request that the guest free DMA mappings as necessary. */ if (!pbdev->rtr_avail) { - vfio_size =3D pbdev->iommu->max_dma_limit << qemu_target_page_bits= (); + vfio_size =3D pbdev->max_dma_limit << qemu_target_page_bits(); if (vfio_size > 0 && vfio_size < cap->end_dma - cap->start_dma + 1= ) { pbdev->zpci_fn.edma =3D cap->start_dma + vfio_size - 1; } diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bu= s.h index 1f5d8d4bd4..e3cbee2695 100644 --- a/include/hw/s390x/s390-pci-bus.h +++ b/include/hw/s390x/s390-pci-bus.h @@ -275,7 +275,6 @@ struct S390PCIIOMMU { Object parent_obj; AddressSpace as; MemoryRegion mr; - uint64_t max_dma_limit; }; =20 typedef struct S390PCIIOMMUTable { @@ -352,6 +351,7 @@ struct S390PCIBusDevice { uint64_t g_iota; uint64_t pba; uint64_t pal; + uint64_t max_dma_limit; S390PCIDMACount *dma_limit; MemoryRegion msix_notify_mr; IndAddr *summary_ind; --=20 2.34.1 From nobody Sun Jun 7 22:17:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1780625963; cv=none; d=zohomail.com; s=zohoarc; b=gK2OXrFaDvE9v227QseIWN9l87uyn+BrpiTjNSMfKljOSConAngzYMRC7RNT5ttOtqkaV9BFc0ieoNLUQikYiuEUh9YTudT/sci3XS1gQiyDE6lILzNGc9/pQtvAG7+GJvB3TUl/15GHSbYmGkgw1JTNd7nIi2vxNu27BSx1g0I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780625963; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=eYbBKH1oO13k9TLelI7GDEIaC9XcIecLzSyl4dhG1eQ=; b=G1667z/S0fCZzFoFZRKgROyQ0fkIGdS14yYTLaVUSd1E8d6yGt9TLsGoCK4OjKcjWcBlo8dHiNZv1ipO8cKr3Z4Rl/Ep+4gvLS41P+LNIK3pjxWduQD1dnsoVN+grigaE8j2Fp4rZyBPczahBTdxZCvSrVVFybVSzTz6p74UmWk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780625963315680.6702093932929; Thu, 4 Jun 2026 19:19:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wVK86-0005Pb-Ec; Thu, 04 Jun 2026 22:17:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK82-0005LL-MD; Thu, 04 Jun 2026 22:17:46 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK7z-0001mm-9m; Thu, 04 Jun 2026 22:17:46 -0400 Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 654JFRU62497718; Fri, 5 Jun 2026 02:17:38 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4efqm5aem8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:38 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 65529WPm003699; Fri, 5 Jun 2026 02:17:37 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4egakw7ubv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:37 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6552HZPp31523460 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jun 2026 02:17:35 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C98AD58052; Fri, 5 Jun 2026 02:17:35 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 94CA95805D; Fri, 5 Jun 2026 02:17:35 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.ibm.com (unknown [9.61.240.22]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Jun 2026 02:17:35 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=eYbBKH1oO13k9TLel I7GDEIaC9XcIecLzSyl4dhG1eQ=; b=HlT+4ujHvwO9xu1cBHOA6vH98cNAxHS9l YSw3jVinw3OStYZkGPvnLAOkQz3ShBkaXUYN4pmjGh2uj+ug/y3hj6ljSo0cHtv6 EWDomvEY/80g81fA5NFaVnui4cSC/Vx6/raohIlEVymBopbN79QXFc1kyaUmC1Vs Ruu65G3DWx3IAJ6+NaCfljLbAlfSlFECKOnZU2YV+wynos+dtY6Nu7mM8UH791EB U5fa0BjXpDiT/ovkkBljq9A6q/iVHN/GTEkyDOeYKDzPb3LJxj0fwEx+GnKdZrTP GuTkUxDFpfdNqY9gWDEqdWEOnIS8EUD3ZdruH6VbtfJ5EuTKV3UdQ== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, richard.henderson@linaro.org, iii@linux.ibm.com, david@kernel.org, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Konstantin Shkolnyy Subject: [PATCH v3 13/15] s390x/pci: Add a comment explaining S390PCIIOMMU purpose Date: Thu, 4 Jun 2026 21:17:26 -0500 Message-Id: <20260605021728.1125090-14-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260605021728.1125090-1-kshk@linux.ibm.com> References: <20260605021728.1125090-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: v2HC4BcjQZ9oTO09yF5-xZ5gLF1B5of7 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjA1MDAxOCBTYWx0ZWRfXxrOHp+yt7ZUK 5YMydwFda1kxEyEw9ER6GhpWV3iJbFN8w9RYgkLKtKcUP8LD0v82y20zuGPZnG2sVnOMgXegFtF JfaonwOdJHTc/M/Vacr2UsGuCMFoDmiBprsLf/eroGxYVFE/RNMl7t0aiI2owKHEwArw5la6VK1 hjmROUWsXSrkckygET7oZZM+9Vtdc726Yh7VChv7/fH6nrIsmN8rnZXVmshy0Qxa77gE25rNFBb av+aUsUaOOz4kk36rNUXHHU8Ylj5W9w3yOkoddhPMZ8eZ0N0fQOl8HWmi09lm/eVaBhKH5uUGDK OZGUrnu0kG4JippPdH3Yi0WDjH1fFk9crAQWeQp9OBdKZSQk8pjDADlu83TpuHvxkJwvDNfuiL+ VQLp/xOu0YdCEKOAgnsxOfBeIps5gQCiyA4wYZNF8wOARy5y/XczSPYSKWfdYHTm3YDm+OTQZhr uUta6tvMplo0x+2LnQA== X-Proofpoint-ORIG-GUID: v2HC4BcjQZ9oTO09yF5-xZ5gLF1B5of7 X-Authority-Analysis: v=2.4 cv=Vf3H+lp9 c=1 sm=1 tr=0 ts=6a2231c2 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=FelO9ux0wxsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=YbwZhMhe-Yu4dYefToEA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-04_07,2026-05-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 adultscore=0 bulkscore=0 impostorscore=0 phishscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2606050018 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=kshk@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1780625963622158500 Content-Type: text/plain; charset="utf-8" Signed-off-by: Konstantin Shkolnyy --- include/hw/s390x/s390-pci-bus.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bu= s.h index e3cbee2695..2fab28e6e0 100644 --- a/include/hw/s390x/s390-pci-bus.h +++ b/include/hw/s390x/s390-pci-bus.h @@ -271,6 +271,14 @@ typedef struct S390PCIDMACount { QTAILQ_ENTRY(S390PCIDMACount) link; } S390PCIDMACount; =20 +/* + * This structure holds the PCI device AddressSpace that QEMU needs to link + * into its internal structures before the zPCI and PCI devices are fully + * initialized. It's a QEMU requirement to provide this "root" AddressSpace + * early. The AddressSpace is only actually used for I/O while the PCI + * device is plugged in and configured by the guest, at which time it gets + * additional memory subregions from zPCI device, that can do real work. + */ struct S390PCIIOMMU { Object parent_obj; AddressSpace as; --=20 2.34.1 From nobody Sun Jun 7 22:17:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1780625967; cv=none; d=zohomail.com; s=zohoarc; b=j23TXJjraOrzVAZf6KjKutykKOMYsip2IbDr7QRB5Ce4zh7QGtTUhc+Cbmi1ZWYPlZYEg/ofqeQsSsPXR7LoO+XOvABM0dLiVT6r3iZ0fGGD3FFv/8dlVkTijNRL3HzBe9213PJJPxPegZDbWDZnCHd6JIlkjJQfrmSNYtzAoc0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780625967; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CvgUhiFHV7V+l0pLlt5cEOzooiRkobGBgEQTgfNx6rI=; b=kMN7Q/Owv8eSDww/F9qR98ySiqXEy0p0ChcdzTlGEjsiHVL5IpZLBDiB6ylqd8Vx9XClCmNkJx5n10ow1F1J99Wp/QctusjltdTW2++Kb2DkhFu0PAyzdPdIgdYd0tMj5EejTzv+zpmPXUylxvvbMw+nsNd4iWhJ0TDXj2FvEGc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1780625967540150.10385077753608; Thu, 4 Jun 2026 19:19:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wVK87-0005Qz-Ah; Thu, 04 Jun 2026 22:17:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK83-0005My-Nl; Thu, 04 Jun 2026 22:17:47 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK7z-0001mp-BO; Thu, 04 Jun 2026 22:17:47 -0400 Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 654KkAPL1260942; Fri, 5 Jun 2026 02:17:38 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4efqd4jkhp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:37 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 65529411025273; Fri, 5 Jun 2026 02:17:37 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4egcegyh13-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:36 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6552Had864946540 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jun 2026 02:17:36 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0F2585805D; Fri, 5 Jun 2026 02:17:36 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CFEF758056; Fri, 5 Jun 2026 02:17:35 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.ibm.com (unknown [9.61.240.22]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Jun 2026 02:17:35 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=CvgUhiFHV7V+l0pLl t5cEOzooiRkobGBgEQTgfNx6rI=; b=lT+ZoL6HSJj807AbMxXs3aaKJx69kigIL d7C8Zb8T6nYTIlpe28Wqk0RbGjh3VyZGvplEbeDvsP6u47ZTU4giVITdq6ERtU3Q 0Tgmgg6vBgd8msak/QvUWP1WjM2wF/PiEUbInFD8MDgdB6kKLEY3xpjfF2xNOQXI NJ8e24BC6+/yd02MjvN02i/qY1YkEjlTn5LzYVG+8XIQP8PNpREQbHepn86RdKl7 GRpV4HV+LbYt1u0Q3z/wMw5IhsimfCSID2U8UG1bAXqqGtIsqG0kJVoCTi5YjcFV tuRB5n3UvKWmppubpyPz4yN3/Phko0EyDGNjMfhIg4897MGxM/kAQ== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, richard.henderson@linaro.org, iii@linux.ibm.com, david@kernel.org, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Konstantin Shkolnyy Subject: [PATCH v3 14/15] s390x/pci: Implement migration for emulated devices Date: Thu, 4 Jun 2026 21:17:27 -0500 Message-Id: <20260605021728.1125090-15-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260605021728.1125090-1-kshk@linux.ibm.com> References: <20260605021728.1125090-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjA1MDAxOCBTYWx0ZWRfX0vQ0XyCHsVPr N4hiFeP1/ymREet7UPNvDuxfSOlGCUR7woMMSO/d9lYLJ7mKLr/k8y4wqaRmv8vc8ADxtiY+FQf our//0SMgMqMvwiZ60BQYl9TSZg+2G6MWPO0uLRwyG41qoFaEKj6L+9qqsS91igq42a9ra4auO+ jX/Iq51natq9+4YLLgn7/SSfLTSzy3qHvMlxNwpXv1fEfUdGzSLYmyd3kNy8de4ueQ8LQ8XgXni jj+XxoWl+uMXy51b9R5kEzbaAsyn49jGiYH78vpX3WNvyM8MpRLLiOZ6XLfu2eodTCp/EMKh4St /6wYiYX30eDOS2HKQUht4tJGUcoB0eRI1Pu32LwzpNT11ft6nnmqWZOf/FjQ/cPOmv6HHnbCEC4 4opFIK4jBGMWyZRQyDVLMaQOlAKv0kbAgR2AARVHXCqCXJ7yLShyzt4eh5XeJ/NP0+I+B6BS+Cx Zc3kMJisD3Vxc+266mw== X-Proofpoint-GUID: XW8uStAxLNo0XXmdUsNr7LSLqIyPEzeF X-Proofpoint-ORIG-GUID: XW8uStAxLNo0XXmdUsNr7LSLqIyPEzeF X-Authority-Analysis: v=2.4 cv=DZknbPtW c=1 sm=1 tr=0 ts=6a2231c1 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=FelO9ux0wxsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=BaPdF8j1E3L0cLeJECkA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-04_07,2026-05-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 suspectscore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2606050018 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=kshk@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1780625970124154100 Content-Type: text/plain; charset="utf-8" Implement zPCI device state migration, consequently enabling migration of VMs that have emulated PCI devices, whether virtio or not. Migration is allowed for devices whose function handle has the FH_SHM_EMUL bit set. For these devices QEMU will save and restore the state of its zPCI emulator. This will enable emulated PCI migration starting with s390-ccw-virtio-11.1. Passthrough devices will continue to block migration. Signed-off-by: Konstantin Shkolnyy --- hw/s390x/s390-pci-bus.c | 187 +++++++++++++++++++++++++++++++- hw/s390x/s390-pci-inst.c | 2 +- hw/s390x/s390-virtio-ccw.c | 5 + include/hw/s390x/s390-pci-bus.h | 4 + 4 files changed, 192 insertions(+), 6 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 8505abcc90..b05c4b43d1 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -26,6 +26,7 @@ #include "hw/pci/pci_bridge.h" #include "hw/pci/msi.h" #include "exec/cpu-common.h" +#include "migration/blocker.h" #include "qemu/error-report.h" #include "qemu/module.h" #include "system/reset.h" @@ -33,6 +34,11 @@ =20 #include "trace.h" =20 +static const Property phb_props[] =3D { + DEFINE_PROP_BOOL("x-zpci-emul-dev-migr-enabled", S390pciState, + emul_dev_migr_enabled, true), +}; + S390pciState *s390_get_phb(void) { static S390pciState *phb; @@ -916,6 +922,23 @@ static void set_pbdev_info(S390PCIBusDevice *pbdev) pbdev->pci_group =3D s390_group_find(ZPCI_DEFAULT_FN_GRP); } =20 +static int s390_set_emul_dev_migration_blocker(S390pciState *s, Error **er= rp) +{ + if (s->emul_dev_migr_enabled) { + return 0; + } + error_setg(&s->emul_dev_migr_blocker, + "Migration disabled for emulated zPCI devices on this machi= ne type"); + return migrate_add_blocker(&s->emul_dev_migr_blocker, errp); +} + +static void s390_clear_emul_dev_migration_blocker(S390pciState *s) +{ + if (s->emul_dev_migr_blocker) { + migrate_del_blocker(&s->emul_dev_migr_blocker); + } +} + static void s390_pcihost_realize(DeviceState *dev, Error **errp) { PCIBus *b; @@ -951,6 +974,7 @@ static void s390_pcihost_realize(DeviceState *dev, Erro= r **errp) css_register_io_adapters(CSS_IO_ADAPTER_PCI, true, false, S390_ADAPTER_SUPPRESSIBLE, errp); s390_pcihost_kvm_realize(); + s390_set_emul_dev_migration_blocker(s, errp); } =20 static void s390_pcihost_unrealize(DeviceState *dev) @@ -958,6 +982,8 @@ static void s390_pcihost_unrealize(DeviceState *dev) S390PCIGroup *group; S390pciState *s =3D S390_PCI_HOST_BRIDGE(dev); =20 + s390_clear_emul_dev_migration_blocker(s); + while (!QTAILQ_EMPTY(&s->zpci_groups)) { group =3D QTAILQ_FIRST(&s->zpci_groups); QTAILQ_REMOVE(&s->zpci_groups, group, link); @@ -1128,6 +1154,27 @@ static int s390_pci_interp_plug(S390pciState *s, S39= 0PCIBusDevice *pbdev) return 0; } =20 +static int s390_set_passthrough_migration_blocker(S390PCIBusDevice *pbdev, + Error **errp) +{ + pbdev->passthrough_migr_blocker =3D NULL; + + if (pbdev->fh & FH_SHM_EMUL) { + return 0; + } + error_setg(&pbdev->passthrough_migr_blocker, + "Migration blocked by passthrough zPCI device " + "fh 0x%x uid %d fid %d", pbdev->fh, pbdev->uid, pbdev->fid); + return migrate_add_blocker(&pbdev->passthrough_migr_blocker, errp); +} + +static void s390_clear_passthrough_migration_blocker(S390PCIBusDevice *pbd= ev) +{ + if (pbdev->passthrough_migr_blocker) { + migrate_del_blocker(&pbdev->passthrough_migr_blocker); + } +} + static void s390_pcihost_plug(HotplugHandler *hotplug_dev, DeviceState *de= v, Error **errp) { @@ -1247,6 +1294,11 @@ static void s390_pcihost_plug(HotplugHandler *hotplu= g_dev, DeviceState *dev, return; } =20 + if (s390_set_passthrough_migration_blocker(pbdev, errp)) { + s390_pci_msix_free(pbdev); + return; + } + if (dev->hotplugged) { s390_pci_generate_plug_event(HP_EVENT_TO_CONFIGURED , pbdev->fh, pbdev->fid); @@ -1283,6 +1335,8 @@ static void s390_pcihost_unplug(HotplugHandler *hotpl= ug_dev, DeviceState *dev, return; } =20 + s390_clear_passthrough_migration_blocker(pbdev); + s390_pci_generate_plug_event(HP_EVENT_STANDBY_TO_RESERVED, pbdev->fh, pbdev->fid); bus =3D pci_get_bus(pci_dev); @@ -1450,6 +1504,7 @@ static void s390_pcihost_class_init(ObjectClass *klas= s, const void *data) hc->unplug_request =3D s390_pcihost_unplug_request; hc->unplug =3D s390_pcihost_unplug; msi_nonbroken =3D true; + device_class_set_props(dc, phb_props); } =20 static const TypeInfo s390_pcihost_info =3D { @@ -1463,10 +1518,33 @@ static const TypeInfo s390_pcihost_info =3D { } }; =20 +/* Return a unique bus "path" for zpci device */ +static char *s390_pci_bus_get_dev_path(DeviceState *dev) +{ + S390PCIBusDevice *pbdev =3D S390_PCI_DEVICE(dev); + return g_strdup_printf("uid-%04x", pbdev->uid); +} + +static void s390_pcibus_class_init(ObjectClass *oc, const void *data) +{ + BusClass *bc =3D BUS_CLASS(oc); + bc->get_dev_path =3D s390_pci_bus_get_dev_path; +} + static const TypeInfo s390_pcibus_info =3D { .name =3D TYPE_S390_PCI_BUS, .parent =3D TYPE_BUS, .instance_size =3D sizeof(S390PCIBus), + /* + * Implement get_dev_path() to provide each zpci device with a unique + * stable UID-based bus "path". The "path" is used as part of idstr in= the + ^ migration stream, making idstr unique and instance_id always 0. + * For migration to succeed, (idstr+instance_id) must match those gene= rated + * during QEMU start. Without unique idstr, QEMU will generate variable + * instance_id to distinquish devices, and that instance_id can change + * if a device is unplugged and plugged back, preventing migration. + */ + .class_init =3D s390_pcibus_class_init, }; =20 static uint16_t s390_pci_generate_uid(S390pciState *s) @@ -1612,13 +1690,112 @@ static const Property s390_pci_device_properties[]= =3D { true), }; =20 -static const VMStateDescription s390_pci_device_vmstate =3D { - .name =3D TYPE_S390_PCI_DEVICE, +static int s390_pci_device_pre_load(void *opaque) +{ + S390PCIBusDevice *pbdev =3D S390_PCI_DEVICE(opaque); + S390PCIBusDevice *found_pbdev; + + /* + * Make sure pbdev is removed from the table before state load. The ch= ange + * of pbdev->idx means it needs to be moved to a different position an= yway, + * and is illegal while in the table. But be careful to not remove + * instead another pbdev whose state might have been loaded earlier and + * that has then replaced our pbdev. (post_load() will put our pbdev b= ack.) + */ + found_pbdev =3D g_hash_table_lookup(s390_get_phb()->zpci_table, &pbdev= ->idx); + assert(found_pbdev); + if (found_pbdev =3D=3D pbdev) { + g_hash_table_remove(s390_get_phb()->zpci_table, &pbdev->idx); + } + + return 0; +} + +static int s390_pci_device_post_load(void *opaque, int version_id) +{ + S390PCIBusDevice *pbdev =3D S390_PCI_DEVICE(opaque); + /* - * TODO: add state handling here, so migration works at least with - * emulated pci devices on s390x + * Now that pbdev->idx has been loaded, use it to place pbdev back into + * the table. This may replace a different not-yet-state-loaded pbdev, + * but pre_load() handles this case. */ - .unmigratable =3D 1, + g_hash_table_replace(s390_get_phb()->zpci_table, &pbdev->idx, pbdev); + + /* + * Regenerate IOMMU state, including IOTLB contents and QEMU memory re= gions. + */ + if (pbdev->iommu_enabled) { + assert(pbdev->iommu); + if (s390_pci_is_translation_enabled(pbdev->g_iota)) { + s390_pci_iommu_enable(pbdev); + s390_pci_ioat_replay(pbdev); + } else { + s390_pci_iommu_direct_map_enable(pbdev); + } + } + + /* + * Guest sets fmb_addr by mpcifc.ZPCI_MOD_FC_SET_MEASURE instruction, + * whose handler consequently starts fmb_timer. We may need to restart= it. + */ + if (pbdev->fmb_addr) { + assert(!pbdev->fmb_timer); + assert(pbdev->pci_group); + pbdev->fmb_timer =3D timer_new_ms(QEMU_CLOCK_VIRTUAL, + fmb_update, pbdev); + timer_mod(pbdev->fmb_timer, + qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + + pbdev->pci_group->zpci_group.mui); + } + return 0; +} + +static const VMStateDescription s390_pci_device_vmstate =3D { + .name =3D TYPE_S390_PCI_DEVICE, + .version_id =3D 1, + .minimum_version_id =3D 1, + .pre_load =3D s390_pci_device_pre_load, + .post_load =3D s390_pci_device_post_load, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT32(state, S390PCIBusDevice), + VMSTATE_UINT16(uid, S390PCIBusDevice), + VMSTATE_UINT32(idx, S390PCIBusDevice), + VMSTATE_UINT32(fh, S390PCIBusDevice), + VMSTATE_UINT32(fid, S390PCIBusDevice), + VMSTATE_BOOL(fid_defined, S390PCIBusDevice), + VMSTATE_UINT64(fmb_addr, S390PCIBusDevice), + VMSTATE_UINT32(fmb.format, S390PCIBusDevice), + VMSTATE_UINT32(fmb.sample, S390PCIBusDevice), + VMSTATE_UINT64(fmb.last_update, S390PCIBusDevice), + VMSTATE_UINT64_ARRAY(fmb.counter, S390PCIBusDevice, + ARRAY_SIZE(((S390PCIBusDevice *)0)->fmb.counter)), + VMSTATE_UINT64(fmb.fmt0.dma_rbytes, S390PCIBusDevice), + VMSTATE_UINT64(fmb.fmt0.dma_wbytes, S390PCIBusDevice), + VMSTATE_UINT8(isc, S390PCIBusDevice), + VMSTATE_UINT16(noi, S390PCIBusDevice), + VMSTATE_UINT8(sum, S390PCIBusDevice), + VMSTATE_UINT8(pft, S390PCIBusDevice), + VMSTATE_UINT64(routes.adapter.ind_addr, S390PCIBusDevice), + VMSTATE_UINT64(routes.adapter.summary_addr, S390PCIBusDevice), + VMSTATE_UINT64(routes.adapter.ind_offset, S390PCIBusDevice), + VMSTATE_UINT32(routes.adapter.summary_offset, S390PCIBusDevice), + VMSTATE_UINT32(routes.adapter.adapter_id, S390PCIBusDevice), + VMSTATE_BOOL(iommu_enabled, S390PCIBusDevice), + VMSTATE_UINT64(g_iota, S390PCIBusDevice), + VMSTATE_UINT64(pba, S390PCIBusDevice), + VMSTATE_UINT64(pal, S390PCIBusDevice), + VMSTATE_UINT64(max_dma_limit, S390PCIBusDevice), + VMSTATE_PTR_TO_IND_ADDR(summary_ind, S390PCIBusDevice), + VMSTATE_PTR_TO_IND_ADDR(indicator, S390PCIBusDevice), + VMSTATE_BOOL(pci_unplug_request_processed, S390PCIBusDevice), + VMSTATE_BOOL(unplug_requested, S390PCIBusDevice), + VMSTATE_BOOL(interp, S390PCIBusDevice), + VMSTATE_BOOL(forwarding_assist, S390PCIBusDevice), + VMSTATE_BOOL(aif, S390PCIBusDevice), + VMSTATE_BOOL(rtr_avail, S390PCIBusDevice), + VMSTATE_END_OF_LIST() + } }; =20 static void s390_pci_device_class_init(ObjectClass *klass, const void *dat= a) diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index 191f549ba7..a9c0a4effb 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -1094,7 +1094,7 @@ static int fmb_do_update(S390PCIBusDevice *pbdev, int= offset, uint64_t val, return ret; } =20 -static void fmb_update(void *opaque) +void fmb_update(void *opaque) { S390PCIBusDevice *pbdev =3D opaque; int64_t t =3D qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL); diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index cc768daeb0..5900d919d2 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -923,8 +923,13 @@ static void ccw_machine_11_0_instance_options(MachineS= tate *machine) =20 static void ccw_machine_11_0_class_options(MachineClass *mc) { + static GlobalProperty compat[] =3D { + { TYPE_S390_PCI_HOST_BRIDGE, "x-zpci-emul-dev-migr-enabled", "off"= }, + }; + ccw_machine_11_1_class_options(mc); compat_props_add(mc->compat_props, hw_compat_11_0, hw_compat_11_0_len); + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); } DEFINE_CCW_MACHINE(11, 0); =20 diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bu= s.h index 2fab28e6e0..3840f6a48f 100644 --- a/include/hw/s390x/s390-pci-bus.h +++ b/include/hw/s390x/s390-pci-bus.h @@ -337,6 +337,7 @@ struct S390PCIBusDevice { uint16_t uid; uint32_t idx; uint32_t fh; + Error *passthrough_migr_blocker; uint32_t fid; bool fid_defined; uint64_t fmb_addr; @@ -390,6 +391,8 @@ struct S390pciState { QTAILQ_HEAD(, S390PCIDMACount) zpci_dma_limit; QTAILQ_HEAD(, S390PCIGroup) zpci_groups; uint8_t next_sim_grp; + bool emul_dev_migr_enabled; + Error *emul_dev_migr_blocker; }; =20 S390pciState *s390_get_phb(void); @@ -415,5 +418,6 @@ S390PCIBusDevice *s390_pci_find_dev_by_pci(S390pciState= *s, S390PCIBusDevice *s390_pci_find_next_avail_dev(S390pciState *s, S390PCIBusDevice *pbdev); void s390_pci_ism_reset(void); +void fmb_update(void *opaque); =20 #endif --=20 2.34.1 From nobody Sun Jun 7 22:17:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1780625918; cv=none; d=zohomail.com; s=zohoarc; b=JmQb8mARzHQH2PubLj4LIA47OM/vxG2Ak8r6MXkbO7QM4tWtdx57EKE0Zzg8rv3yf/je70PcB/9dkV/UWJBn4I8DvZcRhapgZ+1y37J1PeAj5jK3mb2lQyt1Vo+iDT87hwKChTw+ynUaz8MoDgfmOCvRF8581KsV2ef1jbiomXk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780625918; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xuCd9Rv/6MxO6KmEZjxXbtVmsFJBA739WxF+h1lv6g4=; b=iDti3A6wMyc7mOtjVqvbhSHA2q7bUxaixVHoEjPHrcQ/hutv2f+6SptPzXGbEHtD0FndeIKpRHo6N3Afy9pYHSn6bpve+R7S8i1hT7+s0PcGE5Qy8kL79//QsM52fu3xmqxiQW/ILr6S67l1CRIkTxTwdFBwTClLAe8enlrBBto= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17806259185941021.0625125494671; Thu, 4 Jun 2026 19:18:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wVK83-0005Ln-21; Thu, 04 Jun 2026 22:17:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK81-0005Jw-Oy; Thu, 04 Jun 2026 22:17:45 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wVK7y-0001mW-MU; Thu, 04 Jun 2026 22:17:45 -0400 Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6550tooG2350781; Fri, 5 Jun 2026 02:17:39 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4efqjqjf1q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:38 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 65529C7v009455; Fri, 5 Jun 2026 02:17:37 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4egbqhqnck-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2026 02:17:37 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6552HaHR29033138 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jun 2026 02:17:36 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3FB7658056; Fri, 5 Jun 2026 02:17:36 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 146E358065; Fri, 5 Jun 2026 02:17:36 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.ibm.com (unknown [9.61.240.22]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 5 Jun 2026 02:17:36 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=xuCd9Rv/6MxO6KmEZ jxXbtVmsFJBA739WxF+h1lv6g4=; b=S0wewUHqIyKmQzyOWRritHQLBMbpL2PJN LoU9kI0Jpr4GL/7KNZ03fQHPbaZ+4vnlZKHbmbuH8ZNxsEaP25/p/6jxaX/ZmkiR XUU2RCSRWE7aCDAudCgnfLTfMu6OvLnxjcEoXbQkKDybVq32PBZVV3vIyVKKj3g1 fDGah2oyHrmVcOfolE6QPolKHBgS1/RBJus0UN6etLeDtWS09cpGJoMZbFScBTob JiA2S3eNNjayFHrx2qbn/wD2ClRSEO/HiCW9lPz3kq5ETgyF3RDI1HAU7cNUH18y ysvp2KLSrMRx0iiih1pLDrtsj9l1J/0njoZiue0XX3HV6JG6r200Q== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, richard.henderson@linaro.org, iii@linux.ibm.com, david@kernel.org, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, Konstantin Shkolnyy Subject: [PATCH v3 15/15] s390x/pci: Create function to contain fmb_timer start Date: Thu, 4 Jun 2026 21:17:28 -0500 Message-Id: <20260605021728.1125090-16-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260605021728.1125090-1-kshk@linux.ibm.com> References: <20260605021728.1125090-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: BMnp8VfBfKN3tHMDymuMGr9J76E83_b1 X-Proofpoint-GUID: BMnp8VfBfKN3tHMDymuMGr9J76E83_b1 X-Authority-Analysis: v=2.4 cv=bcVbluPB c=1 sm=1 tr=0 ts=6a2231c2 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=FelO9ux0wxsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=sKQJ3MkoBbxYwW_cRDQA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjA1MDAxOCBTYWx0ZWRfX4CQS0oeCK4ei wXOqdkngeMGpVyXzWF82HkXHqHPgJTo0fjE3zVhFFMbtzpqKu7VoTceAqeLI/iHqn/TUGbVpcAQ JM/fdft9xDH5JCVsg8Uc6YVl9akruD+yWgWWv/IDJmoHXNW+C1ACVAMPF0s5jaPtHixftEJASne GwlSlYP37DY+lXpmdw/1piYPavCDQ8Ig1B/o3ubg/zL5AStg2kB3jeCLSYcr5feH4L+KRejOIAp Xlk1xdjbU4G+iNMLd5zBnMHwo+upE2kvA0TGtdMBmC8zWzpw1w6hyq0Rr847a8QjNDvzNvq3fxZ Yx4nyrWkOVsWOAB/OAyKq6Fa7KzogMGEeygVQFqPhP0yZE9r6uNDyz256kbbKwiIF/GYu15pIms 4M6UJmYf1tDsgu54ru38StP4c6ZRd+BxwTA6WpCEvdCYZxRScn1IuQGfoq4gFeLn5NRUVtNMuJk 5UFD1uJp9BAW2uRJrFQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-04_07,2026-05-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 adultscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605210000 definitions=main-2606050018 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=kshk@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1780625919963158500 Content-Type: text/plain; charset="utf-8" fmb_timer is now started in 3 different places. The new function will encap= sulate that to make sure mui is added in all cases. Signed-off-by: Konstantin Shkolnyy --- hw/s390x/s390-pci-bus.c | 5 ++--- hw/s390x/s390-pci-inst.c | 14 ++++++++++---- include/hw/s390x/s390-pci-bus.h | 1 + 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index b05c4b43d1..49efed2724 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -1744,9 +1744,8 @@ static int s390_pci_device_post_load(void *opaque, in= t version_id) assert(pbdev->pci_group); pbdev->fmb_timer =3D timer_new_ms(QEMU_CLOCK_VIRTUAL, fmb_update, pbdev); - timer_mod(pbdev->fmb_timer, - qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + - pbdev->pci_group->zpci_group.mui); + s390_pci_schedule_fmb_timer(pbdev, + qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL)); } return 0; } diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index a9c0a4effb..62ecd50dcb 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -1094,9 +1094,16 @@ static int fmb_do_update(S390PCIBusDevice *pbdev, in= t offset, uint64_t val, return ret; } =20 +void s390_pci_schedule_fmb_timer(S390PCIBusDevice *pbdev, uint64_t start) +{ + timer_mod(pbdev->fmb_timer, start + pbdev->pci_group->zpci_group.mui); +} + void fmb_update(void *opaque) { S390PCIBusDevice *pbdev =3D opaque; + + /* Must be read before updating U bit */ int64_t t =3D qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL); int i; =20 @@ -1133,7 +1140,7 @@ void fmb_update(void *opaque) sizeof(pbdev->fmb.last_update))) { return; } - timer_mod(pbdev->fmb_timer, t + pbdev->pci_group->zpci_group.mui); + s390_pci_schedule_fmb_timer(pbdev, t); } =20 static int mpcifc_reg_int_interp(S390PCIBusDevice *pbdev, ZpciFib *fib) @@ -1326,9 +1333,8 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uin= t64_t fiba, uint8_t ar, timer_del(pbdev->fmb_timer); } pbdev->fmb_addr =3D fmb_addr; - timer_mod(pbdev->fmb_timer, - qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + - pbdev->pci_group->zpci_group.mui); + s390_pci_schedule_fmb_timer(pbdev, + qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL)); break; } default: diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bu= s.h index 3840f6a48f..0385c1aba8 100644 --- a/include/hw/s390x/s390-pci-bus.h +++ b/include/hw/s390x/s390-pci-bus.h @@ -419,5 +419,6 @@ S390PCIBusDevice *s390_pci_find_next_avail_dev(S390pciS= tate *s, S390PCIBusDevice *pbdev); void s390_pci_ism_reset(void); void fmb_update(void *opaque); +void s390_pci_schedule_fmb_timer(S390PCIBusDevice *pbdev, uint64_t start); =20 #endif --=20 2.34.1