vtd: Reinstate ACPI DMAR on system shutdown or S3/S4/S5.
authorKeir Fraser <keir@xen.org>
Fri, 17 Dec 2010 10:46:43 +0000 (10:46 +0000)
committerKeir Fraser <keir@xen.org>
Fri, 17 Dec 2010 10:46:43 +0000 (10:46 +0000)
Signed-off-by: Keir Fraser <keir@xen.org>
xen/arch/x86/acpi/power.c
xen/arch/x86/shutdown.c
xen/arch/x86/tboot.c
xen/common/kexec.c
xen/drivers/passthrough/vtd/dmar.c
xen/include/xen/acpi.h

index f429d9914e8c6cdd27b9c984c64699b217d04cb7..b4a633d544ec09734d0e5baec76ac22e31bc6cf1 100644 (file)
@@ -12,7 +12,6 @@
 
 #include <xen/config.h>
 #include <asm/io.h>
-#include <asm/acpi.h>
 #include <xen/acpi.h>
 #include <xen/errno.h>
 #include <xen/iocap.h>
@@ -140,6 +139,8 @@ static int enter_state(u32 state)
 
     freeze_domains();
 
+    acpi_dmar_reinstate();
+
     if ( (error = disable_nonboot_cpus()) )
         goto enable_cpu;
 
@@ -208,6 +209,7 @@ static int enter_state(u32 state)
     mtrr_aps_sync_begin();
     enable_nonboot_cpus();
     mtrr_aps_sync_end();
+    acpi_dmar_zap();
     thaw_domains();
     spin_unlock(&pm_lock);
     return error;
index c8821ed0a17ee6560e9e1e173002a48446415e4b..74ef63dfc861cb1d6c45008c21d6e66297455828 100644 (file)
@@ -309,6 +309,8 @@ void machine_restart(unsigned int delay_millisecs)
     console_start_sync();
     spin_debug_disable();
 
+    acpi_dmar_reinstate();
+
     local_irq_enable();
 
     /* Ensure we are the boot CPU. */
index ae2d62009975448d41793c556e73acc7f4979bfc..cab39c440eda63c2832efa1dfb5f5d5670193391 100644 (file)
@@ -5,6 +5,7 @@
 #include <xen/sched.h>
 #include <xen/domain_page.h>
 #include <xen/iommu.h>
+#include <xen/acpi.h>
 #include <asm/fixmap.h>
 #include <asm/page.h>
 #include <asm/processor.h>
@@ -475,13 +476,7 @@ int __init tboot_parse_dmar_table(acpi_table_handler dmar_handler)
 
     /* acpi_parse_dmar() zaps APCI DMAR signature in TXT heap table */
     /* but dom0 will read real table, so must zap it there too */
-    dmar_table = NULL;
-    acpi_get_table(ACPI_SIG_DMAR, 0, &dmar_table);
-    if ( dmar_table != NULL )
-    {
-        dmar_table->signature[0] = 'X';
-        dmar_table->checksum -= 'X'-'D';
-    }
+    acpi_dmar_zap();
 
     return rc;
 }
index f6ce3b16a24c3949b0576ca42caa8bc638e80edc..989907b98d33243ac1dd3ef753226402112f23fb 100644 (file)
@@ -203,20 +203,13 @@ crash_xen_info_t *kexec_crash_save_info(void)
     return out;
 }
 
-static int acpi_dmar_reinstate(struct acpi_table_header *table)
-{
-    table->signature[0] = 'D';
-    table->checksum += 'X'-'D';
-    return 0;
-}
-
 static void kexec_common_shutdown(void)
 {
     watchdog_disable();
     console_start_sync();
     spin_debug_disable();
     one_cpu_only();
-    acpi_table_parse(ACPI_SIG_DMAR, acpi_dmar_reinstate);
+    acpi_dmar_reinstate();
 }
 
 void kexec_crash(void)
index 08266ca7045e1d5453719089c716fe4dd0615fe9..0bc10ba0479b7e8ddad6adce0ababb5dcabf83dd 100644 (file)
@@ -771,3 +771,34 @@ int __init acpi_dmar_init(void)
 {
     return parse_dmar_table(acpi_parse_dmar);
 }
+
+static struct acpi_table_header *get_dmar(void)
+{
+    struct acpi_table_header *dmar_table = NULL;
+    unsigned long flags;
+
+    /* Disabling IRQs avoids cross-CPU TLB flush in map_pages_to_xen(). */
+    local_irq_save(flags);
+    acpi_get_table(ACPI_SIG_DMAR, 0, &dmar_table);
+    local_irq_restore(flags);
+
+    return dmar_table;
+}
+
+void acpi_dmar_reinstate(void)
+{
+    struct acpi_table_header *dmar_table = get_dmar();
+    if ( dmar_table == NULL )
+        return;
+    dmar_table->signature[0] = 'D';
+    dmar_table->checksum += 'X'-'D';
+}
+
+void acpi_dmar_zap(void)
+{
+    struct acpi_table_header *dmar_table = get_dmar();
+    if ( dmar_table == NULL )
+        return;
+    dmar_table->signature[0] = 'X';
+    dmar_table->checksum -= 'X'-'D';
+}
index ade73d5616891aac251c9ab60d352cd3b86d0a18..42c3b6b87c3330fc0a59931abde0e5a4ba4ea498 100644 (file)
@@ -444,4 +444,7 @@ extern int pnpacpi_disabled;
 
 void acpi_reboot(void);
 
+void acpi_dmar_zap(void);
+void acpi_dmar_reinstate(void);
+
 #endif /*_LINUX_ACPI_H*/