Giter VIP home page Giter VIP logo

nvidia-vbios-vfio-patcher's Introduction

NVIDIA vBIOS VFIO Patcher

This tool is known to be compatible only with the Pascal series (1xxx) of NVIDIA GPUs.

nvidia_vbios_vfio_patcher.py is a script that creates a patched/spliced copy of a NVIDIA vBIOS that allows PCI passthrough when using libvirt. This copy of the vBIOS can then be passed to libvirt, allowing the NVIDIA GPU to be used in the guest VM. This can be done by adding the following line to the VM domain XML file.

   <hostdev>
     ...
     <rom file='/path/to/your/patched/gpu/bios.bin'/>
     ...
   </hostdev>

This script may be useful if you are using one of the Pascal (1xxx series) series of NVIDIA GPUs and you are having passing the GPU to the guest VM. In this case, the vBIOS of the system's primary GPU is tainted when booting the host OS, making GPU passthrough impossible unless a clean copy of the vBIOS is used.

The patching process requires a full copy of the clean vBIOS. You can either extract it from the graphics card using nvflash or GPU-Z under Windows (recommended), or download one for your specific GPU model from TechPowerUp.

DISCLAIMER

Use this script at your own discretion. This script has NOT been tested extensively, and has only been tested with a few GPUs belonging to he Pascal series of NVIDIA GPUs.

The script performs only a few rudimentary sanity checks, but no guarantees are made of the validity of the patched ROM!

Usage

The script should work with both Python 2 and 3.

To create a patched version of the BIOS, run the script with the following parameters.

python nvidia_vbios_vfio_patcher.py -i <ORIGINAL_ROM> -o <PATCHED_ROM>

A patched version of <ORIGINAL_ROM> will be written to <PATCHED_ROM>.

nvidia-vbios-vfio-patcher's People

Contributors

arcnmx avatar matoking avatar ravenx8 avatar realies avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nvidia-vbios-vfio-patcher's Issues

Sanity Check on file Size

Hey, Thanks for creating this awesome script.

I have just patched the Zotac 1070 Ti mini rom from TechPowerUp using your python script. The initial rom was 269Kb and the resulting "patched" rom was 130Kb. This seemed like a pretty big change if it just removes the header, so I wanted to post a quick sanity check here before using.

Best,
Rob

Script doesn't do anything

Hello!

When I run python3 nvidia_vbios_vfio_patcher.py -i NVIDIA.GTX1070.8192.160520.bin -o patched.bin in cmd, I get no result. Same goes when I run it with python instead of python3

Screenshot:
image

Am I doing something stupidly wrong or? Windows 10 by the way

rtx series

can you please add support for newer rtx 20xx cards? I go crazy having no vfio support

Expected only three 'NPDE' markers

Getting this output:

[mauch@M80 NVIDIA-vBIOS-VFIO-Patcher]$ python nvidia_vbios_vfio_patcher.py -i mx150.rom -o mx150patched.rom
Opening the ROM file...
Scanning for ROM offsets...
Offsets found!
Running sanity checks...
Traceback (most recent call last):
File "nvidia_vbios_vfio_patcher.py", line 194, in <module>
main()
File "nvidia_vbios_vfio_patcher.py", line 172, in main
rom.run_sanity_tests(args.ignore_sanity_check)
File "nvidia_vbios_vfio_patcher.py", line 103, in run_sanity_tests
"footer, found %d" % npde_count)
main.CheckException: Expected only three 'NPDE' markers between header and footer, found 2

cannot patch the gtx1080.rom

root@debian:/home/olproff/NVIDIA-vBIOS-VFIO-Patcher# ./nvidia_vbios_vfio_patcher.py -i ../gtx1080.dump -o ../gtx1080_patched.bin
Opening the ROM file...
Scanning for ROM offsets...
Traceback (most recent call last):
File "./nvidia_vbios_vfio_patcher.py", line 194, in
main()
File "./nvidia_vbios_vfio_patcher.py", line 168, in main
rom.detect_offsets()
File "./nvidia_vbios_vfio_patcher.py", line 77, in detect_offsets
raise CheckException("Couldn't find the ROM footer!")
main.CheckException: Couldn't find the ROM footer!

Non Pascal Gt 710b card

As the other people that open a issue here I have the
same problem : my card is not a Pascal card and I'm
poking around weather I can still make it work. I have a
simple GT 710b model that is some generations before Pascal.

The offset between "564e" and "NPDS" is 124 octels instead of
348 as the script expects:

00020e00: 564e 3f00 0000 0000 0000 0000 0000 0000  VN?.............
00020e10: 0000 0000 0000 0000 4000 65d0 163b 5159  [email protected]..;QY
00020e20: 6859 c05d 501e 0800 0000 0000 0000 0000  hY.]P...........
00020e30: 0000 0000 0000 0000 0000 002e 8bc0 8bc0  ................
00020e40: 4e50 4453 de10 b012 0000 1800 0000 0000  NPDS............
00020e50: 3f00 0000 e000 0000 2e8b c02e 8bc0 8bc0  ?...............
00020e60: 4e50 4445 0101 0c00 3f00 0000 0171 c3f9  NPDE....?....q..
00020e70: c3f8 c30b e4c3 3bc0 c3b8 4f01 c3cb 0000  ......;...O.....

When I do this change then nvidia_vbios_patcher.py finishes:

diff --git a/nvidia_vbios_vfio_patcher.py b/nvidia_vbios_vfio_patcher.py 
index 0e899fd..cda844a 100755 
--- a/nvidia_vbios_vfio_patcher.py 
+++ b/nvidia_vbios_vfio_patcher.py 
@@ -69,11 +69,13 @@ class VBIOSROM(object): 
        # Search for the footer, which are shortly followed by 
        # 'NPDS' and 'NPDE' strings. 'NPDS' and 'NPDE' markers are separated by 
        # 28 ASCII characters 
-        FOOTER_REGEX = ( 
-            b'564e(([a-z]|[0-9]){348})(4e504453)(([a-z]|[0-9]){56})(4e504445)' 
+        # 348 
+        FOOTER_REGEX = (  
+            b'564e(([a-z]|[0-9]){124})(4e504453)(([a-z]|[0-9]){56})(4e504445)' 
        ) 
        result = re.compile(FOOTER_REGEX).search(self.content) 
        if not result or len(result.groups()) != 6:

however I actually dont know what the patch process does and weather there
is a chance that this would work. If I use it in my passthrough command:
-device vfio-pci,host=01:00.0,multifunction=on,romfile=${b}/bioses/nvidia_patched.rom
the nvidia driver is still stuck at "Code 43".
Any tips on howto get it work / insight into what the script does/ tips on howto
get vbios working for 710?

This project is unmaintained

This project is unmaintained. I won't be responding to any issues or pull requests.

You're free to fork the project if you want to continue maintaining the script. The script is licensed under the very permissive CC0, which should pose little if no limitations in what you can do.

Table of known working cards?

Would you be willing to add a small table of the cards that you know this tool will work with?

Additionally, there is a typo in your readme;

"to he Pascal series" should be "to the Pascal series"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.