Index: /trunk/src/VBox/Devices/Bus/DevPciIch9.cpp
===================================================================
--- /trunk/src/VBox/Devices/Bus/DevPciIch9.cpp	(revision 36662)
+++ /trunk/src/VBox/Devices/Bus/DevPciIch9.cpp	(revision 36663)
@@ -891,12 +891,12 @@
 
     rc = MsiInit(pPciDev, pMsiReg);
-    if (rc != VINF_SUCCESS)
+    if (RT_FAILURE(rc))
         return rc;
 
     rc = MsixInit(pPciDev->Int.s.CTX_SUFF(pBus)->CTX_SUFF(pPciHlp), pPciDev, pMsiReg);
-    if (rc != VINF_SUCCESS)
+    if (RT_FAILURE(rc))
         return rc;
 
-    return rc;
+    return VINF_SUCCESS;
 }
 
@@ -1874,8 +1874,8 @@
     if ((u32Address + len) > 256 && (u32Address + len) < 4096)
     {
-        AssertMsgReturn(false, ("Read from extended registers falled back to generic code\n"), 0);
-    }
-
-    AssertMsgReturn(u32Address + len <= 256, ("Read after end of PCI config space\n"),
+        AssertMsgReturn(false, ("Read from extended registers fallen back to generic code\n"), 0);
+    }
+
+    AssertMsgReturn(u32Address + len <= 256, ("Read after the end of PCI config space\n"),
                     0);
     if (   pciDevIsMsiCapable(aDev)
@@ -1956,5 +1956,5 @@
     if ((u32Address + len) > 256 && (u32Address + len) < 4096)
     {
-        AssertMsgReturnVoid(false, ("Write to extended registers falled back to generic code\n"));
+        AssertMsgReturnVoid(false, ("Write to extended registers fallen back to generic code\n"));
     }
 
Index: /trunk/src/VBox/Devices/Bus/MsiCommon.cpp
===================================================================
--- /trunk/src/VBox/Devices/Bus/MsiCommon.cpp	(revision 36662)
+++ /trunk/src/VBox/Devices/Bus/MsiCommon.cpp	(revision 36663)
@@ -102,5 +102,5 @@
 }
 
-
+#ifdef IN_RING3
 void     MsiPciConfigWrite(PPDMDEVINS pDevIns, PCPDMPCIHLP pPciHlp, PPCIDEVICE pDev, uint32_t u32Address, uint32_t val, unsigned len)
 {
@@ -214,9 +214,11 @@
 }
 
-
 int MsiInit(PPCIDEVICE pDev, PPDMMSIREG pMsiReg)
 {
     if (pMsiReg->cMsiVectors == 0)
          return VINF_SUCCESS;
+
+    /* We cannot init MSI on raw devices yet. */
+    Assert(!pciDevIsPassthrough(pDev));
 
     uint16_t   cVectors    = pMsiReg->cMsiVectors;
@@ -261,4 +263,6 @@
 }
 
+#endif /* IN_RING3 */
+
 
 bool     MsiIsEnabled(PPCIDEVICE pDev)
Index: /trunk/src/VBox/Devices/Bus/MsiCommon.h
===================================================================
--- /trunk/src/VBox/Devices/Bus/MsiCommon.h	(revision 36662)
+++ /trunk/src/VBox/Devices/Bus/MsiCommon.h	(revision 36663)
@@ -28,6 +28,8 @@
 #endif
 
+#ifdef IN_RING3
 /* Init MSI support in the device. */
 int      MsiInit(PPCIDEVICE pDev, PPDMMSIREG pMsiReg);
+#endif
 
 /* If MSI is enabled, so that MSINotify() shall be used for notifications.  */
@@ -37,11 +39,12 @@
 void     MsiNotify(PPDMDEVINS pDevIns, PCPDMPCIHLP pPciHlp, PPCIDEVICE pDev, int iVector, int iLevel);
 
+#ifdef IN_RING3
 /* PCI config space accessors for MSI registers */
 void     MsiPciConfigWrite(PPDMDEVINS pDevIns, PCPDMPCIHLP pPciHlp, PPCIDEVICE pDev, uint32_t u32Address, uint32_t val, unsigned len);
 uint32_t MsiPciConfigRead (PPDMDEVINS pDevIns, PPCIDEVICE pDev, uint32_t u32Address, unsigned len);
+#endif
 
-
+#ifdef IN_RING3
 /* Init MSI-X support in the device. */
-#ifdef IN_RING3
 int      MsixInit(PCPDMPCIHLP pPciHlp, PPCIDEVICE pDev, PPDMMSIREG pMsiReg);
 #endif
@@ -53,5 +56,7 @@
 void     MsixNotify(PPDMDEVINS pDevIns, PCPDMPCIHLP pPciHlp, PPCIDEVICE pDev, int iVector, int iLevel);
 
+#ifdef IN_RING3
 /* PCI config space accessors for MSI-X */
 void     MsixPciConfigWrite(PPDMDEVINS pDevIns, PCPDMPCIHLP pPciHlp, PPCIDEVICE pDev, uint32_t u32Address, uint32_t val, unsigned len);
 uint32_t MsixPciConfigRead (PPDMDEVINS pDevIns, PPCIDEVICE pDev, uint32_t u32Address, unsigned len);
+#endif
Index: /trunk/src/VBox/Devices/Bus/MsixCommon.cpp
===================================================================
--- /trunk/src/VBox/Devices/Bus/MsixCommon.cpp	(revision 36662)
+++ /trunk/src/VBox/Devices/Bus/MsixCommon.cpp	(revision 36663)
@@ -167,5 +167,8 @@
          return VINF_SUCCESS;
 
-    uint16_t   cVectors    = pMsiReg->cMsixVectors;
+     /* We cannot init MSI-X on raw devices yet. */
+    Assert(!pciDevIsPassthrough(pDev));
+
+    uint16_t   cVectors    = pMsiReg->cMsixVectors;   
     uint8_t    iCapOffset  = pMsiReg->iMsixCapOffset;
     uint8_t    iNextOffset = pMsiReg->iMsixNextOffset;
@@ -173,16 +176,26 @@
 
     if (cVectors > VBOX_MSIX_MAX_ENTRIES)
+    {
+        AssertMsgFailed(("Too many MSI-X vectors: %d\n", cVectors));
         return VERR_TOO_MUCH_DATA;
+    }
 
     if (iBar > 5)
+    {
+        AssertMsgFailed(("Using wrong BAR for MSI-X: %d\n", iBar));
         return VERR_INVALID_PARAMETER;
+    }
 
     Assert(iCapOffset != 0 && iCapOffset < 0xff && iNextOffset < 0xff);
 
-    int rc;
-
-    rc = PDMDevHlpPCIIORegionRegister (pDev->pDevIns, iBar, 0x1000, PCI_ADDRESS_SPACE_MEM, msixMap);
-    if (RT_FAILURE (rc))
-        return rc;
+    int rc = VINF_SUCCESS;
+
+    /* If device is passthrough, BAR is registered using common mechanism. */
+    if (!pciDevIsPassthrough(pDev))
+    {
+        rc = PDMDevHlpPCIIORegionRegister (pDev->pDevIns, iBar, 0x1000, PCI_ADDRESS_SPACE_MEM, msixMap);
+        if (RT_FAILURE (rc))
+            return rc;
+    }
 
     pDev->Int.s.u8MsixCapOffset = iCapOffset;
