From nobody Tue Apr 7 21:28:21 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 ARC-Seal: i=1; a=rsa-sha256; t=1773257846; cv=none; d=zohomail.com; s=zohoarc; b=VvPS3ckOlBGc5kzE/aJvup2nfo+Y383pyuK0zsX1Jjjv7xeXES3DoKRIz+sLJJWikHkMM79+1gBzW9dc1UCTgFfPRTyhRjrMBnH20uRxIaB8CA8S1gpEER6VElHwBWKt++QYUdVSHowTfxOcZex8yiHho9ldRcuP2Zjxb+QuH58= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773257846; 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=BrNuvFSbc7vVj0NfzeUdASL/cUqiR4qxP5JzhThgC08=; b=Pk8Npsxx/JNwojmanTBj1wzbcn6V3nuTe+yRV3WD5v6AIYc813PT6+lXJr5Mv1Q+snIgh/wz6gRJNCA/p9GFx8CRTJ1rCfv9R/wC8s40Go4p2wM1txftDV44420oqaeqBn5KRSq79E0Ya15ovLg8oQWxDfelzXsly/jBud/l4Ew= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1773257846080625.3020721115015; Wed, 11 Mar 2026 12:37:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w0PL0-0007Sx-IF; Wed, 11 Mar 2026 15:35:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w0PKn-0007RP-Sg; Wed, 11 Mar 2026 15:35:09 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w0PKj-0008UH-Vm; Wed, 11 Mar 2026 15:35:08 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id E07001920E9; Wed, 11 Mar 2026 22:34:25 +0300 (MSK) Received: from think4mjt.tls.msk.ru (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id 29C6D37C44E; Wed, 11 Mar 2026 22:35:04 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tls.msk.ru; s=202602; t=1773257665; bh=LKvMLuP67wh1wfkP2YjbH5OAxzraP19Fv3VPJ3Q/vDw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=P3ZO+OTQNvjyIjTSwsawMa92wu7Xj7+awg+J4XEurcJBVSff8U/A5FBHXOT3A1DIp Emzd6DyADZvMebmwjH+euorIiuEYlF/md7DObXd2LfAeVwTahajEiut4pi831cfszb L0ua+daY9osdb9MfW2UgxX/ZufYTTt6u31Usbuh576t3rE1ZFa1olJPRUfL0XHDFD5 TS2OjWqwKcfQ8HUD/DeZ87sg21X9cilViUrmMLwF7kxrjWg4VEOaJY7ME3c3erozvP 3hJeP+PPrcXFEiyBysSqX/W1bJIt6wWS2knUUDPtt/kfjGHNo43jPfGVEs498YFs7t jOcbCrCulCj4g== From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Jaehoon Kim , Matthew Rosato , Farhan Ali , Eric Farman , Thomas Huth , Michael Tokarev Subject: [Stable-10.2.2 01/53] s390x/pci: Fix endianness for zPCI BAR values. Date: Wed, 11 Mar 2026 22:33:54 +0300 Message-ID: <20260311193449.1096110-1-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @tls.msk.ru) X-ZM-MESSAGEID: 1773257847346154100 Content-Type: text/plain; charset="utf-8" From: Jaehoon Kim During zPCI scan, BAR configuration data retrieved via CLP Query was misinterpreted due to an endianness mismatch between QEMU and the guest kernel. The guest kernel's clp_store_query_pci_fn() expects BAR values in little-endian format and converts them with le32_to_cpu(). However, QEMU was incorrectly sending them in big-endian format, not following the architecture specification. This caused incorrect bit-swapping in the kernel, leading zpci_setup_bus_resources() to perform registration checks against invalid flags, making the process ineffective. Observation values for zPCI device (NVMe passthrough): LPAR from real CLP: [ 0.865595] Resource: PCI Bus 0000:00 -> zdev->bar[0].val: 0x4 [ 0.865597] start: 0x4000000000000000 [ 0.865598] end: 0x4000000000003fff [ 0.865600] flags: 0x100200 QEMU before fix (wrong): [ 0.601083] Resource: PCI Bus 0001:00 -> zdev->bar[0].val: 0x4000000 [ 0.601085] start: 0x4003000000000000 [ 0.601086] end: 0x4003000000003fff [ 0.601087] flags: 0x200 QEMU after fix (correct): [ 0.601116] Resource: PCI Bus 0001:00 -> zdev->bar[0].val: 0x4 [ 0.601117] start: 0x4003000000000000 [ 0.601118] end: 0x4003000000003fff [ 0.601119] flags: 0x100200 Signed-off-by: Jaehoon Kim Reviewed-by: Matthew Rosato Reviewed-by: Farhan Ali Reviewed-by: Eric Farman Message-ID: <20260206164645.1845366-1-jhkim@linux.ibm.com> Signed-off-by: Thomas Huth (cherry picked from commit 00ebc44514a67fb75a46d60e4b44614ebf91230f) Signed-off-by: Michael Tokarev diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c index 5841dfc4fe..a8f08272fe 100644 --- a/hw/s390x/s390-pci-inst.c +++ b/hw/s390x/s390-pci-inst.c @@ -307,7 +307,7 @@ int clp_service_call(S390CPU *cpu, uint8_t r2, uintptr_= t ra) uint32_t data =3D pci_get_long(pbdev->pdev->config + PCI_BASE_ADDRESS_0 + (i * 4)); =20 - stl_be_p(&resquery->bar[i], data); + stl_le_p(&resquery->bar[i], data); resquery->bar_size[i] =3D pbdev->pdev->io_regions[i].size ? ctz64(pbdev->pdev->io_regions[i].size)= : 0; trace_s390_pci_bar(i, --=20 2.47.3