From: Alex Williamson <alex@shazbot.org>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: Tushar Dave <tdave@nvidia.com>,
qemu-devel@nongnu.org, jgg@nvidia.com, skolothumtho@nvidia.com,
qemu-arm@nongnu.org, peter.maydell@linaro.org, mst@redhat.com,
marcel.apfelbaum@gmail.com, devel@edk2.groups.io,
alex@shazbot.org
Subject: Re: [RFC PATCH v2 0/5] hw/pci, hw/arm/virt: fixed PCI BAR placement
Date: Wed, 2 Sep 2026 09:24:26 -0600 [thread overview]
Message-ID: <20260902092426.4906e932@shazbot.org> (raw)
In-Reply-To: <ape0Mbd7Lt4KS-wN@sirius.home.kraxel.org>
On Wed, 2 Sep 2026 08:15:30 +0200
Gerd Hoffmann <kraxel@redhat.com> wrote:
> Hi,
>
> > > And, yes, the logic to match entries in the fw_cfg file with the correct
> > > device using vendor and device id looks somewhat fragile to me too.
> > >
> > > Existing code in qemu+firmware (for example bootorder) uses the location
> > > in the physical device tree to identify devices, like this:
> > >
> > > /pci@i0cf8/pci-bridge@3/*@0/*@0/*@0,0
> > > ^^^^^^^^^ pcie root bus
> > > ^^^^^^^^^^^^ pcie root port @ slot 3
> > > ^^^ virtio-scsi-pci @ slot 0
> > > ^^^ scsi controller bus #0
> > > ^^^^^ scsi device target 0, lun 0
Yeah, I wish such path-based device identification where available here.
> >
> > Good point but the problem is CheckDevice()'s own signature, which is
> > fixed by UEFI PI spec (only passes
> > VendorId/DeviceId/RevisionId/SubsystemVendorId/SubsystemDeviceId). Even
> > though the path exists internally, the standard protocol interface
> > doesn't pass it to the callback.
>
> Hmm, yes. Seems to be designed to apply quirks to device classes, not
> individual devices.
>
> Also note that OVMF already has an incompatible pci device driver and
> there can be only one instance, so the code must be merged into the
> existing driver instead of adding a second.
>
> > Therefore, we prepare the blob entries
> > in the same order PciBusDxe discovers devices, so matching by VID:DID
> > inherently works.
>
> Question is whenever we want have that edk2 limitation and the knowledge
> about edk2 internals (pci scan order) encoded in the qemu <-> firmware
> protocol. I think it makes sense to (additionally) pass the complete
> device path even if the current edk2 implementation doesn't use it, so
> we have the option to improve things later on without having to change
> the qemu <-> firmware protocolS for that.
>
> > > I can see that allowing fixed and non-fixed bars mix is much harder to
> > > handle. Do we need to ask the user to manually set that though? I'd
> > > prefer pci devices propagating automatically to the parent bus that they
> > > have fixed bars and additional constrains apply.
> >
> > I looked at this again, and technically nothing actually needs the flag
> > to exist. The real reason I kept it is closer to a usability one; it's
> > meant to be a visible signal in the launch script itself, so anyone
> > reading or writing the qemu command line sees up front that every device
> > under that root port is expected to have pci-bars= configured, rather
> > than that requirement only surfacing as a runtime error if something's
> > missing.
>
> I'm not sure how much of a usability win that actually is, if you forget
> to set the flag you still get a runtime error.
>
> In general I like things which can be done automatically actually happen
> automatically as this simplifies things for the user in most cases.
>
> > > Also: if the main use case for this is to map vfio devices with guest
> > > physical address == host physical address, is there a need to specify
> > > this manually at all? Shouldn't we have a 'vfio-pci-fixed' device which
> > > handles this automatically?
> >
> > VFIO GPA == HPA is the primary motivation, but I don't think fixed-bar
> > should be tied to VFIO or automatically derive guest addresses from the
> > host.
>
> Why not? It is a great usability improvement IMHO.
We thought about whether to make a vfio-pci shortcut to allow the HPA to
be pushed to the fixed BAR address, but decided that it's also easy for
a userspace script to to collect the physical BAR addresses and
construct the QEMU device options, while maintaining compatibility with
emulated devices and therefore enabling more comprehensive testing. I
don't think we want to be limited by the physical devices available when
we're testing this.
> > For the VFIO use case, the admin can choose to specify the host
> > BAR addresses as the fixed-bar configuration to get GPA == HPA, but the
> > mechanism itself doesn't assume or enforce that -- the desired guest
> > layout isn't always just a copy of the host's, so having fixed-bar
> > auto-derive it on its own would be incorrect in some cases, not just
> > less general.
>
> You still can have fixed-bar-<nr>=<addr> properties to override the
> auto-discovered address for some or all pci bars.
If QEMU is willing to accept both a generic PCI mechanism to specify
this, AND a vfio-pci shortcut, sure, we can create the shortcut. As
above though, it's also something the caller can construct relatively
easily (maybe not by hand, but with a trivial script) and increases the
test surface for QEMU.
> > The mechanism remains a generic way to explicitly specify
> > PCI BAR addresses.
>
> Yes, the code which creates the fw_cfg files is generic and it makes
> sense to have that in the core pci code, so it can be used for every pci
> device.
>
> Nevertheless I'd tend to only expose the properties for devices where an
> actual use case exists. Which is obviously vfio-pci(-fixed). Also
> pci-testdev for development / testing / CI. I can't see much beyond
> that though.
I always imagined the properties would live on the core PCI device and
at best vfio-pci would have a shortcut to prefill those properties
based on physical BAR address. pci-testdev is pretty limited and we
can't fully test arbitrary device functionality with it. We'd also
lose the ability to diverge from the host programming if we need to
debug a layout generated on another system.
IMO, the artificial restriction isn't worth it, especially in the
proposed environment where we enforce and validate fixed BAR
configurations for an entire PCI sub-tree. I think that already
eliminates the most common usage failures we'd see otherwise.
Thanks,
Alex
next prev parent reply other threads:[~2026-09-02 15:24 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 0:40 [RFC PATCH v2 0/5] hw/pci, hw/arm/virt: fixed PCI BAR placement Tushar Dave
2026-08-27 0:40 ` [RFC PATCH v2 1/5] hw/pci: add fixed-bar and pci-bars properties Tushar Dave
2026-08-27 0:40 ` [RFC PATCH v2 2/5] pci: add validation for fixed BAR configuration Tushar Dave
2026-08-27 0:40 ` [RFC PATCH v2 3/5] pci: add fixed BAR fw_cfg blob export Tushar Dave
2026-08-27 0:40 ` [RFC PATCH v2 4/5] hw/arm/virt: export fixed BAR metadata via fw_cfg Tushar Dave
2026-08-27 0:40 ` [RFC PATCH v2 5/5] hw/arm/virt: add highmem-mmio-base property Tushar Dave
2026-08-27 7:18 ` [RFC PATCH v2 0/5] hw/pci, hw/arm/virt: fixed PCI BAR placement Gerd Hoffmann
2026-08-27 13:47 ` Alex Williamson
2026-08-27 14:38 ` [edk2-devel] " Ard Biesheuvel
2026-08-28 15:49 ` Tushar Dave
2026-08-31 13:42 ` Gerd Hoffmann
2026-09-01 21:58 ` Tushar Dave
2026-08-31 13:24 ` Gerd Hoffmann
2026-09-01 22:27 ` Tushar Dave
2026-09-02 6:15 ` Gerd Hoffmann
2026-09-02 15:24 ` Alex Williamson [this message]
2026-09-03 9:34 ` Gerd Hoffmann
2026-09-02 16:30 ` Tushar Dave
2026-09-03 9:47 ` Gerd Hoffmann
2026-09-04 13:46 ` Tushar Dave
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260902092426.4906e932@shazbot.org \
--to=alex@shazbot.org \
--cc=devel@edk2.groups.io \
--cc=jgg@nvidia.com \
--cc=kraxel@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=skolothumtho@nvidia.com \
--cc=tdave@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox