On Mon, Apr 04, 2022 at 08:34:48AM +0200, Corvin Köhne wrote:
> Hi all,
> 
> I'd like to discuss the following patch. At the moment, it's bhyve 
> specific but I'd like to merge it into stock OVMF too. I'm working 
> on GPU passthrough support for Intels integrated graphics devices 
> (Intel calls it GVT-d). In order to get GVT-d working properly, 
> the guest bios should allocate two memory areas (Graphics Stolen 
> Memory and OpRegion). I'm trying to create a platform independent 
> patch which allows to allocate those regions.

Oh no.  Not that discussion again.

First, there is no need to communicate memory regions from the
hypervisor to the guest.  The IGD hardware has registers pointing
to the opregion and to stolen memory, so the guest can simply
allocate and initialize memory, then program the registers
accordingly.  Same procedure you have when initializing IGD on
physical hardware.

Second, that doesn't belong into OVMF.  Drivers for virtual/emulated
hardware are fine, but we certainly don't want enter the business of
maintaining drivers for physical hardware in OVMF.

An EFI driver in the igd option rom should be able to handle all of
the above just fine, and for Intel it should also be easy to cover
differences in hardware generations in the driver.  Bonus points
for also setting up a GOP for the IGD ;)

Unfortunately Intel didn't manage it yet to provide an igd option
rom for virtual machines (or fix their regular driver to also work
in virtual machines) even though this discussion is ongoing on
and off for years meanwhile :(

BTW: Do you talk about GVT-d (== build virtual IGD devices with some
resources of the physical device, roughly comparable to SR-IOV but
with the igd kernel driver instead of the hardware handling this)?
Or do you want pci-assign the complete igd device?

> At the moment, I'm using an E820 table that bhyve provides to the 
> guest. Another approach would be to use the QemuLoader which is 
> used for loader Qemu's ACPI tables. While this has the advantage 
> that the guest bios allocates the memory by it's own, the 
> hypervisor has less control over the address. E.g. the ACRN 
> hypervisor uses an indentical mapping for the Graphics Stolen 
> Memory on Tiger Lake platforms and above (see 
> https://github.com/projectacrn/acrn-hypervisor/blob/master/devicemodel/hw/pci/passthrough.c#L519-L523).

Lovely.  Intel should fix their broken windows drivers ...

The etc/e820 fw_cfg file can have both 'ram' and 'reserved' entries.

And, yes, adding a 'reserved' entry there for the region which requires
an identity mapping (to workaround the driver bug) is fine and should
make sure the region is not used for something else.  Everything else
should be handled by the igd efi driver / optionrom.

Also:  As far I know the stolen memory is only needed at boot, for the
EFI GOP.  Once the guest OS loaded the native drivers for the IGD the
stolen memory is not needed / not used any more, and in theory the
drivers should cope with a stolen memory region not being present just
fine.

For the opregion:  qemu has, for historical reasons, an (optional and
disabled by default) etc/igd-opregion fw_cfg file.  It was a quick hack
which ended up staying.  When a option rom is needed anyway the content
of the opregion can simply be passed to the guest as part of the option
rom image.  But if you prefer to use fw_cfg instead you should at least
use the same hack instead of inventing a new one ...

See also:
  https://gitlab.com/qemu-project/qemu/-/blob/master/docs/igd-assign.txt

Seabios uses etc/igd-opregion, guest code is here:
https://gitlab.com/qemu-project/seabios/-/blob/master/src/fw/pciinit.c#L291
Ideally we'd move that to a proper vgabios too ...

take care,
  Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88407): https://edk2.groups.io/g/devel/message/88407
Mute This Topic: https://groups.io/mt/90236075/21656
Group Owner: [email protected]
Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to