[PATCH 0/3] MdeModulePkg, ArmVirtPkg, OvmfPkg: fixed PCI BAR placement

Tushar Dave posted 3 patches 1 week, 3 days ago
ArmVirtPkg/ArmVirtQemu.dsc                    |   2 +
ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc          |   1 +
MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h       |   2 +
.../Bus/Pci/PciBusDxe/PciEnumeratorSupport.c  |  12 +
.../Bus/Pci/PciBusDxe/PciResourceSupport.c    | 121 +++++
.../Bus/Pci/PciBusDxe/PciResourceSupport.h    |   7 +
.../FixedBars.c                               | 413 ++++++++++++++++++
.../FixedBars.h                               |  63 +++
.../IncompatiblePciDeviceSupport.c            | 114 +++--
.../IncompatiblePciDeviceSupport.inf          |   8 +-
10 files changed, 712 insertions(+), 31 deletions(-)
create mode 100644 OvmfPkg/IncompatiblePciDeviceSupportDxe/FixedBars.c
create mode 100644 OvmfPkg/IncompatiblePciDeviceSupportDxe/FixedBars.h
[PATCH 0/3] MdeModulePkg, ArmVirtPkg, OvmfPkg: fixed PCI BAR placement
Posted by Tushar Dave 1 week, 3 days ago
This is the firmware companion to the QEMU series [1], which validates
fixed BAR configuration and exports it to firmware through the
"etc/fixed-bars" fw_cfg file.

The existing IncompatiblePciDeviceSupportDxe driver is extended to read
the fw_cfg blob and supply fixed BAR addresses to PciBusDxe. The PciBusDxe
changes honor these addresses both when programming a BAR directly and
when sizing and programming the bridge windows above it, so a fixed BAR
behind one or more bridges is placed correctly and covered by the
appropriate bridge windows.

Testing:

The series was tested together with the QEMU companion patches on the
AArch64 virt machine across a range of PCIe topologies: emulated devices,
VFIO passthrough devices, PCIe switches, single and multiple fixed-BAR
endpoints under a shared root port, and fixed BARs behind nested bridges.

Changes since RFC v2:

- Integrate fixed-BAR handling into the existing
  IncompatiblePciDeviceSupportDxe driver instead of adding a new
  QemuFixedBarsDxe driver.
- Size and program PCI bridge windows for fixed BARs as part of
  PciBusDxe's own normal resource calculation and programming
  (CalculateResourceAperture()/ProgramPpbApperture()), instead of a
  separate post-enumeration reprogramming pass.

RFC v2:
https://lore.kernel.org/qemu-devel/20260827004530.600410-1-tdave@nvidia.com/

[1] QEMU companion series:
https://lore.kernel.org/qemu-arm/20260916185554.917526-1-tdave@nvidia.com/

A git branch with this series applied is available at:
https://github.com/tdavenvidia/edk2/tree/Upstream-fixed-bar-Sep-15-V1

The related QEMU change is available at:
https://github.com/tdavenvidia/upstream-qemu/tree/Upstream-fixed-bar-Sep-15-V1

Tushar Dave (3):
  MdeModulePkg/PciBusDxe: honor fixed BAR addresses from IncompatiblePci
  ArmVirtPkg,OvmfPkg: fold fixed BAR placement into IncompatiblePci
  MdeModulePkg/PciBusDxe: size and program bridge windows for fixed BARs

 ArmVirtPkg/ArmVirtQemu.dsc                    |   2 +
 ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc          |   1 +
 MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h       |   2 +
 .../Bus/Pci/PciBusDxe/PciEnumeratorSupport.c  |  12 +
 .../Bus/Pci/PciBusDxe/PciResourceSupport.c    | 121 +++++
 .../Bus/Pci/PciBusDxe/PciResourceSupport.h    |   7 +
 .../FixedBars.c                               | 413 ++++++++++++++++++
 .../FixedBars.h                               |  63 +++
 .../IncompatiblePciDeviceSupport.c            | 114 +++--
 .../IncompatiblePciDeviceSupport.inf          |   8 +-
 10 files changed, 712 insertions(+), 31 deletions(-)
 create mode 100644 OvmfPkg/IncompatiblePciDeviceSupportDxe/FixedBars.c
 create mode 100644 OvmfPkg/IncompatiblePciDeviceSupportDxe/FixedBars.h

-- 
2.34.1
Re: [PATCH 0/3] MdeModulePkg, ArmVirtPkg, OvmfPkg: fixed PCI BAR placement
Posted by Gerd Hoffmann 1 week, 1 day ago
  Hi,

> The series was tested together with the QEMU companion patches on the
> AArch64 virt machine across a range of PCIe topologies: emulated devices,
> VFIO passthrough devices, PCIe switches, single and multiple fixed-BAR
> endpoints under a shared root port, and fixed BARs behind nested bridges.

Given this is active for both aarch64 and x86_64:  Any testing with OVMF
on x86_64?

Overall this looks good to me.  edk2 has switched to github PRs, so
please open a PR there.  edk2 has a policy that patches should not touch
multiple packages, so patch #2 should be split into two for ArmVirtPkg
and OvmfPkg.

take care,
  Gerd
Re: [PATCH 0/3] MdeModulePkg, ArmVirtPkg, OvmfPkg: fixed PCI BAR placement
Posted by Tushar Dave 1 week, 1 day ago

On 9/18/2026 8:24 AM, Gerd Hoffmann wrote:
>   Hi,
> 
>> The series was tested together with the QEMU companion patches on the
>> AArch64 virt machine across a range of PCIe topologies: emulated devices,
>> VFIO passthrough devices, PCIe switches, single and multiple fixed-BAR
>> endpoints under a shared root port, and fixed BARs behind nested bridges.
> 
> Given this is active for both aarch64 and x86_64:  Any testing with OVMF
> on x86_64?

Gerd,

Thank you for the review.

Yes — tested on x86_64 OVMF (OvmfPkgX64, q35). There's no fixed-BAR
placement to actually exercise on x86 since nothing on the QEMU side
populates the fw_cfg blob there, so this was really a check that the
fixed-BAR addition to IncompatiblePciDeviceSupportDxe is a correct no-op
when that blob is absent. And it is — existing behavior is unchanged,
without any regressions.

> 
> Overall this looks good to me.  edk2 has switched to github PRs, so
> please open a PR there.  edk2 has a policy that patches should not touch
> multiple packages, so patch #2 should be split into two for ArmVirtPkg
> and OvmfPkg.

Sure, I'll open a GitHub PR for this series and split patch #2 into
ArmVirtPkg and OvmfPkg patches.

> 
> take care,
>   Gerd

Thanks.
-Tushar


Re: [PATCH 0/3] MdeModulePkg, ArmVirtPkg, OvmfPkg: fixed PCI BAR placement
Posted by Tushar Dave 2 days, 23 hours ago

On 9/18/2026 1:22 PM, Tushar Dave wrote:
> 
> 
> On 9/18/2026 8:24 AM, Gerd Hoffmann wrote:
>>   Hi,
>>
>>> The series was tested together with the QEMU companion patches on the
>>> AArch64 virt machine across a range of PCIe topologies: emulated devices,
>>> VFIO passthrough devices, PCIe switches, single and multiple fixed-BAR
>>> endpoints under a shared root port, and fixed BARs behind nested bridges.
>>
>> Given this is active for both aarch64 and x86_64:  Any testing with OVMF
>> on x86_64?
> 
> Gerd,
> 
> Thank you for the review.
> 
> Yes — tested on x86_64 OVMF (OvmfPkgX64, q35). There's no fixed-BAR
> placement to actually exercise on x86 since nothing on the QEMU side
> populates the fw_cfg blob there, so this was really a check that the
> fixed-BAR addition to IncompatiblePciDeviceSupportDxe is a correct no-op
> when that blob is absent. And it is — existing behavior is unchanged,
> without any regressions.
> 
>>
>> Overall this looks good to me.  edk2 has switched to github PRs, so
>> please open a PR there.  edk2 has a policy that patches should not touch
>> multiple packages, so patch #2 should be split into two for ArmVirtPkg
>> and OvmfPkg.
> 
> Sure, I'll open a GitHub PR for this series and split patch #2 into
> ArmVirtPkg and OvmfPkg patches.

PR submitted https://github.com/tianocore/edk2/pull/13183

Thanks.
-Tushar

> 
>>
>> take care,
>>   Gerd
> 
> Thanks.
> -Tushar