Linux Gaming and VFIO

Posted 2022-01-13

I have been using and gaming on Linux for many years now, back when the AMD/ATI Catalyst drivers were a thing (a horrible horrible thing). I've tried many methods of gaming, from using pure Wine, to using Wine and dual booting windows, full on proton and even giving the hell up completely.

They all have their ups and downs really:

Dual booting is pretty solid because it's just native Windows but, lets be honest, it is extremely annoying to reboot your computer just to play a game. Plus it makes it much harder to pop in and play games when you have downtime at work - not that I would ever do that.

Pure Wine works mostly, there's always a setting or tweak that needs to be done and then a patch comes out and it breaks everything. Sometimes something in Wine itself changes in a minor patch version and you need some kind of voodoo magic of libraries to get everything going again.

Proton honestly works pretty damn good. If you add in the FOSS builds that GloriousEggroll does as well it's pretty hard to fault. It worked with everything in general I threw at it without much issue. Honestly if you just install games and play them, I think you would be hard pressed to beat just using Proton.

But once you venture out of running games in Proton from Steam things start to get a bit messy.

One thing I really enjoy doing though is modding games. Being able to mod games lets you add new life into games you've played before and adds even more value to them. Games you've probably played before like Skyrim, Fallout and even Cyberpunk get an absurd amount of AMAZING free content from using mods.

Modding itself tends to be a pretty finicky experience, it involves injecting replacement files and other assets into game directories. When you start pulling in lots of mods, you'll tend to get situations where one mod has files that will override another mod's files. This can be a massive pain to deal with if you are just extracting files into game directories.

That's why there are tools like ModOrganizer2, Vortex and WyreBash that let you organize your mods, set priorities on files and have it handle the file output.

And while they can sort of work in Wine, they all work EXTREMELY well in Windows.

Which is ultimately why I use VFIO to game.

So, What Exactly is VFIO?

VFIO or Virtual Function I/O allows you to isolate a single IMMOU group on your mothboard, which typically (not always though) is a single PCIe device. This gives the VM the ability to operate as if it was running on the host with direct control of that device.

This is huge in the context of things like graphics cards where the OS needs direct access to the card to preform display operations. Isolating the GPU to the VM lets you run the guest OS as if it was the host OS with the device. This gives you the full performance of the device.

This setup gives you the best of dual booting - a native Windows gaming experience - with none of the downsides of having to reboot.

Further, tools like Looking Glass - which is an absolutely amazing project - allow you to share a single keyboard, mouse, monitor and even clipboard. It provides a nearly native experience in performance while being able to work like it's essentially a RDP instance.

What the Downsides?

Like any compromise setup, there are some downsides to a VFIO setup.

  1. Hardware investment is fairly high, you need enough ram and two GPUs to do it, as well as a monitor that can handle two inputs. And while technically you can do it with one GPU, I find it extremely awkward and you might as well dual boot.
  2. Your motherboard has to have good IOMMU groups for isolating PCIe devices and motherboard manufacturers don't really post this information. There is a very good resource by people here and there are some workarounds if it doesn't you can try the acs patch, though I have never tested it.
  3. The documentation around setting it up is still not copy/paste friendly and does take some understanding of Linux subsystems and tools like libvirtd. That doesn't mean it's hard to to - just not as easy as it could be at this point.
  4. Probably the absolute most minor, yet biggest annoyance for me. If you don't have a motherboard that supports specifying which GPU to use as a boot GPU and can't put your VFIO GPU below your host GPU in the PCIe slots, then you have to remember to unplug the display cable/dummy plug when rebooting. Otherwise it'll get stuck on the first GPU that's plugged in.
  5. At the end of the day you are still running Windows and honestly Windows is a bit yucky.

Final Thoughts

In my opinion VFIO is an amazing piece of tech and an absolute game changer for being able to game on Linux. It completely avoids any type of (ahem, yes I know it's not technically) "emulation" that Proton or Wine provide giving you a truly native Windows Experience.

I'm not one to re-write tutorials so the best place to check in all honestly is the VFIO subreddit here. There are tutorials in the Wiki and a load of information on what to do. If you have any questions I would be happy to try to answer if them if you hit me up on any of the contact methods on the main page.