On 11/4/2026 6:11 AM, Michael S. Tsirkin wrote:
> On Wed, Nov 04, 2026 at 10:59:47AM +0100, Ard Biesheuvel wrote:
>>
>>
>> On Mon, 2 Nov 2026, at 19:12, Tushar Dave wrote:
>>> Introduce a fixed BAR fw_cfg blob exporter that serializes PCI
>>> device and BAR information into the "etc/fixed-bars" fw_cfg file.
>>>
>>> The blob contains an entry for every PCI function with memory BARs.
>>> Each entry carries the device's vendor and device ID, whether it
>>> has a fixed BAR configuration, and its firmware device path. Fixed
>>> BAR entries also include the configured BAR address, size, and type
>>> information for each BAR.
>>>
>>> Document the format in docs/specs/pci-fixed-bars.rst.
>>>
>>> Signed-off-by: Tushar Dave <[email protected]>
>>> ---
>>>  docs/specs/index.rst           |   1 +
>>>  docs/specs/pci-fixed-bars.rst  |  75 ++++++++
>>>  hw/pci/meson.build             |   1 +
>>>  hw/pci/pci-fixed-bar-blob.c    | 308 +++++++++++++++++++++++++++++++++
>>>  include/hw/pci/pci-fixed-bar.h |  63 +++++++
>>>  5 files changed, 448 insertions(+)
>>>  create mode 100644 docs/specs/pci-fixed-bars.rst
>>>  create mode 100644 hw/pci/pci-fixed-bar-blob.c
>>>  create mode 100644 include/hw/pci/pci-fixed-bar.h
>>>
>> ...
>>> diff --git a/hw/pci/pci-fixed-bar-blob.c b/hw/pci/pci-fixed-bar-blob.c
>>> new file mode 100644
>>> index 0000000000..dc94debfad
>>> --- /dev/null
>>> +++ b/hw/pci/pci-fixed-bar-blob.c
>> ...
>>> +/*
>>> + * EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL's CheckDevice interface
>>> + * (UEFI PI Spec 1.2 Vol 5) only passes VendorId/DeviceId/RevisionId/
>>> + * SubsystemVendorId/SubsystemDeviceId, no BDF — so in EDK2 we can't
>>> + * match a blob entry to a specific device directly using BDF. To work
>>> + * around that, we prepare the blob entries in the same order PciBusDxe
>>> + * discovers devices, so matching by VID:DID inherently works.
>>
>> This sounds rather fragile.
>>
>> Could you elaborate on what order this is, and why it is reasonable to
>> rely on that approach being stable?
>>
>>
> 
> Also, bus numbers can be changed by guest, and I don't get why
> would you want to report devices without a fixed bar.


The bus number is not needed in the blob. It is included only for
debugging and is not used for any functionality. The firmware matches
blob entries by vendor/device ID and discovery order, as described in
my earlier reply to Ard. I can drop 'rp_bus' from the blob.

Devices without fixed BARs are kept in the blob to preserve discovery
order for matching. For example, if two identical NICs are present and
only the second has a fixed BAR, including only the second NIC's entry
would cause its fixed BAR address to be assigned to the first NIC,
which is discovered first. Including both entries ensures the first
NIC is skipped (each blob entry carries a flag indicating whether the
device has fixed BARs) and the second NIC gets its own fixed BAR address.

-Tushar


Reply via email to