GithubHelp home page GithubHelp logo

build-edk2-gvtd's Introduction

build-edk2-gvtd

Build EDK2 with Intel GVT-D Support

Tested Platforms

  • Intel Core 13900T ES Q0PV (AlderLake, Asrock Deskmini B660, PVE 8.0.4, Win11 23H2)
  • Intel Intel N100 (AlderLake-N, GMKtec NucBox G3, PVE 8.0.4, Win11 23H2)

Test reports on different platforms are welcomed, feel free to open new issues.

Prerequisites

  • git
  • docker
  • internet access
  • your own intel gop driver (which can be extracted with UEFI-BIOS-Updater from your Motherboard's BIOS image, which can be downloaded from here and here)

Usage

git clone [email protected]:cmd2001/build-edk2-gvtd.git
cd build-edk2-gvtd
sh ./init_edk2.sh
cp <intel gop driver efi> gop/IntelGopDriver.efi
sudo bash ./build_ovmf.sh
sudo bash ./build_oprom.sh

Now you have OVMF_CODE_4MB.fd, OVMF_CODE_4MB.secboot.fd and XXX.rom, XXX_GOP.rom in ./product. (where XXX.rom, XXX_GOP.rom is B660.rom, B660_GOP.rom as default)

The first two files contains a customized edk2 firmware supporting iGPU passthrough, you can copy them to /usr/share/pve-edk2-firmware and overwrite the original files from PVE.

If you are unpleasant about overwritting the edk2 firmware of PVE, you can copy XXX.rom to /usr/share/kvm/ and use this OpRom to achieve iGPU passthrough.

Then edit the configuration file of your VM, now you can boot your VM with integrated graphics passthrough and light your monitor.

Key Changes in VM Config

REMINDER: OS Type must be set to Linux and CPU Type must be set to HOST, otherwise the Windows guest system will not work after installing the driver from Intel.

Using Only OpRom (Recommended, Easier)

args: -set device.hostpci0.addr=02.0 -set device.hostpci0.x-igd-gms=6 -set device.hostpci0.x-igd-opregion=on
hostpci0: 0000:00:02,legacy-igd=1,romfile=XXX.rom

XXX.rom denotes the OpRom generated by build_oprom.sh (B660.rom as default).

Using customized edk2 firmware and OpROM (Fallback, with better capability and higher success rate)

args: -set device.hostpci0.addr=02.0 -set device.hostpci0.x-igd-gms=6 -set device.hostpci0.x-igd-opregion=on
hostpci0: 0000:00:02,legacy-igd=1,romfile=XXX_GOP.rom

XXX_GOP.rom should be placed in /usr/share/kvm/.

This repository uses a patched edk2 repository, which fixes a bug about ASSIGNED_IGD_PCI_BDSM_OFFSET from intel's vanilla patch. The bug could make iGPU use inappropriate memory region as stolen memory, causing a black or blink screen.

Now the customized edk2 firmware method and OpRom only method should do the same work.

Due to loading order of efis in OVMF image during QEMU-KVM runtime, this method (the method using only OpROM) may lead to a blurry screen, or just prevent screen from lighting up. In this case, please switch to previous method.

To dig deeper into this issue, it is caused by reserving stolen memory for iGPU at inappropriate address. As PVE tend to add OpRom used in the vm configuration to the tail of its own OVMF_CODE image, the IgdAssignmentDxe.efi from our OpRom, which reserves stolen memory region for iGPU, is executed after all xxxDxe.efis from OVMF_CODE, which is different from what happens when booting a real(physical) machine with iGPU.

In this case, as some xxxDxe.efis from OVMF_CODE may also allocate memory region for other virtual devices, the stolen memory reserved for iGPU may be allocated behind the address its expected to be, causing iGPU use inappropriate memory region(the memory region allocated for other devices) and a blurry or black screen.

This issue is most seen on 6th-10th gen Intel Core platform, as well as Atom/Embedded platform from same age(AppolloLake and GeminiLake). Currently there is no permanent solution to this issue. The only thing we can do is to switch to the previous method (to use a customized edk2 firmware and GOP-only OpROM) and wish for a good luck.

Note

  • If you have global internet access(in another word, you are not in China Mainland), comment out line 6-7 in Dockerfile.ovmf for faster download speed.

Reference

build-edk2-gvtd's People

Contributors

cmd2001 avatar

Stargazers

 avatar  avatar Joshua Murray avatar badwolf avatar Donny Yu avatar  avatar Chenglong Du avatar  avatar  avatar lintel avatar  avatar  avatar  avatar Simon Elsbrock avatar  avatar  avatar Till0196 avatar  avatar HDragon avatar MyGen avatar  avatar  avatar  avatar Taburiss avatar  avatar Eric.Zhao avatar Old Li who loves research avatar  avatar Chenmo avatar  avatar Humbert avatar  avatar  avatar  avatar wrong avatar  avatar huazhaozhe avatar  avatar  avatar Seiry Yu avatar Dzung Nguyen avatar  avatar SandoGeek avatar  avatar  avatar  avatar  avatar LioN avatar Gavin Ni avatar linkzz avatar  avatar qiuwei0209 avatar BlackBlock avatar  avatar Media Explorer avatar Beacon Zhang avatar Menghan Zheng avatar Jim Ma avatar HU Xuesong avatar  avatar  avatar Fxzou avatar  avatar  avatar  avatar  avatar  avatar anysoft avatar monlor avatar 王雪松 avatar Jian Luo avatar  avatar SHUAI.W avatar Jason avatar lisaac avatar  avatar s1oz avatar

Watchers

Jason avatar  avatar

build-edk2-gvtd's Issues

8代的cpu可以用吗

cpu是Intel J5005 核显是UHD630,之前9月份按照博客上固件编译办法安装ubunt20可以成功实现直通,但是安装win10没装显卡驱动显示器正常直通,安装驱动后再开机就黑屏了换了多个版本驱动也是这样。黑屏状态下用rdp远程进去,打开任务管理器可以看到显卡工作正常。

不知道为啥,我的用不了

设备:cpu n100,零刻 EQ12

新 release 的 n100 aio 都用不了。

于是克服了网络问题,自己构建。
构建也成功构建了,OVMF 也生成了,oprom goprom 都有,但是就是不成功……
Bios 是官方的,IntelGopDriver.efi 是 UBU/UEFITools 提取的 (md5一致)
构建以后文件如下:
product.tar.gz

$ md5sum product/*
46a535624e3f1e944aa6165f1acb0e6d  product/B660_GOP.rom
6599bb0e8a62639f262715cdc9ee9706  product/B660.rom
72b2807f36aaff66fae9cfa2544cb0c9  product/OVMF_CODE_4M.fd
32bb8aa9bbd48bd886bc8443a8040cd0  product/OVMF_CODE_4M.secboot.fd

但是 https://github.com/gangqizai/igd 老兄的 oprom 就能用,奇怪了,帮忙分析下

Alder Lake U, Libvirt support?

Want to know if you may be able to make a next release will support Alder Lake U in later release? I bought a Pentium Gold 8505 based machine (倍控 G31F) and is struggling with this issue, and I don't see anywhere I can download UEFI for that machine.

Morevoer, I am not PVE user and I use Ubuntu server + libvirt instead. Do you have any idea if it is not working just because of missing Alder Lake U ROM? I am asking because I see most other articles (mainly Chinese) mentioned the need of applying "legacy-igd=1" with qemu under PVE, but I can't do that as I am not using PVE: it will complain "no [legacy-igd] property in vfio-pci" if I do something similar by using qemu:override inside libvirt domain xml, which technically just let me modify the VM launching qemu command.

机型用q35还是i440fx呢?

机型用q35还是i440fx呢?q35的性能不是强么。同时win10的虚拟机的“显示”选项是不是要修改为“无”?安装win10虚拟机的时候是“默认”

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.