Skip to content

Instantly share code, notes, and snippets.

@ugudango
Created October 9, 2022 21:55
Show Gist options
  • Save ugudango/36fc0f2993ac342e88e286d85cc45a13 to your computer and use it in GitHub Desktop.
Save ugudango/36fc0f2993ac342e88e286d85cc45a13 to your computer and use it in GitHub Desktop.
How I set up my ASUS ROG STRIX G15 (2021) for dGPU passthrough

Step 0:

Make sure you've got everything needed for C++ compilation and more. This is part of base-devel, and you should be able to figure out how to install it on Arch / Manjaro.

Step 1:

Install the proprietary nVidia drivers. Follow the Manjaro Wiki Guide. For most operations, you'll use mhwd, which is Manjaro's driver management utilty. In my case, I did a PRIME offload setup, with hybrid drivers.

Step 2:

After reading the disclaimer, follow the youtube guide.

Disclaimer: Here he does a setup for a VM with BIOS firmware. For this we'll need UEFI. Even if you mess this up, you can reuse the qcow2 disk for a new VM, but you'll have to type exit in the UEFI shell to boot into windows.

Here is the YouTube guide.

Step 3:

You first need to install asusctl. This is pretty straight-forward.

Then you'll need to set up supergfxctl. While the program itself works well, some parts of it may not fit, because you've got some userspace device rules (udev rules) that unbind/turn off your dedicated GPU if you run in integrated GPU mode only. In my case, I hade some rules that looked like this (in /lib/udev/rules.d/90-asusd-nvidia-pm.rules):

# Enable runtime PM for NVIDIA VGA/3D controller devices on driver bind
ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", TEST=="power/control", ATTR{power/control}="on"
ACTION=="bind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030200", TEST=="power/control", ATTR{power/control}="on"

# Disable runtime PM for NVIDIA VGA/3D controller devices on driver unbind
ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", TEST=="power/control", ATTR{power/control}="on"
ACTION=="unbind", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030200", TEST=="power/control", ATTR{power/control}="on"

While this is generally fantastic, when you want to do pass-through, the power management for the dedicated GPU is going to be disabled if you switch to integrated mode, which is an intermediary step required to switch to vfio mode.

For this, I commented out the last two lines of this rules. The solution lied somewhere else, probably, but I'm not that familiar with udev rules.

To check if everything is in order before you get to the VM, run lspci -k | grep vfio and lspci -k | grep NVIDIA. If either of these returns nothing, then it means you have to reboot, or log out, until you see your nvidia video card in lspci -k with kernel driver in use: vfio-pci.

Step 4:

Follow this guide.

Step 5:

We'll install Looking Glass, to have the theoretically fastest display method, and to support high refresh rates.

Follow the Looking Glass documentation.

To be able to run it, you'll need to have auto-login for windows.

To have it display something, you'll need a virtual device set up in the Windows VM.

Remember! The VM will run with display: none (as any other method will reduce your VM to Windows Basic Display Adapter, which doesn't work with Looking Glass), so normally when you power your VM the Windows machine will have no physical monitor. You can use a physical dummy, but it's easier to set up a virtual monitor.

Follow this guide, from asus-linux.org.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment