xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][VTD] check BIOS settings before enabling interrupt remapping or x2apic
@ 2011-03-29 17:58 Kay, Allen M
  2011-04-05 10:41 ` Jan Beulich
  2011-04-05 10:53 ` Jan Beulich
  0 siblings, 2 replies; 9+ messages in thread
From: Kay, Allen M @ 2011-03-29 17:58 UTC (permalink / raw)
  To: xen-devel@lists.xensource.com; +Cc: Keir Fraser, Jan Beulich

[-- Attachment #1: Type: text/plain, Size: 261 bytes --]

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@intel.com>

[-- Attachment #2: dmar0329.patch --]
[-- Type: application/octet-stream, Size: 5587 bytes --]

diff -r 9549c04a8384 xen/arch/x86/apic.c
--- a/xen/arch/x86/apic.c	Mon Mar 28 13:44:08 2011 +0100
+++ b/xen/arch/x86/apic.c	Tue Mar 29 10:45:37 2011 -0700
@@ -516,7 +516,7 @@ static void resume_x2apic(void)
     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 @@ int lapic_suspend(void)
 
     local_irq_save(flags);
     disable_local_APIC();
-    iommu_disable_IR();
+    iommu_disable_x2apic_IR();
     local_irq_restore(flags);
     return 0;
 }
@@ -958,7 +958,7 @@ void __init x2apic_bsp_setup(void)
     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 9549c04a8384 xen/drivers/passthrough/vtd/dmar.c
--- a/xen/drivers/passthrough/vtd/dmar.c	Mon Mar 28 13:44:08 2011 +0100
+++ b/xen/drivers/passthrough/vtd/dmar.c	Tue Mar 29 10:45:37 2011 -0700
@@ -47,6 +47,7 @@ static LIST_HEAD_READ_MOSTLY(acpi_rhsa_u
 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 @@ out:
 
 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 @@ void acpi_dmar_zap(void)
     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 9549c04a8384 xen/drivers/passthrough/vtd/extern.h
--- a/xen/drivers/passthrough/vtd/extern.h	Mon Mar 28 13:44:08 2011 +0100
+++ b/xen/drivers/passthrough/vtd/extern.h	Tue Mar 29 10:45:37 2011 -0700
@@ -119,5 +119,7 @@ void vtd_ops_postamble_quirk(struct iomm
 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 9549c04a8384 xen/drivers/passthrough/vtd/intremap.c
--- a/xen/drivers/passthrough/vtd/intremap.c	Mon Mar 28 13:44:08 2011 +0100
+++ b/xen/drivers/passthrough/vtd/intremap.c	Tue Mar 29 10:45:37 2011 -0700
@@ -735,6 +735,13 @@ int enable_intremap(struct iommu *iommu,
 
     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,15 +828,18 @@ out:
 }
 
 /*
- * 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;
 
     if ( !iommu_supports_eim() )
+        return -1;
+
+    if ( !platform_supports_x2apic() )
         return -1;
 
     for_each_drhd_unit ( drhd )
@@ -881,7 +891,7 @@ int iommu_enable_IR(void)
  * 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 9549c04a8384 xen/drivers/passthrough/vtd/iommu.c
--- a/xen/drivers/passthrough/vtd/iommu.c	Mon Mar 28 13:44:08 2011 +0100
+++ b/xen/drivers/passthrough/vtd/iommu.c	Tue Mar 29 10:45:37 2011 -0700
@@ -2014,7 +2014,7 @@ static int init_vtd_hw(void)
             if ( enable_intremap(iommu, 0) != 0 )
             {
                 dprintk(XENLOG_WARNING VTDPREFIX,
-                        "Failed to enable Interrupt Remapping!\n");
+                        "Interrupt Remapping not enabled\n");
                 break;
             }
         }
diff -r 9549c04a8384 xen/drivers/passthrough/vtd/iommu.h
--- a/xen/drivers/passthrough/vtd/iommu.h	Mon Mar 28 13:44:08 2011 +0100
+++ b/xen/drivers/passthrough/vtd/iommu.h	Tue Mar 29 10:45:37 2011 -0700
@@ -21,6 +21,10 @@
 #define _INTEL_IOMMU_H_
 
 #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 9549c04a8384 xen/include/xen/iommu.h
--- a/xen/include/xen/iommu.h	Mon Mar 28 13:44:08 2011 +0100
+++ b/xen/include/xen/iommu.h	Tue Mar 29 10:45:37 2011 -0700
@@ -63,8 +63,8 @@ struct iommu {
 
 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);

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-04-06  7:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-29 17:58 [PATCH][VTD] check BIOS settings before enabling interrupt remapping or x2apic Kay, Allen M
2011-04-05 10:41 ` Jan Beulich
2011-04-05 18:13   ` Kay, Allen M
2011-04-06  6:40     ` Jan Beulich
2011-04-06  5:38   ` Wei, Gang
2011-04-05 10:53 ` Jan Beulich
2011-04-05 18:10   ` Kay, Allen M
2011-04-06  6:39     ` Jan Beulich
2011-04-06  7:40       ` Keir Fraser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).