From nobody Sun Sep 20 15:24:58 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=1789140274; cv=none; d=zohomail.com; s=zohoarc; b=On/ntT4i1DIh7xJ0rQeJirr8sW4O/RworWNcK++A1B3aMDWfyUyDfTlcOfvr1OkDtI8oXCc2HweWoGwhjeTp2Mc4CLf4c+Vc0TqI+/eqcWRRyZUUWt6z0LBU5YOVVoXXC8/pXtSOeFvlSPRqExPrwo5L9VN4kKfywfMDppRCvCE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789140274; 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=2J0jttHL2vogfDdlE759gBN/fuM/0Xw0MdkpRXjBCxU=; b=Hkiq0xuT+I00GarLVG0UeSyCI52P8Y3dmlvzvpg8nDONg81Kn54LHH/YgEm1BJjwZaZwIqCNryxu5Y7LOs/WXZVIqrB9Z/aXiAq9vh3AMydlQLEdW6sTVlubdtHcM+kLviqPDDdOIrxOMMFAwI8bVH2MZiaN3ZlDFVZKbYXZ0hI= 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 1789140274336980.445642677992; Fri, 11 Sep 2026 08:24:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x534t-0008KL-Nh; Fri, 11 Sep 2026 11:22:11 -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 1x534b-0007xo-LY; Fri, 11 Sep 2026 11:21:56 -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 1x534W-0004k4-2y; Fri, 11 Sep 2026 11:21:53 -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 68BF1PuP2126736; Fri, 11 Sep 2026 15:21:42 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 4gkd8qvbas-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:42 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68BEoCKu1789525; Fri, 11 Sep 2026 15:21:41 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4gkvwk71s8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:41 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68BFLeWm33423978 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Sep 2026 15:21:40 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0C1FC5805D; Fri, 11 Sep 2026 15:21:40 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CA40D58058; Fri, 11 Sep 2026 15:21:39 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.atx-us.ibm.com (unknown [9.16.62.165]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 11 Sep 2026 15:21:39 +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=2J0jttHL2vogfDdlE 759gBN/fuM/0Xw0MdkpRXjBCxU=; b=Ly8bHF1gImRpu0HRCjRC6DDDPhB7vhHKw 9ckfJrKd5ylwCN8Cu5TB6hiMNl73r9Ri0pwK0Dot35Qdkut/VXlGaWUEY0RZiytd YGAMw40c0Slo8O7GQVrDx9pEAutqaZ0p63EP2jjYeNskyt2k4B/B6zbPZqRzM9dy 7bdzrU911v9+qVOk2d2fZQ0NxgPZFQX3Zzwe6qpQ806ZwqMrsDMmHPm0bwpYFlwy rRZJnofEDeZWnZtg9J4pNU76WfhRSSQ+3NQGvX2jFWZF9wsbtgM5GLD1+HhZlCtG zdFCyiQSihjsjsLgOHSLYEwVVzqMx49T6MDTSplZAjJlPyon0CnoA== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, farman@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 v8 01/16] s390x/pci: implement IOMMU replay Date: Fri, 11 Sep 2026 10:21:22 -0500 Message-Id: <20260911152137.676602-2-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260911152137.676602-1-kshk@linux.ibm.com> References: <20260911152137.676602-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=SpUFe/O0 c=1 sm=1 tr=0 ts=6aa41c86 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=uoNow8biE-CX8mucm5YA:9 X-Proofpoint-ORIG-GUID: IS0eeGOw9tfIjnFsYJPPwUgyQmydyKvw X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfX+mqAB8lvbkEW dCKIG9dQdMM31Xm9UFQrbM8rZLr9IBtjFjiQeyYriNJOa7cbjbIoDTPcWBfDc7N3rgDPYYVaOOl wbVzVRdQQvzzqMOKrKIALyIbdhG66Kf4/Wf1I7ba9MG2t7C+A5MLLC3VcMd8dV7ga6n8NcmSgcM fWy9VpzQ02SwWsay0l0+jASB8dlNG1Y+acMxP6gcMqvqWUW+hywv2NSjFS1jAiRs8zqlljfe1Qp cMT/HbPyabS7Pa9I5diOMjjaI+C5i9A5kbAx6vd8z/VaVO7P3mUSHba2hBba6jZOOemjJPAm4Ol tMyIP1lIyAlXY4gteS/4JxJkADWK5OT2Lx7bIXoWwSM5gt7nemrkD9JVG90Y67475uIUtoDAEbC Pg6pm7XklqkrOW29M12SX+e8LOhVTNSfHortI3HOTPchdQEaFR/Q8ylxOFs8Wqpk2INXdcvsInM 39Vm1ItG/OiQXi4FVhA== X-Proofpoint-Spam-Info: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfX57aTaX1zhqG6 1IJ5T8RWs3HsmHunmh0YzlHoc/09bwyZ1fUet7ZX5u8l407NbfUYi4+Spnjkws6udOYGATn81bW yZzH9HI4WWbxogMJDHFqB9hVVyfVBKY= X-Proofpoint-GUID: IS0eeGOw9tfIjnFsYJPPwUgyQmydyKvw X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-11_05,2026-09-11_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 clxscore=1015 phishscore=0 malwarescore=0 impostorscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609110210 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: 1789140275828158500 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 Reviewed-by: Farhan Ali --- hw/s390x/s390-pci-bus.c | 68 +++++++++++++++++++++++++++++--- hw/s390x/s390-pci-inst.c | 4 +- include/hw/s390x/s390-pci-inst.h | 1 + 3 files changed, 65 insertions(+), 8 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index eff980fdfe..10b417a779 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -593,14 +593,70 @@ err: return ret; } =20 -static void s390_pci_iommu_replay(IOMMUMemoryRegion *iommu, +static void s390_pci_ioat_replay(S390PCIIOMMU *iommu) +{ + S390PCIBusDevice *pbdev =3D iommu->pbdev; + 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 || !pbdev) { + /* 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; + } + + curr +=3D entry.len; + if (entry.perm !=3D IOMMU_NONE) { + while (entry.iova < curr && entry.iova < end) { + if (dma_avail > 0) { + dma_avail =3D s390_pci_update_iotlb(iommu, &entry); + } else { + /* + * There is no reliable method to request the guest to + * release mappings other than in response to a RPCIT + * instruction; generate a permanent error condition a= nd + * require the device 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 fail= ed"); + return; + } + entry.iova +=3D TARGET_PAGE_SIZE; + entry.translated_addr +=3D TARGET_PAGE_SIZE; + } + } + } +} + +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 b7de23c7d2..37ca70dcf1 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -630,8 +630,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 Sep 20 15:24:58 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=1789140224; cv=none; d=zohomail.com; s=zohoarc; b=HSqtFuTZceQ5HevpGyxG/1Y05YRzHrrShfKUVJl1MZEZwrewwyr8NrgZQMmL6qp1gRaCfmYS2uEgEEtUo8kkcHH/yBRCUVOVF6yImnyTSiBww1wrriUNOLBrdB1rtGECXdYgvbthsiWYTSieVaCYWf/niG9sxK7gGkm+PFJIUt0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789140224; 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=dztpV4sHbP6jXWmT6PTrhJ71EXX91O3F0lfOYDQfLz8=; b=DwdeTfvPUmGFt6t/l7uwZRzusa84YF20XMbg0mePWDB2f5eLm5VgkoL1tmsL1Mlfb/SCh3wD7WDs1KHDuR6xePbDKKTCRTJapGA+MAPXlIv97L8N4McWCp5dvvrn7h1cchCghiS8tFE4XLK0cEQvRum//DEmG+X4ZAyQwhQSbmI= 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 1789140224394563.3424417307436; Fri, 11 Sep 2026 08:23:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x534u-0008LX-M2; Fri, 11 Sep 2026 11:22:12 -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 1x534c-0007yR-Pa; Fri, 11 Sep 2026 11:21:56 -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 1x534W-0004jq-1Y; Fri, 11 Sep 2026 11:21:53 -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 68BF1VmS2143591; Fri, 11 Sep 2026 15:21:42 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 4gkd8t4808-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:41 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68BEo8rj1802572; Fri, 11 Sep 2026 15:21:41 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4gkvtff298-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:41 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68BFLed029623030 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Sep 2026 15:21:40 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4898158058; Fri, 11 Sep 2026 15:21:40 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 12C6858061; Fri, 11 Sep 2026 15:21:40 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.atx-us.ibm.com (unknown [9.16.62.165]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 11 Sep 2026 15:21:40 +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=dztpV4sHbP6jXWmT6 PTrhJ71EXX91O3F0lfOYDQfLz8=; b=sD3pqf7wBGTPXgLwMjmARwj67OJFpxFrS 8KHo0M5Y0RT7bGktpozSSUC5XCbZpyR7ADBBCCQ61HDqG3okWYknNwRgLhrrKISh X8OyEEygDdtESaD6TWVamXf/3qRqna1mAwJr8Wh39GOZTUGEvSv08AxGvu1Yvv3c IL7EQBrBqUcA4K+XBJ7DZmFq0GOKM4ndTZmfC/1fE48kpUpENAYUdZhWoda45OCb akHDkgIWjNko1gcAkROKoDQFZm1FjVVexj098B0rOs7UkjY5IiQfXbojjrBkjTmH FG8CcnJj2plqWSpLB/VHJSI9hYHoqTYUYv7N9loRaVPkS/uk3cK/Q== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, farman@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 v8 02/16] s390x/pci: Create function to contain translation status check Date: Fri, 11 Sep 2026 10:21:23 -0500 Message-Id: <20260911152137.676602-3-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260911152137.676602-1-kshk@linux.ibm.com> References: <20260911152137.676602-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Info: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfX4xnSLdftNQ7M 5/UqXeFtEp6nybI8/aS+qFqr2ieIfD/2h2+jFS1rugHR4LnmMZgjmsNb+x7UH6C5jmDr0lRmBK4 LGJkLDVRpwGPNyBW3+ddzpVAw29Iw58= X-Proofpoint-ORIG-GUID: 8tmzF05jyHn3ShmrGCEOxxSj_ZTczLRD X-Proofpoint-GUID: 8tmzF05jyHn3ShmrGCEOxxSj_ZTczLRD X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfXxG94fgFm5sXQ BAZyq1iinnnqlBfKglUJYaATl8/K/6UJiuWgF4FS2QbxOJ0Xt7MlNZQ6HhAwCJxAa7moDtUJrkh buU42WUex9uk2rMmWIRSTT7YdD0WzPdV3pjKjATK8IVrLh1DXOANn+90kHpW5fL5d6ghnD5BV5c +gfUsF95At7GifNrKwVbu5pUIuxJNHTWJnqm93F2eLsjt18ZY0CHoUWOIWFgAl6PHY5+2t0M0YT Ec3HLxKly2hdS+8O0jpBMzOCNuzKyhz/gi0UoSja6IO2tHo4Yb9ypxQENHK5I7KR14PjNHPYYVU FR+4tBQr4xSFr8abldJmVnAz8iw8u+MgvPqSJzoqwSi5cYQY7FMf0FRrlZgMSGqTIr+IK3XzuT9 Mi2lFw9sCFHXxtDnIzwsHA6uAA9PsbdAxYDkU9wspbRaigAyg2RhbFvtA3yhguGH/S18pIBQkSa RJNOgTEI76UD5tOs5WA== X-Authority-Analysis: v=2.4 cv=PIGaavqC c=1 sm=1 tr=0 ts=6aa41c85 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=aCv-BzsnQx_gTHabB28A:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-11_05,2026-09-11_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 bulkscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 spamscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609110210 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: 1789140225494158500 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 Reviewed-by: Farhan Ali 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 37ca70dcf1..00a847f493 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -1021,6 +1021,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) { @@ -1029,7 +1034,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 Sep 20 15:24:58 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=1789140165; cv=none; d=zohomail.com; s=zohoarc; b=H9ai9c5X+b3nZMpMoLNQRTHSz7TiwkrWvFsUqp9LQWuj83nF6fae1blLr5vcM5nC85SsoBjykIffoUsKdmM37w+HgBoqLkYeWOUtShYX452vWUzCjZAzaFxL+wBQ4vcbadEKrylDWxDM/ETU/+hJTBb/+JF4lFbgz19Rr3rgjWo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789140165; 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=9BK6ZKqqogsiR1guHaTUccIjJ/PgjujuLN/O9iXIf90=; b=NiA6p7eueKxo5SQQM9TjsY6XTOd8n28MStVvBQSFwlIcdO4NZ4LvwRO7pHElK4ENykNRCn6E4DpbJWyls8pCGx6QKlxlWTteEz2LVYZVxBH1Mk2i0pXoSdknXCyfccDu9ulj6yCHV6vR0bi6Pj0YC9Q4clUUhku4nNCrpeRJBRw= 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 1789140165760360.12717228044437; Fri, 11 Sep 2026 08:22:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x534w-0008NO-CG; Fri, 11 Sep 2026 11:22:14 -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 1x534d-0007yU-BX; Fri, 11 Sep 2026 11:21:56 -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 1x534W-0004kR-1s; Fri, 11 Sep 2026 11:21:55 -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 68BF1RaB235465; Fri, 11 Sep 2026 15:21:43 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 4gkd8ncbm7-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:42 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68BEo82S1764851; Fri, 11 Sep 2026 15:21:42 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4gkvvrf0p0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:42 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68BFLeiG33423984 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Sep 2026 15:21:40 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8C1A158059; Fri, 11 Sep 2026 15:21:40 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4FABF58064; Fri, 11 Sep 2026 15:21:40 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.atx-us.ibm.com (unknown [9.16.62.165]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 11 Sep 2026 15:21:40 +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=9BK6ZKqqogsiR1guH aTUccIjJ/PgjujuLN/O9iXIf90=; b=arq+/tWumcYE3aY+mkzg2HB1HUeshU7Bw 9CReUDwXQ3zwNkFRZ/enxuWTQ8cRmKU5aEsbfIXdtLiT7DGvLrv/ZQp+YXqCvChg O/WLn8OhvhG9dBLEJQpMsJyusuGzzYziNv8R0VJEJPVqLz5P3833wx2cDX3SmTpc OXMU23Pfslp2+KQvk/ijw+HJVamZ5L4jFNsWqvS7wIi0G5d58QOr3m7w5pC+UwIU e+qNOs0OTeVRmmPDjdGj/I1u8JejXn+BFTG+HjLjMmoxh9Y/kzWLDmGrJVZAK9wx BF+6n9sG1TYzGbjWRBDu9eMCniIMb1HfjUdJqRLQfaW7CPYC2PnQw== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, farman@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 v8 03/16] s390x/pci: Move iommu_mr from S390PCIIOMMU to S390PCIBusDevice Date: Fri, 11 Sep 2026 10:21:24 -0500 Message-Id: <20260911152137.676602-4-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260911152137.676602-1-kshk@linux.ibm.com> References: <20260911152137.676602-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=NMVAaE6g c=1 sm=1 tr=0 ts=6aa41c87 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=n4sMxHAKvM-efvCv8lMA:9 X-Proofpoint-GUID: LVJZX5jSF25_U0WiyQ0yjKb2Idh6IoMm X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfX3qLOwnLUXN7H Mm/FF0Vk8CPwc6II6oB21iY/Gvm4hSPZ7X8E3Q30ANZ4fU2gubSYhvn+4nLXwBZUAfXyCJeN+TN qGIue1L0E8RkskPaNlhhMPhcDtNy+W6Dd1+vi7p3N5lvfhdOpsqngaVZ54UwoK5VooVY/WhTDee +HVhaqt9GDBYZ8ArAJFO7Eip7/wptOr+5ToRULP3NUywC4hjAedSVjQXSE33xiB+f6xp2bvtfzC ionAvVDNyz7I8M8+LWCDJgjIe0GtGtJZeZuKFrcDQFrAfxhHyvdgN3frKXIhNHanVtCrnLWbnMu dnmWOfsnsJAOLF9f7kSgRuIoMSsppqd8A4O3QaKRRid00ilR95Un5NKDqnuBUdTIYiCnWq55jCt l90NvY9RXps8FMxzZOtBTCUqPiI0IEC19BQqMlP2sBLYxvacDXGywdodHB1T965h11KH/5UxnYU jllE0PqU1xLRsAAk7gA== X-Proofpoint-ORIG-GUID: LVJZX5jSF25_U0WiyQ0yjKb2Idh6IoMm X-Proofpoint-Spam-Info: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfX6rDlKPkzOTJE IWwTIoDqTppUhafCIfJimDQg4pRM7U+DfuWVvUssglXG7MVpX+f5ETTgWe54BTpzjnIV4S3vebV Zzqvc/6N038zxOuGpvLMB+VnbR/C2zs= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-11_05,2026-09-11_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 clxscore=1015 malwarescore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 suspectscore=0 impostorscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609110210 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: 1789140167199158500 Content-Type: text/plain; charset="utf-8" This field is only used when S390PCIBusDevice exists, so it can be moved there to simplify S390PCIIOMMU towards a structure that contains only the IOMMU container information needed by the PCI layer for a given slot. Reviewed-by: Farhan Ali Reviewed-by: Matthew Rosato Signed-off-by: Konstantin Shkolnyy --- hw/s390x/s390-pci-bus.c | 35 +++++++++++++++++--------------- 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, 39 insertions(+), 34 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 10b417a779..b6a03bcc6a 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -207,7 +207,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; @@ -539,7 +539,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; @@ -593,18 +594,18 @@ err: return ret; } =20 -static void s390_pci_ioat_replay(S390PCIIOMMU *iommu) +static void s390_pci_ioat_replay(S390PCIBusDevice *pbdev) { - S390PCIBusDevice *pbdev =3D iommu->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; =20 - if (iommu->dm_mr || !pbdev) { + if (iommu->dm_mr) { /* If direct mapping is used, there are no guest tables to replay = */ return; } @@ -629,7 +630,7 @@ static void s390_pci_ioat_replay(S390PCIIOMMU *iommu) if (entry.perm !=3D IOMMU_NONE) { while (entry.iova < curr && entry.iova < end) { 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 @@ -654,9 +655,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, @@ -778,19 +779,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 @@ -816,8 +818,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) { @@ -827,8 +830,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 @@ -1427,7 +1430,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); @@ -1568,7 +1571,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 00a847f493..0772f04cc2 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -630,9 +630,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, @@ -662,7 +663,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; } @@ -680,13 +681,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; @@ -704,7 +705,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; } @@ -801,14 +802,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 { @@ -824,7 +825,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) @@ -1059,7 +1060,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); } @@ -1067,9 +1068,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; @@ -1293,7 +1295,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: @@ -1304,7 +1306,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 Sep 20 15:24:58 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=1789140214; cv=none; d=zohomail.com; s=zohoarc; b=QzYMRa9et9A+TvEJ+q1Oup0Hox3SDdDqgrPxGVCAOjDORNvgeV3HW/NOYAzw+tvza9Eii3MPuCNobsZatwnODo6Kx+kf/t3VQVBWBSVy25V+6P4v10MM+YgGllukPbiZgoG6NK+S9mmuVr6Of8yRQ3iY/d/drci4O0A1uJ7WGgI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789140214; 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=370oi7erpzbA5pBwtzgl9MF+hjpJBIEDmH4vLh3CXKY=; b=lCqDeHBN+UjTO9py7ETvvR7ACyF29Gkpv59fXja5SRLOfbtcyuHeJFlhOqhy2jlneg++tBDJ3D57nY/TWwEetuseRXppdRCi6v+H2HrDXy+slPOWwM8fEV4v+MNCxsPTgu8OJSH9pznKDOh4PQ5Spel2n/S3qXf72mbc5Yiofzs= 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 1789140214027417.1573056363733; Fri, 11 Sep 2026 08:23:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x534r-0008G6-FB; Fri, 11 Sep 2026 11:22:09 -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 1x534d-0007yX-Ef; Fri, 11 Sep 2026 11:21:56 -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 1x534W-0004k6-1P; Fri, 11 Sep 2026 11:21:55 -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 68BF1hHa1973594; Fri, 11 Sep 2026 15:21:42 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 4gkd8sc7v6-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:42 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68BEoApm1789344; Fri, 11 Sep 2026 15:21:42 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4gkvwk71sa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:42 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68BFLeGC27656760 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Sep 2026 15:21:40 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C7FF658059; Fri, 11 Sep 2026 15:21:40 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 92CF95805D; Fri, 11 Sep 2026 15:21:40 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.atx-us.ibm.com (unknown [9.16.62.165]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 11 Sep 2026 15:21:40 +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=370oi7erpzbA5pBwt zgl9MF+hjpJBIEDmH4vLh3CXKY=; b=Nox8WTfwqvekh1x+Fu/ryKUqZLc4nJoSz Pdo6XEkPbjJHP8ToPBsDZKDn6GNsD1yGENvjEO1OSOFjzSHqWP4fZaM53eNa+c5h fnXa8tfBRWlZMRifIBQXT0rdWRl2jIduvdfG5yLxsYtulVJGt3CFzijVdC+3Achk d3YdFree/1R0e0Hwek81ICDMVANZS/fruVW8VL/JudGqAQmE0EToxYBi9IhqbdOx K1x8nn4qNI8xDAQDOuXkJKoMkR+Be9TuSC0kRhWX+rEbRVAO5PEcgVTNgjPo8gym 4FiEvT105Ht8UafjRSSbEuVQ62p9zRESRZrWv4K2EX8c7O7lHRIDw== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, farman@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 v8 04/16] s390x/pci: Move dm_mr from S390PCIIOMMU to S390PCIBusDevice Date: Fri, 11 Sep 2026 10:21:25 -0500 Message-Id: <20260911152137.676602-5-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260911152137.676602-1-kshk@linux.ibm.com> References: <20260911152137.676602-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: u-PqGKNTS5070_CT0t5BZnwc6bsjEDq8 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfX9qrM+TRnLchL TuZp56mytanJn9jn6YnFh0NBJH/OuqtGMiomDLrGxkZqyc9ghKaXqxDoiEx8L1nFGpaf/clmTOQ MdQUuwyUI5zjyNK6cDTwOivREwQPuSQwr0a8apuxx92b7rQQtdDMpsZavjZy90oMU3nQrSeT557 mdk2TUWcsNEgHNAEvsH3uvwBhP0wRn+wUwi2oGc0Sk7xvXc04yum9wtz18OgE+18TWMiwzXrrdj 6n5WiYlV0QnLppNAuGRM4yHnorsWO2yF5b8aTpOmfAvZhqZIYKtkrztW1L6QwQuYUtoBTrO4qxZ jnI/hTKDyfbQcKge7ALgC8iltOblu7ObqU1L+r5zCpDy2coy1J9nYa6GEtJyDPr2YZ3LpDcifpn OuG+5RkRyNeJPLFCL01EX8Pq7eoScqSIjx/M+S7S9kjXp2bmFD8iz/MOXBntbnmhmqtvSUzaRV0 Fqp9qQj3sHgHAXygW9A== X-Proofpoint-Spam-Info: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfX4njmwpVRK57D 20b5nLX2wnE9cDisQbTFBl04Pigk8RDfTzKbnopp9to4WJpywW3t6cNstYtO1wNa2RpXDmxLysj h2lPK/nHoIsFGON08e4FwTJh03FENVQ= X-Authority-Analysis: v=2.4 cv=MpXHeGae c=1 sm=1 tr=0 ts=6aa41c86 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=jDWEBKAz6ZLYevfwb9sA:9 X-Proofpoint-GUID: u-PqGKNTS5070_CT0t5BZnwc6bsjEDq8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-11_05,2026-09-11_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 suspectscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609110210 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: 1789140215521158500 Content-Type: text/plain; charset="utf-8" This field is only used when S390PCIBusDevice exists, so it can be moved there to simplify to simplify S390PCIIOMMU towards a structure that contains only the IOMMU container information needed by the PCI layer for a given slot. Reviewed-by: Farhan Ali Reviewed-by: Matthew Rosato 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 b6a03bcc6a..e1b47f3914 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -605,7 +605,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; } @@ -796,8 +796,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 @@ -809,13 +810,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) @@ -823,11 +824,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 0772f04cc2..582e93a741 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -1062,7 +1062,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 Sep 20 15:24:59 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=1789140186; cv=none; d=zohomail.com; s=zohoarc; b=oKzTkLn9bBGg3FP0MgNvS4BjCY4AMqKQ12Z5h7WxOTB/+tU6pjN1plchx+Yolg22DlY3nbXnrFfiL8RDoCwLGVyqOGaMMbQuuuP3suKmp2QUXeQjXpyIydoB7OLL5ktzpG41tLLgdc22vfphdZsspyrVwE37kbhSP3xKRG1F66Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789140186; 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=Qsv22XMFOF5yhoG8ReOO9gO1TPfKC3by84RZhK3tG88=; b=VJ0968RVrEDxZp1NKsp0mOrPaVOjGMPRYrgpEeL9YGnoAH2wQI9IVND6AIBn9hRGUnpzjMGoILvt2e2rCESGhnODHCCCE9quOponvVp2fVgUle0q1U53YEf4CxLKz3YcX1QsCUK2qBdOoRvCpoNoW4ufB85HXsxMyvcbqCtSVoM= 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 1789140186726945.2403067489624; Fri, 11 Sep 2026 08:23:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x534z-0008PV-DZ; Fri, 11 Sep 2026 11:22:17 -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 1x534c-0007yS-Q0; Fri, 11 Sep 2026 11:21:56 -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 1x534W-0004kT-3J; Fri, 11 Sep 2026 11:21:53 -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 68BF1YaZ2143646; Fri, 11 Sep 2026 15:21:43 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 4gkd8t4809-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:42 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68BEo7k01817328; Fri, 11 Sep 2026 15:21:42 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4gkvnrq2k9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:42 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68BFLfuZ39846166 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Sep 2026 15:21:41 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0EB8D58058; Fri, 11 Sep 2026 15:21:41 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CE65E58061; Fri, 11 Sep 2026 15:21:40 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.atx-us.ibm.com (unknown [9.16.62.165]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 11 Sep 2026 15:21:40 +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=Qsv22XMFOF5yhoG8R eOO9gO1TPfKC3by84RZhK3tG88=; b=jQDway7yiA6az85LpymxiZ551PwXP0fAd Ja8XHTJzJ7k1GFrJii9YR40UMd/F/Zw/erAeZhcE8CK+Jw7P0msKUJMzkedaoUqw n7qFv2p41c3BQHwUFyW5DzvW2IAN1ouAFgZAKLAaekuF0Fk2reODDzm9Mk5UGHOP 2qTf3/DX/RrJ0QxpXhHr/WODbqNcPGHUNl8vYgrxDCh+iT+GH07+UB3V4IeoROTd BwvGj7vq4gfveV8CPnDae85ZKhJtqaLNHWZ18a8rNKTUM3DWhPz/LhjnGWce3fTC aBueyGxHkPuPY7fay/ynFz+1Q2K8dHFv3VorzQIo0/K2DwWZEzqvA== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, farman@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 v8 05/16] s390x/pci: Move iotlb from S390PCIIOMMU to S390PCIBusDevice Date: Fri, 11 Sep 2026 10:21:26 -0500 Message-Id: <20260911152137.676602-6-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260911152137.676602-1-kshk@linux.ibm.com> References: <20260911152137.676602-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Info: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfX4oMqti70IwEa ifAcvPdelzYIn0VKsviEO0MHZunCyomJ3612Pd/IYIIkDURkAlGxMEKn4XkYrfHlxYmXiMFNx13 E5yDdw+eMbujQl0ckwgMJTqUtH3bsX0= X-Proofpoint-ORIG-GUID: jDRNQhE90fRpp85Cxk5s2s86mt5B0DMb X-Proofpoint-GUID: jDRNQhE90fRpp85Cxk5s2s86mt5B0DMb X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfXw/GWv5Qt+h9s XrcoWzV8XI3FRcRG9rWh2apbLpfPusGny+GSyAUeIOr5rPyKKzw/ao5cXMVGW3nb1+5hFPnmprX qdH0ri0zhn7hLnsfJLRQwhVhqtZDrdoKLkVu6cFPQ4TUTROWh306xuFh5dGMDOk2mUrF4lMX0T/ ZT50zF3MAIIgX58t270LkBQnmU+7TE05xOYzXxLnqyLeHlHkCbnCd3LihAyYurdjCO0XMtSI8Pi qhOFWLLiB1Oh0viiWq0qqVpaOJfHq1gCUTJkwiC6/n1Nam2n36HKfEic8Ljf8GA92iciul0kM6A zblmr2b7Vsnk3UzfUexNSSn9G1PwIqOVnnRYQf43evtmWNwlXo59lsulZ19f9S/HOzw+Q340ACk CaQf4BRKvaIGVJ1H17KCWMhiwlIQCNAMVIBVdy8H8yrXfJnEIE5ZjyTV72YYQnKHyQvCmWC8BLz R3cYV7ER7zVjnQyRQhw== X-Authority-Analysis: v=2.4 cv=PIGaavqC c=1 sm=1 tr=0 ts=6aa41c86 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=aa0cxrGLn-JNQd9UaooA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-11_05,2026-09-11_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 bulkscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 spamscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609110210 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: 1789140187287158500 Content-Type: text/plain; charset="utf-8" This field is only used when S390PCIBusDevice exists, so it can be moved there to simplify S390PCIIOMMU towards a structure that contains only the IOMMU container information needed by the PCI layer for a given slot. Reviewed-by: Farhan Ali Reviewed-by: Matthew Rosato 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 e1b47f3914..7c1aa260be 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -570,7 +570,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; @@ -687,8 +687,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); @@ -823,7 +821,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)); @@ -847,7 +845,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 @@ -1269,6 +1266,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 { @@ -1311,6 +1310,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 582e93a741..f648afb401 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -634,7 +634,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 { @@ -650,7 +650,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; @@ -673,7 +673,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 Sep 20 15:24:59 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=1789140191; cv=none; d=zohomail.com; s=zohoarc; b=SH7hqQPo15CweNaZ9OQ8AED4Gj3SHU2K5/J9FkDO7OYX4wn4ghQM0LeThB9/WOjwLO35qFaoG/E1MkajgikYbexDQdj/3O5QH+Ty6feItODWe+yrPicOG+aoz2e2qRX0OZr7ncWW5VdwwxpT/sH2pfWpL8p7HdtsBK13NcowBZM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789140191; 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=xMXCHhZYF61f2K1Aclw98qMc5Gqt6dZMA58X/9fVyUo=; b=PBATDEYAIayo9QMt2QBpEV4/USftJ/8X9Ff9XhqkS1rgQ4Z3Y3NAahpH5i95ACmBqUn/G8h9f019FTj3TrvzVcFGkn/B81H9k+9M/x9C4JXwikAnuKhRnTpSpzBCtKsJRLzghLGJ1L21hhj0HZ+v6W1jADGipJ+i9Idv1ZZI8oA= 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 1789140191970954.3224456375103; Fri, 11 Sep 2026 08:23:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x534p-0008CO-LI; Fri, 11 Sep 2026 11:22:07 -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 1x534b-0007y2-UL; Fri, 11 Sep 2026 11:21:56 -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 1x534W-0004kP-15; Fri, 11 Sep 2026 11:21:53 -0400 Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68BF1laG971807; Fri, 11 Sep 2026 15:21:43 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 4gkd8qc91b-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:42 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68BEo8rl1802572; Fri, 11 Sep 2026 15:21:42 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4gkvtff29c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:42 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68BFLfkT14287368 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Sep 2026 15:21:41 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4B05758065; Fri, 11 Sep 2026 15:21:41 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1580E58059; Fri, 11 Sep 2026 15:21:41 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.atx-us.ibm.com (unknown [9.16.62.165]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 11 Sep 2026 15:21:41 +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=xMXCHhZYF61f2K1Ac lw98qMc5Gqt6dZMA58X/9fVyUo=; b=kuyssSIjv4RT0Gmiuxaj+4nQVJuxn/irf s0L0C0O6YccGlobO8M7mq/MgdLLfy3EkQl7JJAbdR/a9NllRs/JQUA3Sl2mFZvu0 o9+9mgAQy52uR06wLLw70FFZbmsGnz2seKz/+fLaLFMOw+EAydgA+alIlcq9yaT1 Q4/xRBBQzn0VkN8qcxDchJt5WlCpW9Snl7BgY5zkOIj6jxerxSXti+XBtwUvsPKn ahRW4KF7ONiM0l6R4XLYM6Zv/dJ1x/ZDbmFT2+Yp3hwlwAe6CspOlu8GYiXyxVcm ThAomk5f8xG2URwoU5IrCgnZ/EUoK9BdPt4IgocHt9y9OekQ9o9NQ== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, farman@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 v8 06/16] s390x/pci: Remove a ptr to S390PCIBusDevice from S390PCIIOMMU Date: Fri, 11 Sep 2026 10:21:27 -0500 Message-Id: <20260911152137.676602-7-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260911152137.676602-1-kshk@linux.ibm.com> References: <20260911152137.676602-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: lqN4G5UXI7yQRH4X1xqhlYo1D0VC60aa X-Proofpoint-Spam-Info: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfX2c7/95YaDP4l f+MAR/c1IGv9rS2CP0jonpcBPGmZkLLwo7ZX67aSz8oS/EX3gE1l5sO102y8In2Y/toCn43tPvV A/aIaQxFaEKYb1TxBRNOVSsOzW8Ujtk= X-Authority-Analysis: v=2.4 cv=E/dYNqdl c=1 sm=1 tr=0 ts=6aa41c87 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=VnNF1IyMAAAA:8 a=yINFAIt2aqTEABBYJGoA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfXwYAKbwXkU85l wIyiwqmDff3XHPSmsfN0Rt/sfpHAeJJKZ0Ha5TBbm3NuJ3NxjRMSpt7d3OIsj3ig0jts1v1BCIN xn/O/2fcUZbKt9ezSV0pV+AFRkqgTU7wffyUn5wVedkvO3S3W8o2jm7XNfGelSFWI7ZQXeV4eI3 8Bheq5FCWaZ5KuRA+x5RusajPw6lP22FtR3BTi11hsdkSz3/PEL7bWArLLyQC40QMAUOPaHQgus 0E8nH0uHtK0DJJyPbSUqcyWE/BwkvbGl5CEiMUYOyIpVhUzN6AWGEvAgmMKUKY9M8rbOVtHfrIJ e6/lZG4PYuSIZALMhwQoNCP/L8HTPGy2rbVNFsl0Jm6BawveTXV8SaH7Bgnu/L+HEKgrc5EJRY1 El8g/QJtPHT/1iuKP2rNG2NZvl16LVy6xKw1gWnWwrQ+zkeSGtyRrh2i7gi9/4kp1YBX3bVcmjb j02jPhSE0mzOs/tageA== X-Proofpoint-GUID: lqN4G5UXI7yQRH4X1xqhlYo1D0VC60aa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-11_05,2026-09-11_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 spamscore=0 bulkscore=0 clxscore=1015 impostorscore=0 phishscore=0 adultscore=0 lowpriorityscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609110210 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: 1789140193243158500 Content-Type: text/plain; charset="utf-8" This pointer is no longer used, after fields were moved from S390PCIIOMMU to S390PCIBusDevice. Reviewed-by: Farhan Ali Reviewed-by: Matthew Rosato 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 7c1aa260be..10e0c3324a 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -552,7 +552,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) { @@ -587,9 +587,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; } @@ -785,7 +785,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); @@ -806,14 +806,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 @@ -1205,7 +1205,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 Sep 20 15:24:59 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=1789140129; cv=none; d=zohomail.com; s=zohoarc; b=Ld4xyOZV0H2vnYjHs6ZIPE+hGQCR2BF6FB+W9RXlVDSlEHEB5MJ4onGZwKke3CuYoAdsRz3f34bWkwluO7Ft/bZPihUy1arasrmqNbk+rL7qOTMICbk1gUvUDp6Sp6V6y0+vOkvjOI9jBy2SXEvQQZ0Fekhg2kLncv9Q6ovNH9c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789140129; 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=lK6qda7IZST5uk5vDl89q1Rcj9/sZ2jxX93G5MnVN1c=; b=QkV02gWPqyyd5V4GhgFgZF2iEu912zVlH+B46/o+khsWdOg3fr+Kn3jA6pUfwzQqwBVK0VP+nQzBpA7m6wWz3HCuagdR2cvfGJ1C383Xr6YmpMcLAJSL9hj2Tgd0Rw5ByKjBzfOJPD0L3VW5KixTLCUIk2zXHMT6NEtDIEhYWF4= 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 1789140129132121.27707991973159; Fri, 11 Sep 2026 08:22:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x534n-00088L-R4; Fri, 11 Sep 2026 11:22:06 -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 1x534d-0007yV-C5; Fri, 11 Sep 2026 11:21:56 -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 1x534W-0004kZ-1d; Fri, 11 Sep 2026 11:21:55 -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 68BF1X1l2143638; Fri, 11 Sep 2026 15:21:43 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 4gkd8t480b-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:43 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68BEo89J1817350; Fri, 11 Sep 2026 15:21:42 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4gkvnrq2kb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:42 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68BFLfwq10158846 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Sep 2026 15:21:41 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8756658061; Fri, 11 Sep 2026 15:21:41 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 51E0C58058; Fri, 11 Sep 2026 15:21:41 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.atx-us.ibm.com (unknown [9.16.62.165]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 11 Sep 2026 15:21:41 +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=lK6qda7IZST5uk5vD l89q1Rcj9/sZ2jxX93G5MnVN1c=; b=XSrAbyOP2le2RfaUsuCMWd5yWLnHNy93i f66hak3ijKc6x3HzbVxrvz2OYYTiI1ak/oAshqFha3PZgwuMCXje9DTwIMyCM8vt hK8qDr+Ldc1exQEF6/Dz9KDRluq/uCGWKVy3WQCWtb3toh/ztO6J/x2NAEeaygWC o8YjJcPt4Oc6GVR092gd8J+WzzAs+6h7gcXStGV/8jONF1exjvr3cOQ5reRREZiz 3/EC53o7foBeynIc8vp5ywNbQnJAUWqY/Pt5r2AoEolYcRoMBk4R6Vwo3LyTUP9O SqDDEq3AIxqMHD42Nyht1enY0FM30d3mOdw3HOlsMYfRQ2WAqigDw== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, farman@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 v8 07/16] s390x/pci: Move/rename enabled from S390PCIIOMMU to S390PCIBusDevice Date: Fri, 11 Sep 2026 10:21:28 -0500 Message-Id: <20260911152137.676602-8-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260911152137.676602-1-kshk@linux.ibm.com> References: <20260911152137.676602-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Info: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfXy3LCgfy5OSAP UbYVJQHTxQ3H/xqfiV5LAJRM93ypCYJQwZFZxgUFFZAITUe+E/pc6266fwiHyugz+wKs8B6LGvz VavBSe72eN802EPP0zHt0Ra0b2nUj9M= X-Proofpoint-ORIG-GUID: A1YxquvDSVvvDN1-ETN2IVEk1BhGbe-a X-Proofpoint-GUID: A1YxquvDSVvvDN1-ETN2IVEk1BhGbe-a X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfXxc9E/AbLqA/U Lspc2nEgWUBSZw2fEcWG9u3shN2ymhmjgH2IiCSJQiGImCgl8uOznVytXaFzqOOsY8vcRLAEsK6 l35/8HdyptPwSxUTub3ZHSXd9VlY58+Vw8U5oR5BfIC0DmnsHz3i7kBzrcKJJzb0aVVFC0dzlUS nLMfkIB4OW3EfUk0AZTxHLWL4O8yBjgifXPiYqM4lODRKF3/dfaq45xVUh0T6k3vRQUN3WhAHsB kmQ9Z+9dGrEX61l86sHFlraYzzhSGd5i5MVLfnXRMsAvzSHk3C5GsWxbh6F0ILeK4rhq/jOqSvi kuWMSM92ThmE/cCa5OlLgCITvaQmGw8w+JLrFahjqdObI84F0z9Efllamva8vKaEQCcUDdIvZt/ UXN5ZRwBlIPZELMc3Q6oTy4lJPUX3Q2uogfJue+wsYgogd/PlCPl7CQPwCk8hom/qVSJNyjfOn3 lF077f3vb82+ZLMJMEA== X-Authority-Analysis: v=2.4 cv=PIGaavqC c=1 sm=1 tr=0 ts=6aa41c87 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=i0DCopz73FH-yKe2uwYA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-11_05,2026-09-11_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 bulkscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 spamscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609110210 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: 1789140130990158500 Content-Type: text/plain; charset="utf-8" This field is only used when S390PCIBusDevice exists, so it can be moved there to simplify S390PCIIOMMU towards a structure that contains only the I= OMMU container information needed by the PCI layer for a given slot. This also allows to save/restore this field during migration. Reviewed-by: Farhan Ali Reviewed-by: Matthew Rosato 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 10e0c3324a..ee05447084 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) } 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; @@ -555,7 +555,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; @@ -789,7 +789,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); } @@ -812,7 +812,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); } @@ -820,7 +820,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); @@ -1429,7 +1429,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; @@ -1570,7 +1570,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 f648afb401..7081be4619 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -1279,7 +1279,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)) { @@ -1291,7 +1291,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 { @@ -1302,7 +1302,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 { @@ -1432,7 +1432,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 Sep 20 15:24:59 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=1789140317; cv=none; d=zohomail.com; s=zohoarc; b=moVZaH9HMMK/Ojc6YCQfVthYqxq1++bCSfL/3RRY48WQh27w0VeVliXFObKYRzTv4fYgchLxiv36wgoTwPJz6c3lAYRljQEQA7EdTr9CsCeGgtOCs1a/aQCVvBN2mGMPB2xKRkZABmhOD2WM9wTvtAVvGHM2CpSmkAq2lVo1GUQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789140317; 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=pltYl5lwWV7V/bm42aAWVKyb7sYVZXFX0MS9y26rjI0=; b=AqOmdZiMLc8IFaJQ6CyKEbUoVUujKDSj9gZERlXkhgGbqPoahV/luyhNe0QFd84k7Rw4l3tS6dENerEwLY9xfj05XWl9S7ye0dPmiDqvky7ozO+Z+BzuVoMSaQseo2+APX0q32ZiAyiZBFEmFNGLEn3Ra8V/m/3jJVpPaSGEtMc= 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 1789140317738247.31634795382865; Fri, 11 Sep 2026 08:25:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x534v-0008N0-WD; Fri, 11 Sep 2026 11:22:14 -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 1x534k-000860-Vf; Fri, 11 Sep 2026 11:22:05 -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 1x534Z-0004ln-Uf; Fri, 11 Sep 2026 11:21:57 -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 68BF1laE2110298; Fri, 11 Sep 2026 15:21:43 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 4gkd8pvcy8-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:43 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68BEo72w1834064; Fri, 11 Sep 2026 15:21:42 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4gkvmhq3fk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:42 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68BFLfhU20972094 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Sep 2026 15:21:41 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C4EFF58058; Fri, 11 Sep 2026 15:21:41 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8DEB858063; Fri, 11 Sep 2026 15:21:41 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.atx-us.ibm.com (unknown [9.16.62.165]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 11 Sep 2026 15:21:41 +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=pltYl5lwWV7V/bm42 aAWVKyb7sYVZXFX0MS9y26rjI0=; b=jo8Az/BMMhTFbJ9G26FYJEsg1/XjnLsLr 5YZ3qnMNlBj/B/dTtxzbFnUT1bz6M50k9Dl7aJkBNMCaBflN5i8QcSOWD0WWNb9P 6HPb7AmxsoFteYO1aRUAgaC2XP9XohtKP/NixDy2izSy73CIok2y+bdl3PbhoTWq SgtLLvXQXtTD+hw/P26PYYPkJncZ0Y/j9AMc6MHSdDtVTFLskfam2b9uN59+Ebs2 LEVl1IswcZJAmWEYDazCYW7u5msaK5Nxaf1lHryfMyhmMM9MVC8B//KYgBLEPrat FkqhkKFnrFL/2ULrjmhjX1Whc3DL1+KC5t5RDRXFGodwiP8lfPAXw== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, farman@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 v8 08/16] s390x/pci: Move dma_limit from S390PCIIOMMU to S390PCIBusDevice Date: Fri, 11 Sep 2026 10:21:29 -0500 Message-Id: <20260911152137.676602-9-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260911152137.676602-1-kshk@linux.ibm.com> References: <20260911152137.676602-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=eM2GH3p1 c=1 sm=1 tr=0 ts=6aa41c87 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=WVqpMwhuJbQVQ5-U79kA:9 X-Proofpoint-ORIG-GUID: bKOzPgoE8wLtt9THHDhUatLDB5g9flzd X-Proofpoint-GUID: bKOzPgoE8wLtt9THHDhUatLDB5g9flzd X-Proofpoint-Spam-Info: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfX7W8niPjIUJw2 d766KRW6cRrxmMMMmb/2+NJeXZ6AwJgk0LQV9HLC/t85QhyNJi65k4+ewC6k3OeicDgmMcftTgP QVVsy5cdUljw/ror+atWjKv4FEVZWSw= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfX9GgO2l57QeIL 1t4StIXteEIhhh1yxQpgujYGJTG0umfHGXFr/urQF7+k1NmNd2WDKQYb6RsvzfS818tY/5ExtZh U3BGrSHENBA4OS3L2a1S38IS9VzJuNW0YRAhtYt0wrpuKMqx7IaqXtrUNNBtx5eMlfzJqTFA4u+ pwe3TMhuOFnOFKBemyRqi08RxCAIy2fjk3y8qZbRXhrSeTWaJIRT+zL/IzbDV7GbvWih68y9yAO KyIXdbg3hsOoe0geHZXrOiZyPPfyn+laS2YhRVQduspn3AVG5p08oipR+wd2aP36adwhLR6pS2l 89X4A0q817CJJAiFKrNzXMVRS/olWsVok0WUIPHrJi5jIDcQbiujpbSoxejzY0fJqVMm/miWFnR 2hoipKlC4pM7mggUmOUiH0DYCYuXCYZ/eANDg0x/JZTf2j8WGUk2sA3Cg1CFpxGsFC0V8/MAmRg 9EFLKFcVT+cDRPDjWTg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-11_05,2026-09-11_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 malwarescore=0 adultscore=0 phishscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 priorityscore=1501 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609110210 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: 1789140318032158500 Content-Type: text/plain; charset="utf-8" This field is only used when S390PCIBusDevice exists, so it can be moved there to simplify S390PCIIOMMU towards a structure that contains only the IOMMU container information needed by the PCI layer for a given slot. Reviewed-by: Farhan Ali Reviewed-by: Matthew Rosato 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 ee05447084..ad4f527430 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -610,8 +610,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; } @@ -1228,7 +1228,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) { @@ -1306,8 +1306,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 7081be4619..dc52da41b5 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 @@ -633,7 +633,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, @@ -651,7 +650,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 { @@ -674,7 +673,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 /* @@ -684,7 +683,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, @@ -761,8 +760,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 Sep 20 15:24:59 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=1789140235; cv=none; d=zohomail.com; s=zohoarc; b=km9ykqUe6cKYrYT9uoh/itK4utohWEgYlQ68dhljWeYbxtGLt73VCbXAfgIsZ99fNKPaT/Dv7YQoK1kNrZ7SxKqSsB3hzqKrXqzTDUGJBq/uqQW0sX1fVX6OGwD3EkxhsE1rYc25p7btbvQu/3yh/+atM+lmY3TppoIHCe79FHk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789140235; 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=Mkz/yDDmhQPp29Ok9p/9oSsXjFEyn86PqLErF/k+nuQ=; b=LmU600RsGLEJsNoy3WsUaXL000DzQ22F5K8nk0zQy8J0svOciOHdQFBrSpYKbMFDOR1VV+zQ0e0QTyrvCFgs/dnRQXOMX2k5QfYEoalUy5X5jWUcGfVHjl+CY72Cjx/6vjnVrSPnArxd3aeLWqxh7XMFp8AJKGWwj1EkmjnCuOc= 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 1789140235165372.3708552878867; Fri, 11 Sep 2026 08:23:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x534q-0008DY-6u; Fri, 11 Sep 2026 11:22:08 -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 1x534e-00080D-Op; Fri, 11 Sep 2026 11:21:58 -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 1x534Z-0004ku-Rk; Fri, 11 Sep 2026 11:21:56 -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 68BF1PSS2126785; Fri, 11 Sep 2026 15:21:44 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 4gkd8qvbay-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:44 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68BEo8p81789313; Fri, 11 Sep 2026 15:21:43 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4gkvwk71sc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:43 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68BFLglC59572544 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Sep 2026 15:21:42 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 07D3058058; Fri, 11 Sep 2026 15:21:42 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CE34A58062; Fri, 11 Sep 2026 15:21:41 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.atx-us.ibm.com (unknown [9.16.62.165]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 11 Sep 2026 15:21:41 +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=Mkz/yDDmhQPp29Ok9 p/9oSsXjFEyn86PqLErF/k+nuQ=; b=b5164UBo2xsKMZHsYwUJcZlp711MW7Jkg J3D33PeY8S0J9TbUz0XsTktse1giGrNB5Z6LP6rUHAp+rWNIPRNs6avY8NOEs22n exJ4MWyEwbG6UpRbIz/xr+kOYAVgtL506xUCFlrCXuojsjZUPD+WCP0NKqvDuyFq lMdmKc1lQsJ3AbQWIKl1zc5RT5B1Xrg18JsxiG8NyI1/tnnAziFFJFbu0+EptLnu 1AaY/xHq9EWbB/vsxjmNWiF0oPURiZJnmou+NEEZtbbP1KqVJ8HMkXzAxaQa9nT1 zhVWMYTblnmlKKFkoHrRfq9IquZRfXMsptVCMNRGRL/TrSi1xRI/Q== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, farman@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 v8 09/16] s390x/pci: Move g_iota from S390PCIIOMMU to S390PCIBusDevice Date: Fri, 11 Sep 2026 10:21:30 -0500 Message-Id: <20260911152137.676602-10-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260911152137.676602-1-kshk@linux.ibm.com> References: <20260911152137.676602-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=SpUFe/O0 c=1 sm=1 tr=0 ts=6aa41c88 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=eCYPC3wdSG4xViznilUA:9 X-Proofpoint-ORIG-GUID: -niVpGQEETr1tVmhxpLe8py1loBbvvqG X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfXygHfMbPxBEy1 OToPtUgobUJg4NnC7qiThhi5PH8jBW+UoN7L6Pmi2aV05Lxsa5DmWR0klbSz1KEUQb9gpvzjBD1 Zr1a65dnNhlSd3GZYBOnNDygCHWgPqYp6mFGxeqVQVJBGLyM1aBkI/zOqs215nwi7ww+BrY2M1u 1RMvEJpKQr1/254utcgJL33kXEdjeVXbjJ+Ya4KrN6qNiK7+1ekXghXByqy51rZxSJhnkwmezhL THJjvp0yhQs2ag1fAzD//AkWo8mA7cM/hOxP3idOgxYeNT0SX/zYs9z1IN23Lt99C3gpr0928CK KfPXMhW2ACuMC/OohYX7UtgQoldpgL24M9FZKwIlXNDnzuedWS6eeWNIHYQ1Yp9F0rUPF62OFAU DnVzk/5bSujdXekqXuhw5Q0+Vjt/SCnMiTWYCqogmbsBlsCogDFygaycmhr6y+ScQMcR4/q1EXS H59iwNRDBwAIWMQIDEg== X-Proofpoint-Spam-Info: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfX9UEWS2Cbx1P9 87cU8pkgZTVfetfJC2Cb73wPYT4h989oJPnEPBM42MDMMTsncJeDPuadCH/xK0trQb9DRZe/LIV W8ull8TaXjZcOCQHmaJYniswDkuivl4= X-Proofpoint-GUID: -niVpGQEETr1tVmhxpLe8py1loBbvvqG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-11_05,2026-09-11_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 clxscore=1015 phishscore=0 malwarescore=0 impostorscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609110210 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: 1789140235541158500 Content-Type: text/plain; charset="utf-8" This field is only used when S390PCIBusDevice exists, so it can be moved there to simplify S390PCIIOMMU towards a structure that contains only the IOMMU container information needed by the PCI layer for a given slot. This also allows to save/restore this field during migration. Reviewed-by: Farhan Ali Reviewed-by: Matthew Rosato 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 ad4f527430..ec54eb64a6 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -617,7 +617,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 dc52da41b5..22b477ab38 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -765,7 +765,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; } @@ -785,7 +785,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; } @@ -1056,7 +1056,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); @@ -1073,7 +1073,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) @@ -1446,7 +1446,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 Sep 20 15:24:59 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=1789140230; cv=none; d=zohomail.com; s=zohoarc; b=UNGd1LivFabqIzYVElG3oWZaZAHO/JVkAvYcn0lPSp00XoF0gY7mh6fugCdAAy22BpRrv/SNygy4WdFA4pbdVXRNP+9UBsUrKg5hRU0WEZEKvoGsWshyX/U4m0u5AfRTBG/uR8mYgy8B1Ge9C+YKSS91Je0LBAVMwzc6z9cSMyg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789140230; 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=5msSFBZFSz3QiEZHqquXq9/jt6MRDepF1uzVOiQ7gzw=; b=Zvswyg149VOmvbGzHzFyoEkiY03ohMxY5jV5+UdeRj3xhIJGSIV/2bYssBv52OX1IqsYiU9KVatveJgvDdOCQ0RUO83jW9hYCwkMuYWMpbnS/7oDYhvXjdYWF+Ki1tKp4IIYGULGtMrN1W0uBajlIK6sPcttXedjH6UxfjwqOKw= 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 1789140230711696.8570498729754; Fri, 11 Sep 2026 08:23:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x534t-0008JU-48; Fri, 11 Sep 2026 11:22:11 -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 1x534d-0007yW-Cs; Fri, 11 Sep 2026 11:21:56 -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 1x534Z-0004l5-SN; Fri, 11 Sep 2026 11:21:55 -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 68BF1g2K2143845; Fri, 11 Sep 2026 15:21:44 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 4gkd8t480e-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:44 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68BEo8d91802524; Fri, 11 Sep 2026 15:21:43 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4gkvtff29j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:43 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68BFLgdo7209780 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Sep 2026 15:21:42 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4DAD358061; Fri, 11 Sep 2026 15:21:42 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1806B58063; Fri, 11 Sep 2026 15:21:42 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.atx-us.ibm.com (unknown [9.16.62.165]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 11 Sep 2026 15:21:42 +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=5msSFBZFSz3QiEZHq quXq9/jt6MRDepF1uzVOiQ7gzw=; b=MISkPT6LzHK+sypP9+jwRxo3nX9LRP/zq nFevh/cYpeq/4wm1T33XivL5Y7GwATfHqowabw1G9xOTw5aoa3elw/0jtGV5Qxsl zlvT4ak/f+Vg5qyg6HW2Hu6TCg3T8t7kC2zZRlqI3gcC8g1DxsrsJPtnZhkPLZL4 CBNzjXpcNqUZnDm2j3xeQuVwMdf/QxVQd2Y0QEBF4tXJSv6O/Z8/5pBvoWOVOsGc qF8PUW9o55A08Y1OJ2/MpzTseM5XaSK2fyr4yRLnNIw0Lm965EO71sTDe2n/DExR 8Gk6w+suNlRSiBaOIraVWmxmR9cDNsTna3fKzcBocBlBRKLnRLmlQ== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, farman@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 v8 10/16] s390x/pci: Move pba from S390PCIIOMMU to S390PCIBusDevice Date: Fri, 11 Sep 2026 10:21:31 -0500 Message-Id: <20260911152137.676602-11-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260911152137.676602-1-kshk@linux.ibm.com> References: <20260911152137.676602-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Info: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfX/HJWgTaib4pH jEprXBKj5tOGB8ZgbzK+8/BbpWdMOKJarM7g6STJmcye7YZBJ2yHgGbiK2OWIHYMa/WC4QqV6dR A+HbfQm3C+e0MFzDozzHHu21s385568= X-Proofpoint-ORIG-GUID: GWzdVhoJyZ9NaKsfmzLYUVfvmH15WHkl X-Proofpoint-GUID: GWzdVhoJyZ9NaKsfmzLYUVfvmH15WHkl X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfX6+mIsuUMHdIs eGh70Ig2knIM5mSi3zu+HeYDBBNx46oDwIlL/mJmbVHJpwPbC9AOEBxbUWHuT8ibMpOpCFytBCE 5LwYg4TnvXd6oikPeFk8cB566SIvn0Q/FHZNFM8ZGbTVGu/I+tkAVV7LiAxBrI9dpj8zKo11hRa bidbHp3u9iqHsrbiVAHZPmR2tA9fpu6W0XjVwt30FqSd6iX+vgI13NW7JcEyM4Rorlg1Rp6IbW7 A7K5D2qVS4UkCDGwR0SMvzRn7xXVGlY1wafhSn5ZeOUffO3hY3qI0dOZdLG5Fs3Toxw+bew1mGj p5AF+Kd0YjhyjQBwFfZMkreA1ie4VU0iNKIGImVn9veQYRYIRGtuPpGpbi10K1CWbkI7LBiLcOa 1DxwbZgrfKKe8iZsHdqpVDfNwm1L9cITpMXi27ZVUTLUDB5kxNigTlYQSb63pqii+TadKfvJB4z /UZA2KaL2h/MHLKPjRA== X-Authority-Analysis: v=2.4 cv=PIGaavqC c=1 sm=1 tr=0 ts=6aa41c88 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=THYS1zffzJpO_GefUMYA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-11_05,2026-09-11_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 bulkscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 spamscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609110210 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: 1789140233542158500 Content-Type: text/plain; charset="utf-8" This field is only used when S390PCIBusDevice exists, so it can be moved there to simplify S390PCIIOMMU towards a structure that contains only the IOMMU container information needed by the PCI layer for a given slot. This also allows to save/restore this field during migration. Reviewed-by: Farhan Ali Reviewed-by: Matthew Rosato Signed-off-by: Konstantin Shkolnyy --- hw/s390x/s390-pci-bus.c | 4 ++-- hw/s390x/s390-pci-inst.c | 10 +++++----- include/hw/s390x/s390-pci-bus.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index ec54eb64a6..6cf54b8ab6 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -565,7 +565,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; } @@ -602,7 +602,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 22b477ab38..aa2bc98254 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -770,7 +770,7 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_= t r2, uintptr_t ra) goto err; } =20 - if (end < start || end < iommu->pba || start > iommu->pal) { + if (end < start || end < pbdev->pba || start > iommu->pal) { error =3D ERR_EVENT_OORANGE; goto err; } @@ -778,7 +778,7 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_= t r2, uintptr_t ra) * If the specified range at least partially overlaps the registered * aperture, clamp the request to the aperture and ignore the rest. */ - sstart =3D MAX(start, iommu->pba); + sstart =3D MAX(start, pbdev->pba); end =3D MIN(end, iommu->pal + 1); =20 retry: @@ -1054,7 +1054,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 @@ -1071,7 +1071,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; } @@ -1444,7 +1444,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 Sep 20 15:24:59 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=1789140298; cv=none; d=zohomail.com; s=zohoarc; b=KPWQanpc9FvwPvowz186QpOol29UrzkXu4L+faQlt/rytqU9T4wvNPlJNUXmHWuKWb602jYQmi/RrwAIe2sUYcnaqLii2vUZMD3bCxAZm1lv1qIG8Rp/d4o1xYRdu+09xk2Hxx0v891Bg1iQvl4cU077JRL9rp9yZBcYA+6tmx0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789140298; 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=OiYmCo37OvfJw+al7hdGi1UbPHqW0rJGezY3AISwDj8=; b=nbG0I0BbT0/I5FPRfwWIkmLP20vqTRLTjVnYsShK0QorEFqq7SwxiwgEATjHd8WdyesG3pIDzV54Keq+OSQkGPgrVtMTqMlyXgR3YcYrg6w6ob3ukTd60QZW6kRLuqE4lvVSznpDnmDO82bQaDCT0CXvkBDakoRHZssjgP6BOzA= 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 1789140298258495.1050704342192; Fri, 11 Sep 2026 08:24:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x534v-0008MB-EB; Fri, 11 Sep 2026 11:22:13 -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 1x534e-00080O-Ub; Fri, 11 Sep 2026 11:21:58 -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 1x534Z-0004mE-UC; Fri, 11 Sep 2026 11:21:56 -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 68BF1o4O2110386; Fri, 11 Sep 2026 15:21:45 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 4gkd8pvcyc-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:45 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68BEo8iU1764856; Fri, 11 Sep 2026 15:21:44 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4gkvvrf0p2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:44 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68BFLgtu55837128 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Sep 2026 15:21:42 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7FD265805D; Fri, 11 Sep 2026 15:21:42 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 542CE58064; Fri, 11 Sep 2026 15:21:42 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.atx-us.ibm.com (unknown [9.16.62.165]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 11 Sep 2026 15:21:42 +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=OiYmCo37OvfJw+al7 hdGi1UbPHqW0rJGezY3AISwDj8=; b=pvbLDOB+8M18DBjFbeo5CAzxd8MZdr2Op Sn2jZJDQPFapxoJsFrNh1usLma4YguXNk4CjWHg7E3IZl6VLrScR3jUIUeLY1jWy fqP+7OkoHyOPj7C6vqKFGZJYaEt+wb66hoI8idPtmrDmsC4/D1O4rp4+a8yDkkFP roO014xPiSAoKZ0ponLRunjZEm+EHAVCYjE0TMzeXwbimKkz1M1NIQiAyco6NoDm yh6Pmxtofl09bQ4OzBN7N69dS9PrCvoTfNIXoG/rdYR5zvuU3aEQC83qvZavy6DM zONDxgD+Bwiiu3oH1Nwkmz7FpWH5eMgsZ7TPPM6PSQZO2sMjmrOag== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, farman@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 v8 11/16] s390x/pci: Move pal from S390PCIIOMMU to S390PCIBusDevice Date: Fri, 11 Sep 2026 10:21:32 -0500 Message-Id: <20260911152137.676602-12-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260911152137.676602-1-kshk@linux.ibm.com> References: <20260911152137.676602-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=eM2GH3p1 c=1 sm=1 tr=0 ts=6aa41c89 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=WfwOUNX5pORHP_P-vIkA:9 X-Proofpoint-ORIG-GUID: tYnBBNIIgQlqv91emqDd7mzSBe2kkB1g X-Proofpoint-GUID: tYnBBNIIgQlqv91emqDd7mzSBe2kkB1g X-Proofpoint-Spam-Info: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfXy5QtDO9pisQI yaM+YeAlMnrOfr845o1X7vYmLhAVCjQDV3LxPvcuwPVT/clwkWX+LMhodHkK5P5gL22kjdc3pnj 9l9IOzfZz6RZ8ne/dDlaDjamVBpLEnM= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfXwwtmXkWBXYwN o2xQCDFNmM1cIz62IeLkQNI5OPSIEra9eYecNzAajEuqJPwKLrVFZAsMF510ODbQpH9Gw38I7zQ cusSLEMz7HoE38deij85uBsFJ8Ag76XCl7phADejjXeUJj7feQc9EL3s/NRunVwDhhahaA45Joy vy2iwqIc30K/pgttYPW93r+/qWqfEbJoDhS5P6b2IrhCvon6qHrGnzLouGnp9JYKHz+VmakWfAz HI6qbg/zwMrXcycIzUhqV9vOJo6wwv3do7vrFY5pi3aaTYE+xjTstb9u0XP4xnxVhPFiX02h1Aw AjJSmgbPG9YfTcIJzpGWRj2vzBIXp7NyCSJuYJpDK8pbA54TX56jDUrtURxfcy2lB0c9q18ljFL ADmVZN9hVTDWAVM06F7Ri6nNaOF0sigfyCACVpHGTePnAggCrCiQvPxW6U8L5GIrDK68k9MOuJR uAOX2YLOuP6AmZVUHGQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-11_05,2026-09-11_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 malwarescore=0 adultscore=0 phishscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 priorityscore=1501 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609110210 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: 1789140299970158500 Content-Type: text/plain; charset="utf-8" This field is only used when S390PCIBusDevice exists, so it can be moved there to simplify S390PCIIOMMU towards a structure that contains only the IOMMU container information needed by the PCI layer for a given slot. This also allows to save/restore this field during migration. Reviewed-by: Farhan Ali Reviewed-by: Matthew Rosato Signed-off-by: Konstantin Shkolnyy --- hw/s390x/s390-pci-bus.c | 8 +++----- hw/s390x/s390-pci-inst.c | 14 +++++--------- include/hw/s390x/s390-pci-bus.h | 2 +- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 6cf54b8ab6..79bef96c4d 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -540,7 +540,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; @@ -565,7 +564,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; } @@ -600,10 +599,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 = */ @@ -788,7 +786,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 aa2bc98254..f93db10c81 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -717,7 +717,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; @@ -759,7 +758,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 { @@ -770,7 +768,7 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_= t r2, uintptr_t ra) goto err; } =20 - if (end < start || end < pbdev->pba || start > iommu->pal) { + if (end < start || end < pbdev->pba || start > pbdev->pal) { error =3D ERR_EVENT_OORANGE; goto err; } @@ -779,7 +777,7 @@ int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_= t r2, uintptr_t ra) * aperture, clamp the request to the aperture and ignore the rest. */ sstart =3D MAX(start, pbdev->pba); - end =3D MIN(end, iommu->pal + 1); + end =3D MIN(end, pbdev->pal + 1); =20 retry: start =3D sstart; @@ -1029,7 +1027,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); @@ -1055,7 +1052,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) { @@ -1069,10 +1066,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 @@ -1445,7 +1441,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 Sep 20 15:24:59 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=1789140130; cv=none; d=zohomail.com; s=zohoarc; b=WevszR5r+bF8F2GgjAZO1z1ZpqPSYHCOl9MT79Iocol1TJSAiboLnaC0KejGAkdT5GO9L2erwsx2zVxJXu7VWvo9f4zocpgHDgLuSr4yfiVowjBehcygPyk0vSQIu02bCAbYMTo02ER5Wb2DakYRJg/vm4BfGenWxzMBvkmYaFY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789140130; 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=rux/H3LAdtYio6jAJmWWbniXXpuMoyoF5/Z26HUjjSU=; b=Qp4WXIAOo4gZYkXVtOqvfV7yvrqDcevPUCCYZ4XLOeR8AjtPxiWFtNgblAXpEKrDBAXaAcnBVF5QIu5eBrTNKN8xW19lWX4sMlDJYlT+LsQQ40ch7EvCT0rcdWPhMXR1+KJAypo+qGr2dM+IUl7aP0z6Wo8Wy/LLynWs7P1hAbs= 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 1789140130952685.1951602479962; Fri, 11 Sep 2026 08:22:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x534o-0008BR-MM; Fri, 11 Sep 2026 11:22:06 -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 1x534e-00080B-Mf; Fri, 11 Sep 2026 11:21:58 -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 1x534Z-0004lm-RS; Fri, 11 Sep 2026 11:21:56 -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 68BF1VBM2126886; Fri, 11 Sep 2026 15:21:45 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 4gkd8qvbb0-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:45 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68BEo8p91789313; Fri, 11 Sep 2026 15:21:44 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4gkvwk71se-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:44 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68BFLgaY7209784 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Sep 2026 15:21:43 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C58B358064; Fri, 11 Sep 2026 15:21:42 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9060058058; Fri, 11 Sep 2026 15:21:42 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.atx-us.ibm.com (unknown [9.16.62.165]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 11 Sep 2026 15:21:42 +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=rux/H3LAdtYio6jAJ mWWbniXXpuMoyoF5/Z26HUjjSU=; b=syd7dVJnBWHZnkO/0zdxjpGum5cpfzK6t Ih2G9fTCKhFurS8L4lX/CJu3oNs5St6eoqsBNRrvYnsC3/CVuB0+2n9YHyi2L+oi 4vvKDkD0JYFwkUp8rgVCtssnRPAn7TbcYFonc6RKKPZYRnH8nAT+4aTViK4sMg6/ MdAWsmufhes6kFNST0X34wfonZDsaBBd5AD1DoEDHW1eFMRFnA6iGDLVhcfzRxIP ZhHuLs2E0teaRr1Go4f3fF+W6QCQwSLGVguBLB+iNYIaaemyLFPRqf7gbjSrkc04 tL4C3jWWoUpUNGSZu46q6wlckVs9pZ4vVovStGEVCfRuPnaeVgO3A== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, farman@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 v8 12/16] s390x/pci: Move max_dma_limit from S390PCIIOMMU to S390PCIBusDevice Date: Fri, 11 Sep 2026 10:21:33 -0500 Message-Id: <20260911152137.676602-13-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260911152137.676602-1-kshk@linux.ibm.com> References: <20260911152137.676602-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=SpUFe/O0 c=1 sm=1 tr=0 ts=6aa41c89 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=wu6SjTzT1SSAPCv-QiYA:9 X-Proofpoint-ORIG-GUID: 7-3d-lv8T60acSBwcNcbjMmSnlgP3hIG X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfX8hyPkaR88mIQ R31mCY3mbUbKVf80z9fU3GVRAPlJEihIck+LsOUa7zElv7VncwkhlqkAp4qZh25dVLjb+lWONlT Xs0ZV8K58WiSUyY2Zd2VvB+y4lsTDfZ19w49y1ErkWckSzmbPEaxur+OsbjWPu+uzqiXeS9sTZQ hGhHGLlj/+Ei48i9BGuUcjBh0Bp+vqwLjMqIKACZAFfKfaGtyIcqXK760PBrUaKZhfjVMyHiE94 ETC1Q9IBadvJQMfIa7QfY3zTrIw4J8ye0mh3lTKV1iv+0NCxp1lUC+6g2h5tUiOWPyy++/6dFJy +mmr7KXDTzJdIi5s/RPSTSK0YMx9VS7CfOQebEMraMkfptUg2UeixJorUWA3Po5DhXvvdXFcchg XiSLtKJNX6vs0bqcLbpQcSP2CBWf1rxD10IxWBdag0Gsx4ZRIbOGwAke2C9K4Y3NaImmFV+HXRy jTPTMmU+6VLtBWB0ZOg== X-Proofpoint-Spam-Info: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfX0qXgkwu1XTNA 35e7yYEjJTMc+e3i0lSpC2zo8SJptPcx2KPj3O9vkIVD7UZCHlgebU599fwWMXX4YGQDvUHKaFq E61c6mREqi/pyDnXygcxFN4W1XaEoHA= X-Proofpoint-GUID: 7-3d-lv8T60acSBwcNcbjMmSnlgP3hIG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-11_05,2026-09-11_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 clxscore=1015 phishscore=0 malwarescore=0 impostorscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609110210 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: 1789140132982158500 Content-Type: text/plain; charset="utf-8" This field is only used when S390PCIBusDevice exists, so it can be moved there to simplify S390PCIIOMMU towards a structure that contains only the IOMMU container information needed by the PCI layer for a given slot. Reviewed-by: Farhan Ali Reviewed-by: Matthew Rosato 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 db6de00bd2..a035ba5b2c 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 @@ -152,7 +152,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 Sep 20 15:24:59 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=1789140184; cv=none; d=zohomail.com; s=zohoarc; b=NZ51J1TgwuRAJlH4FInTv43AimyBdwX8zqWDXcZgaN/b8IaKAnRqoL4GXaLuekQktWPOsk96w4op+2dnJQBQQfFhjd7qzJjDVZoxkn/ZZTrFOmeiWkujBOwECy7e46k6n0PGFVk9VZ1WOKjgiDT7NFMKdlhbneT2ldERAmHIlKY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789140184; 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=0m0WUDXe06nwq+OXo7togFOkqAO12zTw+7OtM+Ejk2g=; b=OQOAES1fg6k7mToONIVszndu14O7B+g7gTdSGIz9f8YIFqRWPGUKNG2ExjHO0kMFiAc4MB/tDtrCFvsu/lpoeRcRkssyaE+Sg/nbcn8c85vMUi2nChBmfFuxQ04ha3dpOqoaTnDCiHVR//jg/sHckEfa+9IdEMo4O2Afkxm0FMQ= 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 17891401842371014.2144898665202; Fri, 11 Sep 2026 08:23:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x534z-0008PZ-EZ; Fri, 11 Sep 2026 11:22:17 -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 1x534e-00080C-Nt; Fri, 11 Sep 2026 11:21:58 -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 1x534Z-0004l8-Tz; Fri, 11 Sep 2026 11:21:56 -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 68BF1c2f2143697; Fri, 11 Sep 2026 15:21:46 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 4gkd8t480k-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:45 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68BEo7v61834046; Fri, 11 Sep 2026 15:21:45 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([172.16.1.69]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4gkvmhq3fp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:44 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68BFLhFo26084056 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Sep 2026 15:21:43 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1607058058; Fri, 11 Sep 2026 15:21:43 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CC38058061; Fri, 11 Sep 2026 15:21:42 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.atx-us.ibm.com (unknown [9.16.62.165]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 11 Sep 2026 15:21:42 +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=0m0WUDXe06nwq+OXo 7togFOkqAO12zTw+7OtM+Ejk2g=; b=PAYWRif0EejoG3mND8gS+ule5Y2DVewwt bFY4i26Kwcixi2AVuaLSUvGzxRSlgTYOlZpSuc7cthh6VtsCgrK6g36l8penkSzI V6VolzFB3L6f3ToeNyC/CAH+VTm62tPZ/W3FXd5VEs+21PYY8wim4L2T0vKWWQwh 2FhmNwTeMVCunCYw1i8tBwJ37ZHC1RFcSu371d4gbgpQC0A19ZVpnRCijpQDe/6M EO6+1Oc5RF22NKDuP/CUsBltAr51lVxLsDTWv2rIGBjbUMNBf8YPi7SehF89Tbuv p7GzIXPidZFJ4yIFjNhF9G766ZMXbPAUFnpLWDaWAc4SlZPvyIVyQ== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, farman@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 v8 13/16] s390x/pci: Add a comment explaining S390PCIIOMMU purpose Date: Fri, 11 Sep 2026 10:21:34 -0500 Message-Id: <20260911152137.676602-14-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260911152137.676602-1-kshk@linux.ibm.com> References: <20260911152137.676602-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Info: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfX0h0aza1EMmeq Hlyo7emZd5WZMtYsSzQDvbEyH3Tg9jTnVZ5K6VPgIb0OfPwQzBHEAel3uGsASjeyed7TR+SMbyv BgZjzsEq+Ak6ZUKRud0q+cEvnWj7upI= X-Proofpoint-ORIG-GUID: JfSC0CbJViX3ymMQv15hbG126i6vToJN X-Proofpoint-GUID: JfSC0CbJViX3ymMQv15hbG126i6vToJN X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfXz+mYxAKjuuWp Rb/P07Q7MGpI0OyeQQD2m229qPdYWh672ANNVXAh/7u1A4Ibqxd3LFyJSEBkojcnPxg661VWiqC G/picD7lVvyONnSSFzvJCcXz5d2iIaGIbcFYjduefiVgV7UICiQrAk26Ll3LfimiTyq5HJVM0yo TrQvAo+ffliwbmSo6oq7D4sSsUIuTlKpebYIZJ8C4u80X1zSMGb+QI9/cKcJb7dO4dEMRejD388 UBd5suaOVgnaxQY7BMcDiFOjvwSzt64qc+GTHGLoFzlUg7o234O1Gx84nhy8pLXb0JOWG+s166R JuvxyBKbx582Y2UE3XytpA1Drcpv433YkNMRUiC1tw0aR6FGHa0CFC5UfksQHBiOKyF28coK7Fq /srZGmqLtE+qbJpx73wP27bNEbIl/t3rLE2VJxU2FcbFYHfuIq3aCMlPgS9pwlsp3yc3/fDfEPc YkYB2W7izYLYZsXPH+Q== X-Authority-Analysis: v=2.4 cv=PIGaavqC c=1 sm=1 tr=0 ts=6aa41c89 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=LipbnPdcSf65HfI7a3AA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-11_05,2026-09-11_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 bulkscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 spamscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609110210 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: 1789140185192158500 Content-Type: text/plain; charset="utf-8" Now that S390PCIIOMMU had been reduced to only the IOMMU container information needed by the PCI layer for the associated slot, add a comment explaining the purpose of the structure. Reviewed-by: Matthew Rosato 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..0a59be1fd0 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 AddressSpace for a PCI device slot. It must be + * allocated before PCIDevice registration completes, specifically to sati= sfy + * the get_address_space IOMMU callback invoked by do_pci_register_device(= ). + * The root MemoryRegion is otherwise empty; DMA translations only become + * functional once the guest configures the device, at which point + * s390_pci_iommu_enable() registers the zPCI translation subregions benea= th it. + */ struct S390PCIIOMMU { Object parent_obj; AddressSpace as; --=20 2.34.1 From nobody Sun Sep 20 15:24:59 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=1789140323; cv=none; d=zohomail.com; s=zohoarc; b=nYLJSrsujdREYMWrPMNrGUxkm33unFU973XzqU+dSBXmMCCOvVwqA59lA359b1UWYBRcrVfgjwxuehFkQgm/J+V/KCzWeTP1d7pTpwICc/Paa0PqCOZVXPbMTaFZPxtdLfkvPunRi/B1CunP0t+ERIJC3d4sWajm6zHTfN+ONh4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789140323; 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=3/DOB8EnrxHQiH9xrYsGZ+re8eNzeVKb7ux+FIMrmOo=; b=k/9Gyz/b60kSy4FCX4RuKZuVUSIPRFHhEc8M/zw/LamfXvXFTBNz4rMv84alQST42mDj6i0T1m62Wl1az4eEChA1TWqeTgILHshRKmEyyti/3bmUBENZNR9LukoLt0PsIzJ0yZ75F9rqCNNjDNfpMcfICuWFL1EiAOU2SJC1QrU= 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 1789140323529468.713508164309; Fri, 11 Sep 2026 08:25:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x534v-0008MA-DJ; Fri, 11 Sep 2026 11:22:13 -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 1x534d-0007yZ-IN; Fri, 11 Sep 2026 11:21:56 -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 1x534Z-0004lB-Sf; Fri, 11 Sep 2026 11:21:55 -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 68BF1PST2126785; Fri, 11 Sep 2026 15:21:46 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 4gkd8qvbb1-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:45 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68BEo7In1808726; Fri, 11 Sep 2026 15:21:45 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([172.16.1.69]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4gkvq2y35q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:45 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68BFLhin28508820 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Sep 2026 15:21:43 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 541C858061; Fri, 11 Sep 2026 15:21:43 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1D2BE5805D; Fri, 11 Sep 2026 15:21:43 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.atx-us.ibm.com (unknown [9.16.62.165]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 11 Sep 2026 15:21:43 +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=3/DOB8EnrxHQiH9xr YsGZ+re8eNzeVKb7ux+FIMrmOo=; b=APA2TJFBelvq7NRSxXjWT0hL+ivnXME/v 51NqNiIHWedx9EmI5UQ8iNJE/KaG2TLoeOojbCB4C6H7zLb/fQfvvh5owSlk1AJi zzcqLLEbPP6HJ29vS5lxuWOrDFmM5+GHc11AeS+NjwtdE6796zsZXKU8Df9n+/IK EIJY5PMBYDlgwvNBpTsYa1ipGTPYcL9bfP2GYzG79Y1BiaJdot/mUk+R/nvX8RC3 0DQvcUNkGnYa4gPivaJYIdDKyqFe5Q4nclnvoka3QHwcF811yb+MFhj5gq1X1F/o EHYqYXhLVtWDX8NJOYHHGpE6b199NU1AKhwDZdZN/cA1g4eq+lqMQ== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, farman@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 v8 14/16] s390x/pci: Factor ioat sanity checks into a separate function Date: Fri, 11 Sep 2026 10:21:35 -0500 Message-Id: <20260911152137.676602-15-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260911152137.676602-1-kshk@linux.ibm.com> References: <20260911152137.676602-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=SpUFe/O0 c=1 sm=1 tr=0 ts=6aa41c8a cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=tFIIGk-Z8APL5VWaAH4A:9 X-Proofpoint-ORIG-GUID: mIwVUSfsMtM58m0Pu9IwSzOE9OKKn1qE X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfX3podRgozahDj lLc3w3WczwWnKCeqJCk4lQa07GHa4dKEgxMFjseXmU3IIXWt72utw1jAlKH9Vs5jyk31Ae+ohn3 n0fa08mZqMD9y77oWyPRgMnhaYE8E6ppz7CQG1bd6d0xDk/tQahkCqkhuskuILVMIlTbIQnpAuO uz7TFVmm3WCsF5oPZ1zBbin9YyXjGFW5+BPk/478zULRsdxN1qi4B6H/D6+OcqAWXWNlvdYAjEj I1PyENwAxExFSHzQ/qDcn4cpgVIlvqcFf+lCtTqh7nqYID6VQ3Vpltv3Pwla1jNUPyLIMfNVcmI Vhh6wHeyepbMLznloO6TDEtGt4LRtkJtw6jnj4mJxqN66DfEpn+AP9WzO4rIlk/znPOkNTZ2xur +lu3aS57t6zqh3/TRmX80EpZpMZauVHse4YLj2zAqOKc3kW90d6KyjDfUEUDYIt9nJ3IUvGu7Ng 5eOc0Odx8tlGL/QuoLw== X-Proofpoint-Spam-Info: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfX7NR3jqA9R3Mi yhrx5r/bhx5Bva/859Q7gyJKkEMA+APs/CP6uq/hqTqx/CJg1qZU/uGSBguS6fNbNnC7t3KwLKS Av7YaZbbZislp64m5XIyYQa4rlsCj20= X-Proofpoint-GUID: mIwVUSfsMtM58m0Pu9IwSzOE9OKKn1qE X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-11_05,2026-09-11_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 clxscore=1015 phishscore=0 malwarescore=0 impostorscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609110210 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: 1789140324151158500 Content-Type: text/plain; charset="utf-8" Extract the pba, pal and g_iota checks from reg_ioat() into a function. Make it external so that it can also be used in a follow up change. Signed-off-by: Konstantin Shkolnyy --- hw/s390x/s390-pci-inst.c | 39 +++++++++++++++++++++----------- include/hw/s390x/s390-pci-inst.h | 2 ++ 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index f93db10c81..c7f96417cc 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -1024,29 +1024,42 @@ bool s390_pci_is_translation_enabled(uint64_t g_iot= a) return ((g_iota >> 11) & 0x1) !=3D 0; /* "T" bit */ } =20 +bool s390_pci_ioat_validate(S390PCIBusDevice *pbdev, uint64_t pba, + uint64_t pal, uint64_t g_iota, bool report) +{ + uint8_t dt =3D (g_iota >> 2) & 0x7; + bool t =3D s390_pci_is_translation_enabled(g_iota); + + if (pba > pal || pba < pbdev->zpci_fn.sdma || pal > pbdev->zpci_fn.edm= a) { + return false; + } + /* currently we only support designation type 1 with translation */ + if (t && dt !=3D ZPCI_IOTA_RTTO) { + if (report) { + error_report("unsupported ioat dt %d t %d", dt, t); + } + return false; + } + if (!t && !pbdev->rtr_avail) { + if (report) { + error_report("relaxed translation not allowed"); + } + return false; + } + return true; +} + static int reg_ioat(CPUS390XState *env, S390PCIBusDevice *pbdev, ZpciFib f= ib, uintptr_t ra) { 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); - uint8_t dt =3D (g_iota >> 2) & 0x7; bool t =3D s390_pci_is_translation_enabled(g_iota); =20 pba &=3D ~0xfff; pal |=3D 0xfff; - if (pba > pal || pba < pbdev->zpci_fn.sdma || pal > pbdev->zpci_fn.edm= a) { - s390_program_interrupt(env, PGM_OPERAND, ra); - return -EINVAL; - } - - /* currently we only support designation type 1 with translation */ - if (t && dt !=3D ZPCI_IOTA_RTTO) { - error_report("unsupported ioat dt %d t %d", dt, t); - s390_program_interrupt(env, PGM_OPERAND, ra); - return -EINVAL; - } else if (!t && !pbdev->rtr_avail) { - error_report("relaxed translation not allowed"); + if (!s390_pci_ioat_validate(pbdev, pba, pal, g_iota, /*report=3D*/true= )) { s390_program_interrupt(env, PGM_OPERAND, ra); return -EINVAL; } diff --git a/include/hw/s390x/s390-pci-inst.h b/include/hw/s390x/s390-pci-i= nst.h index 38268c256e..b53113ddbc 100644 --- a/include/hw/s390x/s390-pci-inst.h +++ b/include/hw/s390x/s390-pci-inst.h @@ -100,6 +100,8 @@ typedef struct ZpciFib { =20 int pci_dereg_irqs(S390PCIBusDevice *pbdev); void pci_dereg_ioat(S390PCIBusDevice *pbdev); +bool s390_pci_ioat_validate(S390PCIBusDevice *pbdev, uint64_t pba, + uint64_t pal, uint64_t g_iota, bool report); 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= ); --=20 2.34.1 From nobody Sun Sep 20 15:24:59 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=1789140190; cv=none; d=zohomail.com; s=zohoarc; b=LXK7zKYNIcC2rWa0djG8Y40oFwbq7Y+7tXweBvLiYIZYyicRGkF3mo3vnly63DRL9tlXFflMHVXDbghKoXbtK0Hoz0hx7UL+hzU+BRQ1rGXSBpgXt+sE71oLwpKmjgoU6SrbEymVp7U0i0LyaBJ4ckxxxzu3fXn/nQ+aZGoMO80= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789140190; 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=RaKwxxcJRUObSQRWPnk3LgwyUBOIZ8rrW3pdtdgwm70=; b=GBljFh26JUd5Suslj9Q6wRhyQmzZcw6SGXKDLp2b/5P/bY31wfzNs5HdimiJN4Zn/omAgO5DOdPzHP6JLdyImuMBSuIXZeQEoPH2mrPXZWZUiAn8dBDJkDwWDlLLX6rbtL4Fi/XuqCc6NJmoiKzhZ7D6kYLmgwJU1aqwyJ20Qe4= 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 1789140190683849.6137105421533; Fri, 11 Sep 2026 08:23:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x534u-0008L5-5M; Fri, 11 Sep 2026 11:22:12 -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 1x534l-000861-2K; Fri, 11 Sep 2026 11:22:05 -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 1x534Z-0004mU-VW; Fri, 11 Sep 2026 11:21:59 -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 68BF1Q9D2126839; Fri, 11 Sep 2026 15:21:46 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 4gkd8qvbb2-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:46 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68BEo7rU1817322; Fri, 11 Sep 2026 15:21:45 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([172.16.1.69]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4gkvnrq2kh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:45 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68BFLhlR17892014 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Sep 2026 15:21:44 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A45A658058; Fri, 11 Sep 2026 15:21:43 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5AAB458063; Fri, 11 Sep 2026 15:21:43 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.atx-us.ibm.com (unknown [9.16.62.165]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 11 Sep 2026 15:21:43 +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=RaKwxxcJRUObSQRWP nk3LgwyUBOIZ8rrW3pdtdgwm70=; b=UfB7DBGl3KBImPpemEb5cKSr57TMBjvHA hdKzuUP/Hgcvad9NJ+gBmyLvX781LawXMjam7D/s9RmTDPQa1NAlKotz1xXWuBm6 Q9fX8XkB0b+AbZkI5bNqvnbQInKfMLqxpMdTvS727vU+2w9eUVAUyZpFVnw5FdEf tgYGBIAVid32UtmE+PIrDYquE/0y80IJhiEIHvHrMKKPW9iCwPjSsRgyrfmd1T+A DQuzfBiO88KgzaPbN1EIEO/le7v5Z/7nv1cTrhKZXCOXqLZNdZPJLKJ02c477mfI M8oBVtaIEW7dIQIyjrcz7j6mUfscMoVfFiaE3JP/01dC+7AKgLUpg== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, farman@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 v8 15/16] s390x/pci: Implement migration for emulated devices Date: Fri, 11 Sep 2026 10:21:36 -0500 Message-Id: <20260911152137.676602-16-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260911152137.676602-1-kshk@linux.ibm.com> References: <20260911152137.676602-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=SpUFe/O0 c=1 sm=1 tr=0 ts=6aa41c8a cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=waVumpEa8DGoQk7sNJYA:9 X-Proofpoint-ORIG-GUID: YR9hN2FVRLPCPzpQAC2ReiJe02I3bA7W X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfX28860PFQ3Ist /aZdv4zFdVURXlC4PgyeVYHyxB3j6HonCk9NIn7H40xKqUoJwt0fgqxEjIJpUA/kuYxBSxH5fSf 1yPkkGgmX1KmXuFzA+o2kAr9QEIDpF1v9IloQPSN1vMjjMQqeB+EtdhF2IZw1XIFF/lesnSKl8f soViXVsrsLp7RMZ8wEhHxPAXFH39n5LtT1GkntN77fCMIfhPiQkci94ysrfnExJ+ellB3A+OOKh lnLRSxBoIc9yWoeLt9Ve6S+UFL9/8B/tYnFYj5tVK5o5ZH2gxpUG8wMzhNFHlIqmlUshKZSeel1 lCVysbPI9pCidFXAt58xoftjeiKy4w9BvXtsFWkqBVy4PAkiCvSqWbZISvqt96utnOBCY6CGfjU 67BlK6xcTPsZpHpFoVOd3VyVN9yXDgI+mrQEWaqD/qOV+XGzx2W4lAMvErVcHwO2P2Da8Dxx27H 4ON18y8BkggCdc5zmMQ== X-Proofpoint-Spam-Info: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfXwYrM+Yw7L9o2 LhSGhGLXZvhxLfs/9D408cBnirOq6g/MRiegsDCJ1UvA4AKwWmpPb2bzm1GFaRxhgp/73JmPKP9 Pw6Ycv8I8m7L/t5gVeQDrCpn9Vzz+Fo= X-Proofpoint-GUID: YR9hN2FVRLPCPzpQAC2ReiJe02I3bA7W X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-11_05,2026-09-11_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 clxscore=1015 phishscore=0 malwarescore=0 impostorscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609110210 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: 1789140191291158500 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.2. Passthrough devices will continue to block migration. Signed-off-by: Konstantin Shkolnyy --- hw/s390x/s390-pci-bus.c | 306 ++++++++++++++++++++++++++++++- hw/s390x/s390-pci-inst.c | 2 +- hw/s390x/s390-virtio-ccw.c | 4 + include/hw/s390x/s390-pci-bus.h | 13 ++ include/hw/s390x/s390-pci-inst.h | 1 + 5 files changed, 317 insertions(+), 9 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 79bef96c4d..c16941ace6 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -26,6 +26,8 @@ #include "hw/pci/pci_bridge.h" #include "hw/pci/msi.h" #include "exec/cpu-common.h" +#include "migration/blocker.h" +#include "migration/vmstate.h" #include "qemu/error-report.h" #include "qemu/module.h" #include "system/physmem.h" @@ -922,6 +924,8 @@ static void set_pbdev_info(S390PCIBusDevice *pbdev) pbdev->pci_group =3D s390_group_find(ZPCI_DEFAULT_FN_GRP); } =20 +static const VMStateDescription vmstate_s390_pcihost; + static void s390_pcihost_realize(DeviceState *dev, Error **errp) { PCIBus *b; @@ -956,6 +960,7 @@ static void s390_pcihost_realize(DeviceState *dev, Erro= r **errp) s390_pci_init_default_group(); css_register_io_adapters(CSS_IO_ADAPTER_PCI, true, false, S390_ADAPTER_SUPPRESSIBLE, errp); + vmstate_register(VMSTATE_IF(dev), 0, &vmstate_s390_pcihost, s); s390_pcihost_kvm_realize(); } =20 @@ -1134,12 +1139,47 @@ static int s390_pci_interp_plug(S390pciState *s, S3= 90PCIBusDevice *pbdev) return 0; } =20 +static int s390_set_zpci_migration_blocker(S390PCIBusDevice *pbdev, + S390pciState *s, Error **errp) +{ + if (s->zpci_migr_enabled) { + return 0; + } + error_setg(&pbdev->zpci_migr_blocker, + "Migration blocked on this machine type by zPCI device " + "uid %d", pbdev->uid); + return migrate_add_blocker(&pbdev->zpci_migr_blocker, errp); +} + +static void s390_clear_zpci_migration_blocker(S390PCIBusDevice *pbdev) +{ + migrate_del_blocker(&pbdev->zpci_migr_blocker); +} + +static int s390_set_passthrough_migration_blocker(S390PCIBusDevice *pbdev, + Error **errp) +{ + if (pbdev->fh & FH_SHM_EMUL) { + return 0; + } + error_setg(&pbdev->passthrough_migr_blocker, + "Migration blocked by passthrough zPCI device uid %d", + pbdev->uid); + return migrate_add_blocker(&pbdev->passthrough_migr_blocker, errp); +} + +static void s390_clear_passthrough_migration_blocker(S390PCIBusDevice *pbd= ev) +{ + migrate_del_blocker(&pbdev->passthrough_migr_blocker); +} + static void s390_pcihost_plug(HotplugHandler *hotplug_dev, DeviceState *de= v, Error **errp) { S390pciState *s =3D S390_PCI_HOST_BRIDGE(hotplug_dev); PCIDevice *pdev =3D NULL; S390PCIBusDevice *pbdev =3D NULL; + bool auto_pbdev =3D false; int rc; =20 if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_BRIDGE)) { @@ -1199,6 +1239,7 @@ static void s390_pcihost_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, if (!pbdev) { return; } + auto_pbdev =3D true; } =20 pbdev->pdev =3D pdev; @@ -1218,7 +1259,7 @@ static void s390_pcihost_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, if (rc) { error_setg(errp, "Plug failed for zPCI device in " "interpretation mode: %d", rc); - return; + goto err_unlink_pbdev; } } else { trace_s390_pcihost("zPCI interpretation missing"); @@ -1247,16 +1288,44 @@ static void s390_pcihost_plug(HotplugHandler *hotpl= ug_dev, DeviceState *dev, pbdev->rtr_avail =3D false; } =20 + if (s390_set_passthrough_migration_blocker(pbdev, errp) !=3D 0) { + goto err_unlink_pbdev; + } + if (s390_pci_msix_init(pbdev) && !pbdev->interp) { error_setg(errp, "MSI-X support is mandatory " "in the S390 architecture"); - return; + s390_clear_passthrough_migration_blocker(pbdev); + goto err_unlink_pbdev; } =20 if (dev->hotplugged) { s390_pci_generate_plug_event(HP_EVENT_TO_CONFIGURED , pbdev->fh, pbdev->fid); } + return; + +err_unlink_pbdev: + if (pbdev->pft =3D=3D ZPCI_PFT_ISM) { + notifier_remove(&pbdev->shutdown_notifier); + } + if (pbdev->dma_limit) { + s390_pci_end_dma_count(s, pbdev->dma_limit); + pbdev->dma_limit =3D NULL; + } + pbdev->fh &=3D ~FH_MASK_SHM; + pbdev->iommu =3D NULL; + pbdev->pdev =3D NULL; + if (auto_pbdev) { + QTAILQ_REMOVE(&s->zpci_devs, pbdev, link); + if (g_hash_table_lookup(s->zpci_table, &pbdev->idx) =3D=3D pbd= ev) { + g_hash_table_remove(s->zpci_table, &pbdev->idx); + } + g_hash_table_destroy(pbdev->iotlb); + s390_clear_zpci_migration_blocker(pbdev); + qdev_unrealize(DEVICE(pbdev)); + } + return; } else if (object_dynamic_cast(OBJECT(dev), TYPE_S390_PCI_DEVICE)) { pbdev =3D S390_PCI_DEVICE(dev); =20 @@ -1267,6 +1336,12 @@ static void s390_pcihost_plug(HotplugHandler *hotplu= g_dev, DeviceState *dev, NULL, g_free); QTAILQ_INSERT_TAIL(&s->zpci_devs, pbdev, link); g_hash_table_insert(s->zpci_table, &pbdev->idx, pbdev); + if (s390_set_zpci_migration_blocker(pbdev, s, errp) !=3D 0) { + g_hash_table_remove(s->zpci_table, &pbdev->idx); + QTAILQ_REMOVE(&s->zpci_devs, pbdev, link); + g_hash_table_destroy(pbdev->iotlb); + return; + } } else { g_assert_not_reached(); } @@ -1289,6 +1364,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); @@ -1303,11 +1380,22 @@ static void s390_pcihost_unplug(HotplugHandler *hot= plug_dev, DeviceState *dev, pbdev =3D S390_PCI_DEVICE(dev); pbdev->fid =3D 0; QTAILQ_REMOVE(&s->zpci_devs, pbdev, link); - g_hash_table_remove(s->zpci_table, &pbdev->idx); + /* + * If this QEMU is running a migrated guest, and was configured wi= th + * more zpci devices than the source QEMU, extra zpci devices coul= d be + * excluded from zpci_table and invisible to the guest and have + * pbdev->idx values duplicating those of active devices. If the + * pbdev being unplugged is such, the zpci_table entry for pbdev->= idx + * can find a different pbdev which we must not remove. + */ + if (g_hash_table_lookup(s->zpci_table, &pbdev->idx) =3D=3D pbdev) { + g_hash_table_remove(s->zpci_table, &pbdev->idx); + } if (pbdev->dma_limit) { s390_pci_end_dma_count(s, pbdev->dma_limit); } g_hash_table_destroy(pbdev->iotlb); + s390_clear_zpci_migration_blocker(pbdev); qdev_unrealize(dev); } } @@ -1443,6 +1531,65 @@ static void s390_pcihost_reset(DeviceState *dev) pci_for_each_device_under_bus(bus, s390_pci_enumerate_bridge, s); } =20 +/* + * TYPE_S390_PCI_HOST_BRIDGE device state migration is registered via + * vmstate_register() rather than dc->vmsd because dc->vmsd is already ass= igned + * by our base, TYPE_PCI_HOST_BRIDGE, to &vmstate_pcihost which migrates + * PCIHostState.config_reg. There is no mechanism to add a subclass vmsd t= o the + * parent's. + */ +static bool vmstate_s390_pcihost_pending_sei_needed(void *opaque) +{ + S390pciState *s =3D S390_PCI_HOST_BRIDGE(opaque); + return s->zpci_migr_enabled && !QTAILQ_EMPTY(&s->pending_sei); +} + +/* Per-element descriptor for pending_sei list */ +static const VMStateDescription vmstate_sei_container =3D { + .name =3D "s390_sei_container", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT32(fid, SeiContainer), + VMSTATE_UINT32(fh, SeiContainer), + VMSTATE_UINT8(cc, SeiContainer), + VMSTATE_UINT16(pec, SeiContainer), + VMSTATE_UINT64(faddr, SeiContainer), + VMSTATE_UINT32(e, SeiContainer), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_s390_pcihost_pending_sei =3D { + .name =3D TYPE_S390_PCI_HOST_BRIDGE "/pending-sei", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D vmstate_s390_pcihost_pending_sei_needed, + .fields =3D (const VMStateField[]) { + VMSTATE_QTAILQ_V(pending_sei, S390pciState, 1, + vmstate_sei_container, SeiContainer, link), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_s390_pcihost =3D { + .name =3D TYPE_S390_PCI_HOST_BRIDGE, + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (const VMStateField[]) { + VMSTATE_END_OF_LIST() + }, + .subsections =3D (const VMStateDescription * const []) { + &vmstate_s390_pcihost_pending_sei, + NULL + } +}; + +static const Property phb_props[] =3D { + DEFINE_PROP_BOOL("x-zpci-migr-enabled", S390pciState, + zpci_migr_enabled, true), +}; + static void s390_pcihost_class_init(ObjectClass *klass, const void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -1456,6 +1603,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 { @@ -1469,10 +1617,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 distinguish 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) @@ -1618,13 +1789,132 @@ 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; + /* - * TODO: add state handling here, so migration works at least with - * emulated pci devices on s390x + * Because state loading can change pbdev->idx make sure pbdev is remo= ved + * from the table before that happens. The table type used stores a po= inter + * to pbdev->idx and becomes corrupt if idx is changed from outside. B= ut be + * careful to not remove instead another pbdev whose state might have = been + * loaded earlier and that got assigned this idx value and had therefo= re + * already replaced our pbdev in the table. post_load() will reinsert = our + * pbdev into the table. (found_pbdev could even be 0 if a previous + * vmstate_load_vmsd() on this device failed before reaching post_load= ().) */ - .unmigratable =3D 1, + found_pbdev =3D g_hash_table_lookup(s390_get_phb()->zpci_table, &pbdev= ->idx); + if (found_pbdev =3D=3D pbdev) { + g_hash_table_remove(s390_get_phb()->zpci_table, &pbdev->idx); + } + + return 0; +} + +static bool s390_pci_device_post_load_errp(void *opaque, int version_id, + Error **errp) +{ + S390PCIBusDevice *pbdev =3D S390_PCI_DEVICE(opaque); + + pbdev->zpci_fn.fid =3D pbdev->fid; + pbdev->zpci_fn.uid =3D pbdev->uid; + + /* + * 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. + */ + 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) { + if (!pbdev->iommu) { + error_setg(errp, "iommu is NULL"); + return false; + } + if (!s390_pci_ioat_validate(pbdev, pbdev->pba, pbdev->pal, + pbdev->g_iota, /*report=3D*/false)) { + error_setg(errp, "invalid pba, pal or g_iota in migration stre= am"); + return false; + } + if (s390_pci_is_translation_enabled(pbdev->g_iota)) { + s390_pci_iommu_enable(pbdev); + s390_pci_ioat_replay(pbdev); + } else { + /* TODO: unreachable until vfio passthrough migration is enabl= ed */ + 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) { + if (pbdev->fmb_timer) { + error_setg(errp, "fmb_timer is not NULL"); + return false; + } + if (!pbdev->pci_group) { + error_setg(errp, "pci_group is NULL"); + return false; + } + 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 true; +} + +static const VMStateDescription s390_pci_device_vmstate =3D { + .name =3D TYPE_S390_PCI_DEVICE, + .version_id =3D 1, + .minimum_version_id =3D 1, + .priority =3D MIG_PRI_IOMMU, + .pre_load =3D s390_pci_device_pre_load, + .post_load_errp =3D s390_pci_device_post_load_errp, + .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_PTR_TO_IND_ADDR(summary_ind, S390PCIBusDevice), + VMSTATE_PTR_TO_IND_ADDR(indicator, 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 c7f96417cc..9b701b4dff 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -1135,7 +1135,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 17266779a6..db0b49375e 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -1005,12 +1005,16 @@ static void ccw_machine_11_1_instance_options(Machi= neState *machine) static void ccw_machine_11_1_class_options(MachineClass *mc) { S390CcwMachineClass *s390mc =3D S390_CCW_MACHINE_CLASS(mc); + static GlobalProperty compat[] =3D { + { TYPE_S390_PCI_HOST_BRIDGE, "x-zpci-migr-enabled", "off" }, + }; =20 s390mc->use_certs =3D false; s390mc->use_secure =3D false; =20 ccw_machine_11_2_class_options(mc); compat_props_add(mc->compat_props, hw_compat_11_1, hw_compat_11_1_len); + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); } DEFINE_CCW_MACHINE(11, 1); =20 diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bu= s.h index 0a59be1fd0..d310a46e8f 100644 --- a/include/hw/s390x/s390-pci-bus.h +++ b/include/hw/s390x/s390-pci-bus.h @@ -337,6 +337,8 @@ struct S390PCIBusDevice { uint16_t uid; uint32_t idx; uint32_t fh; + Error *zpci_migr_blocker; /* machines 11.1 or older */ + Error *passthrough_migr_blocker; uint32_t fid; bool fid_defined; uint64_t fmb_addr; @@ -385,11 +387,22 @@ struct S390pciState { S390PCIBus *bus; GHashTable *iommu_table; GHashTable *zpci_table; + /* + * pending_sei is the zPCI payload queue drained by CHSC SEI (one + * SeiContainer per instruction execution). It is the zPCI-layer + * counterpart of ChannelSubSys.pending_crws, which carries the + * architectural CRW notifications that prompt the guest to issue + * CHSC SEI in the first place. pending_crws is migrated by + * vmstate_css; pending_sei is migrated by vmstate_s390_pcihost_pendin= g_sei + * in s390-pci-bus.c so that the two queues remain consistent on the + * destination. + */ QTAILQ_HEAD(, SeiContainer) pending_sei; QTAILQ_HEAD(, S390PCIBusDevice) zpci_devs; QTAILQ_HEAD(, S390PCIDMACount) zpci_dma_limit; QTAILQ_HEAD(, S390PCIGroup) zpci_groups; uint8_t next_sim_grp; + bool zpci_migr_enabled; }; =20 S390pciState *s390_get_phb(void); diff --git a/include/hw/s390x/s390-pci-inst.h b/include/hw/s390x/s390-pci-i= nst.h index b53113ddbc..873773f621 100644 --- a/include/hw/s390x/s390-pci-inst.h +++ b/include/hw/s390x/s390-pci-inst.h @@ -113,6 +113,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); +void fmb_update(void *opaque); uint32_t s390_pci_update_iotlb(S390PCIBusDevice *pbdev, S390IOTLBEntry *en= try); =20 #define ZPCI_IO_BAR_MIN 0 --=20 2.34.1 From nobody Sun Sep 20 15:24:59 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=1789140285; cv=none; d=zohomail.com; s=zohoarc; b=fgSt3IP9F6ZqZPrSyAbDSbLjoynmbVgGJIp6Ih3PhxAppFsDcyPqwHm1rS7OIszBTKz6ZSMiikNdm7TDwBIvRNXAUiF1RqEUsjzgwOmxS+MR992VkiO/TuLsyuaLj7TG++YFVbZI1g/oLK56SjhhQHVYvBF9aCB1g5+UqZ3Bs58= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789140285; 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=sKwE0WcDh7WoGxFYQx4Q/0knlI/iybTYRfiDJuI7a4E=; b=QJUipkLyldGE/8Z6oCwWzJmIAoMZXd3aTMvgbHfoLBOB86eTZ+RIe7v8LMZ3gjJqvb8ktJX0G7fnYy5vMssPjLGC4eNr0Ek2Hpj2chzu5WVDR2IW/PGchifKWvax77CgkzUayR0ttvKLD5P6EdunzEPmuqaDCM7GCghK3I8be7c= 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 178914028530590.9910805818215; Fri, 11 Sep 2026 08:24:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x534v-0008M5-8w; Fri, 11 Sep 2026 11:22:13 -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 1x534e-00080I-Qs; Fri, 11 Sep 2026 11:21:58 -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 1x534Z-0004m8-TA; Fri, 11 Sep 2026 11:21:56 -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 68BF1Ulu235530; Fri, 11 Sep 2026 15:21:46 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 4gkd8ncbmc-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:46 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68BEoBta1808819; Fri, 11 Sep 2026 15:21:45 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4gkvq2y35r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 15:21:45 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68BFL2XX38273284 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Sep 2026 15:21:02 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EE1C25805D; Fri, 11 Sep 2026 15:21:43 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B0E4458064; Fri, 11 Sep 2026 15:21:43 +0000 (GMT) Received: from WIN-DU0DFC9G5VV.atx-us.ibm.com (unknown [9.16.62.165]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 11 Sep 2026 15:21:43 +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=sKwE0WcDh7WoGxFYQ x4Q/0knlI/iybTYRfiDJuI7a4E=; b=Y6ahsMxYpV8f/K19ZfzfSRbG00wiS6Zf6 vP4qXaBpwFvDkpKLbRUDOfeFSVoOWHZeP9T/AHFa5K3araBFLDbwZloV2r5id5SC RI7CJTM+aiwCqW6Qh/6oNSeKV19jO04c9ECz1ZtB5gPcvFrGVIMvEImXSA2hL4pN dWWUWj06fEYVgj0u3ArHXVDFhoRnT8NSdRkMmtW/SYk99vel/0r+b0/+gtS5qTG+ TVbpJoUvpTB4ksBwd9k3mZEKZbpJrvjqIO+VKz41hGLmnchX26RoAJ1PVuapJeM8 Huz9evL5uiAnwBmRK7Ek/GEzt82IMwDQSo9+DtVZzRGGjjassU/uA== From: Konstantin Shkolnyy To: mjrosato@linux.ibm.com Cc: alifm@linux.ibm.com, farman@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 v8 16/16] s390x/pci: Create function to contain fmb_timer start Date: Fri, 11 Sep 2026 10:21:37 -0500 Message-Id: <20260911152137.676602-17-kshk@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260911152137.676602-1-kshk@linux.ibm.com> References: <20260911152137.676602-1-kshk@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=NMVAaE6g c=1 sm=1 tr=0 ts=6aa41c8a cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=Q_XnuvSB35syRjF9fnEA:9 X-Proofpoint-GUID: l5cwn0xurxqsx6dONwqRa6JO3DvN5z4K X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfXw6/3NYxHC9cU xZK4S/tw4QgxjRFdxVslWo21wVZn5SwOcvNo6kmSyr6Kp0CcFolmCfMGWJjHSEK9qCGjhq9Wkki ZVMZp8OAaz/3CbJOBea0kO1+cjMEUAjeMTTKztAOy3QWOcBnY5VIwwR2mlwi7LB4VBpAgwk5yas jpbs0LglizGBEiN83WyXlDUX1XNQfgeWLsR9Ww4AApJ2qYY+k7lnbmvZZ+Z0RGQgQciDNly2OFz 5WAQzvdaAIBEqIYlyAIQp46vvbFSnVTTUlFVZzcu9rfMGYHhc3cwYvYPiBYnuFC1mUMkSOlGdd9 meZbOFOjGgMnTRoAV6/dnLm9C/JSyf1w/bX/xglM1gnktRV24ug7lrFbWb65gN/rqEpWPCi4zD1 OGJi1k4PHdZTgY37wuBJlqtlXxBVtfDHKf9FJnpIbaVwaIefQd4lWD85mTWVu008MXTWh0ojYPL ckGsz8zDMtrNacYYHjA== X-Proofpoint-ORIG-GUID: l5cwn0xurxqsx6dONwqRa6JO3DvN5z4K X-Proofpoint-Spam-Info: AW1haW4tMjYwOTExMDIxMCBTYWx0ZWRfX6sKwiN6qWvJ9 2T8RwOnhUTZa8Ivlj+NutO0mdy+qa0ETSi8oiokR5wKf3jyHEm0he4yYkvicroGRcl5fMgoRlcd GVAdUfXSQ/nJUxVj2XFwp+Cxdi5tPF4= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-11_05,2026-09-11_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 clxscore=1015 malwarescore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 suspectscore=0 impostorscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609110210 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: 1789140285828158500 Content-Type: text/plain; charset="utf-8" fmb_timer is now started in 3 different places. The new function will encapsulate that to make sure mui is added in all cases. Reviewed-by: Matthew Rosato Signed-off-by: Konstantin Shkolnyy --- hw/s390x/s390-pci-bus.c | 5 ++--- hw/s390x/s390-pci-inst.c | 14 ++++++++++---- include/hw/s390x/s390-pci-inst.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 c16941ace6..452264976d 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -1864,9 +1864,8 @@ static bool s390_pci_device_post_load_errp(void *opaq= ue, int version_id, } 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 true; } diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index 9b701b4dff..a559b1dcec 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -1135,9 +1135,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 @@ -1174,7 +1181,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) @@ -1367,9 +1374,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-inst.h b/include/hw/s390x/s390-pci-i= nst.h index 873773f621..86d75134b9 100644 --- a/include/hw/s390x/s390-pci-inst.h +++ b/include/hw/s390x/s390-pci-inst.h @@ -114,6 +114,7 @@ int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint= 64_t fiba, uint8_t ar, uintptr_t ra); void fmb_timer_free(S390PCIBusDevice *pbdev); void fmb_update(void *opaque); +void s390_pci_schedule_fmb_timer(S390PCIBusDevice *pbdev, uint64_t start); uint32_t s390_pci_update_iotlb(S390PCIBusDevice *pbdev, S390IOTLBEntry *en= try); =20 #define ZPCI_IO_BAR_MIN 0 --=20 2.34.1