Skip to content

Commit 3f68b03

Browse files
Alex Williamsonavikivity
authored andcommitted
KVM: IOMMU: Disable device assignment without interrupt remapping
IOMMU interrupt remapping support provides a further layer of isolation for device assignment by preventing arbitrary interrupt block DMA writes by a malicious guest from reaching the host. By default, we should require that the platform provides interrupt remapping support, with an opt-in mechanism for existing behavior. Both AMD IOMMU and Intel VT-d2 hardware support interrupt remapping, however we currently only have software support on the Intel side. Users wishing to re-enable device assignment when interrupt remapping is not supported on the platform can use the "allow_unsafe_assigned_interrupts=1" module option. [avi: break long lines] Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
1 parent 4f02264 commit 3f68b03

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

‎virt/kvm/iommu.c‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
#include <linux/iommu.h>
3131
#include <linux/intel-iommu.h>
3232

33+
static int allow_unsafe_assigned_interrupts;
34+
module_param_named(allow_unsafe_assigned_interrupts,
35+
allow_unsafe_assigned_interrupts, bool, S_IRUGO | S_IWUSR);
36+
MODULE_PARM_DESC(allow_unsafe_assigned_interrupts,
37+
"Enable device assignment on platforms without interrupt remapping support.");
38+
3339
static int kvm_iommu_unmap_memslots(struct kvm *kvm);
3440
static void kvm_iommu_put_pages(struct kvm *kvm,
3541
gfn_t base_gfn, unsigned long npages);
@@ -231,6 +237,18 @@ int kvm_iommu_map_guest(struct kvm *kvm)
231237
if (!kvm->arch.iommu_domain)
232238
return -ENOMEM;
233239

240+
if (!allow_unsafe_assigned_interrupts &&
241+
!iommu_domain_has_cap(kvm->arch.iommu_domain,
242+
IOMMU_CAP_INTR_REMAP)) {
243+
printk(KERN_WARNING "%s: No interrupt remapping support,"
244+
" disallowing device assignment."
245+
" Re-enble with \"allow_unsafe_assigned_interrupts=1\""
246+
" module option.\n", __func__);
247+
iommu_domain_free(kvm->arch.iommu_domain);
248+
kvm->arch.iommu_domain = NULL;
249+
return -EPERM;
250+
}
251+
234252
r = kvm_iommu_map_memslots(kvm);
235253
if (r)
236254
goto out_unmap;

0 commit comments

Comments
 (0)