How to Enable VT-d and Configure PCI Passthrough for KVM on Ubuntu 14.04 with Intel i7-4790


3 views

The first step is to confirm whether your system properly detects VT-d functionality. The dmesg output you provided shows IOMMU groups being detected, which is a good sign:

$ dmesg | grep -i iommu
[    0.027450] dmar: IOMMU 0: reg_base_addr fed90000 ver 1:0 cap c0000020660462 ecap f0101a
[    0.027455] dmar: IOMMU 1: reg_base_addr fed91000 ver 1:0 cap d2008020660462 ecap f010da
[    0.027521] IOAPIC id 8 under DRHD base  0xfed91000 IOMMU 1

However, you'll want to check for additional kernel messages:

$ dmesg | grep -e DMAR -e IOMMU
$ cat /proc/cmdline

For Intel processors, you need to add the following parameters to your kernel boot line:

$ sudo nano /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash intel_iommu=on iommu=pt"

After making changes, update GRUB:

$ sudo update-grub
$ sudo reboot

After reboot, check if IOMMU groups are properly formed:

$ ls -l /sys/kernel/iommu_groups/
$ find /sys/kernel/iommu_groups/ -type l

For your specific device (00:1f.2), check its IOMMU group:

$ readlink -f /sys/bus/pci/devices/0000:00:1f.2/iommu_group

Ensure these modules are loaded:

$ sudo modprobe vfio
$ sudo modprobe vfio_iommu_type1
$ sudo modprobe vfio_pci
$ sudo modprobe kvm
$ sudo modprobe kvm_intel

Add them to /etc/modules to load at boot:

$ echo "vfio" | sudo tee -a /etc/modules
$ echo "vfio_iommu_type1" | sudo tee -a /etc/modules
$ echo "vfio_pci" | sudo tee -a /etc/modules
$ echo "kvm" | sudo tee -a /etc/modules
$ echo "kvm_intel" | sudo tee -a /etc/modules

For your specific device (00:1f.2), first identify the vendor and device IDs:

$ lspci -nn -s 00:1f.2
00:1f.2 SATA controller [0106]: Intel Corporation 9 Series Chipset Family SATA Controller [AHCI Mode] [8086:8c82]

Create a VFIO binding file:

$ sudo nano /etc/modprobe.d/vfio.conf
options vfio-pci ids=8086:8c82

Update initramfs:

$ sudo update-initramfs -u
$ sudo reboot

After reboot, check if the device is bound to vfio-pci:

$ lspci -nnk -s 00:1f.2
Kernel driver in use: vfio-pci

Add the PCI device to your VM configuration:

<hostdev mode='subsystem' type='pci' managed='yes'>
  <source>
    <address domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
  </source>
</hostdev>

If you still encounter issues, check:

$ dmesg | grep -i vfio
$ journalctl -xe
$ cat /sys/module/vfio_iommu_type1/parameters/allow_unsafe_interrupts

For ACS override (if needed):

$ sudo nano /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash intel_iommu=on iommu=pt pcie_acs_override=downstream"

Your dmesg output shows the system detects IOMMU units, which means VT-d is technically enabled at the hardware level. However, there are several layers that need proper configuration:


[    0.027450] dmar: IOMMU 0: reg_base_addr fed90000 ver 1:0 cap c0000020660462 ecap f0101a
[    0.027455] dmar: IOMMU 1: reg_base_addr fed91000 ver 1:0 cap d2008020660462 ecap f010da
[    0.027521] IOAPIC id 8 under DRHD base  0xfed91000 IOMMU 1

Before proceeding with passthrough, verify these critical components:


# Check CPU virtualization flags
egrep -c '(vmx|svm)' /proc/cpuinfo

# Verify kernel support
grep -E 'vmx|svm|lm' /proc/cpuinfo

# Check IOMMU activation
dmesg | grep -e DMAR -e IOMMU

# Verify kernel parameters
cat /proc/cmdline | grep iommu

For Ubuntu 14.04, you'll need to modify GRUB configuration:


# Edit GRUB configuration
sudo nano /etc/default/grub

# Find GRUB_CMDLINE_LINUX_DEFAULT and add:
intel_iommu=on iommu=pt

# Update GRUB
sudo update-grub

Reboot your system after making these changes.

Modern KVM passthrough requires VFIO drivers. For your Intel chipset (especially the i7-4790 with Z97 chipset):


# First, identify your PCI devices
lspci -nnk

# Create driver override for your target device (example for 00:1f.2)
echo "options vfio-pci ids=8086:8ca2" | sudo tee /etc/modprobe.d/vfio.conf

# Load necessary modules
echo "vfio" | sudo tee /etc/modules-load.d/vfio.conf
echo "vfio_iommu_type1" | sudo tee -a /etc/modules-load.d/vfio.conf
echo "vfio_pci" | sudo tee -a /etc/modules-load.d/vfio.conf
echo "vfio_virqfd" | sudo tee -a /etc/modules-load.d/vfio.conf

A critical step many overlook is checking IOMMU group isolation:


#!/bin/bash
for d in /sys/kernel/iommu_groups/*/devices/*; do
    n=${d#*/iommu_groups/*}; n=${n%%/*}
    printf 'IOMMU Group %s ' "$n"
    lspci -nns "${d##*/}"
done

After completing all above steps, try detaching again:


# Unbind from current driver
echo "0000:00:1f.2" | sudo tee /sys/bus/pci/devices/0000:00:1f.2/driver/unbind

# Bind to vfio-pci
echo "vfio-pci" | sudo tee /sys/bus/pci/devices/0000:00:1f.2/driver_override
echo "0000:00:1f.2" | sudo tee /sys/bus/pci/drivers/vfio-pci/bind

# Verify binding
lspci -nnk -s 00:1f.2

If you still encounter problems:


# Check for ACS override needs (use carefully)
pci=assign-busses,realloc=off,acs_override=downstream

# Verify IRQ remapping support
dmesg | grep -i "remapping"

# Check for interrupt issues
cat /proc/interrupts | grep -i pci

For MSI-GD65 motherboards specifically, you might need to disable "MSI Fast Boot" in BIOS as it can interfere with proper PCI initialization.