From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3A4E5C88E45 for ; Fri, 11 Sep 2026 15:24:58 +0000 (UTC) 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 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== 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) 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: 8bit 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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(IOMMUMemoryRegion *mr, hwaddr addr, IOMMUAccessFlags flag, int iommu_idx) { S390PCIBusDevice *pbdev = container_of(mr, S390PCIBusDevice, iommu_mr); - S390PCIIOMMU *iommu = pbdev->iommu; S390IOTLBEntry *entry; uint64_t iova = addr & TARGET_PAGE_MASK; uint16_t error = 0; @@ -565,7 +564,7 @@ static IOMMUTLBEntry s390_translate_iommu(IOMMUMemoryRegion *mr, hwaddr addr, trace_s390_pci_iommu_xlate(addr); - if (addr < pbdev->pba || addr > iommu->pal) { + if (addr < pbdev->pba || addr > pbdev->pal) { error = ERR_EVENT_OORANGE; goto err; } @@ -600,10 +599,9 @@ static void s390_pci_ioat_replay(S390PCIBusDevice *pbdev) uint16_t error = 0; uint32_t dma_avail; hwaddr curr, end; - S390PCIIOMMU *iommu = pbdev->iommu; curr = pbdev->pba; - end = iommu->pal; + end = pbdev->pal; 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 = 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 = 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 = 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; } - iommu = pbdev->iommu; if (pbdev->dma_limit) { dma_avail = 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; } - if (end < start || end < pbdev->pba || start > iommu->pal) { + if (end < start || end < pbdev->pba || start > pbdev->pal) { error = 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 = MAX(start, pbdev->pba); - end = MIN(end, iommu->pal + 1); + end = MIN(end, pbdev->pal + 1); retry: start = sstart; @@ -1029,7 +1027,6 @@ bool s390_pci_is_translation_enabled(uint64_t g_iota) static int reg_ioat(CPUS390XState *env, S390PCIBusDevice *pbdev, ZpciFib fib, uintptr_t ra) { - S390PCIIOMMU *iommu = pbdev->iommu; uint64_t pba = ldq_be_p(&fib.pba); uint64_t pal = ldq_be_p(&fib.pal); uint64_t g_iota = ldq_be_p(&fib.iota); @@ -1055,7 +1052,7 @@ static int reg_ioat(CPUS390XState *env, S390PCIBusDevice *pbdev, ZpciFib fib, } pbdev->pba = pba; - iommu->pal = pal; + pbdev->pal = pal; pbdev->g_iota = g_iota; if (t) { @@ -1069,10 +1066,9 @@ static int reg_ioat(CPUS390XState *env, S390PCIBusDevice *pbdev, ZpciFib fib, void pci_dereg_ioat(S390PCIBusDevice *pbdev) { - S390PCIIOMMU *iommu = pbdev->iommu; s390_pci_iommu_disable(pbdev); pbdev->pba = 0; - iommu->pal = 0; + pbdev->pal = 0; pbdev->g_iota = 0; } @@ -1445,7 +1441,7 @@ int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar, } 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-bus.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; }; @@ -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; -- 2.34.1