1. Computers
  2. Display Drivers
  3. Graphics Cards
  4. Memory
  5. Motherboards
  6. Processors
  7. Software
  8. Storage
  9. Operating Systems


Facebook RSS Twitter Twitter Google Plus


Phoronix Test Suite

OpenBenchmarking.org

Graphics Card Support For QEMU/KVM Comes Closer

Virtualization

Published on 29 January 2013 06:09 PM EST
Written by Michael Larabel in Virtualization
8 Comments

One of the major limitations of QEMU/KVM when it comes to Linux desktop virtualization is that it hasn't provided any form of support for graphics acceleration -- either by passing OpenGL calls onto the host for execution by the host's driver and graphics hardware or allowing guest VMs to tap directly the graphics card. Support for the latter feature continues to be developed and is close to becoming a working reality.

Allowing QEMU virtual machines to directly interact with PCI devices has become a reality with the merging of the VFIO driver last August. VFIO for the Linux kernel provides a secure interface for device access using IOMMU so that, among other purposes, a physical PCI device could be assigned to a QEMU guest. Up to this point in the KVM world there were basically some x86 hacks to allow similar support.

QEMU 1.3 picked up VFIO support (among other interesting and fun features), but VFIO hasn't supported graphics cards but only more simple PCI-based devices. As I wrote about at the beginning of the month, QEMU is getting close to allow passing GPUs to guests.

Published today on the Linux kernel mailing list was a new patch for VFIO-PCI to add support for VGA region access. The to-be-added VFIO_PCI_VGA kernel option allows for a VGA extension to the VFIO PCI driver that exposes an additional region on VGA devices for accessing legacy VGA addresses used by BIOS and generic video graphics drivers.

While there's that kernel patch, published since the other Phoronix article earlier this month were QEMU patches. The QEMU patches rely upon the VFIO kernel support for accessing VGA ranges. Accelerated hardware graphics drivers don't work with these initial QEMU patches, but it's working so far for graphics adapters using the SeaBIOS text mode output with standard VGA drivers.

The QEMU patches explain:
Most VGA cards need some kind of quirk to fully operate since they hide backdoors to get to other registers outside of PCI config space within the registers, but this provides the base infrastructure. If we could identity map PCI resources for assigned devices we would need a lot fewer quirks.

To enable this, use a kernel side vfio-pci driver that incorporates VGA support (patches posted), and use the -vga none option and add the x-vga=on option for the vfio-pci device. The "x-" denotes this as an experimental feature. You may also need to use a cached copy of the VGA BIOS for your device, passing it to vfio-pci using the romfile= option.
Additionally:
Apparently graphics vendors need to come up with new ways to retrieve PCI BAR addresses on every revision of their chip. These are the ones that I've found on the following assortment of cards:

Advanced Micro Devices [AMD] nee ATI Cedar PRO [Radeon HD 5450/6350]
Advanced Micro Devices [AMD] nee ATI RV370 [Radeon X550]
NVIDIA Corporation G98 [GeForce 8400 GS]
NVIDIA Corporation G86 [Quadro NVS 290]
NVIDIA Corporation G72 [GeForce 7300 LE]

With these quirks, each is able to POST under seabios, display text mode VGA spew, and switch into graphics mode. All but the X550 also seem to work under Windows7 using the standard VGA driver (Windows automatically installed a new driver for the X550 and it hasn't worked since). Installing the AMD/ATI Catalyst driver for the HD 5450 hung the host, the NVIDIA cards report a yellow bang in device manager, so something is still not entirely happy there. The NVIDIA provided driver install, but reports Code 43(?).

It's relatively easy to figure out many of these quirks. First enable DEBUG_UNASSIGNED in exec.c, then enable DEBUG_VFIO in hw/vfio_pci.c. Log the output and can kill Qemu when Unassigned access errors start to spew (ignore the ones at very low offsets). If the unassigned access matches a range covered by the device (consult lspci or /proc/iomem), then look back in the vfio-pci debug output for read from the device that returned an address or partial address matching the unassigned access. Then follow these examples for creating quirks to trap that access and return the emulated BAR address.

None of these would be necessary if we could identity map devices.

Even with this patch, vfio-based VGA assignment is extremely experimental and quite fragile. Enable at your own risk.
At least they're slowly moving in the right direction...

About The Author
Michael Larabel is the principal author of Phoronix.com and founded the web-site in 2004 with a focus on enriching the Linux hardware experience and being the largest web-site devoted to Linux hardware reviews, particularly for products relevant to Linux gamers and enthusiasts but also commonly reviewing servers/workstations and embedded Linux devices. Michael has written more than 10,000 articles covering the state of Linux hardware support, Linux performance, graphics hardware drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated testing software. He can be followed via and or contacted via .
Latest Linux Hardware Reviews
  1. Rosewill RS-MI-01: An Ultra Low-Cost Mini-ITX Chassis
  2. D-Link DCS-2330L HD Wireless Network Camera
  3. Gigabyte AM1M-S2H
  4. AMD's New Athlon/Semprons Give Old Phenom CPUs A Big Run For The Money
Latest Linux Articles
  1. AMD Catalyst 14.4 On Linux With Radeon R3 APU Graphics
  2. Red Hat Enterprise Linux 7.0 RC Benchmarks
  3. AMD Catalyst 14.4 Brings Few Linux Performance Improvements
  4. The Performance Of Fedora 20 Updated
Latest Linux News
  1. NGINX 1.6 Brings SPDY 3.1 & Other New Features
  2. Linux Foundation Announces A Core Infrastructure Initiative
  3. More Steam Linux Tests/Benchmarks Might Be Coming
  4. NVIDIA's Amazing Single-Board ARM Computer Might Be Delayed
  5. Fedora 21 To Get A Playground, New Features
  6. PC-BSD Is Developing Its Own Desktop Environment
  7. Valve Is Bringing VOGL To Windows & Working On Regression Tests
  8. Canonical Is Taking Over Linux 3.13 Kernel Maintenance
  9. Google Web Designer Is Now Natively Available On Linux
  10. Ubuntu 14.10 Is Codenamed The Utopic Unicorn
  11. Audacious 3.5 Lightweight Audio Player Released
  12. Steam Updated For Ubuntu 14.04 LTS, SteamOS
Latest Forum Discussions
  1. HTPC-upgrade advice: AMD Richland A8-7600 or Kaveri A10-6700T ???
  2. What Else Would You Like To See On Phoronix This Spring?
  3. Linux Kernel Developers Fed Up With Ridiculous Bugs In Systemd
  4. The GNOME Foundation Is Running Short On Money
  5. The Most Amazing OpenGL Tech Demo In 64kb
  6. Announcing radeontop, a tool for viewing the GPU usage
  7. New card. Open source drivers only.
  8. Script for Fan Speed Control