I have an AMD A4-5300 CPU with a motherboard that supports IOMMU and I am trying to enable IOMMU on my Gentoo Hardened 4.3.3-r4 kernel with the intention of using a graphics card on a KVM VM. According to this guide here, I'm supposed to recompile my kernel with a few provided options (Support for DMA Remapping Devices, Enable DMA Remapping Devices and PCI Stub driver). However, Support for DMA Remapping Devices and Enable DMA Remapping Devices are absent from my kernel configuration. I then searched the configuration for remap and tried enabling a number of options, which were CONFIG_IRQ_REMAP, CONFIG_DMAR_TABLE, CONFIG_IOMMU_SUPPORT, CONFIG_SWIOTLB and CONFIG_PCI_IOV. Then I recompiled my kernel with these options enabled, started my system with amd_iommu=fullflush iommu=force on the kernel command line, and according to the aforementioned guide I checked if IOMMU was running on my system by looking for AMD-Vi on my kernel messages:dmesg | grep AMD-ViNothing shows up on my kernel log about AMD-Vi. In addition, when I try to start a VM on virt-manager with an attached PCI device, I get a message that says Error starting domain: unsupported configuration: host doesn't support passthrough of host PCI devices.I've already googled quite a bit, but Gentoo-specific discussion of IOMMU seems to be pretty scarce. pretty much everything I find is for Fedora, Ubuntu and Debian where IOMMU apparently Just Works out of the box. I don't believe it's a matter of my motherboard and CPU not supporting it, because my BIOS has an option for it, and because I remember being able a few years ago to run a VirtualBox VM with IOMMU on Debian (though I didn't follow up on it because noob me never thought at the moment that I required two graphic cards to use a GPU on a VM through IOMMU).Here's what I have already tried but didn't work:Using the standard kernel instead of hardened.Enabling Device Drivers >> IOMMU Hardware Support, AMD IOMMU support, Support for Intel IOMMU using DMA Remapping Devices, Support for Interrupt Remapping and Bus options (PCI etc.) >> PCI Stub.Using the latest kernel, currently just upgraded to 4.4.8-hardened-r1.This is the command line I'm using to start my kernel, with each parameter on a separate line for convenience:root=/dev/ram0 crypt_root=/dev/disk/by-uuid/c1ce6456-4c6a-4a64-8027-5ec4fdc0f344 dolvm real_root=/dev/mapper/cryptgentoo-raiz rootfstype=jfs real_init=/sbin/init root_keydev=/dev/disk/by-partuuid/086194de-e476-4abb-82da-9744e6fb0257 root_key=luks-key.gpg keymap=la amd_iommu=on iommu=onAm I still missing a kernel configuration option?Update: Out of absent-mindedness I mistakenly issued ps -ef | grep -i iommu, and look what I just found...rockshooter ~ # ps -ef | grep iommuroot        66     2  0 02:57 ?        00:00:00 [amd_iommu_v2]If I see a kernel thread, I guess there might be a chance that I can get IOMMU running, it's just that my kernel isn't saying anything about it. It's just a wild guess... but I'm going to go ahead and try using it.
How do I compile my Gentoo kernel for AMD IOMMU?
virtual machine;gentoo;pci;amd
Finally, after much wailing, complaining and head bashing, I finally figured out what was going on.As it turns out, IOMMU was working all along, it's just that the kernel logs weren't showing it. But the IOMMU driver was there, it was working, and I serendipiously found out when I mistakenly typed ps -ef instead of dmesg like this:rockshooter ~ # ps -ef | grep -i iommuroot        66     2  0 04:19 ?        00:00:00 [amd_iommu_v2]  When I saw that kernel thread running I thought, maybe my IOMMU is actually working? So I performed the same configuration steps I did previously for Debian, and one hour later, lo and behold, I was on my virtual machine hooked up to my graphics card playing some games.Please save this thread for future reference, because it took me some good 3 weeks to figure this out. I still gave the other poster some well-deserved +50 reputation for bothering with setting up and testing this issue.