**Description:**
This patch adds support for GPU Passthrough of dedicated AMD GPUs. No integrated or second dedicated GPU is neccessary to use GPU Passthrough. If no second GPU is installed, FreeBSD will run headless after booting your VM.
It's based on some other reviews:
- D24066
- D26209
- D27230 (requires some modifications see //How to use GPU Passthrough//)
To simplify testing, this patch includes all changes. I'm going to rebase this patch as soon as other reviews are merged.
**Prerequisites:**
- CPU with VT-d or AMD-Vi
**Tested Scenarios:**
| **Hardware** | **OS** | |
| Intel Xeon D-1527 + AMD E8860 | Windows 10 | Working |
| Intel Xeon D-1527 + AMD E8860 | Ubuntu 20.04 | Working |
For Windows it's only neccessary to use another BAR-emulation for passthru devices.
Linux GPU driver is searching for a VBIOS which is currently missing. This patch tries to extract VBIOS and passthrough it as PCI ROM to a guest.
**How to use GPU Passthrough:**
Just add your GPU to bhyve like any other pci passthru device:1. Use newest UEFI from D27230 with enabled bus enumeration:
- get latest edk2 sources
- assign ppt driver to your gpu - `portsnap fetch extract`
- add your gpu as passthru device to your bhyve config (e.g.: `-s 2,passthru,3/0/0`) - `cd /usr/ports/sysutils/uefi-edk2-bhyve`
- change files with files provides by D27230
- `make extract`
**Known Issues:** - modify `OvmfPkg/Bhyve/BhyveX64.dsc`:
**1. EFI fails to shadow PCI-ROM** - set `gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration` to `FALSE`:
` gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|FALSE`
- rebuild and install new UEFI
Patch passes VBIOS as PCI-ROM to a guest. EFI scans BARs to detect MMIO-Space. After that, PCI-ROM is copied to non-prefetchable MMIO-Space under 4 GB. This could result in some issues: - `cd /usr/ports/sysutils/uefi-edk2-bhyve`
- MMIO-Space is - `make reinstall`
2. Just add your GPU to small for PCI-ROMbhyve like any other pci passthru device:
- assign ppt driver to your gpu
- PCI-ROM and BARs of the GPU device overlaps - add your gpu as passthru device to your bhyve config (e.g.: `-s 2,passthru,3/0/0`)
Linux GPU driver won't work if any of these issues occurs. They depend on your bhyve-config. Depending on your pci devices and their order, these issues will occur or not. To solve these issues, this patch add a `rom-alloc` device. Addings this device as first pci device (e. g. `-s 1,rom-alloc`) to your bhyve config will avoid all issues.