How much would you like to use Windows on Linux with bare-metal performance?


Imagine you could run anything you want on a windows virtual machine with minimal loss of performance. Written by André Clemente, MD3 Team Software Engineer

Words by
in 04.02.2021

Just imagine that you could run anything you want on a windows virtual machine with minimal loss of performance.

You could do anything from testing some software, edit videos or even play highly demanding games.

But how?!

Kernel-based Virtual Machine (KVM) is an open-source virtualization technology built into Linux. Specifically, KVM lets you turn Linux into a hypervisor that allows a host machine to run multiple, isolated virtual environments called guests or virtual machines.

Virtual Machines are pretty standard nowadays. People use them 100% out of the box with no problems. But when you think of the possibility of having a virtual machine with same or really close performance as bare-metal it seems unreal. But that can be accomplished by a KVM, which is also a really easy setup. The challenge begins when you want to do PCI passthrough.

Ok, but how does it work?

KVM converts Linux into a type-1 (bare-metal) hypervisor. All hypervisors need some operating system-level components, such as a memory manager, process scheduler, input/output (I/O) stack, device drivers, security manager, a network stack and more, to run VMs. 

KVM has all these components because it’s part of the Linux kernel. Every VM is implemented as a regular Linux process, scheduled by the standard Linux scheduler, with dedicated virtual hardware like a network card, graphics adapter, CPU(s), memory, and disks.

How hard it is to accomplish this?

Well, I guess it depends on what your goal is. When I first heard about KVM, I was really curious about how much performance could I get on a Windows VM, because I would really like to remove the dual boot (Linux & Windows) from my computer and just have Linux. But I still want to use Windows sometimes, mostly for playing games… so here it starts my little big project. Now I really want to try this. 

I started by watching a tutorial explaining how to do it and I tried to replicate it. The problem is that I own a laptop, not a desktop. Which becomes my first big obstacle. Why? Well, basically your laptop can either be MUXless, which means that, instead of directly connecting to the monitor, the dGPU transfers the rendered image to iGPU, which in turn sends them to the monitor or  MUXed where there is a switch on the motherboard circuit and the HDMI port and the monitor can be allocated to different GPUs on-demand.

Figure 1: MUXless
Figure 2: MUXed

Unfortunately, my laptop is MUXless. I’ve searched all over the internet and finally some sign of hope: HDMI dummy plug. So let’s try it! Nope, it doesn’t work, you dummy… Your HDMI connector is not connected directly to the GPU. Here is where my expectations were really low, but I couldn’t forget about this… So I’ve found Intel’s GVT-g and this really took my experience inside the Windows Guest to another level, I had finally 3d acceleration! But not enough... So none of those alternatives would provide.

I just couldn’t let it go, there had to be a way. And then, I’ve learned about eGPU (External GPU). 

So, would my laptop be compatible with an eGPU? This would be a really long hard shot. Maybe it wasn’t even worth trying… But there was a cheap component that I could buy to test it… Here we go!!! 

I built an eGPU with an EXP GDC Beast, put a NVIDIA 1660 Super on it and voilà! It works!!!

Great to finally have my Windows Guest working as I would like, or do I? Well, there’s a game with a monster anti-cheat that doesn’t let me play on a VM… Oh, no! So what could I do? 

There are actually some ways to hide a VM from being detected by the guest. So, one more challenge to overcome. I found out that enabling nested virtualization would make my guest “think” that it isn’t a VM itself and bang!

Of course, there’s always some tweak I can do to make it a little better, but overall it’s done. As you can realize, it wasn’t an easy process. But now that it is accomplished, I actually feel good about it and I’ve learned a lot. 

If you would like to try it, here are some useful links: