Skip to contentSkip to conversation

intel-iommu: Check IOAPIC's Trigger Mode against the one in IRTE

PATCH In review Feng Wu 3 participants 9 messages Sep 21, 2016 – Sep 28, 2016

lore
Share & tools
lore

Feng Wu

author
#0 lore raw

PATCH 1/1 intel-iommu: Check IOAPIC's Trigger Mode against the one in IRTE

The Trigger Mode field of IOAPIC must match the Trigger Mode in the IRTE according to VT-d Spec 5.1.5.1.

---
 hw/i386/intel_iommu.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
hw/i386/intel_iommu.c +12 -0
index 28c31a2..f32ad5c 100644
@@ -27,6 +27,7 @@
 #include "hw/pci/pci.h"
 #include "hw/pci/pci_bus.h"
 #include "hw/i386/pc.h"
+#include "hw/i386/apic-msidef.h"
 #include "hw/boards.h"
 #include "hw/i386/x86-iommu.h"
 #include "hw/pci-host/q35.h"
@@ -2203,6 +2204,8 @@ static int vtd_interrupt_remap_msi(IntelIOMMUState *iommu,
         }
     } else {
         uint8_t vector = origin->data & 0xff;
+        uint8_t trigger_mode = (origin->data >> MSI_DATA_TRIGGER_SHIFT) & 0x1;
+
         VTD_DPRINTF(IR, "received IOAPIC interrupt");
         /* IOAPIC entry vector should be aligned with IRTE vector
          * (see vt-d spec 5.1.5.1). */
@@ -2211,6 +2214,15 @@ static int vtd_interrupt_remap_msi(IntelIOMMUState *iommu,
                         "entry: %d, IRTE: %d, index: %d",
                         vector, irq.vector, index);
         }
+
+        /* The Trigger Mode field must match the Trigger Mode in the IRTE.
+         * (see vt-d spec 5.1.5.1). */
+        if (trigger_mode != irq.trigger_mode) {
+            VTD_DPRINTF(GENERAL, "IOAPIC trigger mode inconsistent: "
+                        "entry: %u, IRTE: %u, index: %d",
+                        trigger_mode, irq.trigger_mode, index);
+        }
+
     }
 
     /*
Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Feng Wu

The Trigger Mode field of IOAPIC must match the Trigger Mode in the IRTE according to VT-d Spec 5.1.5.1.

Could I ask why we want this now? I know that both vector and trigger mode should not be aligned in current kernel. However haven't go deeper yet.

Thanks,

-- peterx

author
#2 lore raw
Quoted 14 lines

-----Original Message-----
From: Peter Xu [mailto:[email protected]]
Sent: Wednesday, September 21, 2016 1:45 PM
To: Wu, Feng <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH] intel-iommu: Check IOAPIC's Trigger Mode against the one in IRTE

Quoted 3 lines · Feng Wu

The Trigger Mode field of IOAPIC must match the Trigger Mode in the IRTE according to VT-d Spec 5.1.5.1.

Quoted 6 lines
Quoted 1 line

Could I ask why we want this now? I know that both vector and trigger mode should not be aligned in current kernel.

Oh, I don't aware of this. I was just looking at the code and found seems the Spec says we need to check it. So I added the check. :)

Thanks,
Feng

Quoted 6 lines

However haven't go
deeper yet.

Thanks,

-- peterx

#3 lore raw
Quoted 16 lines · Feng
Quoted 16 lines

-----Original Message-----
From: Peter Xu [mailto:[email protected]]
Sent: Wednesday, September 21, 2016 1:45 PM
To: Wu, Feng <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH] intel-iommu: Check IOAPIC's Trigger Mode against the one in IRTE

Quoted 4 lines · Feng Wu

The Trigger Mode field of IOAPIC must match the Trigger Mode in the IRTE according to VT-d Spec 5.1.5.1.

Quoted 7 lines
Quoted 4 lines

Could I ask why we want this now? I know that both vector and trigger mode should not be aligned in current kernel.

Oh, I don't aware of this. I was just looking at the code and found seems the Spec says we need to check it. So I added the check. :)

Yeah, that's good enough a reason. :-)

-- peterx

author
#4 lore raw
Quoted 30 lines

-----Original Message-----
From: Peter Xu [mailto:[email protected]]
Sent: Wednesday, September 21, 2016 2:12 PM
To: Wu, Feng <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH] intel-iommu: Check IOAPIC's Trigger Mode against the one in IRTE

Quoted 8 lines · Feng
Quoted 8 lines

-----Original Message-----
From: Peter Xu [mailto:[email protected]]
Sent: Wednesday, September 21, 2016 1:45 PM
To: Wu, Feng <[email protected]>
Cc: [email protected]; [email protected]
Subject: Re: [Qemu-devel] [PATCH] intel-iommu: Check IOAPIC's Trigger

Mode

Quoted 10 lines
Quoted 10 lines

against the one in IRTE

Quoted 4 lines · Feng Wu

The Trigger Mode field of IOAPIC must match the Trigger Mode in the IRTE according to VT-d Spec 5.1.5.1.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Could I ask why we want this now? I know that both vector and trigger mode should not be aligned in current kernel.

Oh, I don't aware of this. I was just looking at the code and found seems the Spec says we need to check it. So I added the check. :)

Yeah, that's good enough a reason. :-)

Thanks for your review :)

Thanks,
Feng

Quoted 2 lines

-- peterx

author
#5 lore raw
In reply to Feng Wu

Hi Paolo,

Quoted 10 lines

-----Original Message-----
From: Wu, Feng
Sent: Thursday, September 22, 2016 12:12 AM
To: [email protected]
Cc: [email protected]; Wu, Feng <[email protected]>
Subject: [PATCH] intel-iommu: Check IOAPIC's Trigger Mode against the one in IRTE

The Trigger Mode field of IOAPIC must match the Trigger Mode in the IRTE according to VT-d Spec 5.1.5.1.

Any comments about this patch? Thanks a lot!

Thanks,
Feng

Quoted 47 lines
---
 hw/i386/intel_iommu.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
hw/i386/intel_iommu.c +3 -0
index 28c31a2..f32ad5c 100644
@@ -27,6 +27,7 @@
 #include "hw/pci/pci.h"
 #include "hw/pci/pci_bus.h"
 #include "hw/i386/pc.h"
+#include "hw/i386/apic-msidef.h"
 #include "hw/boards.h"
 #include "hw/i386/x86-iommu.h"
 #include "hw/pci-host/q35.h"
@@ -2203,6 +2204,8 @@ static int vtd_interrupt_remap_msi(IntelIOMMUState
 *iommu,
         }
     } else {
         uint8_t vector = origin->data & 0xff;
+        uint8_t trigger_mode = (origin->data >> MSI_DATA_TRIGGER_SHIFT) & 0x1;
+
         VTD_DPRINTF(IR, "received IOAPIC interrupt");
         /* IOAPIC entry vector should be aligned with IRTE vector

* (see vt-d spec 5.1.5.1). */

hw/i386/intel_iommu.c +9 -0
@@ -2211,6 +2214,15 @@ static int
 vtd_interrupt_remap_msi(IntelIOMMUState *iommu,
                         "entry: %d, IRTE: %d, index: %d",
                         vector, irq.vector, index);
         }
+
+        /* The Trigger Mode field must match the Trigger Mode in the IRTE.
+         * (see vt-d spec 5.1.5.1). */
+        if (trigger_mode != irq.trigger_mode) {
+            VTD_DPRINTF(GENERAL, "IOAPIC trigger mode inconsistent: "
+                        "entry: %u, IRTE: %u, index: %d",
+                        trigger_mode, irq.trigger_mode, index);
+        }
+
     }
 
     /*

--
1.9.1

#6 lore raw
Quoted 11 lines · Feng

Hi Paolo,

Quoted 8 lines

-----Original Message-----
From: Wu, Feng
Sent: Thursday, September 22, 2016 12:12 AM
To: [email protected]
Cc: [email protected]; Wu, Feng <[email protected]>
Subject: [PATCH] intel-iommu: Check IOAPIC's Trigger Mode against the one in IRTE

Quoted 4 lines
Quoted 2 lines

The Trigger Mode field of IOAPIC must match the Trigger Mode in the IRTE according to VT-d Spec 5.1.5.1.

Any comments about this patch? Thanks a lot!

Hi, I am not the maintainer of the IOMMU emulation code. CCing mst and Peter.

Thanks,

Paolo

Quoted 47 lines
Quoted 46 lines
---
 hw/i386/intel_iommu.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
hw/i386/intel_iommu.c +3 -0
index 28c31a2..f32ad5c 100644
@@ -27,6 +27,7 @@
 #include "hw/pci/pci.h"
 #include "hw/pci/pci_bus.h"
 #include "hw/i386/pc.h"
+#include "hw/i386/apic-msidef.h"
 #include "hw/boards.h"
 #include "hw/i386/x86-iommu.h"
 #include "hw/pci-host/q35.h"
@@ -2203,6 +2204,8 @@ static int vtd_interrupt_remap_msi(IntelIOMMUState
 *iommu,
         }
     } else {
         uint8_t vector = origin->data & 0xff;
+        uint8_t trigger_mode = (origin->data >> MSI_DATA_TRIGGER_SHIFT) & 0x1;
+
         VTD_DPRINTF(IR, "received IOAPIC interrupt");
         /* IOAPIC entry vector should be aligned with IRTE vector

* (see vt-d spec 5.1.5.1). */

hw/i386/intel_iommu.c +9 -0
@@ -2211,6 +2214,15 @@ static int
 vtd_interrupt_remap_msi(IntelIOMMUState *iommu,
                         "entry: %d, IRTE: %d, index: %d",
                         vector, irq.vector, index);
         }
+
+        /* The Trigger Mode field must match the Trigger Mode in the IRTE.
+         * (see vt-d spec 5.1.5.1). */
+        if (trigger_mode != irq.trigger_mode) {
+            VTD_DPRINTF(GENERAL, "IOAPIC trigger mode inconsistent: "
+                        "entry: %u, IRTE: %u, index: %d",
+                        trigger_mode, irq.trigger_mode, index);
+        }
+
     }
 
     /*

--
1.9.1

#7 lore raw
Quoted 14 lines · Paolo Bonzini
Quoted 11 lines · Feng

Hi Paolo,

Quoted 8 lines

-----Original Message-----
From: Wu, Feng
Sent: Thursday, September 22, 2016 12:12 AM
To: [email protected]
Cc: [email protected]; Wu, Feng <[email protected]>
Subject: [PATCH] intel-iommu: Check IOAPIC's Trigger Mode against the one in IRTE

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

The Trigger Mode field of IOAPIC must match the Trigger Mode in the IRTE according to VT-d Spec 5.1.5.1.

Any comments about this patch? Thanks a lot!

Hi, I am not the maintainer of the IOMMU emulation code. CCing mst and Peter.

I've provided my r-b already. :)

-- peterx

author
#8 lore raw
Quoted 30 lines

-----Original Message-----
From: Peter Xu [mailto:[email protected]]
Sent: Wednesday, September 28, 2016 6:35 PM
To: Paolo Bonzini <[email protected]>
Cc: Wu, Feng <[email protected]>; [email protected]; Michael S. Tsirkin <[email protected]>
Subject: Re: [PATCH] intel-iommu: Check IOAPIC's Trigger Mode against the one in IRTE

Quoted 6 lines · Paolo Bonzini
Quoted 3 lines · Feng

Hi Paolo,

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

-----Original Message-----
From: Wu, Feng
Sent: Thursday, September 22, 2016 12:12 AM
To: [email protected]
Cc: [email protected]; Wu, Feng <[email protected]>
Subject: [PATCH] intel-iommu: Check IOAPIC's Trigger Mode against the

one in

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

IRTE

The Trigger Mode field of IOAPIC must match the Trigger Mode in the IRTE according to VT-d Spec 5.1.5.1.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Any comments about this patch? Thanks a lot!

Hi, I am not the maintainer of the IOMMU emulation code. CCing mst and Peter.

I've provided my r-b already. :)

Okay, thanks to you guys!

Thanks,
Feng

Quoted 2 lines

-- peterx