Differences between revisions 1 and 2
Revision 1 as of 2015-04-28 09:57:00
Size: 1610
Comment: create qemu/iommu page with initial content
Revision 2 as of 2015-04-28 11:07:15
Size: 2248
Comment: preparations
Deletions are marked like this. Additions are marked like this.
Line 25: Line 25:

The IOMMU sometimes needs to be enabled explicitly from whithin the BIOS.

== Preparations ==

This section assumes a Debian/Ubuntu host. Install {{{qemu-kvm}}}. Create a script with the following contents. Here, we call it pci-setup.sh.
{{{
#!/bin/bash

modprobe vfio-pci

for dev in "$@"; do
        vendor=$(cat /sys/bus/pci/devices/$dev/vendor)
        device=$(cat /sys/bus/pci/devices/$dev/device)
        if [ -e /sys/bus/pci/devices/$dev/driver ]; then
                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
        fi
        echo $vendor $device > /sys/bus/pci/drivers/vfio-pci/new_id
done
}}}

Barrelfish inside qemu with PCIe passthrough

Recent Intel/AMD processors and chipsets support PCIe virtualization. This requires a CPU supporting VT-d/AMD-Vi and a chipset that includes an IOMMU. Linux with KVM support passing a PCIe device to qemu guests transparently. This guide focuses on Intel hardware.

Prerequisites

A computer supporting IOMMU and a processor supporting VT-d are required for this to function. Additionally, a Linux version with KVM and IOMMU support has to be running. Check for IOMMU support using dmesg | grep IOMMU . The output should be similar to the following:

ubuntu@ubuntu:~$ dmesg|grep IOMMU
[    0.000000] Intel-IOMMU: enabled
[    0.000000] Intel-IOMMU: enabled
[    0.401164] dmar: IOMMU 0: reg_base_addr fbffe000 ver 1:0 cap d2078c106f0466 ecap f020de
[    0.416382] dmar: IOMMU 1: reg_base_addr ebffc000 ver 1:0 cap d2078c106f0466 ecap f020de
[    0.436580] IOAPIC id 2 under DRHD base  0xfbffe000 IOMMU 0
[    0.442900] IOAPIC id 0 under DRHD base  0xebffc000 IOMMU 1
[    0.449217] IOAPIC id 1 under DRHD base  0xebffc000 IOMMU 1
[   30.844389] IOMMU 0 0xfbffe000: using Queued invalidation
[   30.850527] IOMMU 1 0xebffc000: using Queued invalidation
[   30.856664] IOMMU: Setting RMRR:
[   30.860391] IOMMU: Setting identity map for device 0000:00:1a.0 [0xbdcf9000 - 0xbdd1dfff]
[   30.869716] IOMMU: Setting identity map for device 0000:00:1d.0 [0xbdcf9000 - 0xbdd1dfff]
[   30.879012] IOMMU: Prepare 0-16MiB unity mapping for LPC
[   30.885068] IOMMU: Setting identity map for device 0000:00:1f.0 [0x0 - 0xffffff]

The IOMMU sometimes needs to be enabled explicitly from whithin the BIOS.

Preparations

This section assumes a Debian/Ubuntu host. Install qemu-kvm. Create a script with the following contents. Here, we call it pci-setup.sh.

modprobe vfio-pci

for dev in "$@"; do
        vendor=$(cat /sys/bus/pci/devices/$dev/vendor)
        device=$(cat /sys/bus/pci/devices/$dev/device)
        if [ -e /sys/bus/pci/devices/$dev/driver ]; then
                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
        fi
        echo $vendor $device > /sys/bus/pci/drivers/vfio-pci/new_id
done

BarrelfishWiki: qemu_iommu (last edited 2015-04-28 11:32:20 by MoritzHoffmann)