WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [VTD] check BIOS settings before enabling

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [VTD] check BIOS settings before enabling interrupt remapping or x2apic
From: Xen patchbot-unstable <patchbot@xxxxxxx>
Date: Sun, 03 Apr 2011 13:00:07 +0100
Delivery-date: Sun, 03 Apr 2011 05:02:15 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Allen Kay <allen.m.kay@xxxxxxxxx>
# Date 1301755765 -3600
# Node ID 1046830079376a4b29fcad0cd037a834e808ed06
# Parent  89c23f58aa986092da0c9a7dfac1c41befbe1f3f
[VTD] check BIOS settings before enabling interrupt remapping or x2apic

Check flags field in ACPI DMAR structure before enabling interrupt
remapping or x2apic.  This allows platform vendors to disable
interrupt remapping or x2apic features if on board BIOS does not
support them.

Signed-off-by: Allen Kay <allen.m.kay@xxxxxxxxx>
---


diff -r 89c23f58aa98 -r 104683007937 xen/arch/x86/apic.c
--- a/xen/arch/x86/apic.c       Thu Mar 31 19:39:30 2011 +0100
+++ b/xen/arch/x86/apic.c       Sat Apr 02 15:49:25 2011 +0100
@@ -516,7 +516,7 @@
     mask_8259A();
     mask_IO_APIC_setup(ioapic_entries);
 
-    iommu_enable_IR();
+    iommu_enable_x2apic_IR();
     __enable_x2apic();
 
     restore_IO_APIC_setup(ioapic_entries);
@@ -735,7 +735,7 @@
 
     local_irq_save(flags);
     disable_local_APIC();
-    iommu_disable_IR();
+    iommu_disable_x2apic_IR();
     local_irq_restore(flags);
     return 0;
 }
@@ -958,7 +958,7 @@
     mask_8259A();
     mask_IO_APIC_setup(ioapic_entries);
 
-    if ( iommu_enable_IR() )
+    if ( iommu_enable_x2apic_IR() )
     {
         if ( x2apic_enabled )
             panic("Interrupt remapping could not be enabled while "
diff -r 89c23f58aa98 -r 104683007937 xen/drivers/passthrough/vtd/dmar.c
--- a/xen/drivers/passthrough/vtd/dmar.c        Thu Mar 31 19:39:30 2011 +0100
+++ b/xen/drivers/passthrough/vtd/dmar.c        Sat Apr 02 15:49:25 2011 +0100
@@ -47,6 +47,7 @@
 static LIST_HEAD_READ_MOSTLY(acpi_rhsa_units);
 
 static struct acpi_table_header *__read_mostly dmar_table;
+static int __read_mostly dmar_flags;
 static u64 __read_mostly igd_drhd_address;
 
 static void __init dmar_scope_add_buses(struct dmar_scope *scope, u16 sec_bus,
@@ -761,7 +762,11 @@
 
 int __init acpi_dmar_init(void)
 {
+    struct acpi_table_dmar *dmar;
+
     acpi_get_table(ACPI_SIG_DMAR, 0, &dmar_table);
+    dmar = (struct acpi_table_dmar *) dmar_table;
+    dmar_flags = dmar->flags;
 
     return parse_dmar_table(acpi_parse_dmar);
 }
@@ -781,3 +786,22 @@
     dmar_table->signature[0] = 'X';
     dmar_table->checksum -= 'X'-'D';
 }
+
+int __init platform_supports_intremap(void)
+{
+    unsigned int flags = 0;
+
+    flags = DMAR_INTR_REMAP;
+    return ((dmar_flags & flags) == DMAR_INTR_REMAP);
+}
+
+int __init platform_supports_x2apic(void)
+{
+    unsigned int flags = 0;
+
+    if (!cpu_has_x2apic)
+        return 0;
+
+    flags = DMAR_INTR_REMAP | DMAR_X2APIC_OPT_OUT;
+    return ((dmar_flags & flags) == DMAR_INTR_REMAP);
+}
diff -r 89c23f58aa98 -r 104683007937 xen/drivers/passthrough/vtd/extern.h
--- a/xen/drivers/passthrough/vtd/extern.h      Thu Mar 31 19:39:30 2011 +0100
+++ b/xen/drivers/passthrough/vtd/extern.h      Sat Apr 02 15:49:25 2011 +0100
@@ -119,5 +119,7 @@
 void vtd_ops_postamble_quirk(struct iommu* iommu);
 void me_wifi_quirk(struct domain *domain, u8 bus, u8 devfn, int map);
 void pci_vtd_quirk(struct pci_dev *pdev);
+int __init platform_supports_intremap(void);
+int __init platform_supports_x2apic(void);
 
 #endif // _VTD_EXTERN_H_
diff -r 89c23f58aa98 -r 104683007937 xen/drivers/passthrough/vtd/intremap.c
--- a/xen/drivers/passthrough/vtd/intremap.c    Thu Mar 31 19:39:30 2011 +0100
+++ b/xen/drivers/passthrough/vtd/intremap.c    Sat Apr 02 15:49:25 2011 +0100
@@ -735,6 +735,13 @@
 
     ASSERT(ecap_intr_remap(iommu->ecap) && iommu_intremap);
 
+    if ( !platform_supports_intremap() )
+    {
+        dprintk(XENLOG_ERR VTDPREFIX,
+                "Platform firmware does not support interrupt remapping\n");
+        return -EINVAL;
+    }
+
     ir_ctrl = iommu_ir_ctrl(iommu);
     sts = dmar_readl(iommu->reg, DMAR_GSTS_REG);
 
@@ -821,10 +828,10 @@
 }
 
 /*
- * This function is used to enable Interrutp remapping when
+ * This function is used to enable Interrupt remapping when
  * enable x2apic
  */
-int iommu_enable_IR(void)
+int iommu_enable_x2apic_IR(void)
 {
     struct acpi_drhd_unit *drhd;
     struct iommu *iommu;
@@ -832,6 +839,9 @@
     if ( !iommu_supports_eim() )
         return -1;
 
+    if ( !platform_supports_x2apic() )
+        return -1;
+
     for_each_drhd_unit ( drhd )
     {
         struct qi_ctrl *qi_ctrl = NULL;
@@ -881,7 +891,7 @@
  * This function is used to disable Interrutp remapping when
  * suspend local apic
  */
-void iommu_disable_IR(void)
+void iommu_disable_x2apic_IR(void)
 {
     struct acpi_drhd_unit *drhd;
 
diff -r 89c23f58aa98 -r 104683007937 xen/drivers/passthrough/vtd/iommu.c
--- a/xen/drivers/passthrough/vtd/iommu.c       Thu Mar 31 19:39:30 2011 +0100
+++ b/xen/drivers/passthrough/vtd/iommu.c       Sat Apr 02 15:49:25 2011 +0100
@@ -2014,7 +2014,7 @@
             if ( enable_intremap(iommu, 0) != 0 )
             {
                 dprintk(XENLOG_WARNING VTDPREFIX,
-                        "Failed to enable Interrupt Remapping!\n");
+                        "Interrupt Remapping not enabled\n");
                 break;
             }
         }
diff -r 89c23f58aa98 -r 104683007937 xen/drivers/passthrough/vtd/iommu.h
--- a/xen/drivers/passthrough/vtd/iommu.h       Thu Mar 31 19:39:30 2011 +0100
+++ b/xen/drivers/passthrough/vtd/iommu.h       Sat Apr 02 15:49:25 2011 +0100
@@ -22,6 +22,10 @@
 
 #include <xen/types.h>
 
+/* DMAR Flags bits */
+#define DMAR_INTR_REMAP 0x1
+#define DMAR_X2APIC_OPT_OUT 0x2
+
 /*
  * Intel IOMMU register specification per version 1.0 public spec.
  */
diff -r 89c23f58aa98 -r 104683007937 xen/include/xen/iommu.h
--- a/xen/include/xen/iommu.h   Thu Mar 31 19:39:30 2011 +0100
+++ b/xen/include/xen/iommu.h   Sat Apr 02 15:49:25 2011 +0100
@@ -63,8 +63,8 @@
 
 int iommu_setup(void);
 int iommu_supports_eim(void);
-int iommu_enable_IR(void);
-void iommu_disable_IR(void);
+int iommu_enable_x2apic_IR(void);
+void iommu_disable_x2apic_IR(void);
 
 int iommu_add_device(struct pci_dev *pdev);
 int iommu_remove_device(struct pci_dev *pdev);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [VTD] check BIOS settings before enabling interrupt remapping or x2apic, Xen patchbot-unstable <=