merge-requests/4/head
Yuri Alek 6 years ago
parent d7c8cf7fa9
commit d4a3f70cb3

@ -0,0 +1,108 @@
# A recompilation of hardware and software combinations working for other people
**Before creating a merge pull, be sure to read this guide**
The files should be named like [{CPU} - {GPU} - {User}.md]; example
```
Ryzen 5 2600 - GTX 770 - @YuriAlek.md
```
## Inside must be something like this:
### System
```
[Author]
@YuriAlek
[Hardware]
CPU: AMD Ryzen 5 2600
Motherboard: Gigabyte AB350M-Gaming 3 rev1.1
Motherboard BIOS: F23d
RAM: 16GB
GPU: Gigabyte Nvidia GeForce GTX 770
GPU model: GV-N770OC-2GD
GPU BIOS: 80.04.C3.00.0F
GPU codename: GK104
[Software]
Linux Distro: ArchLinux
Linux Kernel: 4.17.14 vanilla
Nvidia divers: 396.51-1
QEMU version: 2.12.1-1
OVMF version: r24021
[Guests]
Windows 10 Pro 1709 x64
MacOS High Sierra 10.13.3
```
### How I did it
For extracting the `vBIOS` I used the 1st method in Linux and edited it.
You can add anything that you consider useful like the step needed in your distro for installing everything. The more information, and solutions, the better.
### Files to modify
#### `scripts/windows.sh`
My GPU uses one more Kernel Module so I have to add it as the first module to unload and the last to load:
```
# Unload the Kernel Modules that use the GPU
modprobe -r nvidia_drm
sleep 1
...
------------------------
# Reload the kernel modules. This loads the drivers for the GPU
...
modprobe nvidia_drm
sleep 1
```
I use PulseAudio so I had to kill it for detaching the GPU.
```
## Kill X and related
pulseaudio -k
---------------------
# Reload the Display Manager to access X
...
pulseaudio --start
```
I don't pass a USB controller so I had to add manually USB devices.
```
# Remove
...
echo $usbid > /sys/bus/pci/drivers/vfio-pci/new_id
sleep 1
echo $usbbusid > /sys/bus/pci/devices/$usbbusid/driver/unbind
sleep 1
echo $usbbusid > /sys/bus/pci/drivers/vfio-pci/bind
sleep 1
echo $usbid > /sys/bus/pci/drivers/vfio-pci/remove_id
#ls -la /sys/bus/pci/devices/$usbbusid/
sleep 1
...
-device vfio-pci,host=$IOMMU_USB \
...
echo $usbbusid > /sys/bus/pci/devices/$usbbusid/driver/unbind
echo $usbbusid > /sys/bus/pci/drivers/xhci_hcd/bind
sleep 10
...
----------------------
# Add to the QEMU script
...
-object input-linux,id=kbd,evdev=/dev/input/by-id/usb-HOLDCHIP_USB_Gaming_Keyboard-event-kbd,grab_all=on,repeat=on \
-object input-linux,id=kbd2,evdev=/dev/input/by-id/usb-HOLDCHIP_USB_Gaming_Keyboard-if01-event-kbd,grab_all=on,repeat=on \
-object input-linux,id=mouse-event,evdev=/dev/input/by-id/usb-Logitech_G700_Laser_Mouse_6B5EFC4B0035-event-mouse \
-object input-linux,id=kbd3,evdev=/dev/input/by-id/usb-Logitech_G700_Laser_Mouse_6B5EFC4B0035-if01-event-kbd,grab_all=on,repeat=on \
...
```
I use an image instead of a hard drive.
```
# Remove
-device virtio-scsi-pci,id=scsi0 \
-device scsi-hd,bus=scsi0.0,drive=rootfs \
-drive id=rootfs,file=$HDD,media=disk,format=raw,if=none
-----------------
# Add
-device ide-drive,bus=ide.1,drive=rootfs \
-drive id=rootfs,if=none,file=$IMG,format=raw
```

@ -0,0 +1,29 @@
# System
```
[Author]
@YuriAlek
[Hardware]
CPU: AMD Ryzen 5 2600
Motherboard: Gigabyte AB350M-Gaming 3 rev1.1
Motherboard BIOS: F23d
RAM: 16GB
GPU: Gigabyte Nvidia GeForce GTX 770
GPU model: GV-N770OC-2GD
GPU BIOS: 80.04.C3.00.0F
GPU codename: GK104
[Software]
Linux Distro: ArchLinux
Linux Kernel: 4.17.14 vanilla
Nvidia divers: 396.51-1
QEMU version: 2.12.1-1
OVMF version: r24021
[Guests]
Windows 10 Pro 1709 x64
MacOS High Sierra 10.13.3
```
## How I did it
For extracting the `vBIOS` I used the 2nd method in Linux with nvflash and edited it. The 3rd method also worked for me.

@ -0,0 +1,46 @@
# Install guide for QEMU and VFIO
## ArchLinux
### Install the necessary packages
```
# pacman -S qemu ovmf
```
### Enabling IOMMU support on boot
For systemd-boot, edit `/boot/loader/entries/arch.conf` and add `intel_iommu=on` **OR** `amd_iommu=on` and `iommu=pt`.
```
# AMD
options root=/dev/sda2 amd_iommu=on iommu=pt
---------------------------------------------
# Intel
options root=/dev/sda2 intel_iommu=on iommu=pt
```
For GRUB edit `/etc/default/grub` and append your kernel options to the `GRUB_CMDLINE_LINUX_DEFAULT`.
```
# AMD
GRUB_CMDLINE_LINUX_DEFAULT="amd_iommu=on iommu=pt"
---------------------------------------------------
# Intel
GRUB_CMDLINE_LINUX_DEFAULT="intel_iommu=on iommu=pt"
```
And then automatically re-generate the grub.cfg file with:
```
# grub-mkconfig -o /boot/grub/grub.cfg
```
Reboot.
After reboot IOMMU should be working
```
[yu@ryzen ~]$ dmesg | grep -e DMAR -e IOMMU
--------------------------------------------
[ 0.492684] AMD-Vi: IOMMU performance counters supported
[ 0.494370] AMD-Vi: Found IOMMU at 0000:00:00.2 cap 0x40
[ 0.494644] perf/amd_iommu: Detected AMD IOMMU #0 (2 banks, 4 counters/bank).
```
That's everything, unlike two GPU passthrough you don't need to load kernel modules on boot.
## For more information refer to this guides
https://wiki.archlinux.org/index.php/QEMU
https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF
https://www.se7ensins.com/forums/threads/how-to-setup-a-gaming-virtual-machine-with-gpu-passthrough-qemu-kvm-libvirt-and-vfio.1371980/

@ -20,7 +20,7 @@ In one command it kills X, frees the GPU from drivers and console, detaches the
* CPU support for AMD-v/VT-x and AMD-Vi/VT-d (AMD/Intel).
* Virtualization support enabled on BIOS; check your motherboard manual if you need help.
* One GPU that supports UEFI and its BIOS. All GPUs from 2012 and later should support this, some may have issues. If the GPU does not support UEFI you may be able to make it work, but you won't see anything in the screen until the drivers inside Windows kick in.
* QEMU, OVMF UEFI and VIRTIO drivers for Windows.
* QEMU, OVMF UEFI and VIRTIO drivers for Windows. [If you need to install, refer to ]
* [Optional] HDD only for Windows
* [Recommended] Another computer to login remotely with `ssh` for convenience, at least until you have everything working.
@ -46,7 +46,6 @@ In one command it kills X, frees the GPU from drivers and console, detaches the
[Guests]
Windows: Windows 10 Pro 1709 x64
MacOS: MacOS High Sierra 10.13.3
```
## vBIOS
@ -186,6 +185,8 @@ Sometimes the QEMU command does not exit after shutting down the VM.
### Windows version
Windows 10 Pro 1709 works for me, but 1803 does not (may be the UEFI). [I have heard that the 1803 version comes with a Spectre patch and the performance is bad.](https://www.reddit.com/r/VFIO/comments/97unx4/passmark_lousy_2d_graphics_performance_on_windows/). The Spectre patch can be disabled.
## Submit your own configuration
[Create a pull merge](https://gitlab.com/YuriAlek/vfio/merge_requests/new) with [a file explaining how you got it working](Hardware configurations/readme.md)
## TODO
- [x] Unbind GPU without `virsh`.
@ -193,8 +194,8 @@ Windows 10 Pro 1709 works for me, but 1803 does not (may be the UEFI). [I have h
- [x] Run QEMU as user.
- [x] Try if is necessary to edit `/etc/mkinitcpio.conf`. No need to load the kernel modules at boot.
- [x] Extract the vBIOS in Linux.
- [x] Install guide.
- [ ] Network.
- [ ] Install guide.
- [ ] IOMMU guide.
- [ ] Audio.
- [ ] Troubleshooting guide.

@ -71,7 +71,6 @@ sleep 1
echo $usbbusid > /sys/bus/pci/drivers/vfio-pci/bind
sleep 1
echo $usbid > /sys/bus/pci/drivers/vfio-pci/remove_id
#ls -la /sys/bus/pci/devices/$usbbusid/
sleep 1
# QEMU (VM) command
@ -86,7 +85,8 @@ qemu-system-x86_64 -runas $USER -enable-kvm \
-device vfio-pci,host=$IOMMU_USB \
-usb -device usb-kbd -device usb-tablet \
-device nec-usb-xhci,id=xhci \
-netdev user,id=net0 -device e1000-82545em,netdev=net0,id=net0,mac=52:54:00:c9:18:27 \
-netdev user,id=net0 \
-device e1000-82545em,netdev=net0,id=net0,mac=52:54:00:c9:18:27 \
-device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" \
-drive if=pflash,format=raw,readonly,file=$OVMF \
-drive if=pflash,format=raw,file=$OVMF_VARS \
@ -128,7 +128,6 @@ echo $usbbusid > /sys/bus/pci/drivers/xhci_hcd/bind
sleep 10
# Re-Bind EFI-Framebuffer and Re-bind to virtual consoles
# [Source] [https://github.com/joeknock90/Single-GPU-Passthrough/blob/master/README.md#vm-stop-script]
echo 1 > /sys/class/vtconsole/vtcon0/bind
sleep 1
echo 1 > tee /sys/class/vtconsole/vtcon1/bind

@ -71,10 +71,8 @@ sleep 1
echo $usbbusid > /sys/bus/pci/drivers/vfio-pci/bind
sleep 1
echo $usbid > /sys/bus/pci/drivers/vfio-pci/remove_id
#ls -la /sys/bus/pci/devices/$usbbusid/
sleep 1
# QEMU (VM) command
qemu-system-x86_64 -runas $USER -enable-kvm \
-nographic -vga none -parallel none -serial none \
-m $RAM \
@ -126,7 +124,6 @@ echo $usbbusid > /sys/bus/pci/drivers/xhci_hcd/bind
sleep 10
# Re-Bind EFI-Framebuffer and Re-bind to virtual consoles
# [Source] [https://github.com/joeknock90/Single-GPU-Passthrough/blob/master/README.md#vm-stop-script]
echo 1 > /sys/class/vtconsole/vtcon0/bind
sleep 1
echo 1 > tee /sys/class/vtconsole/vtcon1/bind

Loading…
Cancel
Save