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. Btrfs On 4 x Intel SSDs In RAID 0/1/5/6/10
  2. AMD Radeon R9 290 On Ubuntu 14.10: RadeonSI Gallium3D vs. Catalyst
  3. MSI X99S SLI PLUS On Linux
  4. NVIDIA GeForce GTX 970 Offers Great Linux Performance
Latest Linux Articles
  1. 6-Way Ubuntu 14.10 Radeon Gallium3D vs. Catalyst Driver Comparison
  2. NVIDIA vs. Nouveau Drivers On Ubuntu 14.10
  3. Ubuntu 14.10 Offers AMD Radeon Driver Performance Improvements
  4. Btrfs RAID: Linux 3.10 To Linux 3.18 Benchmarks
Latest Linux News
  1. GLAMOR Acceleration Continues To Be Cleaned Up
  2. Russia's Yandex Web Browser Finally Released For Linux
  3. Linux Kernel Finally Being Optimized For SSHDs
  4. GPU Profiling Support Lands In Mozilla Firefox
  5. Kubuntu 15.04 Will Use KDE's Plasma 5 By Default
  6. KDBUS Submitted For Review To The Mainline Linux Kernel
  7. An Intel-Based Ubuntu Touch Tablet Is Planning To Launch Soon
  8. MIAOW: An Open-Source GPU Design Based On AMD's Southern Islands
  9. X.Org Server 1.17 RC1 Released, Exciting For GLAMOR & Modesetting
  10. OpenGL 4.x Support For Mesa Still Inching Along
Latest Forum Discussions
  1. Reducing The CPU Usage In Mesa To Improve Performance
  2. Is foolish currently develop in machine code, hexadecimal and assembly?
  3. Help diagnosing problems with a Readon HD 4670 on Mesa 10.3.2-1
  4. Advertisements On Phoronix
  5. nv and xorg.conf under Debian PPC
  6. Looking for a Open-Source AMD experienced Linux mentor
  7. Bad perfomance in gaming
  8. Dead Island for Linux (?)