Skip to contentSkip to conversation

AMD IOMMU: fail if there is no southbridge IO-APIC

PATCH In review Jan Beulich 4 participants 10 messages Feb 7, 2014 – Feb 10, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 AMD IOMMU: fail if there is no southbridge IO-APIC

... but interrupt remapping is requested (with per-device remapping tables). Without it, the timer interrupt is usually not working.

Inspired by Linux'es "iommu/amd: Work around wrong IOAPIC device-id in IVRS table" (commit c2ff5cf5294bcbd7fa50f7d860e90a66db7e5059) by Joerg Roedel <[email protected]>.

xen/drivers/passthrough/amd/iommu_acpi.c +18 -2
@@ -984,6 +984,7 @@ static int __init parse_ivrs_table(struc
     const struct acpi_ivrs_header *ivrs_block;
     unsigned long length;
     unsigned int apic;
+    bool_t sb_ioapic = !iommu_intremap;
     int error = 0;
 
     BUG_ON(!table);
@@ -1017,8 +1018,15 @@ static int __init parse_ivrs_table(struc
     /* Each IO-APIC must have been mentioned in the table. */
     for ( apic = 0; !error && iommu_intremap && apic < nr_ioapics; ++apic )
     {
-        if ( !nr_ioapic_entries[apic] ||
-             ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
+        if ( !nr_ioapic_entries[apic] )
+            continue;
+
+        if ( !ioapic_sbdf[IO_APIC_ID(apic)].seg &&
+             /* SB IO-APIC is always on this device in AMD systems. */
+             ioapic_sbdf[IO_APIC_ID(apic)].bdf == PCI_BDF(0, 0x14, 0) )
+            sb_ioapic = 1;
+
+        if ( ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
             continue;
 
         if ( !test_bit(IO_APIC_ID(apic), ioapic_cmdline) )
@@ -1041,6 +1049,14 @@ static int __init parse_ivrs_table(struc
         }
     }
 
+    if ( !error && !sb_ioapic )
+    {
+        if ( amd_iommu_perdev_intremap )
+            error = -ENXIO;
+        printk("%sNo southbridge IO-APIC found in IVRS table\n",
+               amd_iommu_perdev_intremap ? XENLOG_ERR : XENLOG_WARNING);
+    }
+
     return error;
 }
 

AMD IOMMU: fail if there is no southbridge IO-APIC

... but interrupt remapping is requested (with per-device remapping tables). Without it, the timer interrupt is usually not working.

Inspired by Linux'es "iommu/amd: Work around wrong IOAPIC device-id in IVRS table" (commit c2ff5cf5294bcbd7fa50f7d860e90a66db7e5059) by Joerg Roedel <[email protected]>.

xen/drivers/passthrough/amd/iommu_acpi.c +18 -2
@@ -984,6 +984,7 @@ static int __init parse_ivrs_table(struc
     const struct acpi_ivrs_header *ivrs_block;
     unsigned long length;
     unsigned int apic;
+    bool_t sb_ioapic = !iommu_intremap;
     int error = 0;
 
     BUG_ON(!table);
@@ -1017,8 +1018,15 @@ static int __init parse_ivrs_table(struc
     /* Each IO-APIC must have been mentioned in the table. */
     for ( apic = 0; !error && iommu_intremap && apic < nr_ioapics; ++apic )
     {
-        if ( !nr_ioapic_entries[apic] ||
-             ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
+        if ( !nr_ioapic_entries[apic] )
+            continue;
+
+        if ( !ioapic_sbdf[IO_APIC_ID(apic)].seg &&
+             /* SB IO-APIC is always on this device in AMD systems. */
+             ioapic_sbdf[IO_APIC_ID(apic)].bdf == PCI_BDF(0, 0x14, 0) )
+            sb_ioapic = 1;
+
+        if ( ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
             continue;
 
         if ( !test_bit(IO_APIC_ID(apic), ioapic_cmdline) )
@@ -1041,6 +1049,14 @@ static int __init parse_ivrs_table(struc
         }
     }
 
+    if ( !error && !sb_ioapic )
+    {
+        if ( amd_iommu_perdev_intremap )
+            error = -ENXIO;
+        printk("%sNo southbridge IO-APIC found in IVRS table\n",
+               amd_iommu_perdev_intremap ? XENLOG_ERR : XENLOG_WARNING);
+    }
+
     return error;
 }
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Jan Beulich

... but interrupt remapping is requested (with per-device remapping tables). Without it, the timer interrupt is usually not working.

Inspired by Linux'es "iommu/amd: Work around wrong IOAPIC device-id in IVRS table" (commit c2ff5cf5294bcbd7fa50f7d860e90a66db7e5059) by Joerg Roedel <[email protected]>.

Quoted 49 lines
xen/drivers/passthrough/amd/iommu_acpi.c +18 -2
@@ -984,6 +984,7 @@ static int __init parse_ivrs_table(struc
     const struct acpi_ivrs_header *ivrs_block;
     unsigned long length;
     unsigned int apic;
+    bool_t sb_ioapic = !iommu_intremap;
     int error = 0;
 
     BUG_ON(!table);
@@ -1017,8 +1018,15 @@ static int __init parse_ivrs_table(struc
     /* Each IO-APIC must have been mentioned in the table. */
     for ( apic = 0; !error && iommu_intremap && apic < nr_ioapics; ++apic )
     {
-        if ( !nr_ioapic_entries[apic] ||
-             ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
+        if ( !nr_ioapic_entries[apic] )
+            continue;
+
+        if ( !ioapic_sbdf[IO_APIC_ID(apic)].seg &&
+             /* SB IO-APIC is always on this device in AMD systems. */
+             ioapic_sbdf[IO_APIC_ID(apic)].bdf == PCI_BDF(0, 0x14, 0) )
+            sb_ioapic = 1;
+
+        if ( ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
             continue;
 
         if ( !test_bit(IO_APIC_ID(apic), ioapic_cmdline) )
@@ -1041,6 +1049,14 @@ static int __init parse_ivrs_table(struc
         }
     }
 
+    if ( !error && !sb_ioapic )
+    {
+        if ( amd_iommu_perdev_intremap )
+            error = -ENXIO;
+        printk("%sNo southbridge IO-APIC found in IVRS table\n",
+               amd_iommu_perdev_intremap ? XENLOG_ERR : XENLOG_WARNING);
+    }
+
     return error;
 }
 
Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw
In reply to Jan Beulich
Quoted 29 lines · Jan Beulich

... but interrupt remapping is requested (with per-device remapping tables). Without it, the timer interrupt is usually not working.

Inspired by Linux'es "iommu/amd: Work around wrong IOAPIC device-id in IVRS table" (commit c2ff5cf5294bcbd7fa50f7d860e90a66db7e5059) by Joerg Roedel <[email protected]>.

xen/drivers/passthrough/amd/iommu_acpi.c +3 -2
@@ -984,6 +984,7 @@ static int __init parse_ivrs_table(struc
      const struct acpi_ivrs_header *ivrs_block;
      unsigned long length;
      unsigned int apic;
+    bool_t sb_ioapic = !iommu_intremap;
      int error = 0;
 
      BUG_ON(!table);
@@ -1017,8 +1018,15 @@ static int __init parse_ivrs_table(struc
      /* Each IO-APIC must have been mentioned in the table. */
      for ( apic = 0; !error && iommu_intremap && apic < nr_ioapics; ++apic )
      {
-        if ( !nr_ioapic_entries[apic] ||
-             ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
+        if ( !nr_ioapic_entries[apic] )
+            continue;

xen/drivers/passthrough/amd/iommu_acpi.c static int __init parse_ivrs_table(struc · line 1032

Quoted 10 lines
xen/drivers/passthrough/amd/iommu_acpi.c +7 -0
+
+        if ( !ioapic_sbdf[IO_APIC_ID(apic)].seg &&
+             /* SB IO-APIC is always on this device in AMD systems. */
+             ioapic_sbdf[IO_APIC_ID(apic)].bdf == PCI_BDF(0, 0x14, 0) )
+            sb_ioapic = 1;
+
+        if ( ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
              continue;
 
          if ( !test_bit(IO_APIC_ID(apic), ioapic_cmdline) )

I don't know whether 0:14:0 is set in stone, I don't remember seeing anywhere that this is architectural.

In the (unlikely) event that it is moved somewhere else will the user be able to overwrite where it is? Do you think that sb_ioapic may need to be set to true if appropriate bit is set in ioapic_cmdline?

-boris

Quoted 20 lines
xen/drivers/passthrough/amd/iommu_acpi.c +8 -0
@@ -1041,6 +1049,14 @@ static int __init parse_ivrs_table(struc
          }
      }
 
+    if ( !error && !sb_ioapic )
+    {
+        if ( amd_iommu_perdev_intremap )
+            error = -ENXIO;
+        printk("%sNo southbridge IO-APIC found in IVRS table\n",
+               amd_iommu_perdev_intremap ? XENLOG_ERR : XENLOG_WARNING);
+    }
+
      return error;
  }
 
Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw
Quoted 45 lines
Quoted 1 line
Quoted 1 line · Boris Ostrovsky
Quoted 29 lines · Jan Beulich

... but interrupt remapping is requested (with per-device remapping tables). Without it, the timer interrupt is usually not working.

Inspired by Linux'es "iommu/amd: Work around wrong IOAPIC device-id in IVRS table" (commit c2ff5cf5294bcbd7fa50f7d860e90a66db7e5059) by Joerg Roedel <[email protected]>.

xen/drivers/passthrough/amd/iommu_acpi.c +3 -2
@@ -984,6 +984,7 @@ static int __init parse_ivrs_table(struc
      const struct acpi_ivrs_header *ivrs_block;
      unsigned long length;
      unsigned int apic;
+    bool_t sb_ioapic = !iommu_intremap;
      int error = 0;
 
      BUG_ON(!table);
@@ -1017,8 +1018,15 @@ static int __init parse_ivrs_table(struc
      /* Each IO-APIC must have been mentioned in the table. */
      for ( apic = 0; !error && iommu_intremap && apic < nr_ioapics; ++apic )
      {
-        if ( !nr_ioapic_entries[apic] ||
-             ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
+        if ( !nr_ioapic_entries[apic] )
+            continue;

xen/drivers/passthrough/amd/iommu_acpi.c static int __init parse_ivrs_table(struc · line 1032

Quoted 10 lines
xen/drivers/passthrough/amd/iommu_acpi.c +7 -0
+
+        if ( !ioapic_sbdf[IO_APIC_ID(apic)].seg &&
+             /* SB IO-APIC is always on this device in AMD systems. */
+             ioapic_sbdf[IO_APIC_ID(apic)].bdf == PCI_BDF(0, 0x14, 0) )
+            sb_ioapic = 1;
+
+        if ( ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
              continue;
 
          if ( !test_bit(IO_APIC_ID(apic), ioapic_cmdline) )

I don't know whether 0:14:0 is set in stone, I don't remember seeing anywhere that this is architectural.

Quoted 4 lines

In the (unlikely) event that it is moved somewhere else will the user be able to overwrite where it is? Do you
think that sb_ioapic may need to be set to true if appropriate bit is set in ioapic_cmdline?

These are question you'd need to ask to Jörg, the author of the original Linux side patch. I took as a precondition here that he knew what he was doing.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#4 lore raw
Quoted 44 lines · Jan Beulich
Quoted 44 lines
Quoted 1 line
Quoted 1 line · Boris Ostrovsky
Quoted 29 lines · Jan Beulich

... but interrupt remapping is requested (with per-device remapping tables). Without it, the timer interrupt is usually not working.

Inspired by Linux'es "iommu/amd: Work around wrong IOAPIC device-id in IVRS table" (commit c2ff5cf5294bcbd7fa50f7d860e90a66db7e5059) by Joerg Roedel <[email protected]>.

xen/drivers/passthrough/amd/iommu_acpi.c +3 -2
@@ -984,6 +984,7 @@ static int __init parse_ivrs_table(struc
       const struct acpi_ivrs_header *ivrs_block;
       unsigned long length;
       unsigned int apic;
+    bool_t sb_ioapic = !iommu_intremap;
       int error = 0;
 
       BUG_ON(!table);
@@ -1017,8 +1018,15 @@ static int __init parse_ivrs_table(struc
       /* Each IO-APIC must have been mentioned in the table. */
       for ( apic = 0; !error && iommu_intremap && apic < nr_ioapics; ++apic )
       {
-        if ( !nr_ioapic_entries[apic] ||
-             ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
+        if ( !nr_ioapic_entries[apic] )
+            continue;

xen/drivers/passthrough/amd/iommu_acpi.c static int __init parse_ivrs_table(struc · line 1032

Quoted 10 lines
xen/drivers/passthrough/amd/iommu_acpi.c +7 -0
+
+        if ( !ioapic_sbdf[IO_APIC_ID(apic)].seg &&
+             /* SB IO-APIC is always on this device in AMD systems. */
+             ioapic_sbdf[IO_APIC_ID(apic)].bdf == PCI_BDF(0, 0x14, 0) )
+            sb_ioapic = 1;
+
+        if ( ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
               continue;
 
           if ( !test_bit(IO_APIC_ID(apic), ioapic_cmdline) )

I don't know whether 0:14:0 is set in stone, I don't remember seeing anywhere that this is architectural.

Quoted 7 lines
Quoted 4 lines

In the (unlikely) event that it is moved somewhere else will the user be able to overwrite where it is? Do you
think that sb_ioapic may need to be set to true if appropriate bit is set in ioapic_cmdline?

These are question you'd need to ask to Jörg, the author of the original Linux side patch. I took as a precondition here that he knew what he was doing.

Xen already has a way to override IVRS' view of IOAPICs with ioapic_cmdline, something that Linux doesn't. Presumably if the user sets ivrs_ioapic[] option on boot line then he knows what he is doing (at least one would hope so).

My concern is that this patch would prevent the user from specifying where the IOAPIC is. Will this boot option be useful at all now? When we specify anything but 0:14:0 it will be pretty much ignored, won't it?

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#5 lore raw
Quoted 50 lines
Quoted 1 line
Quoted 1 line · Boris Ostrovsky
Quoted 48 lines · Jan Beulich
Quoted 48 lines
Quoted 1 line
Quoted 1 line · Boris Ostrovsky
Quoted 29 lines · Jan Beulich

... but interrupt remapping is requested (with per-device remapping tables). Without it, the timer interrupt is usually not working.

Inspired by Linux'es "iommu/amd: Work around wrong IOAPIC device-id in IVRS table" (commit c2ff5cf5294bcbd7fa50f7d860e90a66db7e5059) by Joerg Roedel <[email protected]>.

xen/drivers/passthrough/amd/iommu_acpi.c +3 -2
@@ -984,6 +984,7 @@ static int __init parse_ivrs_table(struc
       const struct acpi_ivrs_header *ivrs_block;
       unsigned long length;
       unsigned int apic;
+    bool_t sb_ioapic = !iommu_intremap;
       int error = 0;
 
       BUG_ON(!table);
@@ -1017,8 +1018,15 @@ static int __init parse_ivrs_table(struc
       /* Each IO-APIC must have been mentioned in the table. */
       for ( apic = 0; !error && iommu_intremap && apic < nr_ioapics; ++apic )
       {
-        if ( !nr_ioapic_entries[apic] ||
-             ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
+        if ( !nr_ioapic_entries[apic] )
+            continue;

xen/drivers/passthrough/amd/iommu_acpi.c static int __init parse_ivrs_table(struc · line 1032

Quoted 10 lines
xen/drivers/passthrough/amd/iommu_acpi.c +7 -0
+
+        if ( !ioapic_sbdf[IO_APIC_ID(apic)].seg &&
+             /* SB IO-APIC is always on this device in AMD systems. */
+             ioapic_sbdf[IO_APIC_ID(apic)].bdf == PCI_BDF(0, 0x14, 0) )
+            sb_ioapic = 1;
+
+        if ( ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
               continue;
 
           if ( !test_bit(IO_APIC_ID(apic), ioapic_cmdline) )

I don't know whether 0:14:0 is set in stone, I don't remember seeing anywhere that this is architectural.

In the (unlikely) event that it is moved somewhere else will the user be able to overwrite where it is? Do you
think that sb_ioapic may need to be set to true if appropriate bit is set in ioapic_cmdline?

Quoted 8 lines
Quoted 3 lines

These are question you'd need to ask to Jörg, the author of the original Linux side patch. I took as a precondition here that he knew what he was doing.

Xen already has a way to override IVRS' view of IOAPICs with ioapic_cmdline, something that Linux doesn't. Presumably if the user sets ivrs_ioapic[] option on boot line then he knows what he is doing (at least one would hope so).

I think the logic we have is sufficiently similar to Linux'es.

Quoted 3 lines

My concern is that this patch would prevent the user from specifying where the IOAPIC is. Will this boot option be useful at all now? When we specify anything but 0:14:0 it will be pretty much ignored, won't it?

But the purpose here isn't to override how the hardware is structured, but to overcome firmware vendors not getting their ACPI tables correct.

Furthermore, what is being specified here can very well be different from 00:14.0 - consider the northbridge IO-APIC and eventual further ones.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#6 lore raw
Quoted 62 lines · Jan Beulich
Quoted 50 lines
Quoted 1 line
Quoted 1 line · Boris Ostrovsky
Quoted 48 lines · Jan Beulich
Quoted 48 lines
Quoted 1 line
Quoted 1 line · Boris Ostrovsky
Quoted 29 lines · Jan Beulich

... but interrupt remapping is requested (with per-device remapping tables). Without it, the timer interrupt is usually not working.

Inspired by Linux'es "iommu/amd: Work around wrong IOAPIC device-id in IVRS table" (commit c2ff5cf5294bcbd7fa50f7d860e90a66db7e5059) by Joerg Roedel <[email protected]>.

xen/drivers/passthrough/amd/iommu_acpi.c +3 -2
@@ -984,6 +984,7 @@ static int __init parse_ivrs_table(struc
        const struct acpi_ivrs_header *ivrs_block;
        unsigned long length;
        unsigned int apic;
+    bool_t sb_ioapic = !iommu_intremap;
        int error = 0;
 
        BUG_ON(!table);
@@ -1017,8 +1018,15 @@ static int __init parse_ivrs_table(struc
        /* Each IO-APIC must have been mentioned in the table. */
        for ( apic = 0; !error && iommu_intremap && apic < nr_ioapics; ++apic )
        {
-        if ( !nr_ioapic_entries[apic] ||
-             ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
+        if ( !nr_ioapic_entries[apic] )
+            continue;

xen/drivers/passthrough/amd/iommu_acpi.c static int __init parse_ivrs_table(struc · line 1032

Quoted 10 lines
xen/drivers/passthrough/amd/iommu_acpi.c +7 -0
+
+        if ( !ioapic_sbdf[IO_APIC_ID(apic)].seg &&
+             /* SB IO-APIC is always on this device in AMD systems. */
+             ioapic_sbdf[IO_APIC_ID(apic)].bdf == PCI_BDF(0, 0x14, 0) )
+            sb_ioapic = 1;
+
+        if ( ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
                continue;
 
            if ( !test_bit(IO_APIC_ID(apic), ioapic_cmdline) )

I don't know whether 0:14:0 is set in stone, I don't remember seeing anywhere that this is architectural.

In the (unlikely) event that it is moved somewhere else will the user be able to overwrite where it is? Do you
think that sb_ioapic may need to be set to true if appropriate bit is set in ioapic_cmdline?

Quoted 7 lines
Quoted 3 lines

These are question you'd need to ask to Jörg, the author of the original Linux side patch. I took as a precondition here that he knew what he was doing.

Xen already has a way to override IVRS' view of IOAPICs with ioapic_cmdline, something that Linux doesn't. Presumably if the user sets ivrs_ioapic[] option on boot line then he knows what he is doing (at least one would hope so).

I think the logic we have is sufficiently similar to Linux'es.

Quoted 3 lines

My concern is that this patch would prevent the user from specifying where the IOAPIC is. Will this boot option be useful at all now? When we specify anything but 0:14:0 it will be pretty much ignored, won't it?

Quoted 7 lines

But the purpose here isn't to override how the hardware is structured, but to overcome firmware vendors not getting their ACPI tables correct.

Furthermore, what is being specified here can very well be different from 00:14.0 - consider the northbridge IO-APIC and eventual further ones.

This is exactly what I am asking: Suppose we have IOAPIC in the NB (I think it's something like 0:02.0) *and* IVRS is broken. Currently we can say 'ivrs_ioapic[0]=0:02.0' and we are good to go (right?). Will we still be able to do this?

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#7 lore raw
Quoted 68 lines
Quoted 1 line
Quoted 1 line · Boris Ostrovsky
Quoted 66 lines · Jan Beulich
Quoted 50 lines
Quoted 1 line
Quoted 1 line · Boris Ostrovsky
Quoted 48 lines · Jan Beulich
Quoted 48 lines
Quoted 1 line
Quoted 1 line · Boris Ostrovsky
Quoted 29 lines · Jan Beulich

... but interrupt remapping is requested (with per-device remapping tables). Without it, the timer interrupt is usually not working.

Inspired by Linux'es "iommu/amd: Work around wrong IOAPIC device-id in IVRS table" (commit c2ff5cf5294bcbd7fa50f7d860e90a66db7e5059) by Joerg Roedel <[email protected]>.

xen/drivers/passthrough/amd/iommu_acpi.c +3 -2
@@ -984,6 +984,7 @@ static int __init parse_ivrs_table(struc
        const struct acpi_ivrs_header *ivrs_block;
        unsigned long length;
        unsigned int apic;
+    bool_t sb_ioapic = !iommu_intremap;
        int error = 0;
 
        BUG_ON(!table);
@@ -1017,8 +1018,15 @@ static int __init parse_ivrs_table(struc
        /* Each IO-APIC must have been mentioned in the table. */
        for ( apic = 0; !error && iommu_intremap && apic < nr_ioapics; ++apic )
        {
-        if ( !nr_ioapic_entries[apic] ||
-             ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
+        if ( !nr_ioapic_entries[apic] )
+            continue;

xen/drivers/passthrough/amd/iommu_acpi.c static int __init parse_ivrs_table(struc · line 1032

Quoted 10 lines
xen/drivers/passthrough/amd/iommu_acpi.c +7 -0
+
+        if ( !ioapic_sbdf[IO_APIC_ID(apic)].seg &&
+             /* SB IO-APIC is always on this device in AMD systems. */
+             ioapic_sbdf[IO_APIC_ID(apic)].bdf == PCI_BDF(0, 0x14, 0) )
+            sb_ioapic = 1;
+
+        if ( ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
                continue;
 
            if ( !test_bit(IO_APIC_ID(apic), ioapic_cmdline) )

I don't know whether 0:14:0 is set in stone, I don't remember seeing anywhere that this is architectural.

In the (unlikely) event that it is moved somewhere else will the user be able to overwrite where it is? Do you
think that sb_ioapic may need to be set to true if appropriate bit is set in ioapic_cmdline?

Quoted 7 lines
Quoted 3 lines

These are question you'd need to ask to Jörg, the author of the original Linux side patch. I took as a precondition here that he knew what he was doing.

Xen already has a way to override IVRS' view of IOAPICs with ioapic_cmdline, something that Linux doesn't. Presumably if the user sets ivrs_ioapic[] option on boot line then he knows what he is doing (at least one would hope so).

I think the logic we have is sufficiently similar to Linux'es.

Quoted 3 lines

My concern is that this patch would prevent the user from specifying where the IOAPIC is. Will this boot option be useful at all now? When we specify anything but 0:14:0 it will be pretty much ignored, won't it?

But the purpose here isn't to override how the hardware is structured, but to overcome firmware vendors not getting their ACPI tables correct.

Quoted 7 lines
Quoted 3 lines

Furthermore, what is being specified here can very well be different from 00:14.0 - consider the northbridge IO-APIC and eventual further ones.

This is exactly what I am asking: Suppose we have IOAPIC in the NB (I think it's something like 0:02.0) *and* IVRS is broken. Currently we can say 'ivrs_ioapic[0]=0:02.0' and we are good to go (right?).

No - there _has_ to be an IO-APIC in the SB.

Quoted 1 line

Will we still be able to do this?

It shouldn't have worked before either, unless I'm not really understanding the purpose of the check in Linux.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#8 lore raw
Quoted 44 lines · Jan Beulich
Quoted 44 lines
Quoted 1 line
Quoted 1 line · Boris Ostrovsky
Quoted 42 lines · Jan Beulich
Quoted 42 lines
Quoted 1 line
Quoted 1 line · Boris Ostrovsky
Quoted 40 lines · Jan Beulich
Quoted 40 lines
Quoted 1 line
Quoted 1 line · Boris Ostrovsky
Quoted 38 lines · Jan Beulich

... but interrupt remapping is requested (with per-device remapping tables). Without it, the timer interrupt is usually not working.

Inspired by Linux'es "iommu/amd: Work around wrong IOAPIC device-id in IVRS table" (commit c2ff5cf5294bcbd7fa50f7d860e90a66db7e5059) by Joerg Roedel <[email protected]>.

xen/drivers/passthrough/amd/iommu_acpi.c +10 -2
@@ -984,6 +984,7 @@ static int __init parse_ivrs_table(struc
         const struct acpi_ivrs_header *ivrs_block;
         unsigned long length;
         unsigned int apic;
+    bool_t sb_ioapic = !iommu_intremap;
         int error = 0;
 
         BUG_ON(!table);
@@ -1017,8 +1018,15 @@ static int __init parse_ivrs_table(struc
         /* Each IO-APIC must have been mentioned in the table. */
         for ( apic = 0; !error && iommu_intremap && apic < nr_ioapics; ++apic )
         {
-        if ( !nr_ioapic_entries[apic] ||
-             ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
+        if ( !nr_ioapic_entries[apic] )
+            continue;
+
+        if ( !ioapic_sbdf[IO_APIC_ID(apic)].seg &&
+             /* SB IO-APIC is always on this device in AMD systems. */
+             ioapic_sbdf[IO_APIC_ID(apic)].bdf == PCI_BDF(0, 0x14, 0) )
+            sb_ioapic = 1;
+
+        if ( ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
                 continue;
 
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

xen/drivers/passthrough/amd/iommu_acpi.c static int __init parse_ivrs_table(struc · line 1032

Quoted 1 line
xen/drivers/passthrough/amd/iommu_acpi.c +0 -0
             if ( !test_bit(IO_APIC_ID(apic), ioapic_cmdline) )

I don't know whether 0:14:0 is set in stone, I don't remember seeing anywhere that this is architectural.

[Suravee] From what I have seen on all of our system and checking with design engineer. IOAPIC in the SB on AMD system always have "0:14.0" and should always be enabled.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
Quoted 4 lines

In the (unlikely) event that it is moved somewhere else will the user be able to overwrite where it is? Do you
think that sb_ioapic may need to be set to true if appropriate bit is set in ioapic_cmdline?

These are question you'd need to ask to Jörg, the author of the original Linux side patch. I took as a precondition here that he knew what he was doing.

Xen already has a way to override IVRS' view of IOAPICs with ioapic_cmdline, something that Linux doesn't. Presumably if the user sets ivrs_ioapic[] option on boot line then he knows what he is doing (at least one would hope so).

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

I think the logic we have is sufficiently similar to Linux'es.

Quoted 3 lines

My concern is that this patch would prevent the user from specifying where the IOAPIC is. Will this boot option be useful at all now? When we specify anything but 0:14:0 it will be pretty much ignored, won't it?

But the purpose here isn't to override how the hardware is structured, but to overcome firmware vendors not getting their ACPI tables correct.

[Suravee] The ivrs_ioapic[] would work for the case where users want to fix the IVHD when it incorrectly lists the handle ID for IOAPIC, or missing it. But the IOAPIC needs to also be cross checked with the IOAPIC entry listed in the APIC table.

In this case, the IOAPIC is also missing in the APIC table, and I don't think ivrs_ioapic[] would be handling this case anyways.

Suravee

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by on v1 1/1
#9 lore raw
In reply to Jan Beulich
Quoted 57 lines · Jan Beulich

... but interrupt remapping is requested (with per-device remapping tables). Without it, the timer interrupt is usually not working.

Inspired by Linux'es "iommu/amd: Work around wrong IOAPIC device-id in IVRS table" (commit c2ff5cf5294bcbd7fa50f7d860e90a66db7e5059) by Joerg Roedel <[email protected]>.

xen/drivers/passthrough/amd/iommu_acpi.c +18 -2
@@ -984,6 +984,7 @@ static int __init parse_ivrs_table(struc
      const struct acpi_ivrs_header *ivrs_block;
      unsigned long length;
      unsigned int apic;
+    bool_t sb_ioapic = !iommu_intremap;
      int error = 0;
 
      BUG_ON(!table);
@@ -1017,8 +1018,15 @@ static int __init parse_ivrs_table(struc
      /* Each IO-APIC must have been mentioned in the table. */
      for ( apic = 0; !error && iommu_intremap && apic < nr_ioapics; ++apic )
      {
-        if ( !nr_ioapic_entries[apic] ||
-             ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
+        if ( !nr_ioapic_entries[apic] )
+            continue;
+
+        if ( !ioapic_sbdf[IO_APIC_ID(apic)].seg &&
+             /* SB IO-APIC is always on this device in AMD systems. */
+             ioapic_sbdf[IO_APIC_ID(apic)].bdf == PCI_BDF(0, 0x14, 0) )
+            sb_ioapic = 1;
+
+        if ( ioapic_sbdf[IO_APIC_ID(apic)].pin_2_idx )
              continue;
 
          if ( !test_bit(IO_APIC_ID(apic), ioapic_cmdline) )
@@ -1041,6 +1049,14 @@ static int __init parse_ivrs_table(struc
          }
      }
 
+    if ( !error && !sb_ioapic )
+    {
+        if ( amd_iommu_perdev_intremap )
+            error = -ENXIO;
+        printk("%sNo southbridge IO-APIC found in IVRS table\n",
+               amd_iommu_perdev_intremap ? XENLOG_ERR : XENLOG_WARNING);
+    }
+
      return error;
  }