[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] VTd/dmar: Tweak how the DMAR table is clobbered



commit 123c7793797502b222300eb710cd3873dcca41ee
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Fri Apr 10 11:26:18 2015 -0400
Commit:     Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
CommitDate: Fri Apr 10 11:36:24 2015 -0400

    VTd/dmar: Tweak how the DMAR table is clobbered
    
    Intead of clobbering DMAR -> XMAR and back, clobber to RMAD instead. This
    means that changing the signature does not alter the checksum, which allows
    the clobbering/unclobbering to be peformed atomically and idempotently, 
which
    is an advantage on the kexec path which can reenter acpi_dmar_reinstate().
    
    This DMAR clobbering was introduced by
    83904107a33c9badc34ecdd1f8ca0f9271e5e370 which claims that the dom0 VT-d
    driver was capable of playing with the IOMMU(s) while Xen was also using
    them. An alternative approach might be to leave the DMAR table alone
    and sprinkle some iomem_deny_access() around to forcibly prevent dom0
    from playing but this is simpler.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix>
    CC: Yang Zhang <yang.z.zhang@intel>
    Acked-by: Kevin Tian <kevin.tian@intel>
---
 xen/drivers/passthrough/vtd/dmar.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/xen/drivers/passthrough/vtd/dmar.c 
b/xen/drivers/passthrough/vtd/dmar.c
index 1152c3a..18d7903 100644
--- a/xen/drivers/passthrough/vtd/dmar.c
+++ b/xen/drivers/passthrough/vtd/dmar.c
@@ -28,6 +28,7 @@
 #include <xen/xmalloc.h>
 #include <xen/pci.h>
 #include <xen/pci_regs.h>
+#include <asm/atomic.h>
 #include <asm/string.h>
 #include "dmar.h"
 #include "iommu.h"
@@ -838,8 +839,7 @@ static int __init acpi_parse_dmar(struct acpi_table_header 
*table)
 
 out:
     /* Zap ACPI DMAR signature to prevent dom0 using vt-d HW. */
-    dmar->header.signature[0] = 'X';
-    dmar->header.checksum -= 'X'-'D';
+    acpi_dmar_zap();
     return ret;
 }
 
@@ -867,18 +867,18 @@ int __init acpi_dmar_init(void)
 
 void acpi_dmar_reinstate(void)
 {
-    if ( dmar_table == NULL )
-        return;
-    dmar_table->signature[0] = 'D';
-    dmar_table->checksum += 'X'-'D';
+    uint32_t sig = 0x52414d44; /* "DMAR" */
+
+    if ( dmar_table )
+        write_atomic((uint32_t*)&dmar_table->signature[0], sig);
 }
 
 void acpi_dmar_zap(void)
 {
-    if ( dmar_table == NULL )
-        return;
-    dmar_table->signature[0] = 'X';
-    dmar_table->checksum -= 'X'-'D';
+    uint32_t sig = 0x44414d52; /* "RMAD" - doesn't alter table checksum */
+
+    if ( dmar_table )
+        write_atomic((uint32_t*)&dmar_table->signature[0], sig);
 }
 
 int platform_supports_intremap(void)
--
generated by git-patchbot for /home/xen/git/xen.git#master

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.