Browse Source

small typo fix

main
sseneca 10 months ago
parent
commit
15934e78b1
  1. 186
      content/posts/pci-passthrough.md
  2. 2
      website.org

186
content/posts/pci-passthrough.md

@ -46,7 +46,7 @@ _Please note that while this post was originally uploaded in November of 2018, i
## Prerequisites {#prerequisites}
Two main things you'll need:
Three main things you'll need:
1. A Windows 10 ISO
2. 2 GPUs (an [iGPU](https://en.wikipedia.org/wiki/Graphics%5Fprocessing%5Funit#Integrated%5Fgraphics%5Fprocessing%5Funit) is commonly used along with a standard dedicated GPU)
@ -103,13 +103,13 @@ You also have to set the correct kernel parameters. For GRUB, the steps are as f
Generate the GRUB configuration file:
```sh
# grub-mkconfig -o /boot/grub/grub.cfg
# grub-mkconfig -o /boot/grub/grub.cfg
```
To check that this has worked, run
```sh
$ dmesg | grep -i -e DMAR -e IOMMU
$ dmesg | grep -i -e DMAR -e IOMMU
```
You're looking for something about IOMMU being enabled. For example, the top of the output when I run it looks like this:
@ -125,23 +125,23 @@ You're looking for something about IOMMU being enabled. For example, the top of
Now, run the following script:
```sh
#!/bin/bash
shopt -s nullglob
for g in /sys/kernel/iommu_groups/*; do
printf "IOMMU Group ${g##*/}:\n"
for d in $g/devices/*; do
echo -e "\t$(lspci -nns ${d##*/})"
done
done
#!/bin/bash
shopt -s nullglob
for g in /sys/kernel/iommu_groups/*; do
printf "IOMMU Group ${g##*/}:\n"
for d in $g/devices/*; do
echo -e "\t$(lspci -nns ${d##*/})"
done
done
```
```text
IOMMU Group 0:
00:00.0 Host bridge [0600]: Intel Corporation 8th Gen Core Processor Host Bridge/DRAM Registers [8086:3ec2] (rev 07)
IOMMU Group 1:
00:01.0 PCI bridge [0604]: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor PCIe Controller (x16) [8086:1901] (rev 07)
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GM200 [GeForce GTX 980 Ti] [10de:17c8] (rev a1)
01:00.1 Audio device [0403]: NVIDIA Corporation GM200 High Definition Audio [10de:0fb0] (rev a1)
IOMMU Group 0:
00:00.0 Host bridge [0600]: Intel Corporation 8th Gen Core Processor Host Bridge/DRAM Registers [8086:3ec2] (rev 07)
IOMMU Group 1:
00:01.0 PCI bridge [0604]: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor PCIe Controller (x16) [8086:1901] (rev 07)
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GM200 [GeForce GTX 980 Ti] [10de:17c8] (rev a1)
01:00.1 Audio device [0403]: NVIDIA Corporation GM200 High Definition Audio [10de:0fb0] (rev a1)
```
Let's turn to the Arch Wiki for a definition of "IOMMU group":
@ -164,25 +164,25 @@ We're going to use a stub driver called `vfio-pci`, which has been included in L
To do this, edit `/etc/modprobe.d/vfio.conf` as root and add the following, replacing with your relevant IDs from above:
```text
options vfio-pci ids=10de:17c8,10de:0fb0
options vfio-pci ids=10de:17c8,10de:0fb0
```
To be sure that changes in `/etc/modprobe.d/` are registered and applied, open `/etc/mkinitcpio.conf` as root check that `modconf` is listed in `HOOKS`:
```text
HOOKS=(... modconf ...)
HOOKS=(... modconf ...)
```
Next, to ensure that `vfio-pco` loads before other graphics drivers, edit `/etc/mkinitcpio.conf` as root and append the following, _making sure to retain the order_:
```text
MODULES=(... vfio_pci vfio vfio_iommu_type1 vfio_virqfd ...)
MODULES=(... vfio_pci vfio vfio_iommu_type1 vfio_virqfd ...)
```
Finally, regenerate the initramfs:
```sh
# mkinitpcio -p linux
# mkinitpcio -p linux
```
Now it's time to reboot to apply these changes. When you reboot, you won't be able to use the GPU in the guest OS anymore so it's important you've set up your other GPU to be used in the guest OS instead (in the case of the iGPU I didn't have to do anything).
@ -190,11 +190,11 @@ Now it's time to reboot to apply these changes. When you reboot, you won't be ab
Let's check `vfio-pci` has loaded correctly, and that it has bound to the correct devices.
```text
[ 1.265026] VFIO - User Level meta-driver version: 0.3
[ 1.267851] vfio-pci 0000:01:00.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=io+mem:owns=none
[ 1.284271] vfio_pci: add [10de:17c8[ffff:ffff]] class 0x000000/00000000
[ 1.300969] vfio_pci: add [10de:0fb0[ffff:ffff]] class 0x000000/00000000
[ 8.045659] vfio-pci 0000:01:00.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=io+mem:owns=none
[ 1.265026] VFIO - User Level meta-driver version: 0.3
[ 1.267851] vfio-pci 0000:01:00.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=io+mem:owns=none
[ 1.284271] vfio_pci: add [10de:17c8[ffff:ffff]] class 0x000000/00000000
[ 1.300969] vfio_pci: add [10de:0fb0[ffff:ffff]] class 0x000000/00000000
[ 8.045659] vfio-pci 0000:01:00.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=io+mem:owns=none
```
@ -206,13 +206,13 @@ Let's check `vfio-pci` has loaded correctly, and that it has bound to the correc
Install `qemu` , `libvirt`, `ovmf`, and `virt-manager`:
```sh
# pacman -S --needed qemu libvirt ovmf virt-manager
# pacman -S --needed qemu libvirt ovmf virt-manager
```
Start and enable `libvirtd.service`:
```text
# systemctl enable --now libvirtd
# systemctl enable --now libvirtd
```
@ -221,19 +221,19 @@ Start and enable `libvirtd.service`:
If you're using `virt-manager`, add your user to the `libvirt` user group to ensure authentication (replacing `sseneca` with your username):
```text
# usermod -a -G libvirt sseneca
# usermod -a -G libvirt sseneca
```
To stop any network-related issues in the following step, I had to install two extra packages:
```text
# pacman -S ebtables dnsmasq
# pacman -S ebtables dnsmasq
```
And finally, restart `libvirtd`.
```text
# systemctl restart libvirtd
# systemctl restart libvirtd
```
Now start up `virt-manager`:
@ -304,7 +304,7 @@ user = "sseneca"
<!--listend-->
```xml
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
```
- At the bottom of the file, in between the two closing `</devices>` and
@ -313,24 +313,24 @@ user = "sseneca"
<!--listend-->
```xml
</devices>
<qemu:commandline>
<qemu:env name='QEMU_AUDIO_DRV' value='pa'/>
<qemu:env name='QEMU_PA_SERVER' value='/run/user/1000/pulse/native'/>
</qemu:commandline>
</domain>
</devices>
<qemu:commandline>
<qemu:env name='QEMU_AUDIO_DRV' value='pa'/>
<qemu:env name='QEMU_PA_SERVER' value='/run/user/1000/pulse/native'/>
</qemu:commandline>
</domain>
```
Restart `libvirtd.service`:
```text
# systemctl restart libvirtd
# systemctl restart libvirtd
```
And do the same for `pulseaudio.service`:
```text
$ systemctl --user restart pulseaudio.service
$ systemctl --user restart pulseaudio.service
```
@ -349,17 +349,17 @@ NVIDIA drivers on Windows, you won't be able to use the graphics card
(you'll get an Error 43). Fortunately, the solution to this is incredibly simple. Add this to your libvirt domain configuration:
```xml
<features>
<hyperv>
<features>
<hyperv>
...
<vendor_id state='on' value='1234567890ab'/>
...
</hyperv>
...
<vendor_id state='on' value='1234567890ab'/>
...
</hyperv>
...
<kvm>
<hidden state='on'/>
</kvm>
</features>
<kvm>
<hidden state='on'/>
</kvm>
</features>
```
@ -368,23 +368,23 @@ NVIDIA drivers on Windows, you won't be able to use the graphics card
When I decide I want to use Windows, I open `virt-manager` and start up the VM. Once it has loaded int he background, I simply run an `attach` script which passes in my keyboard and mouse, and switch my monitors to the connections used by the VM.
```sh
#!/bin/bash
if [[ $(virsh list | grep win10) != "" ]]
then
vm=win10
fi
sudo virsh attach-device $vm $(dirname $0)/mouse.xml
sudo virsh attach-device $vm $(dirname $0)/keyboard.xml
#!/bin/bash
if [[ $(virsh list | grep win10) != "" ]]
then
vm=win10
fi
sudo virsh attach-device $vm $(dirname $0)/mouse.xml
sudo virsh attach-device $vm $(dirname $0)/keyboard.xml
```
```xml
<hostdev mode='subsystem' type='usb' managed='no'>
<source>
<vendor id='0x2516'/>
<product id='0x003b'/>
</source>
</hostdev>
<hostdev mode='subsystem' type='usb' managed='no'>
<source>
<vendor id='0x2516'/>
<product id='0x003b'/>
</source>
</hostdev>
```
<div class="src-block-caption">
@ -411,16 +411,16 @@ Within Windows, if I want to access Linux, I can ssh into it through Powershell.
You'll want to change `win10` to whatever your VM is named. Also, note the vendor and product IDs above. To find these, install `usbutils` (on Arch) for the `lsusb` command. This is what `lsusb` displays for me:
```text
Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 0b05:1872 ASUSTek Computer, Inc. AURA LED Controller
Bus 001 Device 004: ID 0b05:185c ASUSTek Computer, Inc. Bluetooth Radio
Bus 001 Device 003: ID 1af3:0001 Kingsis Peripherals ZOWIE Gaming mouse
Bus 001 Device 002: ID 2516:003b Cooler Master Co., Ltd. MasterKeys Pro L
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 0b05:1872 ASUSTek Computer, Inc. AURA LED Controller
Bus 001 Device 004: ID 0b05:185c ASUSTek Computer, Inc. Bluetooth Radio
Bus 001 Device 003: ID 1af3:0001 Kingsis Peripherals ZOWIE Gaming mouse
Bus 001 Device 002: ID 2516:003b Cooler Master Co., Ltd. MasterKeys Pro L
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
```
Note how you have to prefix the numbers with an `0x`.
@ -433,7 +433,7 @@ audio latency (it is lower) versus the default Line-Based Interrupts. To
check MSI is supported, run this command:
```text
# lspci -vs 01:00.0 | grep 'MSI:'
# lspci -vs 01:00.0 | grep 'MSI:'
```
Substitute 01:00.0 with the appropriate value for your graphics card.
@ -441,7 +441,7 @@ Substitute 01:00.0 with the appropriate value for your graphics card.
Your output should look something like this:
```text
Capabilities: [68] MSI: Enable- Count=1/1 Maskable- 64bit+
Capabilities: [68] MSI: Enable- Count=1/1 Maskable- 64bit+
```
A `-` after Enable means MSI is supported, but not used by the VM, while
@ -463,23 +463,23 @@ the following additions to the VM's xml gave me dramatically increased
performance:
```xml
<vcpu placement='static'>8</vcpu>
<cputune>
<vcpupin vcpu='0' cpuset='2'/>
<vcpupin vcpu='1' cpuset='8'/>
<vcpupin vcpu='2' cpuset='3'/>
<vcpupin vcpu='3' cpuset='9'/>
<vcpupin vcpu='4' cpuset='4'/>
<vcpupin vcpu='5' cpuset='10'/>
<vcpupin vcpu='6' cpuset='5'/>
<vcpupin vcpu='7' cpuset='11'/>
<emulatorpin cpuset='0-1,6-7'/>
</cputune>
...
</features>
<cpu mode='host-passthrough' check='none'>
<topology sockets='1' cores='4' threads='2'/>
</cpu>
<vcpu placement='static'>8</vcpu>
<cputune>
<vcpupin vcpu='0' cpuset='2'/>
<vcpupin vcpu='1' cpuset='8'/>
<vcpupin vcpu='2' cpuset='3'/>
<vcpupin vcpu='3' cpuset='9'/>
<vcpupin vcpu='4' cpuset='4'/>
<vcpupin vcpu='5' cpuset='10'/>
<vcpupin vcpu='6' cpuset='5'/>
<vcpupin vcpu='7' cpuset='11'/>
<emulatorpin cpuset='0-1,6-7'/>
</cputune>
...
</features>
<cpu mode='host-passthrough' check='none'>
<topology sockets='1' cores='4' threads='2'/>
</cpu>
```
There is an explanation of what this does on the [Arch Wiki](https://wiki.archlinux.org/index.php/PCI%5Fpassthrough%5Fvia%5FOVMF#CPU%5Fpinning).

2
website.org

@ -409,7 +409,7 @@ Seeing people deciding to ditch Windows rather than move to Windows 10 reminded
*** Prerequisites
Two main things you'll need:
Three main things you'll need:
1. A Windows 10 ISO
2. 2 GPUs (an [[https://en.wikipedia.org/wiki/Graphics_processing_unit#Integrated_graphics_processing_unit][iGPU]] is commonly used along with a standard dedicated GPU)
3. Hardware that's not ancient

Loading…
Cancel
Save