If you own, or want to own, an AMD processor and use virtualization with GPU Pass-through you might already know about the NPT bug. Nested Page Tables is a feature that is enabled by default with virtualization in KVM. The aim is for better performance over an emulated page table.

Read also: Binding a GPU to vfio-pci in Debian

With current KVM virtualization with AMD processors, this does not increase performance. While enabled you will see better processor performance but decreased GPU performance. The “workaround” for this was just to disable NPT. With this method users will experience less CPU performance and better GPU performance.

The Resolution Begins

On 26 October 2017, Paolo Bonzini released a patch to fix this bug. All a user would have to do is download the Linux Kernel source, apply the patch, configure and then compile the kernel. After these steps, all NPT related issues with KVM would disappear. This method can be daunting for some users, and it can be a pain to do this every time there is a kernel update.

Luckily for AMD users, Linus Torvalds has merged the NPT patch into the master branch of the Linux Kernel. As as a result, He has released Linux Kernel 4.15-rc1 with the patch included. In the GitHub tag for 4.15-rc1, you can see the patch has been applied. 4.14.3 and later kernels have this patch back ported as well. Paolo Bonzini, who created the patch, is the same person who submitted the commit on GitHub.

What does this mean for you?

As a result, users will be able to use the vanilla Linux Kernel without worrying about patching it for use with AMD processors and GPU Passthrough. At the time of writing, you’re still going to have to compile this for yourself. In the near future, your favorite GNU/Linux distribution will have this in their repositories for you to install and use with ease.

Join the The Passthrough POST Discord to discuss the NPT Patch and other topics!

Images courtesy AMD