From: "Tian, Kevin" <kevin.tian@intel.com> To: Lu Baolu <baolu.lu@linux.intel.com>, Joerg Roedel <joro@8bytes.org> Cc: "iommu@lists.linux-foundation.org" <iommu@lists.linux-foundation.org>, Andy Lutomirski <luto@amacapital.net>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org> Subject: RE: [PATCH 1/1] iommu/vt-d: Serialize IOMMU GCMD register modifications Date: Wed, 26 Aug 2020 05:29:57 +0000 [thread overview] Message-ID: <MWHPR11MB16457C6EC72943EF615AF2538C540@MWHPR11MB1645.namprd11.prod.outlook.com> (raw) In-Reply-To: <20200826025825.2322-1-baolu.lu@linux.intel.com> > From: Lu Baolu > Sent: Wednesday, August 26, 2020 10:58 AM > > The VT-d spec requires (10.4.4 Global Command Register, GCMD_REG > General > Description) that: > > If multiple control fields in this register need to be modified, software > must serialize the modifications through multiple writes to this register. > > However, in irq_remapping.c, modifications of IRE and CFI are done in one > write. We need to do two separate writes with STS checking after each. > > Fixes: af8d102f999a4 ("x86/intel/irq_remapping: Clean up x2apic opt-out > security warning mess") > Cc: Andy Lutomirski <luto@amacapital.net> > Cc: Jacob Pan <jacob.jun.pan@linux.intel.com> > Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> > --- > drivers/iommu/intel/irq_remapping.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/iommu/intel/irq_remapping.c > b/drivers/iommu/intel/irq_remapping.c > index 9564d23d094f..19d7e18876fe 100644 > --- a/drivers/iommu/intel/irq_remapping.c > +++ b/drivers/iommu/intel/irq_remapping.c > @@ -507,12 +507,16 @@ static void iommu_enable_irq_remapping(struct > intel_iommu *iommu) > > /* Enable interrupt-remapping */ > iommu->gcmd |= DMA_GCMD_IRE; > - iommu->gcmd &= ~DMA_GCMD_CFI; /* Block compatibility-format > MSIs */ > writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG); > - > IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, > readl, (sts & DMA_GSTS_IRES), sts); > > + /* Block compatibility-format MSIs */ > + iommu->gcmd &= ~DMA_GCMD_CFI; > + writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG); > + IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, > + readl, !(sts & DMA_GSTS_CFIS), sts); > + Better do it only when CFI is actually enabled (by checking sts). > /* > * With CFI clear in the Global Command register, we should be > * protected from dangerous (i.e. compatibility) interrupts > -- > 2.17.1 > > _______________________________________________ > iommu mailing list > iommu@lists.linux-foundation.org > https://lists.linuxfoundation.org/mailman/listinfo/iommu
WARNING: multiple messages have this Message-ID (diff)
From: "Tian, Kevin" <kevin.tian@intel.com> To: Lu Baolu <baolu.lu@linux.intel.com>, Joerg Roedel <joro@8bytes.org> Cc: "iommu@lists.linux-foundation.org" <iommu@lists.linux-foundation.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, Andy Lutomirski <luto@amacapital.net> Subject: RE: [PATCH 1/1] iommu/vt-d: Serialize IOMMU GCMD register modifications Date: Wed, 26 Aug 2020 05:29:57 +0000 [thread overview] Message-ID: <MWHPR11MB16457C6EC72943EF615AF2538C540@MWHPR11MB1645.namprd11.prod.outlook.com> (raw) In-Reply-To: <20200826025825.2322-1-baolu.lu@linux.intel.com> > From: Lu Baolu > Sent: Wednesday, August 26, 2020 10:58 AM > > The VT-d spec requires (10.4.4 Global Command Register, GCMD_REG > General > Description) that: > > If multiple control fields in this register need to be modified, software > must serialize the modifications through multiple writes to this register. > > However, in irq_remapping.c, modifications of IRE and CFI are done in one > write. We need to do two separate writes with STS checking after each. > > Fixes: af8d102f999a4 ("x86/intel/irq_remapping: Clean up x2apic opt-out > security warning mess") > Cc: Andy Lutomirski <luto@amacapital.net> > Cc: Jacob Pan <jacob.jun.pan@linux.intel.com> > Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> > --- > drivers/iommu/intel/irq_remapping.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/iommu/intel/irq_remapping.c > b/drivers/iommu/intel/irq_remapping.c > index 9564d23d094f..19d7e18876fe 100644 > --- a/drivers/iommu/intel/irq_remapping.c > +++ b/drivers/iommu/intel/irq_remapping.c > @@ -507,12 +507,16 @@ static void iommu_enable_irq_remapping(struct > intel_iommu *iommu) > > /* Enable interrupt-remapping */ > iommu->gcmd |= DMA_GCMD_IRE; > - iommu->gcmd &= ~DMA_GCMD_CFI; /* Block compatibility-format > MSIs */ > writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG); > - > IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, > readl, (sts & DMA_GSTS_IRES), sts); > > + /* Block compatibility-format MSIs */ > + iommu->gcmd &= ~DMA_GCMD_CFI; > + writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG); > + IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG, > + readl, !(sts & DMA_GSTS_CFIS), sts); > + Better do it only when CFI is actually enabled (by checking sts). > /* > * With CFI clear in the Global Command register, we should be > * protected from dangerous (i.e. compatibility) interrupts > -- > 2.17.1 > > _______________________________________________ > iommu mailing list > iommu@lists.linux-foundation.org > https://lists.linuxfoundation.org/mailman/listinfo/iommu _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2020-08-26 5:30 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-08-26 2:58 [PATCH 1/1] iommu/vt-d: Serialize IOMMU GCMD register modifications Lu Baolu 2020-08-26 2:58 ` Lu Baolu 2020-08-26 5:29 ` Tian, Kevin [this message] 2020-08-26 5:29 ` Tian, Kevin 2020-08-27 4:25 ` Lu Baolu 2020-08-27 4:25 ` Lu Baolu
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=MWHPR11MB16457C6EC72943EF615AF2538C540@MWHPR11MB1645.namprd11.prod.outlook.com \ --to=kevin.tian@intel.com \ --cc=baolu.lu@linux.intel.com \ --cc=iommu@lists.linux-foundation.org \ --cc=joro@8bytes.org \ --cc=linux-kernel@vger.kernel.org \ --cc=luto@amacapital.net \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.