Skip to contentSkip to conversation

vt-d: Fix IM bit mask and unmask of Fault Event Control Register.

PATCH RESEND In review Quan Xu 3 participants 7 messages Sep 25, 2015

lore
Share & tools
lore

Quan Xu

author
#0 lore raw

PATCH RESEND 1/1 vt-d: Fix IM bit mask and unmask of Fault Event Control Register.

Bit 0:29 in Fault Event Control Register are 'Reserved and Preserved', software cannot write 0 to it unconditionally. Software must preserve the value read for writes.

---
 xen/drivers/passthrough/vtd/iommu.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
xen/drivers/passthrough/vtd/iommu.c +8 -2
index 3d98fea..f31d41b 100644
@@ -992,10 +992,13 @@ static void dma_msi_unmask(struct irq_desc *desc)
 {
     struct iommu *iommu = desc->action->dev_id;
     unsigned long flags;
+    u32 sts;
 
     /* unmask it */
     spin_lock_irqsave(&iommu->register_lock, flags);
-    dmar_writel(iommu->reg, DMAR_FECTL_REG, 0);
+    sts = dmar_readl(iommu->reg, DMAR_FECTL_REG);
+    sts &= ~DMA_FECTL_IM;
+    dmar_writel(iommu->reg, DMAR_FECTL_REG, sts);
     spin_unlock_irqrestore(&iommu->register_lock, flags);
     iommu->msi.msi_attrib.host_masked = 0;
 }
@@ -1004,10 +1007,13 @@ static void dma_msi_mask(struct irq_desc *desc)
 {
     unsigned long flags;
     struct iommu *iommu = desc->action->dev_id;
+    u32 sts;
 
     /* mask it */
     spin_lock_irqsave(&iommu->register_lock, flags);
-    dmar_writel(iommu->reg, DMAR_FECTL_REG, DMA_FECTL_IM);
+    sts = dmar_readl(iommu->reg, DMAR_FECTL_REG);
+    sts |= DMA_FECTL_IM;
+    dmar_writel(iommu->reg, DMAR_FECTL_REG, sts);
     spin_unlock_irqrestore(&iommu->register_lock, flags);
     iommu->msi.msi_attrib.host_masked = 1;
 }
Signature · 1 line
1.8.3.2
#1 lore raw
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 25.09.15 at 04:29, <[email protected]> wrote:

Bit 0:29 in Fault Event Control Register are 'Reserved and Preserved', software cannot write 0 to it unconditionally. Software must preserve the value read for writes.

I'll apply it considering it got acked, but doesn't the write in init_vtd_hw() need similar adjustment then?

Jan

author
#2 lore raw
Quoted 11 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Friday, September 25, 2015 2:44 PM
To: Xu, Quan; Zhang, Yang Z
Cc: Tian, Kevin; [email protected]
Subject: Re: [Xen-devel] [PATCH resend] vt-d: Fix IM bit mask and unmask of Fault Event Control Register.

Quoted 1 line
Quoted 1 line
Quoted 1 line · On 25.09.15 at 04:29, <[email protected]> wrote:
Quoted 8 lines
Quoted 6 lines

Bit 0:29 in Fault Event Control Register are 'Reserved and Preserved', software cannot write 0 to it unconditionally. Software must preserve the value read for writes.

I'll apply it considering it got acked,

Jan, Thanks!

Quoted 2 lines

but doesn't the write in
init_vtd_hw() need similar adjustment then?

Yes, I will send out another patch to fix it.

Quan

Quoted 2 lines

Jan

#4 lore raw
Quoted 10 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 25.09.15 at 04:29, <[email protected]> wrote:

Bit 0:29 in Fault Event Control Register are 'Reserved and Preserved', software cannot write 0 to it unconditionally. Software must preserve the value read for writes.

I think this should also be applied to 4.6 (after RC4 got tagged).

I expect there to be another patch to adjust init_vtd_hw() as well. I will look at that separately.

Wei.

Quoted 1 line

Jan

author
#5 lore raw
Quoted 16 lines

-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: Friday, September 25, 2015 6:55 PM
To: Jan Beulich
Cc: Wei Liu; Xu, Quan; Tian, Kevin; Zhang, Yang Z; [email protected]
Subject: Re: [Xen-devel] [PATCH resend] vt-d: Fix IM bit mask and unmask of Fault Event Control Register.

Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 25.09.15 at 04:29, <[email protected]> wrote:

Bit 0:29 in Fault Event Control Register are 'Reserved and Preserved', software cannot write 0 to it unconditionally. Software must preserve the value read for writes.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I think this should also be applied to 4.6 (after RC4 got tagged).

Wei, thanks..

Quoted 2 lines

I expect there to be another patch to adjust init_vtd_hw() as well. I will look at that separately.

Kevin and Yang are out of office from 9.26 to 10.7.. Maybe Jan Beulich can ack it.

-Quan

Quoted 4 lines

Wei.

Quoted 1 line

Jan

#6 lore raw
Quoted 17 lines
Quoted 9 lines
Quoted 1 line · On 25.09.15 at 15:42, <[email protected]> wrote:

From: Wei Liu [mailto:[email protected]]
Sent: Friday, September 25, 2015 6:55 PM

Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 25.09.15 at 04:29, <[email protected]> wrote:

Bit 0:29 in Fault Event Control Register are 'Reserved and Preserved', software cannot write 0 to it unconditionally. Software must preserve the value read for writes.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I think this should also be applied to 4.6 (after RC4 got tagged).

Quoted 8 lines

Wei, thanks..

Quoted 1 line

I expect there to be another patch to adjust init_vtd_hw() as well. I will

look at

Quoted 1 line

that separately.

Kevin and Yang are out of office from 9.26 to 10.7.. Maybe Jan Beulich can ack it.

I'm a little hesitant to override patch approval rules, but I guess in this case it is fine (on the basis that the other similar patch got acked by Yang).

Jan