From nobody Mon Feb 9 01:47:28 2026 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+80301+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+80301+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1631027442; cv=none; d=zohomail.com; s=zohoarc; b=c84C9AFZ/AxEj9no5SWk/lb+nHY8y3cYTEuZplsMplm8o0XqQvWDraqrYEkJDPuiMRhPP90Olxx+6CUns2EipSB93S5buvcJINAHrJVk3NgUqr5yyK5Kptt80zHItOdL9meD6XZ5J/43VlZZQPIjKa6Sbzt1oANfP6GHYGpaha4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631027442; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=UWlrDNKmrsaeC2vythTCPcJV6vA4yTWosBIW7OsCtIs=; b=JvnQS5H6bWR2brbwjDg1sQ/tiLSElWEAqorXKT7dr6fO8MCptbwKtkiBrnDFkItk05dAvpyf0i8Vl4uCvHyCQ5bf6suAG5yiW2XXDdgu7JGNViA1PWOHsEX0eQcryg55Rj5kmKnyJsrotG3f2L8X6FbUSS4grUh8C9rQbB7Z8Lg= 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+80301+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1631027442870283.9074919271758; Tue, 7 Sep 2021 08:10:42 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id NPjdYY1788612xCHs6cNviQI; Tue, 07 Sep 2021 08:10:42 -0700 X-Received: from smtp-fw-80007.amazon.com (smtp-fw-80007.amazon.com [99.78.197.218]) by mx.groups.io with SMTP id smtpd.web08.11841.1630766541972468133 for ; Sat, 04 Sep 2021 07:42:22 -0700 X-IronPort-AV: E=Sophos;i="5.85,268,1624320000"; d="scan'208";a="24529243" X-Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-1d-5dd976cd.us-east-1.amazon.com) ([10.25.36.210]) by smtp-border-fw-80007.pdx80.corp.amazon.com with ESMTP; 04 Sep 2021 14:42:21 +0000 X-Received: from EX13D49EUC003.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-1d-5dd976cd.us-east-1.amazon.com (Postfix) with ESMTPS id EA099A28E0 for ; Sat, 4 Sep 2021 14:42:20 +0000 (UTC) X-Received: from ub4014a598e6c52.ant.amazon.com (10.43.162.52) by EX13D49EUC003.ant.amazon.com (10.43.164.91) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Sat, 4 Sep 2021 14:42:18 +0000 From: "Nicolas Ojeda Leon via groups.io" To: CC: Nicolas Ojeda Leon , Alexander Graf Subject: [edk2-devel] [PATCH 3/5] MdeModulePkg OvmfPkg: Add Pcd token for PCI pre-populated BARs Date: Sat, 4 Sep 2021 16:37:54 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.43.162.52] X-ClientProxiedBy: EX13D16UWC001.ant.amazon.com (10.43.162.117) To EX13D49EUC003.ant.amazon.com (10.43.164.91) Precedence: Bulk List-Unsubscribe: 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,ncoleon@amazon.com X-Gm-Message-State: G3rttFvsZDKiesCaIl7HJvl9x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1631027442; bh=k+RTs1ZxcQJE+Yg+qC1y1JN5jbMAxtgNMBzUAKPHpjI=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=eN+9s18Tq/aUte5PbOaVBghSJQNGx34wOa4ho82Mom/wg9krUzIThF5Q7sswnN3cXQY 0CQZjhJzXw1nEi+dXe7AQ1IArUtV22xkdDO4F1VDYBKEvmQPSuR44POmInD6R1cEGyudW V0XVeW5gmn6yHpemfEDOWQr0Iia7XLwZ32A= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1631027445055100016 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Create a new PCD boolean token in MdeModulePkg for global use. We use this token to indicate if the configuration, parsed from fw-cfg, requires pre-populated BARs to be preserved. During creation of root bridges configurations, the flag is set according to the "pre-populated-bars" item in fw-cfg. The Pcd token is created as a dynamic item for consumption in both Pei and Dxe PCI modules. The token provides a globally accessible configuration flag to determine, during PCI BAR allocation, if pre-populated BARs must be respected. The pre-allocated PCI BARs are used in platforms in which MMIO resources are configured with host physical addresses so that DMA transactions can happen between PCI devices without packets going through the IOMMU. Performance is improved due to PCI packets travelling shorter distances and avoiding links reaching the Root Complex, which can get busy during I/O intensive periods. Signed-off-by: Nicolas Ojeda Leon Cc: Alexander Graf --- MdeModulePkg/MdeModulePkg.dec | 6 ++++++ OvmfPkg/OvmfPkgX64.dsc | 1 + MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf | 1 + .../PciHostBridgeUtilityLib.inf | 4 ++++ OvmfPkg/PlatformPei/PlatformPei.inf | 1 + .../PciHostBridgeUtilityLib.c | 17 +++++++++++++++++ 6 files changed, 30 insertions(+) diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 133e04ee86..44a2150628 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -1902,6 +1902,12 @@ # @Prompt Disable full PCI enumeration. gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|FALSE|BOOLEAN= |0x10000048 =20 + ## The flag to control preservation of pre-populated PCI BARs + # TRUE - Respect pre-populated PCI BARs + # FALSE - No pre-populated BARs, place all BARs + # @Prompt Enable preservsation of pre-populated PCI BARs + gEfiMdeModulePkgTokenSpaceGuid.PcdPciPreservePopulatedMappings|FALSE|BOO= LEAN|0x10000050 + ## Disk I/O - Number of Data Buffer block. # Define the size in block of the pre-allocated buffer. It provide better # performance for large Disk I/O requests. diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index e56b83d95e..fff50355b0 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -605,6 +605,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0 !endif + gEfiMdeModulePkgTokenSpaceGuid.PcdPciPreservePopulatedMappings|FALSE gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|800 gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|600 gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable|FALSE diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf b/MdeModulePkg/Bu= s/Pci/PciBusDxe/PciBusDxe.inf index e317169d9c..046876bb3b 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf @@ -107,6 +107,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdMrIovSupport ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration ## SOMETIM= ES_CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdPcieResizableBarSupport ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdPciPreservePopulatedMappings## CONSUMES =20 [UserExtensions.TianoCore."ExtraFiles"] PciBusDxeExtra.uni diff --git a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLi= b.inf b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf index 83a734c172..3643ffd79e 100644 --- a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf +++ b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf @@ -39,5 +39,9 @@ DebugLib DevicePathLib MemoryAllocationLib + PcdLib PciLib QemuFwCfgLib + +[Pcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdPciPreservePopulatedMappings diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/Plat= formPei.inf index 67eb7aa716..61bcf25999 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -93,6 +93,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved + gEfiMdeModulePkgTokenSpaceGuid.PcdPciPreservePopulatedMappings gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack diff --git a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLi= b.c b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c index 7567da8423..0a9aac5359 100644 --- a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c +++ b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -298,6 +299,7 @@ PciHostBridgeUtilityGetRootBridges ( FIRMWARE_CONFIG_ITEM FwCfgItem; UINTN FwCfgSize; UINT64 ExtraRootBridges; + UINT64 PrePopulatedBars; PCI_ROOT_BRIDGE *Bridges; UINTN Initialized; UINTN LastRootBridgeNumber; @@ -339,6 +341,21 @@ PciHostBridgeUtilityGetRootBridges ( __FUNCTION__, ExtraRootBridges)); } =20 + // + // Find file for pre-populated bars and set Pcd token if enabled + // + Status =3D QemuFwCfgFindFile ("etc/pre-populated-bars", &FwCfgItem, &FwC= fgSize); + PrePopulatedBars =3D 0; + if (!EFI_ERROR (Status) && FwCfgSize =3D=3D sizeof (PrePopulatedBars)) { + QemuFwCfgSelectItem (FwCfgItem); + QemuFwCfgReadBytes (FwCfgSize, &PrePopulatedBars); + + if (PrePopulatedBars) { + PcdSetBoolS (PcdPciPreservePopulatedMappings, TRUE); + DEBUG ((DEBUG_INFO, "%a: Pre-populated BARs present\n", __FUNCTION__= )); + } + } + // // Initialize RootBridgeInfo pointer, so in case no fw-cfg item is found // the default configuration is used. --=20 2.17.1 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879 -=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 (#80301): https://edk2.groups.io/g/devel/message/80301 Mute This Topic: https://groups.io/mt/85437211/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-