VT-d: use two 32-bit writes to update DMAR fault address registers
PATCH v2 1/1 VT-d: use two 32-bit writes to update DMAR fault address registers
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. Note that when x2APIC is not enabled DMAR_FEUADDR_REG is reserved and it's not necessary to update it.
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.
---
Changes in v2:
* Explain in commit message and code comment why not updating DMAR_FEUADDR_REG when x2APIC is not enabled
This patch actually reverts part of commit ae05fd3912b ("VT-d: use qword MMIO access for MSI address writes"). The latter was included in XSA-120, 128..131 follow-up patch series [1]. I don't know whether my patch breaks those XSA fixes. If it does, please drop my patch.
[1] https://lists.xenproject.org/archives/html/xen-devel/2015-06/msg00638.html
--- xen/drivers/passthrough/vtd/iommu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
xen/drivers/passthrough/vtd/iommu.c +7 -1
@@ -1105,7 +1105,13 @@ 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); +/* +* When x2APIC is not enabled, DMAR_FEUADDR_REG is reserved and +* it's not necessary to update it. +*/ +if (x2apic_enabled) +dmar_writel (iommu->reg,DMAR_FEUADDR_REG , msg.address_hi);spin_unlock_irqrestore (&iommu->register_lock, flags); }
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 11.10.17 at 05:03, <[email protected]> wrote:
xen/drivers/passthrough/vtd/iommu.c +0
-0@@ -1105,7 +1105,13 @@ static void dma_msi_set_affinity(struct irq_desc *desc, const cpumask_t *mask)
xen/drivers/passthrough/vtd/iommu.c static void dma_msi_set_affinity(struct irq_desc · line 1114
Quoted 10 lines
xen/drivers/passthrough/vtd/iommu.c +6
-1spin_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); +/* +* When x2APIC is not enabled, DMAR_FEUADDR_REG is reserved and +* it's not necessary to update it. +*/ +if (x2apic_enabled)
I'm pretty sure it was pointed out before that the style here is wrong (missing spaces). That's easy to fix while committing, but anyway.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 11.10.17 at 05:03, <[email protected]> wrote:
xen/drivers/passthrough/vtd/iommu.c +0
-0@@ -1105,7 +1105,13 @@ static void dma_msi_set_affinity(struct irq_desc *desc, const cpumask_t *mask)
Quoted 13 lines
xen/drivers/passthrough/vtd/iommu.c static void dma_msi_set_affinity(struct irq_desc *desc, const cpumask_t *mask) · line 1113
Quoted 9 lines
xen/drivers/passthrough/vtd/iommu.c +6
-1spin_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); +/* +* When x2APIC is not enabled, DMAR_FEUADDR_REG is reserved and +* it's not necessary to update it. +*/ +if (x2apic_enabled)I'm pretty sure it was pointed out before that the style here is wrong (missing spaces). That's easy to fix while committing, but anyway.
It seems like this was not applied. Can someone fix the style and apply it?
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 22 lines
Quoted 1 line
Quoted 1 line · On 22.02.18 at 10:44, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 11.10.17 at 05:03, <[email protected]> wrote:
xen/drivers/passthrough/vtd/iommu.c +0
-0@@ -1105,7 +1105,13 @@ static void dma_msi_set_affinity(struct irq_desc *desc, const cpumask_t *mask)Quoted 13 lines
xen/drivers/passthrough/vtd/iommu.c static void dma_msi_set_affinity(struct irq_desc *desc, const cpumask_t *mask) · line 1113
Quoted 9 lines
xen/drivers/passthrough/vtd/iommu.c +6
-1spin_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); +/* +* When x2APIC is not enabled, DMAR_FEUADDR_REG is reserved and +* it's not necessary to update it. +*/ +if (x2apic_enabled)I'm pretty sure it was pointed out before that the style here is wrong (missing spaces). That's easy to fix while committing, but anyway.
Quoted 2 lines
It seems like this was not applied. Can someone fix the style and apply it?
I would have fixed the style issue, but I have no VT-d maintainer ack on record. It is the patch submitter to go hunt for acks.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Tian, Kevin
Acked-byQuoted 27 lines
From: Jan Beulich [mailto:[email protected]]
Sent: Thursday, February 22, 2018 5:50 PMQuoted 6 lines
Quoted 1 line
Quoted 1 line · On 22.02.18 at 10:44, <[email protected]> wrote:
Quoted 4 lines · Jan Beulich
xen/drivers/passthrough/vtd/iommu.c static void dma_msi_set_affinity(struct
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 11.10.17 at 05:03, <[email protected]> wrote:
xen/drivers/passthrough/vtd/iommu.c +0
-0@@ -1105,7 +1105,13 @@ static void dma_msi_set_affinity(struct
irq_descQuoted 8 lines
Quoted 8 lines
xen/drivers/passthrough/vtd/iommu.c static void dma_msi_set_affinity(struct irq_desc *desc, const cpumask_t *mask)
Quoted 8 lines
xen/drivers/passthrough/vtd/iommu.c +3
-1*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); +/* +* When x2APIC is not enabled, DMAR_FEUADDR_REG is reserved and
Quoted 8 lines
Quoted 7 lines
xen/drivers/passthrough/vtd/iommu.c static void dma_msi_set_affinity(struct irq_desc *desc, const cpumask_t *mask) · line 1113
Quoted 3 lines
xen/drivers/passthrough/vtd/iommu.c +3
-0+* it's not necessary to update it. +*/ +if (x2apic_enabled)I'm pretty sure it was pointed out before that the style here is wrong (missing spaces). That's easy to fix while committing, but anyway.
Quoted 6 lines
Quoted 2 lines
It seems like this was not applied. Can someone fix the style and apply it?
I would have fixed the style issue, but I have no VT-d maintainer ack on record. It is the patch submitter to go hunt for acks.
I didn't realize no ack from me. Anyway, here it is:
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel