diff mbox

[v6,00/26] IOMMU: Enable interrupt remapping for Intel IOMMU

Message ID 20160509171525.GA9224@potion
State New
Headers show

Commit Message

Radim Krčmář May 9, 2016, 5:15 p.m. UTC
2016-05-05 11:25+0800, Peter Xu:
> Hi, all,
> 
> This is v6 for Intel IOMMU IR support. This series introduced quite
> a few new patches based on v5. Sorry for that (Yes, Jan is
> contributing to it as well, though most of which are really good
> ideas for me :). Hopefully we can get its convergence in this
> version.
> 
> To make the review easier, I tried to keep all the existing patches
> and indexes (also, this is easier for me too to do the
> modifications, and logically I feel this make more sense and clean,
> please let me know if I am wrong). Patches 1-18 are v5 patches, and
> patches 19-26 are newly added patches.
> 
> All the new patches may need more review, many of them are outside
> Intel IOMMU scope, and touching other part of codes, which I am
> still not very sure about.
> 
> Testing is only covering basic smoke test for the following matrix:
> 
> - IR enabled/disable
> - kernel irqchip off/split
> - network device: tap with/without vhost, e1000

I noticed a bug with RHEL7 linux guest, 3.10.0-390.el7.x86_64.
Kernel complains about queued invalidation and fails to boot:

  virtio-pci 0000:00:01.0: virtio_pci: leaving for legacy driver
  DMAR-IR: Requested mask 1 exceeds the max invalidation handle mask value 0
  DMAR-IR: Unable to allocate 2 IRTE for PCI 0000:00:01.0
  DMAR-IR: Requested mask 1 exceeds the max invalidation handle mask value 0
  DMAR-IR: Unable to allocate 2 IRTE for PCI 0000:00:01.0
  dracut-initqueue[263]: Warning: dracut-initqueue timeout - starting timeout scripts
  dracut-initqueue[263]: Warning: Could not boot.
  dracut-initqueue[263]: Warning: /dev/mapper/rhel-root does not exist
  dracut-initqueue[263]: Warning: /dev/rhel/root does not exist
  dracut-initqueue[263]: Warning: /dev/rhel/swap does not exist

The patch below helps,
---8<---
From: =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= <rkrcmar@redhat.com>
Date: Mon, 9 May 2016 19:04:56 +0200
Subject: [PATCH] intel_iommu: support all masks in interrupt entry cache
 invalidation

Linux guests do not gracefully handle cases when the invalidation mask
they wanted is not supported, probably because real hardware always
allowed all.

We can just say that all 16 masks are supported, because both
ioapic_iec_notifier and kvm_update_msi_routes_all invalidate all caches.

Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
 hw/i386/intel_iommu.c          | 2 +-
 hw/i386/intel_iommu_internal.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

Comments

Radim Krčmář May 9, 2016, 8:37 p.m. UTC | #1
2016-05-09 19:15+0200, Radim Krčmář:
> From: =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= <rkrcmar@redhat.com>
> Date: Mon, 9 May 2016 19:04:56 +0200
> Subject: [PATCH] intel_iommu: support all masks in interrupt entry cache
>  invalidation
> 
> Linux guests do not gracefully handle cases when the invalidation mask
> they wanted is not supported, probably because real hardware always
> allowed all.
> 
> We can just say that all 16 masks are supported, because both
> ioapic_iec_notifier and kvm_update_msi_routes_all invalidate all caches.
> 
> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
> ---
> diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
> @@ -2359,7 +2359,7 @@ static void vtd_init(IntelIOMMUState *s)
>      s->ecap = VTD_ECAP_QI | VTD_ECAP_IRO;
>  
>      if (ms->iommu_intr) {
> -        s->ecap |= VTD_ECAP_IR | VTD_ECAP_EIM;
> +        s->ecap |= VTD_ECAP_IR | VTD_ECAP_EIM | VTD_ECAP_MHVM;

Eh, I really cannot spell ... this one should read VTD_ECAP_MHMV.
(... or compile after a last-second renaming.)

> diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h
> @@ -186,6 +186,7 @@
> +#define VTD_ECAP_MHMV               (15ULL << 20)
Peter Xu May 10, 2016, 6:16 a.m. UTC | #2
On Mon, May 09, 2016 at 10:37:24PM +0200, Radim Krčmář wrote:
> 2016-05-09 19:15+0200, Radim Krčmář:
> > From: =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= <rkrcmar@redhat.com>
> > Date: Mon, 9 May 2016 19:04:56 +0200
> > Subject: [PATCH] intel_iommu: support all masks in interrupt entry cache
> >  invalidation
> > 
> > Linux guests do not gracefully handle cases when the invalidation mask
> > they wanted is not supported, probably because real hardware always
> > allowed all.
> > 
> > We can just say that all 16 masks are supported, because both
> > ioapic_iec_notifier and kvm_update_msi_routes_all invalidate all caches.
> > 
> > Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
> > ---
> > diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
> > @@ -2359,7 +2359,7 @@ static void vtd_init(IntelIOMMUState *s)
> >      s->ecap = VTD_ECAP_QI | VTD_ECAP_IRO;
> >  
> >      if (ms->iommu_intr) {
> > -        s->ecap |= VTD_ECAP_IR | VTD_ECAP_EIM;
> > +        s->ecap |= VTD_ECAP_IR | VTD_ECAP_EIM | VTD_ECAP_MHVM;
> 
> Eh, I really cannot spell ... this one should read VTD_ECAP_MHMV.
> (... or compile after a last-second renaming.)

Thanks, Radim. If you would not mind, I'll pick this one up and put
it in v7. :)

-- peterx
diff mbox

Patch

diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index d10064289551..be3647f6b006 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -2359,7 +2359,7 @@  static void vtd_init(IntelIOMMUState *s)
     s->ecap = VTD_ECAP_QI | VTD_ECAP_IRO;
 
     if (ms->iommu_intr) {
-        s->ecap |= VTD_ECAP_IR | VTD_ECAP_EIM;
+        s->ecap |= VTD_ECAP_IR | VTD_ECAP_EIM | VTD_ECAP_MHVM;
     }
 
     vtd_reset_context_cache(s);
diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h
index 72b011492755..0829a5064f2c 100644
--- a/hw/i386/intel_iommu_internal.h
+++ b/hw/i386/intel_iommu_internal.h
@@ -186,6 +186,7 @@ 
 /* Interrupt Remapping support */
 #define VTD_ECAP_IR                 (1ULL << 3)
 #define VTD_ECAP_EIM                (1ULL << 4)
+#define VTD_ECAP_MHMV               (15ULL << 20)
 
 /* CAP_REG */
 /* (offset >> 4) << 24 */