Sunday, August 31, 2014

Does my graphics card ROM support EFI?

If you're wanting to try legacy-free OVMF-based GPU assignment, it might be a good idea to start by testing whether your graphics card has EFI support in the PCI option ROM.  I've written a small program to parse the ROM and report some basic info about the contents.  Here's example output:

$ ./rom-parser GT635.rom 
Valid ROM signature found @0h, PCIR offset 190h
 PCIR: type 0, vendor: 10de, device: 1280, class: 030000
 PCIR: revision 0, vendor revision: 1
Valid ROM signature found @f400h, PCIR offset 1ch
 PCIR: type 3, vendor: 10de, device: 1280, class: 030000
 PCIR: revision 3, vendor revision: 0
  EFI: Signature Valid
 Last image

This is what we typically expect to see, there are two headers, the first is type 0, which is a standard PC BIOS ROM, the second is type 3, an EFI ROM. If you don't have EFI support in the ROM, the OVMF solution will not work for you.  Newer graphics card will hopefully all have EFI support.

To get this program:

$ git clone https://github.com/awilliam/rom-parser
$ cd rom-parser
$ make

You'll need to copy the ROM to a file first, the program does not have support for enabling the ROM through pci-sysfs. To do this from the host:

# cd /sys/bus/pci/devices/0000:01:00.0/
# echo 1 > rom
# cat rom > /tmp/image.rom
# echo 0 > rom

If you get a zero-sized file, look for an error in dmesg. The ROM may only be readable initially after boot, before any drivers have bound to it. Use the pci-stub.ids= boot option to attempt to keep the device in a pristine, unused state.

15 comments:

  1. While my card's vbios doesn't have EFI support (VTX3D HD7870 GHZ Edition), Powercolor's equivalent does and apparently it's running flawlessly.

    ReplyDelete
    Replies
    1. That's a good point, since we can supply the ROM via the romfile= option, you aren't necessarily tied to the ROM flashed on the card. There's likely to be some interchangeability between vendors for the same chipset.

      Delete
    2. Do you know if support for the romfile= option is included in libvirt (PCI device element?) or it can only be specified as a qemu argument?

      Delete
    3. <rom file=/path/to/file.rom/>

      https://libvirt.org/formatdomain.html#elementsHostDevSubsys

      Delete
  2. Note that some graphics card vendors don't ship an EFI compatible ROM on the card, but do provide an update with it. This seems to be the case with many EVGA cards, unfortunately you need to go through the hassle of registering your card and filing a support ticket to get it.

    ReplyDelete
  3. If you have the EfiRom program from Tiano Core (in Fedora it is part of the "edk2" package) you can also use "EfiRom -d /path/to/image.tom".

    ReplyDelete
    Replies
    1. Thanks Paolo! Here's what that produces for the same example ROM above:

      $ EfiRom -d GT635.rom
      Image 1 -- Offset 0x0
      ROM header contents
      Signature 0xAA55
      PCIR offset 0x0190
      Signature PCIR
      Vendor ID 0x10DE
      Device ID 0x1280
      Length 0x0018
      Revision 0x0000
      DeviceListOffset 0x00
      Class Code 0x030000
      Image size 0xF400
      Code revision: 0x0001
      MaxRuntimeImageLength 0x00
      ConfigUtilityCodeHeaderOffset 0x8B2E
      DMTFCLPEntryPointOffset 0x2EC0
      Indicator 0x00
      Code type 0x00
      Image 2 -- Offset 0xF400
      ROM header contents
      Signature 0xAA55
      PCIR offset 0x001C
      Signature PCIR
      Vendor ID 0x10DE
      Device ID 0x1280
      Length 0x001C
      Revision 0x0003
      DeviceListOffset 0x00
      Class Code 0x030000
      Image size 0x10400
      Code revision: 0x0000
      MaxRuntimeImageLength 0x00
      ConfigUtilityCodeHeaderOffset 0x00
      DMTFCLPEntryPointOffset 0x00
      Indicator 0x80 (last image)
      Code type 0x03 (EFI image)
      EFI ROM header contents
      EFI Signature 0x0EF1
      Compression Type 0x0001 (compressed)
      Machine type 0x8664 (unknown)
      Subsystem 0x000B (EFI boot service driver)
      EFI image offset 0x004C (@0xF44C)

      Delete
  4. lspci -nn said:
    01:00.0 VGA compatible controller [0300]: NVIDIA Corporation G73 [GeForce 7600 GS] [10de:0392] (rev a1)

    so I've booted with pci-stub.ids=10de:0392,8086:0151.

    Then I run:
    [root@hermes 0000:01:00.0]# echo 1 > rom
    [root@hermes 0000:01:00.0]# cat rom > /tmp/image.rom
    cat: rom: Input/output error
    [root@hermes 0000:01:00.0]# dmesg
    ....
    [11386.105826] pci-stub 0000:01:00.0: Invalid ROM contents

    ReplyDelete
    Replies
    1. If it's your primary graphics it can be a pain to collect the ROM. Sometimes it's a pain regardless. I'd guess chances are very, very, very slim that a 7-series Nvidia card supports EFI. All the ROMs on TechPowerUp are dated 2006/2007. If your card is listed there you can test their copy instead.

      Delete
    2. It's the secondary graphics card, the primary is an Intel HD 4000.

      It's a Gigabyte Nvidia 7600GS with 256 MB of memory which I was able to find on TechPowerUp, but none of the ROMs has any trace of EFI :-(

      Delete
    3. Try your luck switching off CSM in your EFI, and then booting using the kernel arguments: "nomodeset init=/bin/bash pci-stub.ids=10de:0392,8086:0151"

      That worked for me where even GPU-Z would only ever result in a crash. CSM is definitely required for some reason, at least on my machine. init=/bin/bash will (at least on Debian) leave you in your initrd environment prior to the nvidia driver being loaded. No need to edit files, just temporary kernel arguments at the Grub menu.

      Delete
  5. This comment has been removed by a blog administrator.

    ReplyDelete
  6. Hi.

    Compiler rookie here, what do I need to compile your rom-parser?
    Using grml 2014.11 to see if the ROM of my GPU had EFI support.

    installed gcc-4.9 and installed linux-headers-$(uname -r) but am stuck on

    # make
    gcc-4.9 -o rom-parser rom-parser.c
    rom-parser.c:1:19: fatal error: fcntl.h: No such file or directory
    #include
    ^
    compilation terminated.
    Makefile:4: recipe for target 'rom-parser' failed
    make: *** [rom-parser] Error 1

    I'm not sure if fcntl.h is installed

    # find / -name fcntl.h
    /usr/src/linux-headers-3.16.0-1-grml-common/include/uapi/asm-generic/fcntl.h
    /usr/src/linux-headers-3.16.0-1-grml-common/include/uapi/linux/fcntl.h
    /usr/src/linux-headers-3.16.0-1-grml-common/include/linux/fcntl.h
    /usr/src/linux-headers-3.16.0-1-grml-common/arch/x86/include/uapi/asm/fcntl.h

    But the compiler doesn't find on of the 4 header files.
    Thanks for any help.

    ReplyDelete
    Replies
    1. got it compiled!
      In the end for GRML 2014.11:
      # apt-get update
      # apt-get kernel-package

      And sadly my GTX 750 Ti misses the second entry, so no EFI, to bad :(

      Delete
  7. In case you also have an MSI NVIDIA 7xx series: most of the cards in this series don't have a EFI vbios, but posting a message on their support forums with your cards serial number will usually get you the EFI vbios in less that one day.

    Its working here :)

    ReplyDelete

Comments are not a support forum. For help with problems, please try the vfio-users mailing list (https://www.redhat.com/mailman/listinfo/vfio-users)