From nobody Fri May 17 15:31:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+110782+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+110782+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1699322547; cv=none; d=zohomail.com; s=zohoarc; b=CmyW5Wfoce02MgGJbegd6Wl6h4mUvSDL9DyblykqzQA1qyw2Sc/wM39rIop5BrTzWfzPzzTpgtjWS8cYbRLGdl4SBarIyslMuV2mLnOjWr33n4nkpo4DBOVOjDIF5osYuvsLd9VDqtqB1WeubTmiRvLzcslnwiLK/QV2e7+cNYc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699322547; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=6BRGeZyYra2QpYzy8crMud2Mk/crBrtUvtO2gK6tv4U=; b=IClhhTescdYx6qot6tJWmvgSA5B/m7KAFx4KB+RPaVM5RVuf5risW5jQifEhyiHhC4PRKsPJAQODYTbpH8+x0VMo1OhqTr2L2/1qRB5BbHfa4jvZntEYx/w19dc3aBhFa0Ue5cDy4DjdhY44HB6ZtPR9xiNT9DGbGsgODXNvrs0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+110782+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1699322547081649.759992919175; Mon, 6 Nov 2023 18:02:27 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=xm8wAE8bYflGv+kBL9xxQ/fMz4gbFUZUgyAL9hWRXyU=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1699322546; v=1; b=US6JuWF9VM6BfHKcowPA5IaJpPsoZUZHiV7BSZ/h7WCFUdQ4x40j0xHLSDgZLWhmWZRXV/0a zPXf0HFbLF0PN+DkAGkm/k6ggC2B8b3UYHq4ZIyHTFv7QacdS+eTBd4BAopH9iZad9sEpkLSd03 qbSDGRI71B5JzyI4Vga/PVyI= X-Received: by 127.0.0.2 with SMTP id 7u8TYY1788612xXlJTNYGFMa; Mon, 06 Nov 2023 18:02:26 -0800 X-Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by mx.groups.io with SMTP id smtpd.web10.1627.1699322546141458876 for ; Mon, 06 Nov 2023 18:02:26 -0800 X-Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1cc9b626a96so26807255ad.2 for ; Mon, 06 Nov 2023 18:02:26 -0800 (PST) X-Gm-Message-State: KbAZZlhg2etLkCE5HRlAPIyjx1787277AA= X-Google-Smtp-Source: AGHT+IE/ZUnaFdSxnr/j+1hCXkjRAhdPXGMYV0RiTCy+zeBmPhXIchLx3r/pejd+p2fZ9jojmmIgNg== X-Received: by 2002:a17:902:d28b:b0:1c9:ea71:8032 with SMTP id t11-20020a170902d28b00b001c9ea718032mr22363016plc.31.1699322545249; Mon, 06 Nov 2023 18:02:25 -0800 (PST) X-Received: from JOE-LENO.redmond.corp.microsoft.com ([131.107.159.145]) by smtp.gmail.com with ESMTPSA id m15-20020a170902db0f00b001c7443d0890sm5093947plx.102.2023.11.06.18.02.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 18:02:24 -0800 (PST) From: "Joe L" To: devel@edk2.groups.io Cc: joelopez333 Subject: [edk2-devel] [PATCH v2] MdeModulePkg/PciHostBridgeDxe: Add readback after final Cfg-Write Date: Mon, 6 Nov 2023 18:02:21 -0800 Message-Id: <34167f0f873c01654aee0e9c8629221dad241529.1699322498.git.jlotwo@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,jlotwo@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1699322548887100003 Content-Type: text/plain; charset="utf-8" From: joelopez333 REF:https://edk2.groups.io/g/devel/topic/102310377#110456 Problem Report: On AARCH64, there is no ordering guarantee between configuration space (ECAM) writes and memory space reads (MMIO). ARM AMBA CHI only guarantees ordering for reads and writes within a single address r= egion, however, on some systems MMIO and ECAM may be split into separate address regions. A problem may arise when an ECAM write is issued a completion before a = subsequent MMIO read is issued and receives a completion. For example, a typical PCI software flow is the following: 1. ECAM write to device command register to enable memory space 2. MMIO read from device memory space for which access was enabled in step 1. There is no guarantee that step 2. will not begin before the completion= of step 1. on systems where ECAM/MMIO are specified as separate address regions, e= ven if both spaces have the memory attributes device-nGnRnE. Fix: - Add a read after the final PCI Configuration space write in RootBridgeIoPciAccess. - When configuration space is strongly ordered, this ensures that program execution cannot continue until the completion is received for the previous Cfg-Write, which may have side-effects. - Risk of reading a "write-only" register and causing a CA which leaves= the device unresponsive. The expectation based on the PCI Base Spec v6.1 section= 7.4 is that all PCI Spec-defined registers will be readable, however, there may e= xist design-specific registers that fall into this category. Cc: Leif Lindholm Cc: Ard Biesheuvel Cc: Sami Mujawar Cc: Jian J Wang Cc: Liming Gao Cc: Hao A Wu Cc: Ray Ni Cc: Pedro Falcato Cc: Michael Brown Signed-off-by: Joe Lopez --- MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c b/MdeM= odulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c index 157a0ada80..c2dc2018d6 100644 --- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c +++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c @@ -1238,6 +1238,14 @@ RootBridgeIoPciAccess ( } } =20 + // + // Perform readback after write to confirm completion was received for t= he last write + // before subsequent memory operations can be issued. + // + if (!Read) { + PciSegmentRead8 (Address - InStride); + } + return EFI_SUCCESS; } =20 --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#110782): https://edk2.groups.io/g/devel/message/110782 Mute This Topic: https://groups.io/mt/102435564/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-