xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vt-d: use two 32-bit writes to update DMAR fault address registers
@ 2017-09-11  6:00 Haozhong Zhang
  2017-09-11  9:38 ` Roger Pau Monné
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Haozhong Zhang @ 2017-09-11  6:00 UTC (permalink / raw)
  To: xen-devel; +Cc: Haozhong Zhang, Kevin Tian

The 64-bit DMAR fault address is composed of two 32 bits registers
DMAR_FEADDR_REG and DMAR_FEUADDR_REG. According to VT-d spec:
"Software is expected to access 32-bit registers as aligned doublewords",
a hypervisor should use two 32-bit writes to DMAR_FEADDR_REG and
DMAR_FEUADDR_REG separately in order to update a 64-bit fault address,
rather than a 64-bit write to DMAR_FEADDR_REG.

Though I haven't seen any errors caused by such one 64-bit write on
real machines, it's still better to follow the specification.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
---
 xen/drivers/passthrough/vtd/iommu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c
index daaed0abbd..067c092214 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -1105,7 +1105,9 @@ static void dma_msi_set_affinity(struct irq_desc *desc, const cpumask_t *mask)
 
     spin_lock_irqsave(&iommu->register_lock, flags);
     dmar_writel(iommu->reg, DMAR_FEDATA_REG, msg.data);
-    dmar_writeq(iommu->reg, DMAR_FEADDR_REG, msg.address);
+    dmar_writel(iommu->reg, DMAR_FEADDR_REG, msg.address_lo);
+    if (x2apic_enabled)
+        dmar_writel(iommu->reg, DMAR_FEUADDR_REG, msg.address_hi);
     spin_unlock_irqrestore(&iommu->register_lock, flags);
 }
 
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

end of thread, other threads:[~2017-10-10  5:40 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-11  6:00 [PATCH] vt-d: use two 32-bit writes to update DMAR fault address registers Haozhong Zhang
2017-09-11  9:38 ` Roger Pau Monné
2017-09-11 12:13   ` Haozhong Zhang
2017-09-18  8:14     ` Tian, Kevin
2017-09-11 10:02 ` Jan Beulich
2017-09-18  8:18   ` Tian, Kevin
2017-09-18  8:30     ` Jan Beulich
2017-09-18  9:05       ` Haozhong Zhang
2017-09-18  9:10         ` Roger Pau Monné
2017-09-20  2:48           ` Tian, Kevin
2017-09-20  8:31 ` Roger Pau Monné
2017-10-10  5:36   ` Tian, Kevin
2017-10-10  5:40     ` Zhang, Haozhong

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).