HOW-TO patch Nvidia drivers in Windows 10 for VGA passthrough

Questions about virtualization software
Forum rules
Before you post please read how to get help
Level 5
Level 5
Posts: 925
Joined: Thu May 03, 2012 3:54 am
Location: Israel

HOW-TO patch Nvidia drivers in Windows 10 for VGA passthrough

Postby powerhouse » Sun Sep 04, 2016 9:24 am


For the past 4 years I'm running Linux Mint as my main operating system, and Windows in a VM using VGA passthrough for bare-metal graphics performance. This much more elegant solution has entirely replaced the need for dual-booting. I have written two How-Tos, one for Xen VGA passthrough, the other for KVM VGA passthrough (see here for reference).

Nvidia graphics cards - specifically the consumer-type versions - have a mysterious bug that prevents them from running in a virtual machine. Nvidia has no plans to fix this bug, so if someone wants to run his/her graphics card in a virtual environment with VGA passthrough, he/she needs to buy the expensive professional versions (Quadro 2000 and above). For more on that, see

There is a workaround in KVM:

Code: Select all

-cpu host,kvm=off

kvm=off turns off the hypervisor extensions, which may have an impact on features and performance of the VM.

sk1080 over at the Arch Linux forum has written a nice little patch for the Nvidia driver to fix the bug Nvidia can't or doesn't want to fix :x .

Warning: Patching the Nvidia driver will most likely void your license to use the driver software. In other words, you are not allowed to modify the driver!

This means the entire how-to below was written to show how Nvidia could fix their drivers.

Is it necessary to patch the Nvidia driver?

No! Nvidia should fix their "bugs", not we. Performance-wise I haven't seen a difference between the patched Nvidia driver and using the kvm=off option. My complete qemu -cpu option line is now:

Code: Select all

-cpu host,kvm=off,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time,hv_vendor_id=whatever123

Here my benchmarks using above qemu option:
UserBenchmarks: Game 76%, Desk 75%, Work 66%
CPU: Intel Core i7-3930K - 85.5%
GPU: Nvidia GTX 970 - 78.3%
SSD: Red Hat VirtIO 118GB - 83.1%
HDD: Red Hat VirtIO 1.5TB - 72.1%
HDD: Red Hat VirtIO 1.5TB - 166.6%
RAM: QEMU 20GB - 98.3%
MBD: QEMU Standard PC (Q35 + ICH9, 2009)

How to patch the Nvidia driver under Windows 10

1. Backup your Windows VM !!!

2. Using KVM/qemu, boot your Windows 10 VM using the kvm=off option described above.

3. Inside Windows, download the Nvidia graphics driver for your graphics card from here
The latest driver for my Nvidia GTX 970, as of this writing, is 372.54.

4. Run the Nvidia driver installer. It will unpack the files to C:/NVIDIA/DisplayDriver/{version}/Win10_64/International/Display.Driver, with the driver as of this writing it will be C:\NVIDIA\DisplayDriver\372.54\Win10_64\International\Display.Driver

Exit the Nvidia installer once it unpacked the files !!!

5. Download the Windows WDK from here:

On the webpage that opens, go to step 2, then click "Install Windows Driver Kit (WDK) 10". You do NOT need to install the other stuff!

Run the installer and install the Windows Driver Kit (WDK).

6. Download Python from As of this writing the latest version is 3.5.2

Run the installer.

7. To enable testsigning:
  1. Right-click on the Windows menu icon and select "Command Prompt (Admin)"
  2. On the command prompt, enter

    Code: Select all

    Bcdedit.exe -set TESTSIGNING ON
    and press Enter

Later, if you wish to disable testsigning, use the following command:

Code: Select all

Bcdedit.exe -set TESTSIGNING OFF

Important: Please be aware of the security risks when you run testsigned drivers.

8. Reboot your Windows 10 VM.

9. Open and download the two script files (a Powershell script and a Python script):
  • gencert.ps1

Both files must reside in the same location. (Note: I opened the file, copied the content into an empty Notepad file and saved it.)

10. Open the Windows File Explorer and go to the folder where you saved the two files.

Click "File", then select "Open command prompt" -> "Open command prompt as administrator".

11. Before running the script, open the file in Notepad or with IDLE (right click on the file and select) and check that the driver version you are going to install is actually supported by this patch. See below for reference:
# TODO: Wildcard Search
"41FF978804000085C0": "31C0909090909085C0", # 361.91 - 368.39
"41FF97B804000085C0": "31C0909090909085C0", # 372.54

12. Copy and paste the following onto the command line:

Code: Select all C:\NVIDIA\DisplayDriver\372.54\Win10_64\International\Display.Driver
and hit Enter.

Note: Replace the version (here "372.54") in the path name with the Nvidia driver version you downloaded.

The script will run for a few minutes, after which you see "Warnings: None". Hit Enter.

The Python script will now execute the Powershell script and testsign the driver.

13. Using the File Explorer, go to

Code: Select all


and run "setup.exe" to install the patched Nvidia driver.

14. Shutdown Windows and modify your qemu start script:

Code: Select all

-cpu host,hv_vapic,hv_time,hv_relaxed,hv_spinlocks=0x1fff \

Note: Remove the "kvm=off" option and instead add "hv_vapic,hv_time,hv_relaxed,hv_spinlocks=0x1fff"



All credit should go to sk1080 who wrote the script and provided the instructions. Great work !!!
Asus Sabertooth X79, i7 3930K CPU, 8x4GB Kingston DDR3 RAM, Noctua NH-D14 CPU cooler, Gigabyte GTX 970 + PNY Quadro 2000 GPU, Asus Xonar Essence STX, Sandisk Extreme 120GB + Samsung EVO 850 250GB SSD + 5 HDD, Corsair 500R case, SeaSonic 660W Gold X PS

Return to “Virtualization”

Who is online

Users browsing this forum: No registered users and 1 guest