Integrated GPU on VM - powwu/pso2-na-linux GitHub Wiki
This guide is intended for Intel iGPUs. If you have an AMD iGPU, try the steps in Dedicated GPU on VM first and come back here if it didn't work for you.
To start, first ensure that VT-d/AMD-Vi are enabled in your BIOS.
Then, set a kernel parameter (by editing the GRUB_CMDLINE_LINUX_DEFAULT entry in /etc/default/grub
):
- For Intel CPUs (VT-d) set
intel_iommu=on
- For AMD CPUs (AMD-Vi) set `amd_iommu=on``
After a reboot, you can verify that it worked by running dmesg | grep -i -e DMAR -e IOMMU
:
[ 0.000000] ACPI: DMAR 0x00000000BDCB1CB0 0000B8 (v01 INTEL BDW 00000001 INTL 00000001)
[ 0.000000] Intel-IOMMU: enabled
[ 0.028879] dmar: IOMMU 0: reg_base_addr fed90000 ver 1:0 cap c0000020660462 ecap f0101a
[ 0.028883] dmar: IOMMU 1: reg_base_addr fed91000 ver 1:0 cap d2008c20660462 ecap f010da
[ 0.028950] IOAPIC id 8 under DRHD base 0xfed91000 IOMMU 1
[ 0.536212] DMAR: No ATSR found
[ 0.536229] IOMMU 0 0xfed90000: using Queued invalidation
[ 0.536230] IOMMU 1 0xfed91000: using Queued invalidation
[ 0.536231] IOMMU: Setting RMRR:
[ 0.536241] IOMMU: Setting identity map for device 0000:00:02.0 [0xbf000000 - 0xcf1fffff]
[ 0.537490] IOMMU: Setting identity map for device 0000:00:14.0 [0xbdea8000 - 0xbdeb6fff]
[ 0.537512] IOMMU: Setting identity map for device 0000:00:1a.0 [0xbdea8000 - 0xbdeb6fff]
[ 0.537530] IOMMU: Setting identity map for device 0000:00:1d.0 [0xbdea8000 - 0xbdeb6fff]
[ 0.537543] IOMMU: Prepare 0-16MiB unity mapping for LPC
[ 0.537549] IOMMU: Setting identity map for device 0000:00:1f.0 [0x0 - 0xffffff]
[ 2.182790] [drm] DMAR active, disabling use of stolen memory
Run the following script to determine your IOMMU groups:
#!/bin/bash
shopt -s nullglob
for g in /sys/kernel/iommu_groups/*; do
echo "IOMMU Group ${g##*/}:"
for d in $g/devices/*; do
echo -e "\t$(lspci -nns ${d##*/})"
done;
done;
Look for the group with your GPU in it. If the group has more than just the GPU, you'll have to pass through all of the devices in the group in the step below. Otherwise, just pass through the GPU. Take note of the PCI IDs (example 10de:13c2
) as you'll need them later.
Edit your kernel parameters once more, and add the following:
vfio-pci.ids=[IDS]
For example:
vfio-pci.ids=10de:13c2
vfio-pci.ids=10de:13c2,10de:0fbb
Then, edit /etc/mkinitcpio.conf
. Add the following to the MODULES entry:
vfio_pci vfio vfio_iommu_type1 vfio_virqfd
Additionally, ensure that modconf
is present in the HOOKS entry. Then, regenerate the initramfs. If you are on a Debian-based distro (i.e Ubuntu), you may want to see this instead.
You can ensure it works by running:
dmesg | grep -i vfio
Example output:
[ 0.329224] VFIO - User Level meta-driver version: 0.3
[ 0.341372] vfio_pci: add [10de:13c2[ffff:ffff]] class 0x000000/00000000
[ 0.354704] vfio_pci: add [10de:0fbb[ffff:ffff]] class 0x000000/00000000
[ 2.061326] vfio-pci 0000:06:00.0: enabling device (0100 -> 0103)
Then, edit your virtual machine. Add your PCI host devices (your GPU, and anything else you passed through to VFIO).
Now that your integrated graphics are attached to the machine, but cannot be viewed, new windows may pop up there. You can either remove the iGPU from the VM until you finish setting up Looking Glass (recommended), or you can move windows to the SPICE display manually using Windows Key + Shift + Right Arrow/Left Arrow. Note that you must log in blind if you use the latter method.
Install the following: Arch:
sudo pacman -S binutils sdl2 sdl2_ttf libx11 nettle fontconfig cmake spice-protocol gnu-free-fonts
Ubuntu:
apt-get install binutils-dev cmake fonts-freefont-ttf libsdl2-dev libsdl2-ttf-dev libspice-protocol-dev libfontconfig1-dev libx11-dev nettle-dev
Make sure that you have a QXL video adapter and a SPICE server on your VM. These will be needed for setting up Looking Glass, as well as for providing sound down the line.
Make sure XML editing is enabled in the preferences of your virt-manager.
To start, first take your monitor's resolution and run it through this equation:
width x height x 4 x 2 = total bytes total bytes / 1024 / 1024 = total megabytes + 2
Round the result up to the nearest power of 2. So, for example, for 1920x1080:
1920 x 1080 x 4 x 2 = 16,588,800 bytes 16,588,800 / 1024 / 1024 = 15.82 MB + 2 = 17.82 (rounded up to 32)
Add the following to your <devices>
XML section of your VM:
<shmem name='looking-glass'>
<model type='ivshmem-plain'/>
<size unit='M'>equation result</size>
</shmem>
Where "equation result" is your equation result (for example 32).
Then, reboot.
On your VM, install this driver and unzip it. Press Windows Key + R, and run devmgmt.msc
. Under system devices, there should be a "PCI standard RAM Controller". If you do not see one, reboot your virtual machine. Right click the PCI standard RAM Controller and update drivers. When it asks you for where the drivers are, opt to locate them manually. Said drivers are located in:
[DRIVER FOLDER DOWNLOADED EARLIER]\Win10\amd64
Be sure to accept the driver installation from RedHat when it prompts.
Now that the drivers are installed, you must install the Looking Glass host on your VM, and the client on your Linux machine. Instructions on how to do so are located in the official Looking Glass installation guide. If you are having issues downloading said packages, please feel free to create an issue and I will help you right away.
Press Windows Key + R and run netplwiz
. From there, disable the required password checkbox. Press apply and enter your account details (your PASSWORD, not your pin).
Now, shut down your VM. Pass through a USB keyboard and mouse to your machine. On your Linux host, run the following:
looking-glass-client -s
You should be able to start your VM now. If you want to be able to use your mouse and keyboard on your host and in the VM, remove the -s
flag and detach both from your VM. Do be warned, however, that this will disable sound support. You could also try alternative methods for keyboards and mice, such as via evdev.
If all is working well, then continue to the Post-complete install page for instructions on installing PSO2. This will also show you how to bypass the secure desktop used by UAC.